<?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>Squirrel Hacker &#187; PHP</title>
	<atom:link href="http://blog.seanja.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.seanja.com</link>
	<description>I have come forward in time from the year 1986 to share this with you</description>
	<lastBuildDate>Mon, 06 Feb 2012 12:38:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>17 &#8220;rm&#8221;s? Wonder what I&#8217;m hiding&#8230;</title>
		<link>http://blog.seanja.com/2011/12/17-rms-wonder-what-im-hiding/</link>
		<comments>http://blog.seanja.com/2011/12/17-rms-wonder-what-im-hiding/#comments</comments>
		<pubDate>Sat, 24 Dec 2011 02:11:40 +0000</pubDate>
		<dc:creator>SeanJA</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[AWK]]></category>
		<category><![CDATA[Configure script]]></category>
		<category><![CDATA[CURL]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[history]]></category>
		<category><![CDATA[Mkdir]]></category>
		<category><![CDATA[Nautilus]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Uniq]]></category>

		<guid isPermaLink="false">http://blog.seanja.com/?p=38982</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blog.seanja.com/2011/12/17-rms-wonder-what-im-hiding/' addthis:title='17 &#8220;rm&#8221;s? Wonder what I&#8217;m hiding&#8230; '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>seanja@deepthought:~$ history &#124; awk {'print $2'} &#124; sort &#124; uniq -c &#124; sort -k1 -rn &#124; 204 svn 138 cd 125 ssh 116 sudo 95 ls 63 ll 37 exit 20 nano 17 rm 17 convert Related posts: Smarty&#8230; again Damn-it PHP UBB AVP&#8230; same difference<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.seanja.com/2011/12/17-rms-wonder-what-im-hiding/' addthis:title='17 &#8220;rm&#8221;s? Wonder what I&#8217;m hiding&#8230; ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>
Related posts:<ol>
<li><a href='http://blog.seanja.com/2009/04/smarty-again/' rel='bookmark' title='Smarty&#8230; again'>Smarty&#8230; again</a></li>
<li><a href='http://blog.seanja.com/2009/02/damn-it-php/' rel='bookmark' title='Damn-it PHP'>Damn-it PHP</a></li>
<li><a href='http://blog.seanja.com/2011/03/ubb-avp-same-difference/' rel='bookmark' title='UBB AVP&#8230; same difference'>UBB AVP&#8230; same difference</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blog.seanja.com/2011/12/17-rms-wonder-what-im-hiding/' addthis:title='17 &#8220;rm&#8221;s? Wonder what I&#8217;m hiding&#8230; '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p><code>seanja@deepthought:~$ history | awk {'print $2'} | sort | uniq -c | sort -k1 -rn | </code></p>
<pre>
    204 svn
    138 cd
    125 ssh
    116 sudo
     95 ls
     63 ll
     37 exit
     20 nano
     17 rm
     17 convert
</pre>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.seanja.com/2011/12/17-rms-wonder-what-im-hiding/' addthis:title='17 &#8220;rm&#8221;s? Wonder what I&#8217;m hiding&#8230; ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div><p>Related posts:<ol>
<li><a href='http://blog.seanja.com/2009/04/smarty-again/' rel='bookmark' title='Smarty&#8230; again'>Smarty&#8230; again</a></li>
<li><a href='http://blog.seanja.com/2009/02/damn-it-php/' rel='bookmark' title='Damn-it PHP'>Damn-it PHP</a></li>
<li><a href='http://blog.seanja.com/2011/03/ubb-avp-same-difference/' rel='bookmark' title='UBB AVP&#8230; same difference'>UBB AVP&#8230; same difference</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.seanja.com/2011/12/17-rms-wonder-what-im-hiding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Code: Custom Node Add/Edit Title</title>
		<link>http://blog.seanja.com/2011/07/code-custom-node-addedit-title/</link>
		<comments>http://blog.seanja.com/2011/07/code-custom-node-addedit-title/#comments</comments>
		<pubDate>Fri, 22 Jul 2011 19:24:41 +0000</pubDate>
		<dc:creator>SeanJA</dc:creator>
				<category><![CDATA[Drupal]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Blog software]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Cross-platform software]]></category>
		<category><![CDATA[custom title]]></category>
		<category><![CDATA[node add]]></category>
		<category><![CDATA[node edit]]></category>
		<category><![CDATA[Web development]]></category>
		<category><![CDATA[World Wide Web]]></category>

		<guid isPermaLink="false">http://blog.seanja.com/?p=38887</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blog.seanja.com/2011/07/code-custom-node-addedit-title/' addthis:title='Code: Custom Node Add/Edit Title '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>You can achieve this by adding this to template.php in your theme folder. function phptemplate_node_form&#40;$form&#41; &#123; switch&#40;$form&#91;'type'&#93;&#91;'#value'&#93;&#41; &#123; case 'my_node_type': $title = empty&#40;$form&#91;'nid'&#93;&#91;'#value'&#93;&#41; ? 'Add a new custom node' : 'Edit a new custom node'; drupal_set_title&#40;$title&#41;; break; &#125; /** note: returning drupal_render_form() will bump your save / preview buttons up to the top **/ return [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.seanja.com/2011/07/code-custom-node-addedit-title/' addthis:title='Code: Custom Node Add/Edit Title ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>
Related posts:<ol>
<li><a href='http://blog.seanja.com/2011/07/check-if-the-current-node-has-been-updated/' rel='bookmark' title='Check if the current node has been updated'>Check if the current node has been updated</a></li>
<li><a href='http://blog.seanja.com/2010/03/documenting-php-code/' rel='bookmark' title='Documenting PHP Code'>Documenting PHP Code</a></li>
<li><a href='http://blog.seanja.com/2011/08/module-login-with-email-or-username-drupal/' rel='bookmark' title='Module: Login With Email or Username Drupal'>Module: Login With Email or Username Drupal</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blog.seanja.com/2011/07/code-custom-node-addedit-title/' addthis:title='Code: Custom Node Add/Edit Title '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>You can achieve this by adding this to <code>template.php</code> in your theme folder.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> phptemplate_node_form<span style="color: #009900;">&#40;</span><span style="color: #000088;">$form</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">switch</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$form</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'#value'</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;">'my_node_type'</span><span style="color: #339933;">:</span>
      <span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> <span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$form</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'nid'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'#value'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">'Add a new custom node'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">'Edit a new custom node'</span><span style="color: #339933;">;</span>
      drupal_set_title<span style="color: #009900;">&#40;</span><span style="color: #000088;">$title</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #009933; font-style: italic;">/** note: returning drupal_render_form() will bump your save / preview buttons up to the top **/</span>
  <span style="color: #b1b100;">return</span> theme_node_form<span style="color: #009900;">&#40;</span><span style="color: #000088;">$form</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.seanja.com/2011/07/code-custom-node-addedit-title/' addthis:title='Code: Custom Node Add/Edit Title ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div><p>Related posts:<ol>
<li><a href='http://blog.seanja.com/2011/07/check-if-the-current-node-has-been-updated/' rel='bookmark' title='Check if the current node has been updated'>Check if the current node has been updated</a></li>
<li><a href='http://blog.seanja.com/2010/03/documenting-php-code/' rel='bookmark' title='Documenting PHP Code'>Documenting PHP Code</a></li>
<li><a href='http://blog.seanja.com/2011/08/module-login-with-email-or-username-drupal/' rel='bookmark' title='Module: Login With Email or Username Drupal'>Module: Login With Email or Username Drupal</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.seanja.com/2011/07/code-custom-node-addedit-title/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>You are doing it wrong&#8230;</title>
		<link>http://blog.seanja.com/2011/06/you-are-doing-it-wrong/</link>
		<comments>http://blog.seanja.com/2011/06/you-are-doing-it-wrong/#comments</comments>
		<pubDate>Mon, 20 Jun 2011 14:57:37 +0000</pubDate>
		<dc:creator>SeanJA</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[WTF]]></category>
		<category><![CDATA[Human Interest]]></category>
		<category><![CDATA[Social Issues]]></category>

		<guid isPermaLink="false">http://blog.seanja.com/?p=38828</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blog.seanja.com/2011/06/you-are-doing-it-wrong/' addthis:title='You are doing it wrong&#8230; '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>If you are putting this at the top of every file&#8230; // i will keep yelling this // DON'T FORGET TO START THE SESSION !!! session_start&#40;&#41;; You may just be doing php wrong&#8230; and I hate you Related posts: PHP Functions, you&#8217;re doing it wrong&#8230; PHP SQL Query Builder Job Search Results<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.seanja.com/2011/06/you-are-doing-it-wrong/' addthis:title='You are doing it wrong&#8230; ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>
Related posts:<ol>
<li><a href='http://blog.seanja.com/2010/04/php-functions-youre-doing-it-wrong/' rel='bookmark' title='PHP Functions, you&#8217;re doing it wrong&#8230;'>PHP Functions, you&#8217;re doing it wrong&#8230;</a></li>
<li><a href='http://blog.seanja.com/2011/01/php-sql-query-builder/' rel='bookmark' title='PHP SQL Query Builder'>PHP SQL Query Builder</a></li>
<li><a href='http://blog.seanja.com/2008/08/job-search-results/' rel='bookmark' title='Job Search Results'>Job Search Results</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blog.seanja.com/2011/06/you-are-doing-it-wrong/' addthis:title='You are doing it wrong&#8230; '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>If you are putting this at the top of every file&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// i will keep yelling this</span>
<span style="color: #666666; font-style: italic;">// DON'T FORGET TO START THE SESSION !!!</span>
<span style="color: #990000;">session_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>You may just be doing php wrong&#8230; and I hate you</p>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.seanja.com/2011/06/you-are-doing-it-wrong/' addthis:title='You are doing it wrong&#8230; ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div><p>Related posts:<ol>
<li><a href='http://blog.seanja.com/2010/04/php-functions-youre-doing-it-wrong/' rel='bookmark' title='PHP Functions, you&#8217;re doing it wrong&#8230;'>PHP Functions, you&#8217;re doing it wrong&#8230;</a></li>
<li><a href='http://blog.seanja.com/2011/01/php-sql-query-builder/' rel='bookmark' title='PHP SQL Query Builder'>PHP SQL Query Builder</a></li>
<li><a href='http://blog.seanja.com/2008/08/job-search-results/' rel='bookmark' title='Job Search Results'>Job Search Results</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.seanja.com/2011/06/you-are-doing-it-wrong/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up PHP 5.x on webfaction</title>
		<link>http://blog.seanja.com/2011/03/setting-up-php-5-x-on-webfaction/</link>
		<comments>http://blog.seanja.com/2011/03/setting-up-php-5-x-on-webfaction/#comments</comments>
		<pubDate>Mon, 21 Mar 2011 02:56:13 +0000</pubDate>
		<dc:creator>SeanJA</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[postaweek2011]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[webhost]]></category>
		<category><![CDATA[Chmod]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[HTTP clients]]></category>
		<category><![CDATA[PHP programming language]]></category>
		<category><![CDATA[Portable software]]></category>
		<category><![CDATA[Secure Shell]]></category>
		<category><![CDATA[Text mode]]></category>
		<category><![CDATA[Wget]]></category>

		<guid isPermaLink="false">http://blog.seanja.com/?p=38721</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blog.seanja.com/2011/03/setting-up-php-5-x-on-webfaction/' addthis:title='Setting up PHP 5.x on webfaction '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>PHP 5.2 1. Create a &#8220;Custom app listening on port&#8221; call it phpstack, note the port number you are assigned. 2. SSH into the server into the new application directory (~/webapps/phpstack/) 3. run: wget http://wiki.webfaction.com/attachment/wiki/MiscellaneousFiles/build_php_worker.sh?format=raw 4. Check that the file is executable by running: chmod +x build_php_worker.sh 5. Run the script ./build_php_worker.sh . PORT_NUMBER 6. [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.seanja.com/2011/03/setting-up-php-5-x-on-webfaction/' addthis:title='Setting up PHP 5.x on webfaction ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>
Related posts:<ol>
<li><a href='http://blog.seanja.com/2010/03/php-datetime-is-missing-methods-in-5-2/' rel='bookmark' title='PHP DateTime is missing methods in 5.2'>PHP DateTime is missing methods in 5.2</a></li>
<li><a href='http://blog.seanja.com/2011/01/ajaxy-pagination-using-jquery/' rel='bookmark' title='Ajaxy Pagination using jQuery'>Ajaxy Pagination using jQuery</a></li>
<li><a href='http://blog.seanja.com/2010/04/an-alternative-to-poor-mans-mvc-in-php/' rel='bookmark' title='An alternative to Poor Man&#8217;s MVC in PHP'>An alternative to Poor Man&#8217;s MVC in PHP</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blog.seanja.com/2011/03/setting-up-php-5-x-on-webfaction/' addthis:title='Setting up PHP 5.x on webfaction '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>PHP 5.2</p>
<p>1. Create a &#8220;Custom app listening on port&#8221; call it <strong>phpstack</strong>, note the port number you are assigned.<br />
2. SSH into the server into the new application directory (~/webapps/<strong>phpstack</strong>/)<br />
3. run: wget http://wiki.webfaction.com/attachment/wiki/MiscellaneousFiles/build_php_worker.sh?format=raw<br />
4. Check that the file is executable by running: chmod +x build_php_worker.sh<br />
5. Run the script ./build_php_worker.sh <strong>.</strong> <strong>PORT_NUMBER</strong><br />
6. Wait for it to finish building and read the instructions at the end.<br />
(This can take 1 to 2 hours to complete.)</p>
<p>PHP 5.3</p>
<p>1. Create a &#8220;Custom app listening on port&#8221; call it <strong>phpstack</strong>, note the port number you are assigned.<br />
2. SSH into the server into the new application directory (~/webapps/<strong>phpstack</strong>/)<br />
3. run: wget -O build_php_worker531.sh &#8216;http://nero.webfactional.com/build_php_worker531.sh&#8217;<br />
4. Check that the file is executable by running: chmod +x build_php_worker531.sh<br />
5. Run the script: ./build_php_worker531.sh  <strong>.</strong> <strong>PORT_NUMBER</strong><br />
6. Wait for it to finish building and read the instructions at the end.<br />
(This can take 1 to 2 hours to complete.)</p>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.seanja.com/2011/03/setting-up-php-5-x-on-webfaction/' addthis:title='Setting up PHP 5.x on webfaction ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div><p>Related posts:<ol>
<li><a href='http://blog.seanja.com/2010/03/php-datetime-is-missing-methods-in-5-2/' rel='bookmark' title='PHP DateTime is missing methods in 5.2'>PHP DateTime is missing methods in 5.2</a></li>
<li><a href='http://blog.seanja.com/2011/01/ajaxy-pagination-using-jquery/' rel='bookmark' title='Ajaxy Pagination using jQuery'>Ajaxy Pagination using jQuery</a></li>
<li><a href='http://blog.seanja.com/2010/04/an-alternative-to-poor-mans-mvc-in-php/' rel='bookmark' title='An alternative to Poor Man&#8217;s MVC in PHP'>An alternative to Poor Man&#8217;s MVC in PHP</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.seanja.com/2011/03/setting-up-php-5-x-on-webfaction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>It is like driving a new car off a cliff</title>
		<link>http://blog.seanja.com/2011/02/it-is-like-driving-a-new-car-off-a-cliff/</link>
		<comments>http://blog.seanja.com/2011/02/it-is-like-driving-a-new-car-off-a-cliff/#comments</comments>
		<pubDate>Fri, 25 Feb 2011 05:03:36 +0000</pubDate>
		<dc:creator>SeanJA</dc:creator>
				<category><![CDATA[Drupal]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[piwik]]></category>
		<category><![CDATA[WTF]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[free open source web analytics]]></category>
		<category><![CDATA[GerixSoft Ltd.]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Google Inc.]]></category>
		<category><![CDATA[hostgator]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[mod_security]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[representative in our Technical Support department]]></category>
		<category><![CDATA[seanja.com]]></category>
		<category><![CDATA[Technology_Internet]]></category>
		<category><![CDATA[urgh]]></category>
		<category><![CDATA[web analytics]]></category>
		<category><![CDATA[wtf]]></category>

		<guid isPermaLink="false">http://blog.seanja.com/?p=38448</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blog.seanja.com/2011/02/it-is-like-driving-a-new-car-off-a-cliff/' addthis:title='It is like driving a new car off a cliff '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>So&#8230; This was fun&#8230; Welcome to GatorChat! You are being connected to a representative in our Technical Support department right now. For immediate answers to your questions, check out our knowledge base and video tutorials at http://support.hostgator.com. Your Chat ID is 3333053. Your question is, &#8220;My primary domain is seanja.com. mod_security&#8221; (10:03:41 PM) System: There [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.seanja.com/2011/02/it-is-like-driving-a-new-car-off-a-cliff/' addthis:title='It is like driving a new car off a cliff ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>
Related posts:<ol>
<li><a href='http://blog.seanja.com/2008/10/twitter-updates-for-2008-10-18/' rel='bookmark' title='Twitter Updates for 2008-10-18'>Twitter Updates for 2008-10-18</a></li>
<li><a href='http://blog.seanja.com/2008/11/twitter-updates-for-2008-11-05/' rel='bookmark' title='Twitter Updates for 2008-11-05'>Twitter Updates for 2008-11-05</a></li>
<li><a href='http://blog.seanja.com/2009/04/links-for-2009-04-08/' rel='bookmark' title='links for 2009-04-08'>links for 2009-04-08</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blog.seanja.com/2011/02/it-is-like-driving-a-new-car-off-a-cliff/' addthis:title='It is like driving a new car off a cliff '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>So&#8230; This was fun&#8230;</p>
<blockquote><p>
Welcome to GatorChat!</p>
<p>You are being connected to a representative in our Technical Support department right now.</p>
<p>For immediate answers to your questions, check out our knowledge base and video tutorials at http://support.hostgator.com.</p>
<p>Your Chat ID is 3333053.</p>
<p>Your question is, &#8220;My primary domain is seanja.com. mod_security&#8221;</p>
<p>(10:03:41 PM) System: There are currently 3 people in front of you and 86 chat technicians assisting customers.<br />
(10:04:10 PM) System: There are currently 3 people in front of you and 86 chat technicians assisting customers.<br />
(10:04:41 PM) System: There are currently 1 people in front of you and 86 chat technicians assisting customers.<br />
(10:05:11 PM) System: There are currently 0 people in front of you and 87 chat technicians assisting customers.<br />
(10:05:12 PM) <strong style="color:#C00">Gator Tech Support</strong>: has entered the chat.<br />
(10:05:18 PM) <strong style="color:#C00">Gator Tech Support</strong>: Hello, welcome to HostGator Live Chat.<br />
(10:05:32 PM) <strong style="color:#00C">SeanJA</strong>: hi<br />
(10:05:44 PM) <strong style="color:#C00">Gator Tech Support</strong>: How may I assist you today?<br />
(10:06:40 PM) <strong style="color:#00C">SeanJA</strong>: I keep getting a 403 error when trying to use piwik as a tracking server&#8230; I have also run into this problem with drupal&#8217;s &#8216;shurly&#8217; module and the oauth login module as well&#8230; I believe that it would be related to mod_security?<br />
(10:07:55 PM) <strong style="color:#C00">Gator Tech Support</strong>: It really depends<br />
(10:07:55 PM) <strong style="color:#00C">SeanJA</strong>: I got around the one for oauth and shurly (a bit of hackery in drupal core that I would have liked to avoid&#8230;) but the one for piwik seems to be a bit more difficult to get around&#8230;<br />
(10:08:07 PM) <strong style="color:#00C">SeanJA</strong>: http://stats.seanja.com/piwik.php?idsite=1&#038;rec=1&#038;rand=0.11890891543589532&#038;h=0&#038;m=7&#038;s=23&#038;url=http%3A%2F%2Fseanja.com%2F&#038;urlref=&#038;res=1920&#215;1200&#038;cookie=1&#038;pdf=1&#038;qt=1&#038;realp=0&#038;wma=0&#038;dir=0&#038;fla=1&#038;java=1&#038;gears=1&#038;ag=0&#038;action_name=seanja.com<br />
(10:08:11 PM) <strong style="color:#C00">Gator Tech Support</strong>: Here is the mod security http://support.hostgator.com/articles/employees/daily-tasks/mod-sec-and-you<br />
(10:08:20 PM) <strong style="color:#00C">SeanJA</strong>: this is the url giving me the 403 error<br />
(10:08:46 PM) <strong style="color:#C00">Gator Tech Support</strong>: I am seeing a 500 error<br />
(10:09:46 PM) <strong style="color:#00C">SeanJA</strong>: odd&#8230; I am seeing that now too<br />
(10:10:13 PM) <strong style="color:#00C">SeanJA</strong>: oh&#8230; the 500 error is for the ErrorDocument<br />
(10:10:19 PM) <strong style="color:#C00">Gator Tech Support</strong>: here is everything I have on mod_security: <http://support.hostgator.com/articles/employees/daily-tasks/mod-sec-and-you></p>
<p>(10:10:45 PM) <strong style="color:#00C">SeanJA</strong>: I keep getting bounced out to support.hostgator.com<br />
(10:11:05 PM) <strong style="color:#C00">Gator Tech Support</strong>: Yes, all I would be able to do is create a ticket that goes to them.<br />
(10:11:14 PM) <strong style="color:#00C">SeanJA</strong>: http://support.hostgator.com/articles/pre-sales-policies/secfilterengine-and-secfilterscanpost<br />
(10:11:41 PM) <strong style="color:#00C">SeanJA</strong>: this is what prompted me to contact you<br />
(10:12:37 PM) <strong style="color:#C00">Gator Tech Support</strong>: Right, but I see a 500 error<br />
(10:13:52 PM) <strong style="color:#00C">SeanJA</strong>: ok&#8230; but that is for the Error Document, the title of the page is &#8220;Error 403&#8243;<br />
(10:14:24 PM) <strong style="color:#C00">Gator Tech Support</strong>: Right<br />
(10:14:47 PM) <strong style="color:#C00">Gator Tech Support</strong>: Those two are very different errors<br />
(10:14:51 PM) <strong style="color:#00C">SeanJA</strong>: http://forums.hostgator.com/mod-security-and-403-errors-t71394.html<br />
(10:16:09 PM) <strong style="color:#C00">Gator Tech Support</strong>: I understand, a 403, is very different then a 500.<br />
(10:16:54 PM) <strong style="color:#C00">Gator Tech Support</strong>: http://support.hostgator.com/articles/cpanel/internal-server-error-help-500-error<br />
(10:17:30 PM) <strong style="color:#00C">SeanJA</strong>: what I see is:</p>
<p>Error 403 Forbidden,</p>
<p>Also a 500 error was thrown when trying to use ErrorDocument to handle the request<br />
(10:17:58 PM) <strong style="color:#C00">Gator Tech Support</strong>: I am getting:Forbidden</p>
<p>You don&#8217;t have permission to access /piwik.php on this server.</p>
<p>Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.<br />
(10:18:29 PM) <strong style="color:#C00">Gator Tech Support</strong>: That would just need the pwiik.php permissions changed to 644<br />
(10:19:33 PM) <strong style="color:#00C">SeanJA</strong>: if you go to http://stats.seanja.com/piwik.php you actually get a result though<br />
(10:19:42 PM) <strong style="color:#C00">Gator Tech Support</strong>: Piwik is a free open source web analytics alternative to Google analytics.<br />
(10:20:09 PM) <strong style="color:#00C">SeanJA</strong>: as soon as you add ?url=http://test.com to the url it fails to work because the http:// is caught as &#8220;bad&#8221;<br />
(10:20:49 PM) <strong style="color:#C00">Gator Tech Support</strong>: I am getting a page with the following text<br />
(10:20:53 PM) <strong style="color:#C00">Gator Tech Support</strong>: Piwik is a free open source web analytics alternative to Google analytics.<br />
(10:21:00 PM) <strong style="color:#00C">SeanJA</strong>: yep<br />
(10:21:09 PM) <strong style="color:#C00">Gator Tech Support</strong>: Piwik is highlighted and so is web analytics<br />
(10:21:14 PM) <strong style="color:#00C">SeanJA</strong>: and the permissions are set to 664<br />
(10:21:29 PM) <strong style="color:#00C">SeanJA</strong>: well.. 0664<br />
(10:22:32 PM) <strong style="color:#C00">Gator Tech Support</strong>: Right, it is working for me<br />
(10:22:38 PM) <strong style="color:#C00">Gator Tech Support</strong>: Have you cleared your cache?<br />
(10:24:00 PM) <strong style="color:#00C">SeanJA</strong>: hitting the page without and url parameters works fine for me<br />
(10:26:23 PM) <strong style="color:#C00">Gator Tech Support</strong>: Is there anything else I can help you with today?<br />
(10:27:11 PM) <strong style="color:#00C">SeanJA</strong>: is there anyway that you could pass me on to someone that can help me with whitelisting stats.seanja.com/piwik.php from mod_security?<br />
(10:28:11 PM) <strong style="color:#C00">Gator Tech Support</strong>: If you tried to change that, you will cause your site to go down, but I can do that for you if you like<br />
(10:28:27 PM) <strong style="color:#00C">SeanJA</strong>: it will go down?<br />
(10:28:35 PM) <strong style="color:#C00">Gator Tech Support</strong>: It is like driving a new car off a cliff<br />
(10:28:49 PM) <strong style="color:#C00">Gator Tech Support</strong>: If it is not broken you dont want to try and fix it<br />
(10:28:57 PM) <strong style="color:#00C">SeanJA</strong>: it is broken though&#8230;?<br />
(10:29:20 PM) <strong style="color:#C00">Gator Tech Support</strong>: I do not show that<br />
(10:29:48 PM) <strong style="color:#00C">SeanJA</strong>: it has a blanket ignore urls with http:// in them<br />
(10:30:00 PM) <strong style="color:#C00">Gator Tech Support</strong>: A<br />
(10:30:08 PM) <strong style="color:#C00">Gator Tech Support</strong>: Are you trying to show this: http://stats.seanja.com/<br />
(10:31:24 PM) <strong style="color:#C00">Gator Tech Support</strong>: Hello?<br />
(10:31:28 PM) <strong style="color:#00C">SeanJA</strong>: nope&#8230; what /piwik.php does it log a hit to my site<br />
(10:31:53 PM) <strong style="color:#C00">Gator Tech Support</strong>: Ok, what is the php supposed to do?<br />
(10:32:22 PM) <strong style="color:#00C">SeanJA</strong>: on this page: http://seanja.com/tools/unlab-minecraft/<br />
if you look at the net panel in firebug, or the error console in chrome, you will see a 404 for the call to piwik.php?[...]<br />
(10:32:59 PM) <strong style="color:#C00">Gator Tech Support</strong>: I see a picture of a post with yes written on it with graphics of 1996<br />
(10:34:07 PM) <strong style="color:#00C">SeanJA</strong>: yes, but in the error console there is a 403 forbidden error (if you are using chrome: ctrl+shift+i , or firebug F12 in the Net tab (it has to be active on page load though) )<br />
(10:34:23 PM) <strong style="color:#00C">SeanJA</strong>: which means that the hit is not being logged<br />
(10:34:49 PM) <strong style="color:#C00">Gator Tech Support</strong>: I am using firefox<br />
(10:34:58 PM) <strong style="color:#C00">Gator Tech Support</strong>: I will try IE<br />
(10:35:39 PM) <strong style="color:#00C">SeanJA</strong>: probably won&#8217;t show up in IE<br />
(10:35:47 PM) <strong style="color:#C00">Gator Tech Support</strong>: is unlabe a mincraft, yes<br />
(10:36:05 PM) <strong style="color:#C00">Gator Tech Support</strong>: is unlab mincraft up<br />
(10:36:06 PM) <strong style="color:#C00">Gator Tech Support</strong>: yes<br />
(10:37:05 PM) <strong style="color:#00C">SeanJA</strong>: I mean the error in the console (IE&#8217;s console isn&#8217;t great, nor does it exist in IE6/7)<br />
(10:37:29 PM) <strong style="color:#C00">Gator Tech Support</strong>: No, Firefox is fine though.<br />
(10:37:55 PM) <strong style="color:#00C">SeanJA</strong>: do you have firebug installed in firefox?<br />
(10:38:36 PM) <strong style="color:#C00">Gator Tech Support</strong>: Yes<br />
(10:39:20 PM) <strong style="color:#00C">SeanJA</strong>: if you pull it up, and open up the &#8216;Net&#8217; tab, then reload the page you will see the 403 Forbidden error that I am talking about<br />
(10:39:36 PM) <strong style="color:#C00">Gator Tech Support</strong>: I dont see it.<br />
(10:40:07 PM) <strong style="color:#00C">SeanJA</strong>: is the Net tab actually active?<br />
(10:41:25 PM) <strong style="color:#00C">SeanJA</strong>: I think they disabled it by default in recent releases as it slows down page loads considerably on larger sites<br />
(10:41:53 PM) <strong style="color:#C00">Gator Tech Support</strong>: It may be a bug issue but if you just want that mod sec changed I can do that<br />
(10:43:04 PM) <strong style="color:#00C">SeanJA</strong>: I think I have found another way around it&#8230; I will just do what I did to drupal:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// © by Andriy Gerasika from GerixSoft, Ltd.</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_int</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$return</span> <span style="color: #339933;">==</span> MENU_NOT_FOUND<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$uri</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REQUEST_URI'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$uri</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://'</span><span style="color: #339933;">,</span> <span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$uri</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$path</span> <span style="color: #339933;">=</span> <span style="color: #990000;">parse_url</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$uri</span><span style="color: #339933;">,</span> PHP_URL_PATH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//FIX: SeanJA don't use ereg, use preg_match</span>
<span style="color: #000088;">$paths</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/shurly/api/shorten'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'/openid/authenticate'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #339933;">,</span> <span style="color: #000088;">$paths</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/^\/user\/[0-9]+\/openid$/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">!=</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$path</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'q='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$path</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&amp;'</span> <span style="color: #339933;">.</span> <span style="color: #990000;">parse_url</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$uri</span><span style="color: #339933;">,</span> PHP_URL_QUERY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'QUERY_STRING'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$query</span><span style="color: #339933;">;</span>
<span style="color: #990000;">parse_str</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">parse_str</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> menu_execute_active_handler<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>(10:43:26 PM) <strong style="color:#00C">SeanJA</strong>: basically refill the $_GET and $_REQUEST variables before they are checked<br />
(10:44:08 PM) <strong style="color:#C00">Gator Tech Support</strong>: I see<br />
(10:44:09 PM) <strong style="color:#C00">Gator Tech Support</strong>: Is there anything else I can help you with today?<br />
(10:44:14 PM) <strong style="color:#00C">SeanJA</strong>: nope<br />
(10:44:28 PM) <strong style="color:#C00">Gator Tech Support</strong>: Ok, let us know if you have any further questions<br />
(10:44:31 PM) <strong style="color:#C00">Gator Tech Support</strong>: Thank you for using HostGator Live Chat. If you could take a minute to rate your experience with HostGator as well as my overall performance, that would help us to improve our customer service. To do that, just click the button that says Rate and Exit in the upper right hand corner. The survey takes less than a minute to fill out.
</p></blockquote>
<p>In the end, I didn&#8217;t trust him not to screw up my site&#8230; so now I have to do a bunch of hackery to get it to work&#8230;</p>
<p>1 star</p>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.seanja.com/2011/02/it-is-like-driving-a-new-car-off-a-cliff/' addthis:title='It is like driving a new car off a cliff ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div><p>Related posts:<ol>
<li><a href='http://blog.seanja.com/2008/10/twitter-updates-for-2008-10-18/' rel='bookmark' title='Twitter Updates for 2008-10-18'>Twitter Updates for 2008-10-18</a></li>
<li><a href='http://blog.seanja.com/2008/11/twitter-updates-for-2008-11-05/' rel='bookmark' title='Twitter Updates for 2008-11-05'>Twitter Updates for 2008-11-05</a></li>
<li><a href='http://blog.seanja.com/2009/04/links-for-2009-04-08/' rel='bookmark' title='links for 2009-04-08'>links for 2009-04-08</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.seanja.com/2011/02/it-is-like-driving-a-new-car-off-a-cliff/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Drupal: Page Not found when returning from an OpenID provider</title>
		<link>http://blog.seanja.com/2011/02/drupal-page-not-found-when-returning-from-an-openid-provider/</link>
		<comments>http://blog.seanja.com/2011/02/drupal-page-not-found-when-returning-from-an-openid-provider/#comments</comments>
		<pubDate>Sat, 12 Feb 2011 16:24:03 +0000</pubDate>
		<dc:creator>SeanJA</dc:creator>
				<category><![CDATA[Drupal]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[postaweek2011]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[GerixSoft Ltd.]]></category>
		<category><![CDATA[hostgator]]></category>
		<category><![CDATA[Hypertext Transfer Protocol]]></category>
		<category><![CDATA[Identity management systems]]></category>
		<category><![CDATA[OpenID]]></category>
		<category><![CDATA[Technology_Internet]]></category>
		<category><![CDATA[Uniform Resource Identifier]]></category>
		<category><![CDATA[Uniform Resource Locator]]></category>
		<category><![CDATA[urgh]]></category>
		<category><![CDATA[URI scheme]]></category>
		<category><![CDATA[URL]]></category>
		<category><![CDATA[USD]]></category>
		<category><![CDATA[World Wide Web]]></category>

		<guid isPermaLink="false">http://blog.seanja.com/?p=38443</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blog.seanja.com/2011/02/drupal-page-not-found-when-returning-from-an-openid-provider/' addthis:title='Drupal: Page Not found when returning from an OpenID provider '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Apparently there are some issues with the OpenID module sometimes (I found this out when I switched over to hostgator from my previous webhost)&#8230; so here is the solution that worked for me: This is the patch that is provided: // © by Andriy Gerasika from GerixSoft, Ltd. if &#40;is_int&#40;$return&#41; &#38;&#38; $return == MENU_NOT_FOUND&#41; &#123; [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.seanja.com/2011/02/drupal-page-not-found-when-returning-from-an-openid-provider/' addthis:title='Drupal: Page Not found when returning from an OpenID provider ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>
Related posts:<ol>
<li><a href='http://blog.seanja.com/2011/02/it-is-like-driving-a-new-car-off-a-cliff/' rel='bookmark' title='It is like driving a new car off a cliff'>It is like driving a new car off a cliff</a></li>
<li><a href='http://blog.seanja.com/2011/08/module-login-with-email-or-username-drupal/' rel='bookmark' title='Module: Login With Email or Username Drupal'>Module: Login With Email or Username Drupal</a></li>
<li><a href='http://blog.seanja.com/2011/01/php-sql-query-builder/' rel='bookmark' title='PHP SQL Query Builder'>PHP SQL Query Builder</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blog.seanja.com/2011/02/drupal-page-not-found-when-returning-from-an-openid-provider/' addthis:title='Drupal: Page Not found when returning from an OpenID provider '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>Apparently there are some issues with the OpenID module sometimes (I found this out when I switched over to hostgator from my previous webhost)&#8230; so here is the solution that worked for me:</p>
<p>This is the patch that is provided:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// © by Andriy Gerasika from GerixSoft, Ltd.</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_int</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$return</span> <span style="color: #339933;">==</span> MENU_NOT_FOUND<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$uri</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REQUEST_URI'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$path</span> <span style="color: #339933;">=</span> <span style="color: #990000;">parse_url</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$uri</span><span style="color: #339933;">,</span> PHP_URL_PATH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'/openid/authenticate'</span> <span style="color: #339933;">||</span> <span style="color: #990000;">ereg</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'^/user/[0-9]+/openid$'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">!=</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$path</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'q='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$path</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&amp;'</span> <span style="color: #339933;">.</span> <span style="color: #990000;">parse_url</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$uri</span><span style="color: #339933;">,</span> PHP_URL_QUERY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'QUERY_STRING'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$query</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">parse_str</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">parse_str</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> menu_execute_active_handler<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>I made a small change for PHP 5.3 compatibility</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// © by Andriy Gerasika from GerixSoft, Ltd.</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_int</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$return</span> <span style="color: #339933;">==</span> MENU_NOT_FOUND<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$uri</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REQUEST_URI'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$path</span> <span style="color: #339933;">=</span> <span style="color: #990000;">parse_url</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$uri</span><span style="color: #339933;">,</span> PHP_URL_PATH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">//FIX: SeanJA don't use ereg, use preg_match</span>
	<span style="color: #666666; font-style: italic;">//also, preg_match returns a count, so compare to 0 instead of false</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'/openid/authenticate'</span> <span style="color: #339933;">||</span> <span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/^\/user\/[0-9]+\/openid$/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">!=</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$path</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'q='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$path</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&amp;'</span> <span style="color: #339933;">.</span> <span style="color: #990000;">parse_url</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$uri</span><span style="color: #339933;">,</span> PHP_URL_QUERY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'QUERY_STRING'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$query</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">parse_str</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">parse_str</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> menu_execute_active_handler<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This gets applied to the index.php file, just under:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//~line 18</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> menu_execute_active_handler<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Source: <a href="http://www.gerixsoft.com/blog/drupal/openid-page-not-found">http://www.gerixsoft.com/blog/drupal/openid-page-not-found</a></p>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.seanja.com/2011/02/drupal-page-not-found-when-returning-from-an-openid-provider/' addthis:title='Drupal: Page Not found when returning from an OpenID provider ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div><p>Related posts:<ol>
<li><a href='http://blog.seanja.com/2011/02/it-is-like-driving-a-new-car-off-a-cliff/' rel='bookmark' title='It is like driving a new car off a cliff'>It is like driving a new car off a cliff</a></li>
<li><a href='http://blog.seanja.com/2011/08/module-login-with-email-or-username-drupal/' rel='bookmark' title='Module: Login With Email or Username Drupal'>Module: Login With Email or Username Drupal</a></li>
<li><a href='http://blog.seanja.com/2011/01/php-sql-query-builder/' rel='bookmark' title='PHP SQL Query Builder'>PHP SQL Query Builder</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.seanja.com/2011/02/drupal-page-not-found-when-returning-from-an-openid-provider/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP SQL Query Builder</title>
		<link>http://blog.seanja.com/2011/01/php-sql-query-builder/</link>
		<comments>http://blog.seanja.com/2011/01/php-sql-query-builder/#comments</comments>
		<pubDate>Thu, 27 Jan 2011 03:18:22 +0000</pubDate>
		<dc:creator>SeanJA</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[Databases]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[postaweek2011]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Condition]]></category>
		<category><![CDATA[Data management]]></category>
		<category><![CDATA[From]]></category>
		<category><![CDATA[Human Interest]]></category>
		<category><![CDATA[Select]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL keywords]]></category>
		<category><![CDATA[Where]]></category>

		<guid isPermaLink="false">http://blog.seanja.com/?p=34813</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blog.seanja.com/2011/01/php-sql-query-builder/' addthis:title='PHP SQL Query Builder '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>As an excersise I have started building another php based sql query builder (separate from my stagnating php framework). So far I can do SELECT [columns] FROM table WHERE [conditions] This is how it should be used (so far): (for the examples, assume that $q is a query object) $q-&#62;table&#40;'test'&#41; -&#62;column&#40;'test_2', 'test'&#41; -&#62;table&#40;'test_3', 'test_2'&#41;; //=&#62; [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.seanja.com/2011/01/php-sql-query-builder/' addthis:title='PHP SQL Query Builder ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>
Related posts:<ol>
<li><a href='http://blog.seanja.com/2008/09/a-look-at-postgresql/' rel='bookmark' title='A look at PostgreSQL'>A look at PostgreSQL</a></li>
<li><a href='http://blog.seanja.com/2010/03/re-top-10-php-techniques-that-will-save-you-time-and-effort/' rel='bookmark' title='RE: Top 10 PHP Techniques That Will Save You Time and Effort'>RE: Top 10 PHP Techniques That Will Save You Time and Effort</a></li>
<li><a href='http://blog.seanja.com/2009/04/smarty-again/' rel='bookmark' title='Smarty&#8230; again'>Smarty&#8230; again</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blog.seanja.com/2011/01/php-sql-query-builder/' addthis:title='PHP SQL Query Builder '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>As an excersise I have started building another php based sql query builder (separate from my stagnating php framework). So far I can do SELECT [columns] FROM table WHERE [conditions]</p>
<p>This is how it should be used (so far):<br />
(for the examples, assume that $q is a query object)</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$q</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">table</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'test'</span><span style="color: #009900;">&#41;</span>
	<span style="color: #339933;">-&gt;</span><span style="color: #004000;">column</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'test_2'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'test'</span><span style="color: #009900;">&#41;</span>
	<span style="color: #339933;">-&gt;</span><span style="color: #004000;">table</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'test_3'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'test_2'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//=&gt; SELECT test_2 as test FROM test, test_3 AS test_2</span></pre></div></div>

<p>You can also group conditions:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$q</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">table</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'table'</span><span style="color: #009900;">&#41;</span>
	<span style="color: #339933;">-&gt;</span><span style="color: #004000;">begin_and</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #339933;">-&gt;</span><span style="color: #004000;">and_where</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'col_1'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
	<span style="color: #339933;">-&gt;</span><span style="color: #004000;">or_where</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'col_2'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span>
	<span style="color: #339933;">-&gt;</span><span style="color: #004000;">end_and</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #339933;">-&gt;</span><span style="color: #004000;">or_where</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'col_3'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'!='</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//=&gt;SELECT * FROM table WHERE ( col_1 = '1'  OR col_2 = '2' ) or col_3 != '3'</span></pre></div></div>

<p>which is fun.</p>
<p>I have just tried this example and am pleased to say that you can put multiple groups at the start of the query:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$q</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">table</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'table'</span><span style="color: #009900;">&#41;</span>
	<span style="color: #339933;">-&gt;</span><span style="color: #004000;">begin_and</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #339933;">-&gt;</span><span style="color: #004000;">begin_and</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #339933;">-&gt;</span><span style="color: #004000;">and_where</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'col_1'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
	<span style="color: #339933;">-&gt;</span><span style="color: #004000;">or_where</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'col_2'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span>
	<span style="color: #339933;">-&gt;</span><span style="color: #004000;">end_and</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #339933;">-&gt;</span><span style="color: #004000;">end_and</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #339933;">-&gt;</span><span style="color: #004000;">or_where</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'col_3'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'!='</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//=&gt;SELECT * FROM table WHERE ( ( col_1 = '1' OR col_2 = '2' ) ) OR col_3 != '3'</span></pre></div></div>

<p>You can follow along <a href="https://github.com/SeanJA/query-builder">here</a> if you want, suggest improvements, criticize it to no end because I am doing it toally wrong, or &#8220;steal&#8221; my ideas and make your own (but give me some of the credit at least).</p>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.seanja.com/2011/01/php-sql-query-builder/' addthis:title='PHP SQL Query Builder ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div><p>Related posts:<ol>
<li><a href='http://blog.seanja.com/2008/09/a-look-at-postgresql/' rel='bookmark' title='A look at PostgreSQL'>A look at PostgreSQL</a></li>
<li><a href='http://blog.seanja.com/2010/03/re-top-10-php-techniques-that-will-save-you-time-and-effort/' rel='bookmark' title='RE: Top 10 PHP Techniques That Will Save You Time and Effort'>RE: Top 10 PHP Techniques That Will Save You Time and Effort</a></li>
<li><a href='http://blog.seanja.com/2009/04/smarty-again/' rel='bookmark' title='Smarty&#8230; again'>Smarty&#8230; again</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.seanja.com/2011/01/php-sql-query-builder/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using Valums File Uploader with CodeIgniter</title>
		<link>http://blog.seanja.com/2011/01/using-valums-file-uploader-with-codeigniter/</link>
		<comments>http://blog.seanja.com/2011/01/using-valums-file-uploader-with-codeigniter/#comments</comments>
		<pubDate>Thu, 13 Jan 2011 05:12:23 +0000</pubDate>
		<dc:creator>SeanJA</dc:creator>
				<category><![CDATA[Code Igniter]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[postaweek2011]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[2]]></category>
		<category><![CDATA[Computer programming]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Cross-platform software]]></category>
		<category><![CDATA[Initialisms]]></category>
		<category><![CDATA[PHP programming language]]></category>
		<category><![CDATA[Software engineering]]></category>
		<category><![CDATA[Strlen]]></category>
		<category><![CDATA[This]]></category>

		<guid isPermaLink="false">http://blog.seanja.com/?p=33524</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blog.seanja.com/2011/01/using-valums-file-uploader-with-codeigniter/' addthis:title='Using Valums File Uploader with CodeIgniter '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Valums file uploader is a fancy pants ajaxy uploader widgit that is meant to be used with normal php pages. It, by default, doesn&#8217;t really play well with CodeIgniter. Fortunately, it isn&#8217;t that hard to make it work. There is a bit of a modification to the .js file: Basically, you just have to turn [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.seanja.com/2011/01/using-valums-file-uploader-with-codeigniter/' addthis:title='Using Valums File Uploader with CodeIgniter ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>
Related posts:<ol>
<li><a href='http://blog.seanja.com/2010/03/php-datetime-is-missing-methods-in-5-2/' rel='bookmark' title='PHP DateTime is missing methods in 5.2'>PHP DateTime is missing methods in 5.2</a></li>
<li><a href='http://blog.seanja.com/2011/01/ajaxy-pagination-using-jquery/' rel='bookmark' title='Ajaxy Pagination using jQuery'>Ajaxy Pagination using jQuery</a></li>
<li><a href='http://blog.seanja.com/2009/01/netbeans-subversion-eclipse-subversion/' rel='bookmark' title='Netbeans Subversion &gt; Eclipse Subversion'>Netbeans Subversion &gt; Eclipse Subversion</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blog.seanja.com/2011/01/using-valums-file-uploader-with-codeigniter/' addthis:title='Using Valums File Uploader with CodeIgniter '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p><a href="http://valums.com/ajax-upload/" target="_blank">Valums file uploader</a> is a fancy pants ajaxy uploader widgit that is meant to be used with normal php pages. It, by default, doesn&#8217;t really play well with CodeIgniter.</p>
<p>Fortunately, it isn&#8217;t that hard to make it work. There is a bit of a modification to the .js file:</p>
<p><script src="https://gist.github.com/777345.js?file=ci_patch.patch"></script></p>
<p>Basically, you just have to turn the <code>?qqfile=blah</code> into <code> /blah </code>. Granted, this is a quick fix&#8230; and it will not work if you want to pass extra params to the upload. A better fix would be to rewrite parts of the <code>qq.obj2url</code> function so that it accepts a different separator.</p>
<p>The other thing you have to worry about is CodeIgniter&#8217;s magical stripping of characters that it doesn&#8217;t like specifically: the <code>.</code> in your file&#8217;s name. Fortunately this is easy to fix:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//snip [......]</span>
	  <span style="color: #666666; font-style: italic;">//codeigniter replaces the . with a _ argh, we can fix that by doing this:</span>
	  <span style="color: #000088;">$filename</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr_replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$param1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span> <span style="color: #990000;">strrpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$param1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'_'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'_'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//[......]   /snip</span></pre></div></div>

<p>That is about it, the code is available here: <a href="https://github.com/SeanJA/uploadr">https://github.com/SeanJA/uploadr</a>.</p>
<p>Also, since I don&#8217;t subscribe to the &#8220;we must support php 4 forever&#8221; mentality, you will notice that the methods in my classes have private, public, and protected, you can just remove all of those if you need to support PHP 4 still (but you really should upgrade&#8230;).</p>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.seanja.com/2011/01/using-valums-file-uploader-with-codeigniter/' addthis:title='Using Valums File Uploader with CodeIgniter ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div><p>Related posts:<ol>
<li><a href='http://blog.seanja.com/2010/03/php-datetime-is-missing-methods-in-5-2/' rel='bookmark' title='PHP DateTime is missing methods in 5.2'>PHP DateTime is missing methods in 5.2</a></li>
<li><a href='http://blog.seanja.com/2011/01/ajaxy-pagination-using-jquery/' rel='bookmark' title='Ajaxy Pagination using jQuery'>Ajaxy Pagination using jQuery</a></li>
<li><a href='http://blog.seanja.com/2009/01/netbeans-subversion-eclipse-subversion/' rel='bookmark' title='Netbeans Subversion &gt; Eclipse Subversion'>Netbeans Subversion &gt; Eclipse Subversion</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.seanja.com/2011/01/using-valums-file-uploader-with-codeigniter/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Ajaxy Pagination using jQuery</title>
		<link>http://blog.seanja.com/2011/01/ajaxy-pagination-using-jquery/</link>
		<comments>http://blog.seanja.com/2011/01/ajaxy-pagination-using-jquery/#comments</comments>
		<pubDate>Thu, 06 Jan 2011 03:26:23 +0000</pubDate>
		<dc:creator>SeanJA</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[postaweek2011]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Animation]]></category>
		<category><![CDATA[Computer programming]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[controller]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JavaScript programming language]]></category>
		<category><![CDATA[Pagination]]></category>
		<category><![CDATA[paging]]></category>
		<category><![CDATA[PHP programming language]]></category>
		<category><![CDATA[Software engineering]]></category>
		<category><![CDATA[Technology_Internet]]></category>

		<guid isPermaLink="false">http://blog.seanja.com/?p=32353</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blog.seanja.com/2011/01/ajaxy-pagination-using-jquery/' addthis:title='Ajaxy Pagination using jQuery '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Saw this today: AJAX Pagination using jQuery and PHP with Animation. While it is quite simple to add paging using jQuery, why not make it work without the jQuery as well? It isn&#8217;t too hard to do, add a url to each of the a tags, then load the content based on that instead. This [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.seanja.com/2011/01/ajaxy-pagination-using-jquery/' addthis:title='Ajaxy Pagination using jQuery ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>
Related posts:<ol>
<li><a href='http://blog.seanja.com/2008/06/jquery-and-wordpress/' rel='bookmark' title='JQuery and WordPress'>JQuery and WordPress</a></li>
<li><a href='http://blog.seanja.com/2009/12/simple-tool-tip-with-jquery/' rel='bookmark' title='Simple Tool Tip with jQuery'>Simple Tool Tip with jQuery</a></li>
<li><a href='http://blog.seanja.com/2009/07/a-better-way-to-use-jquery-in-wordpress-themes/' rel='bookmark' title='A better way to use jQuery in WordPress Themes'>A better way to use jQuery in WordPress Themes</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blog.seanja.com/2011/01/ajaxy-pagination-using-jquery/' addthis:title='Ajaxy Pagination using jQuery '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>Saw this today: <a href="http://www.99points.info/2011/01/ajax-pagination-using-jquery-and-php-with-animation/" rel="nofollow">AJAX Pagination using jQuery and PHP with Animation</a>. While it is quite simple to add paging using jQuery, why not make it work without the jQuery as well?</p>
<p>It isn&#8217;t too hard to do, add a url to each of the a tags, then load the content based on that instead.</p>
<p>This would be the code (some of it has been left as an exercise for the reader):</p>
<p>the table would look like this (or you know, something else&#8230;)</p>
<p><script src="https://gist.github.com/767437.js?file=results.sql"></script></p>
<p>page.php is sort of like a controller&#8230; for a one off page this would be fine, I would abstract it a bit more if it were part of a bigger site.</p>
<p><script src="https://gist.github.com/767437.js?file=page.php"></script></p>
<p>paged_results.tpl.php Spit out the stuff to the users</p>
<p><script src="https://gist.github.com/767437.js?file=paged_results.tpl.php"></script></p>
<p>Here is script.js&#8230; it has the javascript that would be used to make it ahem&#8230; ajaxy</p>
<p><script src="https://gist.github.com/767437.js?file=script.js"></script></p>
<p>Code is here if you want it: <a href="https://gist.github.com/767437">https://gist.github.com/767437</a></p>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.seanja.com/2011/01/ajaxy-pagination-using-jquery/' addthis:title='Ajaxy Pagination using jQuery ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div><p>Related posts:<ol>
<li><a href='http://blog.seanja.com/2008/06/jquery-and-wordpress/' rel='bookmark' title='JQuery and WordPress'>JQuery and WordPress</a></li>
<li><a href='http://blog.seanja.com/2009/12/simple-tool-tip-with-jquery/' rel='bookmark' title='Simple Tool Tip with jQuery'>Simple Tool Tip with jQuery</a></li>
<li><a href='http://blog.seanja.com/2009/07/a-better-way-to-use-jquery-in-wordpress-themes/' rel='bookmark' title='A better way to use jQuery in WordPress Themes'>A better way to use jQuery in WordPress Themes</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.seanja.com/2011/01/ajaxy-pagination-using-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Orms and Circular References</title>
		<link>http://blog.seanja.com/2010/05/orms-and-circular-references/</link>
		<comments>http://blog.seanja.com/2010/05/orms-and-circular-references/#comments</comments>
		<pubDate>Thu, 27 May 2010 05:17:54 +0000</pubDate>
		<dc:creator>SeanJA</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[circular relationships]]></category>
		<category><![CDATA[Class]]></category>
		<category><![CDATA[class car]]></category>
		<category><![CDATA[Computer programming]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Constructor]]></category>
		<category><![CDATA[factory]]></category>
		<category><![CDATA[Ford]]></category>
		<category><![CDATA[Ford Motor Company]]></category>
		<category><![CDATA[Ford Pinto]]></category>
		<category><![CDATA[gist]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[Method]]></category>
		<category><![CDATA[Object-oriented programming]]></category>
		<category><![CDATA[orm]]></category>
		<category><![CDATA[Software engineering]]></category>
		<category><![CDATA[static functions]]></category>

		<guid isPermaLink="false">http://blog.seanja.com/?p=998</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blog.seanja.com/2010/05/orms-and-circular-references/' addthis:title='Orms and Circular References '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>In my spare time I have been working on an ORM&#8230; not one meant to be used in the real world (well&#8230; not yet anyway). I currently have hasOne and hasMany working like so: &#60;?php &#160; /** * @property int $id * @property string $type * @property int $car_id */ class wheelBoilerplate extends orm&#123; protected [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.seanja.com/2010/05/orms-and-circular-references/' addthis:title='Orms and Circular References ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>
Related posts:<ol>
<li><a href='http://blog.seanja.com/2011/06/around-the-world-lyrics/' rel='bookmark' title='Around the World lyrics'>Around the World lyrics</a></li>
<li><a href='http://blog.seanja.com/2009/02/links-for-2009-02-11/' rel='bookmark' title='links for 2009-02-11'>links for 2009-02-11</a></li>
<li><a href='http://blog.seanja.com/2009/02/templating/' rel='bookmark' title='Templating'>Templating</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blog.seanja.com/2010/05/orms-and-circular-references/' addthis:title='Orms and Circular References '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>In my spare time I have been working on an ORM&#8230; not one meant to be used in the real world (well&#8230; not yet anyway). I currently have hasOne and hasMany working like so:</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;">/**
 * @property int $id
 * @property string $type
 * @property int $car_id
 */</span>
<span style="color: #000000; font-weight: bold;">class</span> wheelBoilerplate <span style="color: #000000; font-weight: bold;">extends</span> orm<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #009900;">&#40;</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;">addProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'type'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'type'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'string'</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'default'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'monster truck'</span><span style="color: #339933;">,</span>
		<span style="color: #009900;">&#41;</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;">hasOne</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'car'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> wheel <span style="color: #000000; font-weight: bold;">extends</span> wheelBoilerplate<span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * @property int $id
 * @property int $wheel_count
 * @property array $wheels
 * @property string $type
 */</span>
abstract <span style="color: #000000; font-weight: bold;">class</span> carBoilerplate <span style="color: #000000; font-weight: bold;">extends</span> orm<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #009900;">&#40;</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;">addProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wheel_count'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'default'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">4</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'type'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'int'</span><span style="color: #339933;">,</span>
		<span style="color: #009900;">&#41;</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;">addProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'type'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'default'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'monster truck'</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'type'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'string'</span><span style="color: #339933;">,</span>
		<span style="color: #009900;">&#41;</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;">hasMany</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wheels'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> car <span style="color: #000000; font-weight: bold;">extends</span> carBoilerplate<span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$car</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> car<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$car</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">wheels</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">car</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">wheels</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">car</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">wheels</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">car</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">wheels</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">type</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">#=&gt; 'monster truck'</span></pre></div></div>

<p>The problem as you can probably guess, is you now have 4 of the same car loaded into memory, and 4 wheels, 2 of which are the same. So, when you do this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$car</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">type</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Ford Pinto'</span><span style="color: #339933;">;</span></pre></div></div>

<p>You are only actually changing one instance of all of the instances of car that you have created in memory. Not so good for keeping things straight, which one do you save? What happens if you save one over top of the other?</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$car</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">type</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Ford Pinto'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$car</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$car</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">wheels</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">car</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>You have just overwritten your changes in the database. I didn&#8217;t think that was a good thing to let someone do (even accidentally). That is where this class came from:</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: #000000; font-weight: bold;">class</span> factory <span style="color: #009900;">&#123;</span>
	<span style="color: #009933; font-style: italic;">/**
	 * Holds all of the items in the factory
	 * @var array
	 */</span>
	<span style="color: #000000; font-weight: bold;">protected</span> static <span style="color: #000088;">$created</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: #009933; font-style: italic;">/**
	 * Create/Load an object from the factory
	 * @param string $className
	 * @param int $id
	 * @return orm
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> Create<span style="color: #009900;">&#40;</span><span style="color: #000088;">$className</span><span style="color: #339933;">,</span> <span style="color: #000088;">$id</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">null</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$className</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$className</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$created</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$className</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$created</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$className</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000088;">$className</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$created</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$className</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #009933; font-style: italic;">/**
	 * Load an object from the factory
	 * @param string $className the object's class
	 * @param int $id the id of the object you are loading
	 * @return orm or null
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> Load<span style="color: #009900;">&#40;</span><span style="color: #000088;">$className</span><span style="color: #339933;">,</span> <span style="color: #000088;">$id</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$className</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$className</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$created</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$className</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</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;">$created</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$className</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">:</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #009933; font-style: italic;">/**
	 * Add an object to the factory, has no effect if the object is already part of the factory
	 * @param string $className
	 * @param orm $class
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> Add<span style="color: #009900;">&#40;</span>orm <span style="color: #339933;">&amp;</span><span style="color: #000088;">$class</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$className</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$class</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">class_name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$created</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$className</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$class</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$created</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$className</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$class</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span><span style="color: #000088;">$class</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #009933; font-style: italic;">/**
	 * Destroy an instance of something in the factory and the object itself
	 * @param orm $class the class being destroyed
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> Destroy<span style="color: #009900;">&#40;</span>orm <span style="color: #339933;">&amp;</span><span style="color: #000088;">$class</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$className</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$class</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">class_name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$class</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$created</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$className</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$class</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>I haven&#8217;t had the chance to actually merge them together, but this is how it should work:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000088;">$car</span> <span style="color: #339933;">=</span> factory<span style="color: #339933;">::</span><span style="color: #004000;">Create</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'car'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$car</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">wheels</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: #666666; font-style: italic;">//#=&gt; factory::Create('wheel', 1);</span>
<span style="color: #000088;">$car</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">wheels</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: #666666; font-style: italic;">//#=&gt; factory::Create('wheel', 2);</span>
<span style="color: #000088;">$car</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">wheels</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//#=&gt; factory::Create('wheel', 3);</span>
<span style="color: #000088;">$car</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">wheels</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//#=&gt; factory::Create('wheel', 4);</span>
&nbsp;
<span style="color: #000088;">$car</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">wheels</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">car</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//#=&gt; factory::Load('car', 1);</span>
<span style="color: #000088;">$car</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">wheels</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">car</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">wheels</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: #666666; font-style: italic;">//#=&gt; factory::Load('wheel', 1);</span>
&nbsp;
<span style="color: #000088;">$car</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">wheels</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">car</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">type</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Ford Pinto'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$car</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">type</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//#=&gt; 'Ford Pinto'</span></pre></div></div>

<p>Now, no matter which of the cars that you load (as long as it has the same ID), it will be the same one instead of just another instance of the same one. Changes are made to all of them, because they are all the same instance of that car.</p>
<p>The factory class and some sample usage code are <a href="http://gist.github.com/409112">on github</a>, if&#8217;n you want to look at it, or fork it, or whatever.</p>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.seanja.com/2010/05/orms-and-circular-references/' addthis:title='Orms and Circular References ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div><p>Related posts:<ol>
<li><a href='http://blog.seanja.com/2011/06/around-the-world-lyrics/' rel='bookmark' title='Around the World lyrics'>Around the World lyrics</a></li>
<li><a href='http://blog.seanja.com/2009/02/links-for-2009-02-11/' rel='bookmark' title='links for 2009-02-11'>links for 2009-02-11</a></li>
<li><a href='http://blog.seanja.com/2009/02/templating/' rel='bookmark' title='Templating'>Templating</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.seanja.com/2010/05/orms-and-circular-references/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

