<?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>Michael Hartmayer - Portfolio &#187; PHP</title>
	<atom:link href="http://www.michaelhartmayer.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.michaelhartmayer.com</link>
	<description>Have a Leet Smoothy</description>
	<lastBuildDate>Wed, 21 Jul 2010 04:04:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>CSV Export Class for PHP</title>
		<link>http://www.michaelhartmayer.com/php/csv-export-class-for-php/</link>
		<comments>http://www.michaelhartmayer.com/php/csv-export-class-for-php/#comments</comments>
		<pubDate>Mon, 03 May 2010 01:39:29 +0000</pubDate>
		<dc:creator>Michael Hartmayer</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[CSV]]></category>
		<category><![CDATA[Export]]></category>

		<guid isPermaLink="false">http://www.michaelhartmayer.com/?p=455</guid>
		<description><![CDATA[Since I&#8217;ve been working with a lot of different data sources lately, I&#8217;ve found myself needing an easy to use CSV Export class. So, here it is, CSVMaker.php This class makes it very easy to create CSV files on the fly, from any type of data. Here&#8217;s a usage example: $CSV = new CSVMaker&#40;&#41;; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>Since I&#8217;ve been working with a lot of different data sources lately, I&#8217;ve found myself needing an easy to use CSV Export class. So, here it is, <a href="http://pastebin.com/4ZwBM6y7" target="_blank">CSVMaker.php</a></p>
<p>This class makes it very easy to create CSV files on the fly, from any type of data. Here&#8217;s a usage example:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$CSV</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> CSVMaker<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Optionally Change the Format</span>
<span style="color: #000088;">$CSV</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">csvDelimeter</span>    <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// (What seperates each value in a set Foo,Bar,Etc)</span>
<span style="color: #000088;">$CSV</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">csvLine</span>         <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// (What ends one set of data - usually a new line)</span>
<span style="color: #000088;">$CSV</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">csvCapsule</span>      <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&quot;'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// (What comes before and after each piece of data &quot;Foo&quot;,&quot;Bar&quot;,&quot;Etc&quot;)</span>
&nbsp;
<span style="color: #000088;">$CSVHeader</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$CSVHeader</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'first_name'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;First Name&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$CSVHeader</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'last_name'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Last Name&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$CSV</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createTemplate</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$CSVHeader</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$CSVLine</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$CSVLine</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'first_name'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Michael&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$CSVLine</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'last_name'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Hartmayer&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$CSV</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addEntry</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$CSVLine</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">file_put_contents</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;MyCSVFile.csv&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$CSV</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">buildDoc</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>


<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fcsv-export-class-for-php%2F&amp;title=CSV%20Export%20Class%20for%20PHP&amp;bodytext=Since%20I%27ve%20been%20working%20with%20a%20lot%20of%20different%20data%20sources%20lately%2C%20I%27ve%20found%20myself%20needing%20an%20easy%20to%20use%20CSV%20Export%20class.%20So%2C%20here%20it%20is%2C%20CSVMaker.php%0D%0A%0D%0AThis%20class%20makes%20it%20very%20easy%20to%20create%20CSV%20files%20on%20the%20fly%2C%20from%20any%20type%20of%20data.%20Here%27" title="Digg"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fcsv-export-class-for-php%2F" title="Sphinn"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fcsv-export-class-for-php%2F&amp;title=CSV%20Export%20Class%20for%20PHP&amp;notes=Since%20I%27ve%20been%20working%20with%20a%20lot%20of%20different%20data%20sources%20lately%2C%20I%27ve%20found%20myself%20needing%20an%20easy%20to%20use%20CSV%20Export%20class.%20So%2C%20here%20it%20is%2C%20CSVMaker.php%0D%0A%0D%0AThis%20class%20makes%20it%20very%20easy%20to%20create%20CSV%20files%20on%20the%20fly%2C%20from%20any%20type%20of%20data.%20Here%27" title="del.icio.us"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fcsv-export-class-for-php%2F&amp;t=CSV%20Export%20Class%20for%20PHP" title="Facebook"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fcsv-export-class-for-php%2F&amp;title=CSV%20Export%20Class%20for%20PHP" title="Mixx"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fcsv-export-class-for-php%2F&amp;title=CSV%20Export%20Class%20for%20PHP&amp;annotation=Since%20I%27ve%20been%20working%20with%20a%20lot%20of%20different%20data%20sources%20lately%2C%20I%27ve%20found%20myself%20needing%20an%20easy%20to%20use%20CSV%20Export%20class.%20So%2C%20here%20it%20is%2C%20CSVMaker.php%0D%0A%0D%0AThis%20class%20makes%20it%20very%20easy%20to%20create%20CSV%20files%20on%20the%20fly%2C%20from%20any%20type%20of%20data.%20Here%27" title="Google Bookmarks"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fcsv-export-class-for-php%2F&amp;title=CSV%20Export%20Class%20for%20PHP&amp;source=Michael+Hartmayer+-+Portfolio+Have+a+Leet+Smoothy&amp;summary=Since%20I%27ve%20been%20working%20with%20a%20lot%20of%20different%20data%20sources%20lately%2C%20I%27ve%20found%20myself%20needing%20an%20easy%20to%20use%20CSV%20Export%20class.%20So%2C%20here%20it%20is%2C%20CSVMaker.php%0D%0A%0D%0AThis%20class%20makes%20it%20very%20easy%20to%20create%20CSV%20files%20on%20the%20fly%2C%20from%20any%20type%20of%20data.%20Here%27" title="LinkedIn"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fcsv-export-class-for-php%2F&amp;title=CSV%20Export%20Class%20for%20PHP" title="Live"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fcsv-export-class-for-php%2F&amp;t=CSV%20Export%20Class%20for%20PHP" title="MySpace"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fcsv-export-class-for-php%2F&amp;title=CSV%20Export%20Class%20for%20PHP" title="Reddit"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fcsv-export-class-for-php%2F&amp;title=CSV%20Export%20Class%20for%20PHP" title="StumbleUpon"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.michaelhartmayer.com/php/csv-export-class-for-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fetch Google Pages Indexed Using PHP and AJAX</title>
		<link>http://www.michaelhartmayer.com/php/fetch-google-pages-indexed-using-php-and-ajax/</link>
		<comments>http://www.michaelhartmayer.com/php/fetch-google-pages-indexed-using-php-and-ajax/#comments</comments>
		<pubDate>Fri, 02 Apr 2010 01:27:26 +0000</pubDate>
		<dc:creator>Michael Hartmayer</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.michaelhartmayer.com/?p=447</guid>
		<description><![CDATA[Here&#8217;s a quick and dirty solution I threw together to fetch how many pages of a site google has index. I needed this for one of my control panels, so my work group could track this and other metrics on the fly. gpindex.php &#60;?php // Some arbitrary access code so not everyone can access it. [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a quick and dirty solution I threw together to fetch how many pages of a site google has index. I needed this for one of my control panels, so my work group could track this and other metrics on the fly.</p>
<p><strong>gpindex.php</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
	<span style="color: #666666; font-style: italic;">// Some arbitrary access code so not everyone can access it. Not &quot;real&quot; security :)</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'accessCode'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">!=</span><span style="color: #0000ff;">&quot;some_password&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Access Denied&quot;</span><span style="color: #339933;">;</span> <span style="color: #990000;">exit</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000088;">$site</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'site'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$gurl</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://www.google.com/search?q=site:&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$curl_handle</span><span style="color: #339933;">=</span><span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span>CURLOPT_URL<span style="color: #339933;">,</span><span style="color: #000088;">$gurl</span><span style="color: #339933;">.</span><span style="color: #000088;">$site</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span>CURLOPT_CONNECTTIMEOUT<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: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span>CURLOPT_RETURNTRANSFER<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;">$buffer</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">curl_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;#Results(.*)of about &lt;b&gt;(.*)&lt;/b&gt; from &lt;b&gt;<span style="color: #006699; font-weight: bold;">$site</span>&lt;/b&gt;#&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$buffer</span><span style="color: #339933;">,</span><span style="color: #000088;">$matches</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</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: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>And here&#8217;s the Ajax via jQuery that is used to fetch the information:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot; src=&quot;js/patch/jquery.min.js&quot;&gt;&lt;/script&gt;
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
   $<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      $.<span style="color: #660066;">ajax</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
         url<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;http://www.example.com/path/to/gpindex.php?accessCode=some_password&amp;site=example.com&quot;</span><span style="color: #339933;">,</span>
         success<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>d<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#googleIndexed&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>d<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot; Pages&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span>
&lt;p style=&quot;font-size:11px;&quot;&gt;Indexed on Google&lt;/p&gt;
&lt;p style=&quot;font-size:11px; font-weight:bold;&quot; id=&quot;googleIndexed&quot;&gt;( Fetching Data )&lt;/p&gt;</pre></div></div>


<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Ffetch-google-pages-indexed-using-php-and-ajax%2F&amp;title=Fetch%20Google%20Pages%20Indexed%20Using%20PHP%20and%20AJAX&amp;bodytext=Here%27s%20a%20quick%20and%20dirty%20solution%20I%20threw%20together%20to%20fetch%20how%20many%20pages%20of%20a%20site%20google%20has%20index.%20I%20needed%20this%20for%20one%20of%20my%20control%20panels%2C%20so%20my%20work%20group%20could%20track%20this%20and%20other%20metrics%20on%20the%20fly.%0D%0A%0D%0Agpindex.php%0D%0A%0D%0A%0D%0A" title="Digg"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Ffetch-google-pages-indexed-using-php-and-ajax%2F" title="Sphinn"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Ffetch-google-pages-indexed-using-php-and-ajax%2F&amp;title=Fetch%20Google%20Pages%20Indexed%20Using%20PHP%20and%20AJAX&amp;notes=Here%27s%20a%20quick%20and%20dirty%20solution%20I%20threw%20together%20to%20fetch%20how%20many%20pages%20of%20a%20site%20google%20has%20index.%20I%20needed%20this%20for%20one%20of%20my%20control%20panels%2C%20so%20my%20work%20group%20could%20track%20this%20and%20other%20metrics%20on%20the%20fly.%0D%0A%0D%0Agpindex.php%0D%0A%0D%0A%0D%0A" title="del.icio.us"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Ffetch-google-pages-indexed-using-php-and-ajax%2F&amp;t=Fetch%20Google%20Pages%20Indexed%20Using%20PHP%20and%20AJAX" title="Facebook"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Ffetch-google-pages-indexed-using-php-and-ajax%2F&amp;title=Fetch%20Google%20Pages%20Indexed%20Using%20PHP%20and%20AJAX" title="Mixx"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Ffetch-google-pages-indexed-using-php-and-ajax%2F&amp;title=Fetch%20Google%20Pages%20Indexed%20Using%20PHP%20and%20AJAX&amp;annotation=Here%27s%20a%20quick%20and%20dirty%20solution%20I%20threw%20together%20to%20fetch%20how%20many%20pages%20of%20a%20site%20google%20has%20index.%20I%20needed%20this%20for%20one%20of%20my%20control%20panels%2C%20so%20my%20work%20group%20could%20track%20this%20and%20other%20metrics%20on%20the%20fly.%0D%0A%0D%0Agpindex.php%0D%0A%0D%0A%0D%0A" title="Google Bookmarks"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Ffetch-google-pages-indexed-using-php-and-ajax%2F&amp;title=Fetch%20Google%20Pages%20Indexed%20Using%20PHP%20and%20AJAX&amp;source=Michael+Hartmayer+-+Portfolio+Have+a+Leet+Smoothy&amp;summary=Here%27s%20a%20quick%20and%20dirty%20solution%20I%20threw%20together%20to%20fetch%20how%20many%20pages%20of%20a%20site%20google%20has%20index.%20I%20needed%20this%20for%20one%20of%20my%20control%20panels%2C%20so%20my%20work%20group%20could%20track%20this%20and%20other%20metrics%20on%20the%20fly.%0D%0A%0D%0Agpindex.php%0D%0A%0D%0A%0D%0A" title="LinkedIn"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Ffetch-google-pages-indexed-using-php-and-ajax%2F&amp;title=Fetch%20Google%20Pages%20Indexed%20Using%20PHP%20and%20AJAX" title="Live"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Ffetch-google-pages-indexed-using-php-and-ajax%2F&amp;t=Fetch%20Google%20Pages%20Indexed%20Using%20PHP%20and%20AJAX" title="MySpace"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Ffetch-google-pages-indexed-using-php-and-ajax%2F&amp;title=Fetch%20Google%20Pages%20Indexed%20Using%20PHP%20and%20AJAX" title="Reddit"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Ffetch-google-pages-indexed-using-php-and-ajax%2F&amp;title=Fetch%20Google%20Pages%20Indexed%20Using%20PHP%20and%20AJAX" title="StumbleUpon"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.michaelhartmayer.com/php/fetch-google-pages-indexed-using-php-and-ajax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scripting for Smarties : Application Portability 101</title>
		<link>http://www.michaelhartmayer.com/php/scripting-for-smarties-application-portability-101/</link>
		<comments>http://www.michaelhartmayer.com/php/scripting-for-smarties-application-portability-101/#comments</comments>
		<pubDate>Wed, 23 Sep 2009 17:42:15 +0000</pubDate>
		<dc:creator>Michael Hartmayer</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Scripting for Smarties]]></category>
		<category><![CDATA[YouTube]]></category>

		<guid isPermaLink="false">http://www.michaelhartmayer.com/?p=384</guid>
		<description><![CDATA[Here&#8217;s the first &#8216;tutorial&#8217;-esque video that I&#8217;ve published in my new Channel Scripting for Smarties. Enjoy~ Share and Enjoy:]]></description>
			<content:encoded><![CDATA[<div style="text-align:center;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/IjGPMf70-d0&amp;hl=en&amp;fs=1&amp;" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/IjGPMf70-d0&amp;hl=en&amp;fs=1&amp;" allowscriptaccess="always" allowfullscreen="true"></embed></object>
</div>
<p><BR /><br />
Here&#8217;s the first &#8216;tutorial&#8217;-esque video that I&#8217;ve published in my new Channel <a title="Scripting for Smarties on YouTube" href="http://www.youtube.com/ScriptingForSmarties/" target="_blank">Scripting for Smarties</a>.</p>
<p>Enjoy~</p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fscripting-for-smarties-application-portability-101%2F&amp;title=Scripting%20for%20Smarties%20%3A%20Application%20Portability%20101&amp;bodytext=%0D%0A%0D%0A%0D%0AHere%27s%20the%20first%20%27tutorial%27-esque%20video%20that%20I%27ve%20published%20in%20my%20new%20Channel%20Scripting%20for%20Smarties.%0D%0A%0D%0AEnjoy%7E" title="Digg"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fscripting-for-smarties-application-portability-101%2F" title="Sphinn"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fscripting-for-smarties-application-portability-101%2F&amp;title=Scripting%20for%20Smarties%20%3A%20Application%20Portability%20101&amp;notes=%0D%0A%0D%0A%0D%0AHere%27s%20the%20first%20%27tutorial%27-esque%20video%20that%20I%27ve%20published%20in%20my%20new%20Channel%20Scripting%20for%20Smarties.%0D%0A%0D%0AEnjoy%7E" title="del.icio.us"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fscripting-for-smarties-application-portability-101%2F&amp;t=Scripting%20for%20Smarties%20%3A%20Application%20Portability%20101" title="Facebook"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fscripting-for-smarties-application-portability-101%2F&amp;title=Scripting%20for%20Smarties%20%3A%20Application%20Portability%20101" title="Mixx"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fscripting-for-smarties-application-portability-101%2F&amp;title=Scripting%20for%20Smarties%20%3A%20Application%20Portability%20101&amp;annotation=%0D%0A%0D%0A%0D%0AHere%27s%20the%20first%20%27tutorial%27-esque%20video%20that%20I%27ve%20published%20in%20my%20new%20Channel%20Scripting%20for%20Smarties.%0D%0A%0D%0AEnjoy%7E" title="Google Bookmarks"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fscripting-for-smarties-application-portability-101%2F&amp;title=Scripting%20for%20Smarties%20%3A%20Application%20Portability%20101&amp;source=Michael+Hartmayer+-+Portfolio+Have+a+Leet+Smoothy&amp;summary=%0D%0A%0D%0A%0D%0AHere%27s%20the%20first%20%27tutorial%27-esque%20video%20that%20I%27ve%20published%20in%20my%20new%20Channel%20Scripting%20for%20Smarties.%0D%0A%0D%0AEnjoy%7E" title="LinkedIn"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fscripting-for-smarties-application-portability-101%2F&amp;title=Scripting%20for%20Smarties%20%3A%20Application%20Portability%20101" title="Live"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fscripting-for-smarties-application-portability-101%2F&amp;t=Scripting%20for%20Smarties%20%3A%20Application%20Portability%20101" title="MySpace"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fscripting-for-smarties-application-portability-101%2F&amp;title=Scripting%20for%20Smarties%20%3A%20Application%20Portability%20101" title="Reddit"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fscripting-for-smarties-application-portability-101%2F&amp;title=Scripting%20for%20Smarties%20%3A%20Application%20Portability%20101" title="StumbleUpon"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.michaelhartmayer.com/php/scripting-for-smarties-application-portability-101/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Database Class</title>
		<link>http://www.michaelhartmayer.com/php/php-database-class/</link>
		<comments>http://www.michaelhartmayer.com/php/php-database-class/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 17:09:36 +0000</pubDate>
		<dc:creator>Michael Hartmayer</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Class]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[Singleton]]></category>

		<guid isPermaLink="false">http://www.michaelhartmayer.com/?p=369</guid>
		<description><![CDATA[I just recently wrote a brand new Database class to add to my PHP library. The old one was starting to get stale. This class is capable of taking advantage of the Singleton design pattern. &#60;?php &#160; /** * @author Michael Hartmayer (michaelhartmayer[at]gmail.com) * @copyright 2009 */ &#160; class Db &#123; &#160; static $ref; // [...]]]></description>
			<content:encoded><![CDATA[<p>I just recently wrote a brand new Database class to add to my PHP library. The old one was starting to get stale. This class is capable of taking advantage of the Singleton design pattern.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * @author Michael Hartmayer (michaelhartmayer[at]gmail.com)
 * @copyright 2009
 */</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">class</span> Db <span style="color: #009900;">&#123;</span>
&nbsp;
		static <span style="color: #000088;">$ref</span><span style="color: #339933;">;</span>				<span style="color: #666666; font-style: italic;">// Database Resource</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$user</span> 	<span style="color: #339933;">=</span> <span style="color: #0000ff;">'root'</span><span style="color: #339933;">;</span>		<span style="color: #666666; font-style: italic;">// Username</span>
		<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$pass</span> 	<span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>			<span style="color: #666666; font-style: italic;">// Password</span>
		<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$host</span> 	<span style="color: #339933;">=</span> <span style="color: #0000ff;">'localhost'</span><span style="color: #339933;">;</span>		<span style="color: #666666; font-style: italic;">// Host</span>
		<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$db</span> 	<span style="color: #339933;">=</span> <span style="color: #0000ff;">'test'</span><span style="color: #339933;">;</span>		<span style="color: #666666; font-style: italic;">// Database</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$err</span> 	<span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>		<span style="color: #666666; font-style: italic;">// Error Log</span>
		<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$errHalt</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>		<span style="color: #666666; font-style: italic;">// Toggle: Halt on DB Error?</span>
&nbsp;
		static <span style="color: #000088;">$q</span><span style="color: #339933;">;</span>				<span style="color: #666666; font-style: italic;">// Last Query</span>
		static <span style="color: #000088;">$r</span><span style="color: #339933;">;</span>				<span style="color: #666666; font-style: italic;">// Last Results</span>
&nbsp;
		static <span style="color: #000088;">$singleton</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Db<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">return</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;">//endMethod</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getInstance<span style="color: #009900;">&#40;</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: #339933;">!</span><span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$singleton</span><span style="color: #009900;">&#41;</span>
				<span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$singleton</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$singleton</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #666666; font-style: italic;">//endMethod</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setUser<span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">user</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$i</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">return</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;">//endMethod </span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setPass<span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">pass</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$i</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">return</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;">//endMethod</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setHost<span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">host</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$i</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">return</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;">//endMethod</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setDb<span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$i</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">return</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;">//endMethod</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setAll<span style="color: #009900;">&#40;</span><span style="color: #000088;">$h</span><span style="color: #339933;">,</span><span style="color: #000088;">$u</span><span style="color: #339933;">,</span><span style="color: #000088;">$p</span><span style="color: #339933;">,</span><span style="color: #000088;">$d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">host</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$h</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">user</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$u</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">pass</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$p</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$d</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #666666; font-style: italic;">//endMethod</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> doConnect<span style="color: #009900;">&#40;</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: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ref</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
				<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">doDisconnect</span><span style="color: #009900;">&#40;</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: #339933;">!</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ref</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">host</span><span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">user</span><span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">pass</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
				<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dbErr</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</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: #339933;">!@</span><span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ref</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>			
				<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dbErr</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ref</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">return</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;">//endMethod</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> doDisconnect<span style="color: #009900;">&#40;</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;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ref</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #990000;">mysql_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ref</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ref</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">return</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;">//endMethod</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getRef<span style="color: #009900;">&#40;</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;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ref</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #666666; font-style: italic;">//endMethod</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> dbSet<span style="color: #009900;">&#40;</span><span style="color: #000088;">$q</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">q</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$q</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">r</span><span style="color: #339933;">=@</span><span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">q</span><span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ref</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> 
				<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dbErr</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ref</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #666666; font-style: italic;">//endMethod</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> dbGet<span style="color: #009900;">&#40;</span><span style="color: #000088;">$q</span><span style="color: #339933;">,</span><span style="color: #000088;">$type</span><span style="color: #339933;">=</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
			<span style="color: #b1b100;">switch</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$type</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'STR'</span><span style="color: #339933;">:</span>
					<span style="color: #000088;">$resultType</span> <span style="color: #339933;">=</span> MYSQL_ASSOC<span style="color: #339933;">;</span>
					<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'INT'</span><span style="color: #339933;">:</span>
					<span style="color: #000088;">$resultType</span> <span style="color: #339933;">=</span> MYSQL_NUM<span style="color: #339933;">;</span>
					<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">default</span><span style="color: #339933;">:</span>
					<span style="color: #000088;">$resultType</span> <span style="color: #339933;">=</span> MYSQL_BOTH<span style="color: #339933;">;</span>
					<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">q</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$q</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">r</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">q</span><span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ref</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> 
				<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dbErr</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ref</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #000088;">$resultArr</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$makeDbArr</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">r</span><span style="color: #339933;">,</span><span style="color: #000088;">$resultType</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$resultArr</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$makeDbArr</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #666666; font-style: italic;">//endWhile</span>
&nbsp;
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$resultArr</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #666666; font-style: italic;">//endMethod</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> dbCount<span style="color: #009900;">&#40;</span><span style="color: #000088;">$table</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matchPartialQuery</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: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">q</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT COUNT(*) AS 'COUNT' FROM `<span style="color: #006699; font-weight: bold;">$table</span>` <span style="color: #006699; font-weight: bold;">$matchPartialQuery</span>;&quot;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">r</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dbGet</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">q</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
				<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">r</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'COUNT'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dbErr</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">err</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #666666; font-style: italic;">//endMethod</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> dbErr<span style="color: #009900;">&#40;</span><span style="color: #000088;">$err</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;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$err</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">err</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$err</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">errHalt</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;&gt;&gt; System has halted on Db Error. &lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&gt;&gt; Error Log:&lt;br /&gt;&lt;br /&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;">$err</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #990000;">exit</span><span style="color: #339933;">;</span>	
			<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #b1b100;">return</span> err<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #666666; font-style: italic;">//endMethod</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> strClean<span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #990000;">mysql_real_escape_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ref</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #666666; font-style: italic;">//endMethod</span>
&nbsp;
	<span style="color: #009900;">&#125;</span><span style="color: #666666; font-style: italic;">//endClass</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>


<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-database-class%2F&amp;title=PHP%20Database%20Class&amp;bodytext=I%20just%20recently%20wrote%20a%20brand%20new%20Database%20class%20to%20add%20to%20my%20PHP%20library.%20The%20old%20one%20was%20starting%20to%20get%20stale.%20This%20class%20is%20capable%20of%20taking%20advantage%20of%20the%20Singleton%20design%20pattern.%0D%0A%0D%0A%0D%0A%0D%0A" title="Digg"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-database-class%2F" title="Sphinn"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-database-class%2F&amp;title=PHP%20Database%20Class&amp;notes=I%20just%20recently%20wrote%20a%20brand%20new%20Database%20class%20to%20add%20to%20my%20PHP%20library.%20The%20old%20one%20was%20starting%20to%20get%20stale.%20This%20class%20is%20capable%20of%20taking%20advantage%20of%20the%20Singleton%20design%20pattern.%0D%0A%0D%0A%0D%0A%0D%0A" title="del.icio.us"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-database-class%2F&amp;t=PHP%20Database%20Class" title="Facebook"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-database-class%2F&amp;title=PHP%20Database%20Class" title="Mixx"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-database-class%2F&amp;title=PHP%20Database%20Class&amp;annotation=I%20just%20recently%20wrote%20a%20brand%20new%20Database%20class%20to%20add%20to%20my%20PHP%20library.%20The%20old%20one%20was%20starting%20to%20get%20stale.%20This%20class%20is%20capable%20of%20taking%20advantage%20of%20the%20Singleton%20design%20pattern.%0D%0A%0D%0A%0D%0A%0D%0A" title="Google Bookmarks"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-database-class%2F&amp;title=PHP%20Database%20Class&amp;source=Michael+Hartmayer+-+Portfolio+Have+a+Leet+Smoothy&amp;summary=I%20just%20recently%20wrote%20a%20brand%20new%20Database%20class%20to%20add%20to%20my%20PHP%20library.%20The%20old%20one%20was%20starting%20to%20get%20stale.%20This%20class%20is%20capable%20of%20taking%20advantage%20of%20the%20Singleton%20design%20pattern.%0D%0A%0D%0A%0D%0A%0D%0A" title="LinkedIn"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-database-class%2F&amp;title=PHP%20Database%20Class" title="Live"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-database-class%2F&amp;t=PHP%20Database%20Class" title="MySpace"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-database-class%2F&amp;title=PHP%20Database%20Class" title="Reddit"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-database-class%2F&amp;title=PHP%20Database%20Class" title="StumbleUpon"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.michaelhartmayer.com/php/php-database-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP LoadScript Class</title>
		<link>http://www.michaelhartmayer.com/php/php-loadscript-class/</link>
		<comments>http://www.michaelhartmayer.com/php/php-loadscript-class/#comments</comments>
		<pubDate>Sun, 28 Jun 2009 03:46:16 +0000</pubDate>
		<dc:creator>Michael Hartmayer</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Optimization]]></category>

		<guid isPermaLink="false">http://www.michaelhartmayer.com/?p=289</guid>
		<description><![CDATA[This is a really handy class I wrote that loads all your scripts Server Side so that when your page loads there aren&#8217;t so many HTTP Requests. Useful if you&#8217;re trying to load 6 different js files and 4 different style sheets, or whatever. That&#8217;s 10 requests, completely gone. Just keep in mind that it [...]]]></description>
			<content:encoded><![CDATA[<p>This is a really handy class I wrote that loads all your scripts Server Side so that when your page loads there aren&#8217;t so many HTTP Requests. Useful if you&#8217;re trying to load 6 different js files and 4 different style sheets, or whatever. That&#8217;s 10 requests, completely gone. Just keep in mind that it dumps all your files straight into the html document- so, as long as you don&#8217;t have a problem with that, this is a great tool.</p>
<p>In addition, it&#8217;s really easy to add your own script types. Check out the script for details.</p>
<p>( Available At: <a title="PasteBin: LoadScript Class" rel="nofollow" href="http://pastebin.com/f5241789e" target="_blank">PasteBin: LoadScript Class</a> )</p>
<p>Usage:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
   <span style="color: #666666; font-style: italic;"># Include Class
</span>   <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'class.scriptloader.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;"># Instantiate
</span>   <span style="color: #000088;">$jsLoader</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ScriptLoader<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'JS'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;"># Add Scripts
</span>   <span style="color: #000088;">$jsLoader</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addScript</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'my-javascript.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$jsLoader</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addScript</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$jsLoader</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addScript</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'other-scripts.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;"># Dump into Document
</span>   <span style="color: #000088;">$jsLoader</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">echoScripts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>On a quick note, it&#8217;d probably be a lot &#8216;neater&#8217; to mod-rewrite a php file to handle at least one request per script type. That way it doesn&#8217;t all get dumped straight into the page.</p>
<p>Something like:</p>
<p><em>RewriteRule ^script\.(.*)$ script-loader.php?type=$1 [L]</em></p>
<p>And for <strong>script-loader.php</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
   <span style="color: #b1b100;">switch</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'js'</span><span style="color: #339933;">:</span>
         <span style="color: #666666; font-style: italic;">// Load all of the JavaScript files here</span>
         <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>That way when you load something like <strong>script.js</strong> it will dump all of your java scripts into a &#8216;fake&#8217; file. Just make sure to use the default <em>$<span style="text-decoration: underline;">ScriptLoader</span>-&gt;type</em> (don&#8217;t set one when instantiating) if you are loading it from a <em>src=&#8221;foo.bar&#8221;</em>.</p>
<p>.. or something like that xD</p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-loadscript-class%2F&amp;title=PHP%20LoadScript%20Class&amp;bodytext=This%20is%20a%20really%20handy%20class%20I%20wrote%20that%20loads%20all%20your%20scripts%20Server%20Side%20so%20that%20when%20your%20page%20loads%20there%20aren%27t%20so%20many%20HTTP%20Requests.%20Useful%20if%20you%27re%20trying%20to%20load%206%20different%20js%20files%20and%204%20different%20style%20sheets%2C%20or%20whatever.%20That%27s%2010%20re" title="Digg"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-loadscript-class%2F" title="Sphinn"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-loadscript-class%2F&amp;title=PHP%20LoadScript%20Class&amp;notes=This%20is%20a%20really%20handy%20class%20I%20wrote%20that%20loads%20all%20your%20scripts%20Server%20Side%20so%20that%20when%20your%20page%20loads%20there%20aren%27t%20so%20many%20HTTP%20Requests.%20Useful%20if%20you%27re%20trying%20to%20load%206%20different%20js%20files%20and%204%20different%20style%20sheets%2C%20or%20whatever.%20That%27s%2010%20re" title="del.icio.us"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-loadscript-class%2F&amp;t=PHP%20LoadScript%20Class" title="Facebook"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-loadscript-class%2F&amp;title=PHP%20LoadScript%20Class" title="Mixx"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-loadscript-class%2F&amp;title=PHP%20LoadScript%20Class&amp;annotation=This%20is%20a%20really%20handy%20class%20I%20wrote%20that%20loads%20all%20your%20scripts%20Server%20Side%20so%20that%20when%20your%20page%20loads%20there%20aren%27t%20so%20many%20HTTP%20Requests.%20Useful%20if%20you%27re%20trying%20to%20load%206%20different%20js%20files%20and%204%20different%20style%20sheets%2C%20or%20whatever.%20That%27s%2010%20re" title="Google Bookmarks"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-loadscript-class%2F&amp;title=PHP%20LoadScript%20Class&amp;source=Michael+Hartmayer+-+Portfolio+Have+a+Leet+Smoothy&amp;summary=This%20is%20a%20really%20handy%20class%20I%20wrote%20that%20loads%20all%20your%20scripts%20Server%20Side%20so%20that%20when%20your%20page%20loads%20there%20aren%27t%20so%20many%20HTTP%20Requests.%20Useful%20if%20you%27re%20trying%20to%20load%206%20different%20js%20files%20and%204%20different%20style%20sheets%2C%20or%20whatever.%20That%27s%2010%20re" title="LinkedIn"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-loadscript-class%2F&amp;title=PHP%20LoadScript%20Class" title="Live"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-loadscript-class%2F&amp;t=PHP%20LoadScript%20Class" title="MySpace"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-loadscript-class%2F&amp;title=PHP%20LoadScript%20Class" title="Reddit"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-loadscript-class%2F&amp;title=PHP%20LoadScript%20Class" title="StumbleUpon"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.michaelhartmayer.com/php/php-loadscript-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP TripCode</title>
		<link>http://www.michaelhartmayer.com/php/php-tripcode/</link>
		<comments>http://www.michaelhartmayer.com/php/php-tripcode/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 06:00:08 +0000</pubDate>
		<dc:creator>Michael Hartmayer</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tripcode]]></category>

		<guid isPermaLink="false">http://www.michaelhartmayer.com/?p=276</guid>
		<description><![CDATA[** EDIT ** I found some problems with my code. =) Did some research on PHP&#8217;s crypt() and found out that the salt doesn&#8217;t quite work they way I had expected it to. Going to post a revision soon. This is my version of a PHP TripCode (that I will be using for No-Mess-Enger). The [...]]]></description>
			<content:encoded><![CDATA[<p><em>** EDIT **<br />
I found some problems with my code. =) Did some research on PHP&#8217;s <strong>crypt()</strong> and found out that the salt doesn&#8217;t quite work they way I had expected it to. Going to post a revision soon.<br />
</em><br />
This is my version of a PHP <a href="http://en.wikipedia.org/wiki/Tripcode" target="_blank" title="WikiPedia: TripCode">TripCode</a> (that I will be using for No-Mess-Enger). The way it works is, the user chooses a name, and a key. That information along with the randomly generated URI generate an integer that will eventually be used to select a random animal or something like that. This will allow users to remain anonymous while upholding the integrity of the users authenticity, in case another user tries to choose the same name.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> utilMakeTripcode<span style="color: #009900;">&#40;</span><span style="color: #000088;">$alias</span><span style="color: #339933;">,</span><span style="color: #000088;">$key</span><span style="color: #339933;">,</span><span style="color: #000088;">$uri</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;"># generate tripcode
</span>  <span style="color: #000088;">$s</span> <span style="color: #339933;">=</span> <span style="color: #990000;">crypt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$alias</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$key</span>#<span style="color: #006699; font-weight: bold;">$uri</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$r</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&lt;</span>strlen<span style="color: #009900;">&#40;</span><span style="color: #000088;">$s</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #000088;">$r</span><span style="color: #339933;">.=</span> <span style="color: #990000;">hexdec</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$s</span><span style="color: #339933;">,</span><span style="color: #000088;">$i</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #b1b100;">return</span> <span style="color: #990000;">bindec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$r</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Example:</p>
<p>- User enters the Alias: Jon<br />
- User enters the Key: SecretWord<br />
- The TripCode Int generated is <strong>101</strong></p>
<p>At this point I can use something like this to select the users animal:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$usersAnimal</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$allAnimals</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$maxAnimals</span><span style="color: #339933;">-</span><span style="color: #000088;">$maxAnimals</span><span style="color: #339933;">%</span><span style="color: #000088;">$tripCodeInt</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></div></div>

<p>In this example <strong>$allAnimals</strong> is an array holding every Animal name. $maxAnimals is the array size, and $tripCodeInt is the integer generated from the <strong>utilMakeTripCode()</strong> function. </p>
<p>So now when the user talks in Chat he might be called:<br />
Jon the <em>Koala</em></p>
<p><em>** Note **<br />
I&#8217;ve only TESTED the function. Can&#8217;t verify that the second snippet works exactly that way. It&#8217;s more pseudo code.. so don&#8217;t hate me if it&#8217;s not quite right. ^.^<br />
</em></p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-tripcode%2F&amp;title=PHP%20TripCode&amp;bodytext=%2A%2A%20EDIT%20%2A%2A%0D%0AI%20found%20some%20problems%20with%20my%20code.%20%3D%29%20Did%20some%20research%20on%20PHP%27s%20crypt%28%29%20and%20found%20out%20that%20the%20salt%20doesn%27t%20quite%20work%20they%20way%20I%20had%20expected%20it%20to.%20Going%20to%20post%20a%20revision%20soon.%0D%0A%0D%0AThis%20is%20my%20version%20of%20a%20PHP%20TripCode%20%28that%20I%20will%20be" title="Digg"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-tripcode%2F" title="Sphinn"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-tripcode%2F&amp;title=PHP%20TripCode&amp;notes=%2A%2A%20EDIT%20%2A%2A%0D%0AI%20found%20some%20problems%20with%20my%20code.%20%3D%29%20Did%20some%20research%20on%20PHP%27s%20crypt%28%29%20and%20found%20out%20that%20the%20salt%20doesn%27t%20quite%20work%20they%20way%20I%20had%20expected%20it%20to.%20Going%20to%20post%20a%20revision%20soon.%0D%0A%0D%0AThis%20is%20my%20version%20of%20a%20PHP%20TripCode%20%28that%20I%20will%20be" title="del.icio.us"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-tripcode%2F&amp;t=PHP%20TripCode" title="Facebook"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-tripcode%2F&amp;title=PHP%20TripCode" title="Mixx"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-tripcode%2F&amp;title=PHP%20TripCode&amp;annotation=%2A%2A%20EDIT%20%2A%2A%0D%0AI%20found%20some%20problems%20with%20my%20code.%20%3D%29%20Did%20some%20research%20on%20PHP%27s%20crypt%28%29%20and%20found%20out%20that%20the%20salt%20doesn%27t%20quite%20work%20they%20way%20I%20had%20expected%20it%20to.%20Going%20to%20post%20a%20revision%20soon.%0D%0A%0D%0AThis%20is%20my%20version%20of%20a%20PHP%20TripCode%20%28that%20I%20will%20be" title="Google Bookmarks"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-tripcode%2F&amp;title=PHP%20TripCode&amp;source=Michael+Hartmayer+-+Portfolio+Have+a+Leet+Smoothy&amp;summary=%2A%2A%20EDIT%20%2A%2A%0D%0AI%20found%20some%20problems%20with%20my%20code.%20%3D%29%20Did%20some%20research%20on%20PHP%27s%20crypt%28%29%20and%20found%20out%20that%20the%20salt%20doesn%27t%20quite%20work%20they%20way%20I%20had%20expected%20it%20to.%20Going%20to%20post%20a%20revision%20soon.%0D%0A%0D%0AThis%20is%20my%20version%20of%20a%20PHP%20TripCode%20%28that%20I%20will%20be" title="LinkedIn"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-tripcode%2F&amp;title=PHP%20TripCode" title="Live"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-tripcode%2F&amp;t=PHP%20TripCode" title="MySpace"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-tripcode%2F&amp;title=PHP%20TripCode" title="Reddit"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fphp-tripcode%2F&amp;title=PHP%20TripCode" title="StumbleUpon"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.michaelhartmayer.com/php/php-tripcode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom Scripting Language for Items</title>
		<link>http://www.michaelhartmayer.com/php/custom-scripting-language-for-items/</link>
		<comments>http://www.michaelhartmayer.com/php/custom-scripting-language-for-items/#comments</comments>
		<pubDate>Sun, 21 Jun 2009 02:15:13 +0000</pubDate>
		<dc:creator>Michael Hartmayer</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Item Scripting]]></category>

		<guid isPermaLink="false">http://www.michaelhartmayer.com/?p=253</guid>
		<description><![CDATA[I&#8217;ve been working on some new software.. Below is a prototype version of my proprietary itemScript parser, written in PHP. The goal is to have a pseudo-scripting language available for game-items that can be read dynamically by the server, so that new items can be added without additional hard coding. function scriptToArr&#40;$str&#41; &#123; # Parse [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working on some new software.. Below is a prototype version of my proprietary itemScript parser, written in PHP. The goal is to have a pseudo-scripting language available for game-items that can be read dynamically by the server, so that new items can be added without additional hard coding.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> scriptToArr<span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #666666; font-style: italic;"># Parse for Whitespace
</span>   <span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;#(<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>|<span style="color: #000099; font-weight: bold;">\r</span>|<span style="color: #000099; font-weight: bold;">\n</span>|<span style="color: #000099; font-weight: bold;">\t</span>|\s)#&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;"># Event Handlers
</span>   <span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;#(.*?)\{(.*?)\}(,|)#is&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$str</span><span style="color: #339933;">,</span><span style="color: #000088;">$findEventHandlers</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #000088;">$arrEvents</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$j</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><span style="color: #000088;">$j</span><span style="color: #339933;">&lt;</span>sizeof<span style="color: #009900;">&#40;</span><span style="color: #000088;">$findEventHandlers</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000088;">$j</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #666666; font-style: italic;"># this event
</span>      <span style="color: #000088;">$thisEvent</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$findEventHandlers</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$j</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;"># these functions
</span>      <span style="color: #000088;">$getFunctions</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$findEventHandlers</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$j</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$allFunctions</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;;&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$getFunctions</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;"># get all parameters
</span>      <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$allFunctions</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$function</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #666666; font-style: italic;"># read and parse function
</span>         <span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;#(.+?)\((.*)\)#&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$function</span><span style="color: #339933;">,</span><span style="color: #000088;">$functionAndPara</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
         <span style="color: #000088;">$thisFunction</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$functionAndPara</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
         <span style="color: #000088;">$thisParaSet</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$functionAndPara</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>               
&nbsp;
         <span style="color: #666666; font-style: italic;"># parse and arr strings
</span>         <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;#\'(.+),(.+)\'#&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$thisParaSet</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$thisParaSet</span><span style="color: #339933;">=</span><span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;#\'(.+?),(.+?)\'#&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;'<span style="color: #006699; font-weight: bold;">$1</span><span style="color: #660099; font-weight: bold;">\0</span>COMMA<span style="color: #660099; font-weight: bold;">\0</span><span style="color: #006699; font-weight: bold;">$2</span>'&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$thisParaSet</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
         <span style="color: #009900;">&#125;</span>
         <span style="color: #000088;">$thisParaSet</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$thisParaSet</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
         <span style="color: #666666; font-style: italic;"># get each parameter
</span>         <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$thisParaSet</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$parameter</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;">$addPara</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: #660099; font-weight: bold;">\0</span>COMMA<span style="color: #660099; font-weight: bold;">\0</span>&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$parameter</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
               <span style="color: #000088;">$arrEvents</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$thisEvent</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$thisFunction</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$addPara</span><span style="color: #339933;">;</span>
         <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
   <span style="color: #b1b100;">return</span> <span style="color: #000088;">$arrEvents</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Here is a sample script I created:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">      onDraw <span style="color: #009900;">&#123;</span>
         setMana<span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> thisPlayer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
         doOtherThing<span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span> thisPlayer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
      onExert <span style="color: #009900;">&#123;</span>
         sendToHand<span style="color: #009900;">&#40;</span> thisTile<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> thisPlayer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> x<span style="color: #339933;">,</span> y<span style="color: #339933;">,</span> z<span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
      onDestroy <span style="color: #009900;">&#123;</span>
         setMana<span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span> thisPlayer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span></pre></div></div>

<p>The script then gets torn apart and dumped into a multi-dimensional array. See Screenshot.</p>
<p><a href="http://www.michaelhartmayer.com/wp-content/uploads/2009/06/phpItemParse.jpg" rel="lightbox"><img class="alignnone size-medium wp-image-261" title="PHP Item Script Parser" src="http://www.michaelhartmayer.com/wp-content/uploads/2009/06/phpItemParse-300x241.jpg" alt="PHP Item Script Parser" width="300" height="241" /></a></p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fcustom-scripting-language-for-items%2F&amp;title=Custom%20Scripting%20Language%20for%20Items&amp;bodytext=I%27ve%20been%20working%20on%20some%20new%20software..%20Below%20is%20a%20prototype%20version%20of%20my%20proprietary%20itemScript%20parser%2C%20written%20in%20PHP.%20The%20goal%20is%20to%20have%20a%20pseudo-scripting%20language%20available%20for%20game-items%20that%20can%20be%20read%20dynamically%20by%20the%20server%2C%20so%20that%20ne" title="Digg"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fcustom-scripting-language-for-items%2F" title="Sphinn"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fcustom-scripting-language-for-items%2F&amp;title=Custom%20Scripting%20Language%20for%20Items&amp;notes=I%27ve%20been%20working%20on%20some%20new%20software..%20Below%20is%20a%20prototype%20version%20of%20my%20proprietary%20itemScript%20parser%2C%20written%20in%20PHP.%20The%20goal%20is%20to%20have%20a%20pseudo-scripting%20language%20available%20for%20game-items%20that%20can%20be%20read%20dynamically%20by%20the%20server%2C%20so%20that%20ne" title="del.icio.us"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fcustom-scripting-language-for-items%2F&amp;t=Custom%20Scripting%20Language%20for%20Items" title="Facebook"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fcustom-scripting-language-for-items%2F&amp;title=Custom%20Scripting%20Language%20for%20Items" title="Mixx"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fcustom-scripting-language-for-items%2F&amp;title=Custom%20Scripting%20Language%20for%20Items&amp;annotation=I%27ve%20been%20working%20on%20some%20new%20software..%20Below%20is%20a%20prototype%20version%20of%20my%20proprietary%20itemScript%20parser%2C%20written%20in%20PHP.%20The%20goal%20is%20to%20have%20a%20pseudo-scripting%20language%20available%20for%20game-items%20that%20can%20be%20read%20dynamically%20by%20the%20server%2C%20so%20that%20ne" title="Google Bookmarks"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fcustom-scripting-language-for-items%2F&amp;title=Custom%20Scripting%20Language%20for%20Items&amp;source=Michael+Hartmayer+-+Portfolio+Have+a+Leet+Smoothy&amp;summary=I%27ve%20been%20working%20on%20some%20new%20software..%20Below%20is%20a%20prototype%20version%20of%20my%20proprietary%20itemScript%20parser%2C%20written%20in%20PHP.%20The%20goal%20is%20to%20have%20a%20pseudo-scripting%20language%20available%20for%20game-items%20that%20can%20be%20read%20dynamically%20by%20the%20server%2C%20so%20that%20ne" title="LinkedIn"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fcustom-scripting-language-for-items%2F&amp;title=Custom%20Scripting%20Language%20for%20Items" title="Live"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fcustom-scripting-language-for-items%2F&amp;t=Custom%20Scripting%20Language%20for%20Items" title="MySpace"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fcustom-scripting-language-for-items%2F&amp;title=Custom%20Scripting%20Language%20for%20Items" title="Reddit"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.michaelhartmayer.com%2Fphp%2Fcustom-scripting-language-for-items%2F&amp;title=Custom%20Scripting%20Language%20for%20Items" title="StumbleUpon"><img src="http://www.michaelhartmayer.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.michaelhartmayer.com/php/custom-scripting-language-for-items/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
