<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Christopher Hacia</title>
	<atom:link href="http://chrishacia.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://chrishacia.com</link>
	<description>Just another Web Developer/Consultant/Engineer San Jose, CA</description>
	<lastBuildDate>Mon, 02 Apr 2012 05:50:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>WordPress Memory Allocation error while installing a plugin</title>
		<link>http://chrishacia.com/2012/03/wordpress-memory-allocation-error-while-installing-a-plugin/</link>
		<comments>http://chrishacia.com/2012/03/wordpress-memory-allocation-error-while-installing-a-plugin/#comments</comments>
		<pubDate>Fri, 16 Mar 2012 11:35:46 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[memory allocation]]></category>
		<category><![CDATA[nextgen gallery]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://chrishacia.com/?p=210</guid>
		<description><![CDATA[Ever run into an error while installing a plugin and or attempting to activate it within your copy of wordpress. Your error may look something like Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 491520 bytes) in wp-content/plugins/nextgen-gallery/admin/manage-images.php on line 485 I recently recieved this error installing NextGEN Gallery on one [...]]]></description>
			<content:encoded><![CDATA[<p>Ever run into an error while installing a plugin and or attempting to activate it within your copy of wordpress. Your error may look something like</p>
<blockquote><p>Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 491520 bytes) in wp-content/plugins/nextgen-gallery/admin/manage-images.php on line 485</p></blockquote>
<p>I recently recieved this error installing NextGEN Gallery on one of my other blogs, unfortunately it wasn&#8217;t the first time, nor do I believe it will be the last, as NextGEN is one of the only decent galleries for your blogware out there currently and has been for some time now. So what happens when you get this error huh? How do you fix it? The answer is rather simple in most cases.</p>
<p>Just go into your web directory. Find the <strong>wp-config.php </strong>file and open it up. Scroll down a bit and find a nice spot to add one line of code. That code being:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WP_MEMORY_LIMIT'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'96M'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>If that doesn&#8217;t work there might always be the option of dropping a temp php.ini file on your server where you can give this ini file one line</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">memory_limit <span style="color: #339933;">=</span> 96M<span style="color: #339933;">;</span></pre></div></div>

<p>or you can try the .htaccess route similar notion to the php.ini but with an .htaccess file where you would add to that file</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">php_value memory_limit 96M</pre></div></div>

<p>You could also try just opening the index.php of your site and try adding this one line of php to it</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">ini_set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'memory_limit'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'96M'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>And, last but not least if all else fails, consult the tech support of your hosting provider.</p>
]]></content:encoded>
			<wfw:commentRss>http://chrishacia.com/2012/03/wordpress-memory-allocation-error-while-installing-a-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to put site in construction mode quick and easy via .htaccess</title>
		<link>http://chrishacia.com/2012/03/how-to-put-site-in-construction-mode-quick-and-easy-via-htaccess/</link>
		<comments>http://chrishacia.com/2012/03/how-to-put-site-in-construction-mode-quick-and-easy-via-htaccess/#comments</comments>
		<pubDate>Fri, 16 Mar 2012 09:52:11 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[htaccess]]></category>

		<guid isPermaLink="false">http://chrishacia.com/?p=144</guid>
		<description><![CDATA[Do you run a blog like wordpress or some other CMS driven website? Or even a MVC like CakePHP or Codeigniter? Something that in essense runs solely off of index.php for the most part? Sure why not. Most sites now a days run off of a lone php file. So. A quick easy way to [...]]]></description>
			<content:encoded><![CDATA[<p>Do you run a blog like wordpress or some other CMS driven website? Or even a MVC like CakePHP or Codeigniter? Something that in essense runs solely off of index.php for the most part? Sure why not. Most sites now a days run off of a lone php file. So. A quick easy way to get your site into a maintenance or construction mode is to alter your .htaccess file by adding the next line to it (above everything else in there already).</p>
<p>DirectoryIndex underconst.html index.php index.html index.htm</p>
<p>What this one line does is pretty much tells your Apache driven server (or other like server that supports .htaccess (most do, but the ones that don&#8217;t have a similar directive somewhere). Is that you want to serve these files in order each one taking precedence over the other. So in this case I can have 3 index files in the same directory and only one of them will be seen (unless you point your browser directly at it) so the line above says php is first in line, then html, then htm. But theres one more specific file before them all underconst.html you can name it whatever you like really. But if this file is found in the same directory as the .htaccess file, this file is going to be served first and foremost.</p>
<p>Now why is this handy. Easy, lets say something goes seriously wrong with your site and you need to fix it. But you want to shut others out that come to the site while in the mode (Note this does not cover all the bases of booting everyone off but its a good start, pending how you have your entire site built up). </p>
<p>Anyway just wanted to offer that tasty nugget of useless wisdom. </p>
]]></content:encoded>
			<wfw:commentRss>http://chrishacia.com/2012/03/how-to-put-site-in-construction-mode-quick-and-easy-via-htaccess/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Query to get radius of longitude and latitude</title>
		<link>http://chrishacia.com/2012/03/mysql-query-to-get-radius-of-longitude-and-latitude/</link>
		<comments>http://chrishacia.com/2012/03/mysql-query-to-get-radius-of-longitude-and-latitude/#comments</comments>
		<pubDate>Thu, 08 Mar 2012 17:03:44 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://chrishacia.com/?p=199</guid>
		<description><![CDATA[Lately I have been doing a lot of work with longitude and latitude references, of which I needed to search my Database for points of interest surrounding a particular reference. At first it was quite difficult, as I have never done something to that extreme query wise, and I couldn&#8217;t find something via google or [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I have been doing a lot of work with longitude and latitude references, of which I needed to search my Database for points of interest surrounding a particular reference. At first it was quite difficult, as I have never done something to that extreme query wise, and I couldn&#8217;t find something via google or other resource that really helped for my needs, and the ones I did find were either broken or just not the right fit. So between that and a few hours of working on it I came up with something that is repetitively fast checking against upwards of almost 100,000 records. So with that I know Geo-location is a rising star as its becoming easier and easier for people to use it with tech supporting it better now a days and all else, and a lot of people need to search there DB for data similar to like what I am. So without any more trouble of having to hear me babble on here is that query. Simplified a bit more from how I use it but none the less just as effective (I usually tie this into a query that has server INNER JOIN and or LEFT JOIN references). Note: Calculation is based on Miles in this version easily changed to Nautical or Kilometers by changing a couple numbers but, in this example currently just miles (maybe Ill update it later so one can know what to change in order to do one of the others).</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$distance</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$latitude</span> <span style="color: #339933;">=</span> <span style="color:#800080;">37.295092</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$longitude</span> <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color:#800080;">121.896490</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT loc.*, (((acos(sin((<span style="color: #006699; font-weight: bold;">$latitude</span>*pi()/180)) * sin((`latitude`*pi()/180))+cos((<span style="color: #006699; font-weight: bold;">$latitude</span>*pi()/180)) * cos((`latitude`*pi()/180)) * cos(((<span style="color: #006699; font-weight: bold;">$longitude</span> - `longitude`)*pi()/180))))*180/pi())*60*1.1515) AS `distance` FROM table_with_lonlat_ref loc HAVING distance &lt; <span style="color: #006699; font-weight: bold;">$distance</span>&quot;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://chrishacia.com/2012/03/mysql-query-to-get-radius-of-longitude-and-latitude/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Debug Array or JSON object easily</title>
		<link>http://chrishacia.com/2012/03/php-debug-array-or-json-object-easily/</link>
		<comments>http://chrishacia.com/2012/03/php-debug-array-or-json-object-easily/#comments</comments>
		<pubDate>Thu, 08 Mar 2012 16:45:53 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[array debug]]></category>
		<category><![CDATA[json debug]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://chrishacia.com/?p=193</guid>
		<description><![CDATA[As a engineer I work with Arrays of Data, day in and day out. Whether its building them out or pulling them in from somewhere. More often than I&#8217;d like to admit something gets lost in translation and I have to see whats going on. Now most people will just simply do a quick debug [...]]]></description>
			<content:encoded><![CDATA[<p>As a engineer I work with Arrays of Data, day in and day out. Whether its building them out or pulling them in from somewhere. More often than I&#8217;d like to admit something gets lost in translation and I have to see whats going on. Now most people will just simply do a quick debug statement like:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">   <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;pre&gt;&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arrayData</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt; /pre &gt;&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p>and with the above, call it the day. However as I said I have to do it more often then I&#8217;d like to admit sometimes. With that I also have to do it with JSON Objects as well not just standard Array&#8217;s so for myself I came up with a nifty little function to help me do either/or quickly mimicking the above output. Only thing I Need to do with mine however is type out a function name and pass two arguments with it to get the same result and it works with either a standard array or a JSON string.</p>
<p>$arrayType can be either PHP or JSON (lowercase)<br />
$theArray would be the actual array of data either JSON or an Array.</p>
<p>Note in the function above and below the end <strong>&lt;/pre&gt;</strong> tags I had to break apart with spacing of the less-than and greater-than symbols otherwise it broke the display here on the page.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #000000; font-weight: bold;">function</span> debugArray<span style="color: #009900;">&#40;</span><span style="color: #000088;">$arrayType</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color: #000088;">$theArray</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$output</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;success&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$msg</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$theArray</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">||</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$theArray</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$output</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;error&quot;</span><span style="color: #339933;">;</span><span style="color: #000088;">$msg</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;No Array to Process.&quot;</span><span style="color: #339933;">;</span>			
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arrayType</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">||</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arrayType</span> <span style="color: #339933;">!==</span> <span style="color: #0000ff;">'php'</span><span style="color: #009900;">&#41;</span>AND<span style="color: #009900;">&#40;</span><span style="color: #000088;">$arrayType</span> <span style="color: #339933;">!==</span> <span style="color: #0000ff;">'json'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$output</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;error&quot;</span><span style="color: #339933;">;</span><span style="color: #000088;">$msg</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;No Array type Specified.&quot;</span><span style="color: #339933;">;</span>			
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$output</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;error&quot;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$msg</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">else</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arrayType</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'php'</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;pre&gt;'</span><span style="color: #339933;">;</span>
				<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$theArray</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt; /pre &gt;'</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arrayType</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'json'</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;pre&gt;'</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">echo</span> <span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">json_decode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$theArray</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt; /pre &gt;'</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">else</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;No Array type Specified.&quot;</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://chrishacia.com/2012/03/php-debug-array-or-json-object-easily/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Calculate Distance between 2 Longitude / Latitude Points</title>
		<link>http://chrishacia.com/2012/03/php-calculate-distance-between-2-longitude-latitude-points/</link>
		<comments>http://chrishacia.com/2012/03/php-calculate-distance-between-2-longitude-latitude-points/#comments</comments>
		<pubDate>Thu, 08 Mar 2012 16:36:37 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[longitude latitude calculation]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://chrishacia.com/?p=190</guid>
		<description><![CDATA[Geo-location is becoming more and more popular as time passes and technology supports it better more so as there is plenty of free resources to help you get the data you need to be more GEO centric with your users. However sometimes you want to give a range from point A to point B and [...]]]></description>
			<content:encoded><![CDATA[<p>Geo-location is becoming more and more popular as time passes and technology supports it better more so as there is plenty of free resources to help you get the data you need to be more GEO centric with your users. However sometimes you want to give a range from point A to point B and this is one way you can do it.</p>
<p>You can do the calculation in this function to return Miles (default), Nautical Miles, or Kilometers just enter the longitude/latitude of point A and do the same for point B and your good to go.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> distance<span style="color: #009900;">&#40;</span><span style="color: #000088;">$lat1</span><span style="color: #339933;">,</span> <span style="color: #000088;">$lon1</span><span style="color: #339933;">,</span> <span style="color: #000088;">$lat2</span><span style="color: #339933;">,</span> <span style="color: #000088;">$lon2</span><span style="color: #339933;">,</span> <span style="color: #000088;">$unit</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
	<span style="color: #000088;">$theta</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$lon1</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$lon2</span><span style="color: #339933;">;</span> 
	<span style="color: #000088;">$dist</span> <span style="color: #339933;">=</span> <span style="color: #990000;">sin</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">deg2rad</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$lat1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #990000;">sin</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">deg2rad</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$lat2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span>  <span style="color: #990000;">cos</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">deg2rad</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$lat1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #990000;">cos</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">deg2rad</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$lat2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #990000;">cos</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">deg2rad</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$theta</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
	<span style="color: #000088;">$dist</span> <span style="color: #339933;">=</span> <span style="color: #990000;">acos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dist</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
	<span style="color: #000088;">$dist</span> <span style="color: #339933;">=</span> <span style="color: #990000;">rad2deg</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dist</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
	<span style="color: #000088;">$miles</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$dist</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">60</span> <span style="color: #339933;">*</span> <span style="color:#800080;">1.1515</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$unit</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtoupper</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$unit</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$unit</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;K&quot;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$miles</span> <span style="color: #339933;">*</span> <span style="color:#800080;">1.609344</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$unit</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;N&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$miles</span> <span style="color: #339933;">*</span> <span style="color:#800080;">0.8684</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$miles</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">echo</span> distance<span style="color: #009900;">&#40;</span><span style="color:#800080;">32.9697</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color:#800080;">96.80322</span><span style="color: #339933;">,</span> <span style="color:#800080;">29.46786</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color:#800080;">98.53506</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;m&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; miles&lt;br&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> distance<span style="color: #009900;">&#40;</span><span style="color:#800080;">32.9697</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color:#800080;">96.80322</span><span style="color: #339933;">,</span> <span style="color:#800080;">29.46786</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color:#800080;">98.53506</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;k&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; kilometers&lt;br&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> distance<span style="color: #009900;">&#40;</span><span style="color:#800080;">32.9697</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color:#800080;">96.80322</span><span style="color: #339933;">,</span> <span style="color:#800080;">29.46786</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color:#800080;">98.53506</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;n&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; nautical miles&lt;br&gt;&quot;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://chrishacia.com/2012/03/php-calculate-distance-between-2-longitude-latitude-points/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Validate Email Address</title>
		<link>http://chrishacia.com/2012/03/php-validate-email-address/</link>
		<comments>http://chrishacia.com/2012/03/php-validate-email-address/#comments</comments>
		<pubDate>Thu, 08 Mar 2012 16:30:05 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[php validate email address]]></category>

		<guid isPermaLink="false">http://chrishacia.com/?p=188</guid>
		<description><![CDATA[If you have ever needed to validate an email address to see if the format is good then heres a nice function that does that and more up to and including checking the DNS of the domain of the email address to see if its actually a real domain. Though a lot of people will [...]]]></description>
			<content:encoded><![CDATA[<p>If you have ever needed to validate an email address to see if the format is good then heres a nice function that does that and more up to and including checking the DNS of the domain of the email address to see if its actually a real domain. Though a lot of people will insist that a single one line regex with preg_match() will be more than enough to suffice most peoples needs, which yes this is true. However I am particular about how I handle things and like to cover as many bases as I possibly can to ensure I am not about to get a spam bomb from some bots.</p>
<p>This function returns true/false. True = valid email, False = invalid email<br />
Example of use would be</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>validEmail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'email'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Error: Email address provided not valid&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> validEmail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$email</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$isValid</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$atIndex</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strrpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$email</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;@&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_bool</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$atIndex</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$atIndex</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$isValid</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">else</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$domain</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$email</span><span style="color: #339933;">,</span> <span style="color: #000088;">$atIndex</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$local</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$email</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$atIndex</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$localLen</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$local</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$domainLen</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$domain</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$localLen</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$localLen</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">64</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">// local part length exceeded</span>
				<span style="color: #000088;">$isValid</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$domainLen</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$domainLen</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">// domain part length exceeded</span>
				<span style="color: #000088;">$isValid</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$local</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'.'</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$local</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$localLen</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'.'</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">// local part starts or ends with '.'</span>
				<span style="color: #000088;">$isValid</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/\\.\\./'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$local</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">// local part has two consecutive dots</span>
				<span style="color: #000088;">$isValid</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/^[A-Za-z0-9\\-\\.]+$/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$domain</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">// character not valid in domain part</span>
				<span style="color: #000088;">$isValid</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/\\.\\./'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$domain</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">// domain part has two consecutive dots</span>
				<span style="color: #000088;">$isValid</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/^(\\\\.|[A-Za-z0-9!#%&amp;`_=\\/$\'*+?^{}|~.-])+$/'</span><span style="color: #339933;">,</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\\</span><span style="color: #000099; font-weight: bold;">\\</span>&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$local</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">// character not valid in local part unless </span>
				<span style="color: #666666; font-style: italic;">// local part is quoted</span>
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/^&quot;(\\\\&quot;|[^&quot;])+&quot;$/'</span><span style="color: #339933;">,</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\\</span><span style="color: #000099; font-weight: bold;">\\</span>&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$local</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$isValid</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$isValid</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">checkdnsrr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$domain</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;MX&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #990000;">checkdnsrr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$domain</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;A&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">// domain not found in DNS</span>
				<span style="color: #000088;">$isValid</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$isValid</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://chrishacia.com/2012/03/php-validate-email-address/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Strong Password</title>
		<link>http://chrishacia.com/2012/03/php-strong-password/</link>
		<comments>http://chrishacia.com/2012/03/php-strong-password/#comments</comments>
		<pubDate>Thu, 08 Mar 2012 16:17:54 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[password strength]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://chrishacia.com/?p=186</guid>
		<description><![CDATA[If you want to prompt your users to create password that is a certain length more or less, that is also strong by today&#8217;s definition then here is a good example. This can be elaborated on even more but for common use in most practices this is more than enough. You can comment out like [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to prompt your users to create password that is a certain length more or less, that is also strong by today&#8217;s definition then here is a good example. This can be elaborated on even more but for common use in most practices this is more than enough. You can comment out like I have in the example below one or more if-else statements if you wish to not enforce that particular type. In my example I commented out the need for symbols like @ # $ &#038;&#8230; What this function out of the box seeks is at least 1 letter and 1 number, it seeks to make sure at least 1 letter is capitalized and wants the password to be more than 8 char long but less than 20. This function returns true/false. False if the password has passed the requirements true if not. An example of its use would be</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>pwStrongCheck<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'password'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Error: Password does not meet strength requirements&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> pwStrongCheck<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pwd</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$error</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pwd</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">8</span><span style="color: #009900;">&#41;</span><span style="color: #666666; font-style: italic;">//to short</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$error</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pwd</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">20</span><span style="color: #009900;">&#41;</span><span style="color: #666666; font-style: italic;">//to long</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$error</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>	
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;#[0-9]+#&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pwd</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #666666; font-style: italic;">//at least one number</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$error</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;#[a-z]+#&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pwd</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #666666; font-style: italic;">//at least one letter</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$error</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;#[A-Z]+#&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pwd</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #666666; font-style: italic;">//at least one capital letter</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$error</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #666666; font-style: italic;">/*if(!preg_match(&quot;#\W+#&quot;, $pwd))//at least one symbol
		{
			$error = true;
		}*/</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$error</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://chrishacia.com/2012/03/php-strong-password/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Verify a Dollar Amount</title>
		<link>http://chrishacia.com/2012/03/php-verify-a-dollar-amount/</link>
		<comments>http://chrishacia.com/2012/03/php-verify-a-dollar-amount/#comments</comments>
		<pubDate>Thu, 08 Mar 2012 16:05:04 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[validate dollar ammount]]></category>

		<guid isPermaLink="false">http://chrishacia.com/?p=179</guid>
		<description><![CDATA[Just a simple function to see if an input numeric value is actually a US Dollar (USD) format Example: Two Dollar Amounts provided to the script.. 1502.38 and 10O.00 Good: 1,502.38 Bad: 10O.00 came back false. function verifyMoney&#40;$what&#41;&#123; if &#40;preg_match&#40;'#^[0-9]+(\.[0-9]{0,2})?$#', $what&#41;&#41;&#123; $monkey = number_format&#40;$what, 2&#41;; return $monkey; &#125;else&#123; return FALSE; &#125; &#125; &#160; $goodmoney = [...]]]></description>
			<content:encoded><![CDATA[<p>Just a simple function to see if an input numeric value is actually a US Dollar (USD) format<br />
Example:<br />
Two Dollar Amounts provided to the script.. 1502.38 and 10O.00</p>
<p>Good: 1,502.38<br />
Bad: 10O.00 came back false.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> verifyMoney<span style="color: #009900;">&#40;</span><span style="color: #000088;">$what</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'#^[0-9]+(\.[0-9]{0,2})?$#'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$what</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     <span style="color: #000088;">$monkey</span> <span style="color: #339933;">=</span> <span style="color: #990000;">number_format</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$what</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #b1b100;">return</span> <span style="color: #000088;">$monkey</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$goodmoney</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;1502.38&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$badmoney</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;10O.00&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>verifyMoney<span style="color: #009900;">&#40;</span><span style="color: #000088;">$goodmoney</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Good: &quot;</span><span style="color: #339933;">.</span>verifyMoney<span style="color: #009900;">&#40;</span><span style="color: #000088;">$goodmoney</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span><span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;The Dollar amount you have entered is not valid&quot;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>verifyMoney<span style="color: #009900;">&#40;</span><span style="color: #000088;">$badmoney</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Bad: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$badmoney</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; came back false.&quot;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span><span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;The Dollar amount you have entered is valid&quot;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://chrishacia.com/2012/03/php-verify-a-dollar-amount/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Validate Credit Card format</title>
		<link>http://chrishacia.com/2012/03/php-validate-credit-card-format/</link>
		<comments>http://chrishacia.com/2012/03/php-validate-credit-card-format/#comments</comments>
		<pubDate>Thu, 08 Mar 2012 16:00:40 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[credit-card validation]]></category>
		<category><![CDATA[debit-card validation]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://chrishacia.com/?p=175</guid>
		<description><![CDATA[Are you in a bind trying to figure out if that user input credit card number is valid as far as format goes. Not just length but the actual combination of numbers as well? Well then here is a quickie solution. Due to the sensitive nature of the topic though I will omit the example [...]]]></description>
			<content:encoded><![CDATA[<p>Are you in a bind trying to figure out if that user input credit card number is valid as far as format goes. Not just length but the actual combination of numbers as well? Well then here is a quickie solution. Due to the sensitive nature of the topic though I will omit the example portion of this code but the concept of use in this particular version is take a select box of the various types then a standard input text and plug the numbers in. It takes the card choice and numbers and compares the 2 for a valid match. <strong>Note:</strong> I can&#8217;t guarantee 100% that this will work with every credit card out there. But I have yet to run into an issue with it to date.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> validateCC<span style="color: #009900;">&#40;</span><span style="color: #000088;">$cc_num</span><span style="color: #339933;">,</span> <span style="color: #000088;">$type</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;American&quot;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$pattern</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/^([34|37]{2})([0-9]{13})$/&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pattern</span><span style="color: #339933;">,</span><span style="color: #000088;">$cc_num</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000088;">$verified</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">else</span>
        <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$verified</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;Dinners&quot;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$pattern</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/^([30|36|38]{2})([0-9]{12})$/&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pattern</span><span style="color: #339933;">,</span><span style="color: #000088;">$cc_num</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$verified</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">else</span>
        <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$verified</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;Discover&quot;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$pattern</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/^([6011]{4})([0-9]{12})$/&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pattern</span><span style="color: #339933;">,</span><span style="color: #000088;">$cc_num</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$verified</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">else</span>
        <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$verified</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;Master&quot;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$pattern</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/^([51|52|53|54|55]{2})([0-9]{14})$/&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pattern</span><span style="color: #339933;">,</span><span style="color: #000088;">$cc_num</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$verified</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">else</span>
        <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$verified</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;Visa&quot;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$pattern</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/^([4]{1})([0-9]{12,15})$/&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pattern</span><span style="color: #339933;">,</span><span style="color: #000088;">$cc_num</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
           <span style="color: #000088;">$verified</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">else</span>
        <span style="color: #009900;">&#123;</span>
           <span style="color: #000088;">$verified</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">else</span>
    <span style="color: #009900;">&#123;</span>
	    verified <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$verified</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
	    <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">&quot;invalid&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">else</span>
    <span style="color: #009900;">&#123;</span>
	    <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">&quot;valid&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://chrishacia.com/2012/03/php-validate-credit-card-format/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Last day of Month</title>
		<link>http://chrishacia.com/2012/03/php-last-day-of-month/</link>
		<comments>http://chrishacia.com/2012/03/php-last-day-of-month/#comments</comments>
		<pubDate>Thu, 08 Mar 2012 15:55:49 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[time manipulation]]></category>

		<guid isPermaLink="false">http://chrishacia.com/?p=172</guid>
		<description><![CDATA[Need to get the last day of any given month? Everyone occasionally does, here&#8217;s how. Example: 02-2012 = 2012-02-29 05-2012 = 2012-05-31 function lastday&#40;$month = '', $year = ''&#41; &#123; if&#40;empty&#40;$month&#41;&#41; &#123; $month = date&#40;'m'&#41;; &#125; if&#40;empty&#40;$year&#41;&#41; &#123; $year = date&#40;'Y'&#41;; &#125; $result = strtotime&#40;&#34;{$year}-{$month}-01&#34;&#41;; $result = strtotime&#40;'-1 second', strtotime&#40;'+1 month', $result&#41;&#41;; return date&#40;'Y-m-d', $result&#41;; [...]]]></description>
			<content:encoded><![CDATA[<br />
<b>Fatal error</b>:  Cannot redeclare lastday() (previously declared in /home/monkey/public_html/sites/chrishacia.com/wp-content/plugins/exec-php/includes/runtime.php(42) : eval()'d code:2) in <b>/home/monkey/public_html/sites/chrishacia.com/wp-content/plugins/exec-php/includes/runtime.php(42) : eval()'d code</b> on line <b>15</b><br />

