<?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>Ben Lobaugh Online &#187; blobaugh</title>
	<atom:link href="http://ben.lobaugh.net/blog/author/blobaugh/feed" rel="self" type="application/rss+xml" />
	<link>http://ben.lobaugh.net/blog</link>
	<description>/(bb&#124;[^b]{2})/</description>
	<lastBuildDate>Thu, 02 Sep 2010 18:44:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>VW Bus: Changing the exhaust</title>
		<link>http://ben.lobaugh.net/blog/667/vw-bus-changing-the-exhaust</link>
		<comments>http://ben.lobaugh.net/blog/667/vw-bus-changing-the-exhaust#comments</comments>
		<pubDate>Thu, 02 Sep 2010 18:44:43 +0000</pubDate>
		<dc:creator>blobaugh</dc:creator>
				<category><![CDATA[VW Bus]]></category>

		<guid isPermaLink="false">http://ben.lobaugh.net/blog/?p=667</guid>
		<description><![CDATA[I had a god-awfully loud exhaust on my 1965 Volkswagen Bus that awoke people two blocks over in the mornings and drove me nuts. I ordered a new exhaust from Cip1 and here are the steps I took removing the old one and putting the new one on. You want to make sure the engine [...]]]></description>
			<content:encoded><![CDATA[<p>I had a god-awfully loud exhaust on my 1965 Volkswagen Bus that awoke people two blocks over in the mornings and drove me nuts. I ordered a new exhaust from <a title="Cip1 Aircooled Volkswagen Parts" href="http://www2.cip1.com/" target="_blank">Cip1</a> and here are the steps I took removing the old one and putting the new one on.</p>
<div id="attachment_668" class="wp-caption alignnone" style="width: 610px"><img class="size-full wp-image-668 " title="Original noisy exhaust" src="http://ben.lobaugh.net/blog/wp-content/uploads/2010/09/IMG_3968.jpg" alt="Original noisy exhaust" width="600" height="450" /><p class="wp-caption-text">Original noisy exhaust</p></div>
<div id="attachment_669" class="wp-caption alignnone" style="width: 610px"><img class="size-full wp-image-669" title="IMG_3958" src="http://ben.lobaugh.net/blog/wp-content/uploads/2010/09/IMG_3958.jpg" alt="" width="600" height="450" /><p class="wp-caption-text">New Exhaust</p></div>
<p>You want to make sure the engine is cool when you do this because you exhaust system can get quite hot.</p>
<p>Take off the rear bumper and the rear engine tin. Once you have that completed follow the exhaust pipes back to where they connect on the motor. There could be up to six connection points, though mine only had four hooked up. Take all the bolts out and put them into a safe place. I use a magnetic mechanics bowl just for this purpose. Now pull straight backwards on the exhaust and it should slide off. All the carbon and such coming from your motor may have it locked on there tight, but a couple good yanks should allow it to come right off. This is what it should look like once your exhaust is off.</p>
<div id="attachment_670" class="wp-caption alignnone" style="width: 610px"><img class="size-full wp-image-670" title="IMG_3964" src="http://ben.lobaugh.net/blog/wp-content/uploads/2010/09/IMG_3964.jpg" alt="" width="600" height="450" /><p class="wp-caption-text">Rear view of motor without exhaust</p></div>
<p>My original exhaust was all one piece, but my new exhaust was two pieces, headers and a muffler. If you have a single piece you are almost done, if you have two pieces pick up the headers and slide them on where you just took the old exhaust from and put the bolts in. If you ordered a kit you should have some new gaskets, don't forget to put those on. It helps seal the exhaust and prevent leaks. Here is a shot of the newly installed headers.</p>
<div id="attachment_671" class="wp-caption alignnone" style="width: 610px"><img class="size-full wp-image-671" title="IMG_3973" src="http://ben.lobaugh.net/blog/wp-content/uploads/2010/09/IMG_3973.jpg" alt="" width="600" height="450" /><p class="wp-caption-text">New headers installed</p></div>
<p>Now the final item to complete the new exhaust is the muffler. Slap on the gasket and bolt it up to the headers.</p>
<div id="attachment_672" class="wp-caption alignnone" style="width: 610px"><img class="size-full wp-image-672" title="IMG_3978" src="http://ben.lobaugh.net/blog/wp-content/uploads/2010/09/IMG_3978.jpg" alt="" width="600" height="450" /><p class="wp-caption-text">New exhaust</p></div>
<p>Congrats, you have new exhaust! Just bolt up the tin, replace the bumper, and put away your tools and you will have successfully changed you own exhaust.</p>
]]></content:encoded>
			<wfw:commentRss>http://ben.lobaugh.net/blog/667/vw-bus-changing-the-exhaust/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Beautiful sunset</title>
		<link>http://ben.lobaugh.net/blog/625/beautiful-sunset</link>
		<comments>http://ben.lobaugh.net/blog/625/beautiful-sunset#comments</comments>
		<pubDate>Tue, 10 Aug 2010 18:56:00 +0000</pubDate>
		<dc:creator>blobaugh</dc:creator>
				<category><![CDATA[Life]]></category>
		<category><![CDATA[Randomness]]></category>

		<guid isPermaLink="false">http://ben.lobaugh.net/blog/625/beautiful-sunset</guid>
		<description><![CDATA[Beautiful sunset from the parent's house.]]></description>
			<content:encoded><![CDATA[<p>Beautiful sunset from the parent's house. </p>
<p><a href="http://ben.lobaugh.net/blog/wp-content/uploads/2010/08/p_1600_1200_1B7FD07E-00E1-45E1-9898-BE45B68565BD.jpeg"><img src="http://ben.lobaugh.net/blog/wp-content/uploads/2010/08/p_1600_1200_1B7FD07E-00E1-45E1-9898-BE45B68565BD.jpeg" alt="" class="alignnone size-full" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://ben.lobaugh.net/blog/625/beautiful-sunset/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP: Autoloader</title>
		<link>http://ben.lobaugh.net/blog/621/php-autoloader</link>
		<comments>http://ben.lobaugh.net/blog/621/php-autoloader#comments</comments>
		<pubDate>Tue, 10 Aug 2010 05:36:14 +0000</pubDate>
		<dc:creator>blobaugh</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://ben.lobaugh.net/blog/?p=621</guid>
		<description><![CDATA[SirGecko just released the first version of their PHP Autoloader. This auto loader is great because I can use it in any of my PHP projects and no longer have to keep track of and/or require() my objects. I simply drop this auto loader into my project, setup the directories my classes are in in [...]]]></description>
			<content:encoded><![CDATA[<p><a title="SirGecko Development Group" href="http://sirgecko.com" target="_blank">SirGecko</a> just released the first version of their <a title="SirGecko PHP Autoloader" href="http://sirgecko.com/projects/php-autoloader" target="_blank">PHP Autoloader</a>. This auto loader is great because I can use it in any of my PHP projects and no longer have to keep track of and/or require() my objects. I simply drop this auto loader into my project, setup the directories my classes are in in the autoloader.php file, and include it in the project bootstrap file. Blam! No more requiring class files.  Surprisingly my development time has actually increased quite a bit through the usage of this library. Be sure to check it out and use it on your projects.</p>
<p><a title="SirGecko PHP Autoloader" href="http://sirgecko.com/projects/php-autoloader" target="_blank">SirGecko PHP Autoloader</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ben.lobaugh.net/blog/621/php-autoloader/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to remove a starter from a 1965 VW Bus</title>
		<link>http://ben.lobaugh.net/blog/613/how-to-remove-a-starter-from-a-1965-vw-bus</link>
		<comments>http://ben.lobaugh.net/blog/613/how-to-remove-a-starter-from-a-1965-vw-bus#comments</comments>
		<pubDate>Tue, 10 Aug 2010 04:26:30 +0000</pubDate>
		<dc:creator>blobaugh</dc:creator>
				<category><![CDATA[VW Bus]]></category>

		<guid isPermaLink="false">http://ben.lobaugh.net/blog/?p=613</guid>
		<description><![CDATA[This should work on most old aircooled Volkswagens, like the bug or beetle, though you will need to jack up the vehicle in order to get under it and at the starter. Tools I used: 17mm wrench 13mm wrench Now before we start it is very important that you disconnect the battery. Also make sure [...]]]></description>
			<content:encoded><![CDATA[<p>This should work on most old aircooled Volkswagens, like the bug or beetle, though you will need to jack up the vehicle in order to get under it and at the starter.</p>
<p>Tools I used:<br />
17mm wrench<br />
13mm wrench</p>
<p>Now before we start it is very <strong>important</strong> that you <strong>disconnect the battery</strong>. Also make sure the VW is out of gear with the emergency brake on and the key off or out of the vehicle altogether. These precautions will help to ensure your safety while working on the vehicle. It is entirely possible to start the vehicle while you are underneath it and I am sure your ribcage would appreciate not getting highly compressed today.</p>
<p>First let's roll under the dub and take a gander at what we are going to be removing. Put down your drop cloth right in front of the rear passenger wheel. Slide your head under there and look up and maybe a little to the rear of the car. You should see something resembling the following.</p>
<p><img class="alignnone size-medium wp-image-616" title="IMG_41712" src="http://ben.lobaugh.net/blog/wp-content/uploads/2010/08/IMG_41712-600x450.jpg" alt="" width="600" height="450" /></p>
<p>There should be several wires sticking out of the solenoid. The top wire comes off your ignition switch which sends the signal to power the starter. The large wire with the bolt on it goes to the positive battery post, and the small wire on the bottom is the ground wire. There should be one more wire on the right heading off the solenoid to the starter.</p>
<p>The top starter bolt is a dual purpose bolt. Not only does it hold the starter to the transmission, it also holds the engine to the transmission. So let's roll out from under the dub and head back to the engine compartment. I did not take a picture of this part because it has to be done by feel and if you are going to wrench on an aircooled VW you need to be able to feel it out. Squat down behind the motor with you 17mm wrench and reach around the right side (passenger side) of the motor. Feel around in the lower region and you will eventually encounter a bolt with a nut on it. Stick the open end of your wrench on the nut and loosen it up. This nut may be difficult to move, as it should be as it holds your motor in your machine. I personally recommend a good set of ratcheting wrenches to help speed up the removal of nuts and bolts in hard to reach or see areas.</p>
<p>Okey dokey, that side is all done. Poke yourself back under the dub. Take your 13mm wrench with you and take the nut off the solenoid. When the wires are off stick the nut back on for safe storage. The ignition and ground wires need to be unattached as well, they may be push on, or held on by a nut. The wire from the solenoid to the starter can remain.</p>
<p>Pull your 17mm wrench back out and remove the bottom nut from the starter. You starter is now loose. You should probably use two hands to pull the starter out as it has some heft to it. Grasp the starter and pull it straight back, be careful not to drop it. Work it through the hoses and all the miscellaneous items until it is safely on the ground.</p>
<p>Your starter may be greasy as mine was, after a little cleanup you should have something looking like...</p>
<p><img class="alignnone size-medium wp-image-617" title="IMG_41752" src="http://ben.lobaugh.net/blog/wp-content/uploads/2010/08/IMG_41752-600x450.jpg" alt="" width="600" height="450" /></p>
<p>Congratulations, your starter is now out!</p>
]]></content:encoded>
			<wfw:commentRss>http://ben.lobaugh.net/blog/613/how-to-remove-a-starter-from-a-1965-vw-bus/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What you shouldn&#8217;t find in your VW transmission</title>
		<link>http://ben.lobaugh.net/blog/609/what-you-shouldnt-find-in-your-vw-transmission</link>
		<comments>http://ben.lobaugh.net/blog/609/what-you-shouldnt-find-in-your-vw-transmission#comments</comments>
		<pubDate>Tue, 10 Aug 2010 03:26:52 +0000</pubDate>
		<dc:creator>blobaugh</dc:creator>
				<category><![CDATA[VW Bus]]></category>

		<guid isPermaLink="false">http://ben.lobaugh.net/blog/?p=609</guid>
		<description><![CDATA[Drained the transmission fluid on  1965 VW Bus and changed a seal in the brake drum recently. Found a couple goodies in there that are definitely  not good to find. First off, this is the entirety of the fluid that came out...notice something missing...like most of the fluid that should be there? After rolling out [...]]]></description>
			<content:encoded><![CDATA[<p>Drained the transmission fluid on  1965 VW Bus and changed a seal in the brake drum recently. Found a couple goodies in there that are definitely  not good to find.</p>
<p>First off, this is the entirety of the fluid that came out...notice something missing...like most of the fluid that should be there?</p>
<p><img class="size-medium wp-image-610 alignnone" title="IMG_39812" src="http://ben.lobaugh.net/blog/wp-content/uploads/2010/08/IMG_39812-600x450.jpg" alt="" width="600" height="450" /></p>
<p>After rolling out from under the bus with the drain plug in hand I found this nice big chunk of metal stuck to the magnetized plug surrounded by metal shavings...another bad sign.</p>
<p><img class="size-medium wp-image-611 alignnone" title="IMG_39802" src="http://ben.lobaugh.net/blog/wp-content/uploads/2010/08/IMG_39802-600x450.jpg" alt="" width="600" height="450" /></p>
<p>If you find this in your transmission you might want to think about looking around for a new one, soon. That said, I did make it almost 500 miles a couple weekends after finding this.</p>
<p>Cheers</p>
]]></content:encoded>
			<wfw:commentRss>http://ben.lobaugh.net/blog/609/what-you-shouldnt-find-in-your-vw-transmission/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript: Parse Twitter Usernames, Hashtags and URIs</title>
		<link>http://ben.lobaugh.net/blog/605/javascript-parse-twitter-usernames-hashtags-and-uris</link>
		<comments>http://ben.lobaugh.net/blog/605/javascript-parse-twitter-usernames-hashtags-and-uris#comments</comments>
		<pubDate>Wed, 28 Jul 2010 20:56:04 +0000</pubDate>
		<dc:creator>blobaugh</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://ben.lobaugh.net/blog/?p=605</guid>
		<description><![CDATA[Twitter provides a plain-text stream of tweets. I was looking to add links to this stream for the usernames, URIs, and hashes. I wound up with the following function that hopefully you will find useful. &#160; function parseTwitter&#40;text&#41; &#123; // Parse URIs text = text.replace&#40;/&#91;A-Za-z&#93;+:\/\/&#91;A-Za-z0-9-_&#93;+\.&#91;A-Za-z0-9-_:%&#38;\?\/.=&#93;+/, function&#40;uri&#41; &#123; return uri.link&#40;uri&#41;; &#125;&#41;; &#160; // Parse Twitter usernames [...]]]></description>
			<content:encoded><![CDATA[<p>Twitter provides a plain-text stream of tweets. I was looking to add links to this stream for the usernames, URIs, and hashes. I wound up with the following function that hopefully you will find useful.</p>
<pre class="javascript">&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> parseTwitter<span style="color: #66cc66;">&#40;</span>text<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #009900; font-style: italic;">// Parse URIs</span>
        text = text.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066FF;">/<span style="color: #66cc66;">&#91;</span>A-Za-z<span style="color: #66cc66;">&#93;</span>+:\/\/<span style="color: #66cc66;">&#91;</span>A-Za-z0<span style="color: #CC0000;">-9</span>-_<span style="color: #66cc66;">&#93;</span>+\.<span style="color: #66cc66;">&#91;</span>A-Za-z0<span style="color: #CC0000;">-9</span>-_:%&amp;\?\/.=<span style="color: #66cc66;">&#93;</span>+/</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>uri<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">return</span> uri.<span style="color: #006600;">link</span><span style="color: #66cc66;">&#40;</span>uri<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
        <span style="color: #009900; font-style: italic;">// Parse Twitter usernames</span>
        text = text.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066FF;">/<span style="color: #66cc66;">&#91;</span>@<span style="color: #66cc66;">&#93;</span>+<span style="color: #66cc66;">&#91;</span>A-Za-z0<span style="color: #CC0000;">-9</span>-_<span style="color: #66cc66;">&#93;</span>+/</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>u<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> username = u.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;@&quot;</span>,<span style="color: #3366CC;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #000066; font-weight: bold;">return</span> u.<span style="color: #006600;">link</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;http://twitter.com/&quot;</span>+username<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #009900; font-style: italic;">// Parse Twitter hash tags</span>
	text = text.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066FF;">/<span style="color: #66cc66;">&#91;</span>#<span style="color: #66cc66;">&#93;</span>+<span style="color: #66cc66;">&#91;</span>A-Za-z0<span style="color: #CC0000;">-9</span>-_<span style="color: #66cc66;">&#93;</span>+/</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>t<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> tag = t.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;#&quot;</span>,<span style="color: #3366CC;">&quot;%23&quot;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #000066; font-weight: bold;">return</span> t.<span style="color: #006600;">link</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;http://search.twitter.com/search?q=&quot;</span>+tag<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #000066; font-weight: bold;">return</span> text;
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p>To use it simply toss in any string with a Twitteresque format and viola, links!</p>
]]></content:encoded>
			<wfw:commentRss>http://ben.lobaugh.net/blog/605/javascript-parse-twitter-usernames-hashtags-and-uris/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bus Pilots: 2010 Family Reunion</title>
		<link>http://ben.lobaugh.net/blog/597/bus-pilots-2010-family-reunion</link>
		<comments>http://ben.lobaugh.net/blog/597/bus-pilots-2010-family-reunion#comments</comments>
		<pubDate>Mon, 19 Jul 2010 14:39:44 +0000</pubDate>
		<dc:creator>blobaugh</dc:creator>
				<category><![CDATA[VW Bus]]></category>

		<guid isPermaLink="false">http://ben.lobaugh.net/blog/?p=597</guid>
		<description><![CDATA[I had a great time at the Family Reunion this year! I highly encourage anyone reading this to check out the Bus Pilots website and attend next year. It is a weekend long event starting Friday evening and ending Sunday afternoon. On Friday we all met a Sonic in Boise for dinner. Afterwards we cruised [...]]]></description>
			<content:encoded><![CDATA[<p>I had a great time at the Family Reunion this year! I highly encourage anyone reading this to check out the <a title="Bus Pilots" href="http://buspilots.com" target="_blank">Bus Pilots website</a> and attend next year. It is a weekend long event starting Friday evening and ending Sunday afternoon. On Friday we all met a Sonic in Boise for dinner. Afterwards we cruised the dubs around downtown Boise drawing quite the attention and frustrating all the non-VW drivers. Mike then graciously allowed us to crash his place for a social BBQ. Saturday morning we did a road rallye. That was a hoot. Each car was given cryptic directions and we had to attempt to follow them and pick up clues for points along the way. It was great driving around Boise and seeing everyone else turning down random streets just as lost as you. And then there was Sunday, the big day. Sunday we all piled in to Anne Morrison park in Boise and lined up the cars for the show. It was great fun, perfect weather, good food vendors, and lots of cars. I think the total came in around 90. Come next year if you can, and keep an eye out on the <a title="Bus Pilots" href="http://buspilots.com" target="_blank">Bus Pilots website</a> for more events!</p>
<p>I took pictures of almost every car there. You can view the full gallery by clicking any image below.</p>
<p><a href="http://ben.lobaugh.net/gallery/main.php?g2_itemId=22977"><img class="alignnone" title="Bus Pilots 2010 Family Reunion" src="http://ben.lobaugh.net/gallery/main.php?g2_view=core.DownloadItem&amp;g2_itemId=22978&amp;g2_serialNumber=1" alt="" width="640" height="427" /></a></p>
<p><a href="http://ben.lobaugh.net/gallery/main.php?g2_itemId=22977&amp;g2_page=1"><img class="alignnone" title="Bus Pilots 2010 Family Reunion" src="http://ben.lobaugh.net/gallery/main.php?g2_view=core.DownloadItem&amp;g2_itemId=23103&amp;g2_serialNumber=2" alt="" width="640" height="480" /></a></p>
<p><a href="http://ben.lobaugh.net/gallery/main.php?g2_itemId=22977&amp;g2_page=1"><img class="alignnone" title="Bus Pilots 2010 Family Reunion" src="http://ben.lobaugh.net/gallery/main.php?g2_view=core.DownloadItem&amp;g2_itemId=23073&amp;g2_serialNumber=2" alt="" width="640" height="480" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://ben.lobaugh.net/blog/597/bus-pilots-2010-family-reunion/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP: Downloading remote content with CURL</title>
		<link>http://ben.lobaugh.net/blog/592/php-downloading-remote-content-with-curl</link>
		<comments>http://ben.lobaugh.net/blog/592/php-downloading-remote-content-with-curl#comments</comments>
		<pubDate>Wed, 07 Jul 2010 21:57:42 +0000</pubDate>
		<dc:creator>blobaugh</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://ben.lobaugh.net/blog/?p=592</guid>
		<description><![CDATA[With fopen becoming increasingly scarce on web hosts, CURL is becoming a better and better solution to retrieving remote content with PHP. CURL is a fairly standard PHP module and chances are if your host does not support it a simple ticket will have them installing it for you. Because I am constantly loosing my [...]]]></description>
			<content:encoded><![CDATA[<p>With fopen becoming increasingly scarce on web hosts, CURL is becoming a better and better solution to retrieving remote content with <a href="http://php.net" target="_blank">PHP</a>. <a title="CURL Wikipedia" href="http://en.wikipedia.org/wiki/CURL" target="_blank">CURL</a> is a fairly standard PHP module and chances are if your host does not support it a simple ticket will have them installing it for you.</p>
<p>Because I am constantly loosing my CURL code and being forced to look it up again I decided to post my favorite CURL function for future reference for myself. I hope that you may get some use out of this as well.</p>
<pre class="php">&nbsp;
<span style="color: #808080; font-style: italic;">/**
 * Get a web file (HTML, XHTML, XML, image, etc.) from a URL.  Return an
 * array containing the HTTP server response header fields and content.
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> curlFile<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$url</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #0000ff;">$options</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span>
        CURLOPT_RETURNTRANSFER =&gt; <span style="color: #000000; font-weight: bold;">true</span>,     <span style="color: #808080; font-style: italic;">// return web page</span>
        CURLOPT_HEADER         =&gt; <span style="color: #000000; font-weight: bold;">false</span>,    <span style="color: #808080; font-style: italic;">// don't return headers</span>
        CURLOPT_FOLLOWLOCATION =&gt; <span style="color: #000000; font-weight: bold;">true</span>,     <span style="color: #808080; font-style: italic;">// follow redirects</span>
        CURLOPT_ENCODING       =&gt; <span style="color: #ff0000;">&quot;&quot;</span>,       <span style="color: #808080; font-style: italic;">// handle all encodings</span>
        CURLOPT_USERAGENT      =&gt; <span style="color: #ff0000;">&quot;blob curler 1.2&quot;</span>, <span style="color: #808080; font-style: italic;">// who am i</span>
        CURLOPT_AUTOREFERER    =&gt; <span style="color: #000000; font-weight: bold;">true</span>,     <span style="color: #808080; font-style: italic;">// set referer on redirect</span>
        CURLOPT_CONNECTTIMEOUT =&gt; <span style="color: #cc66cc;">120</span>,      <span style="color: #808080; font-style: italic;">// timeout on connect</span>
        CURLOPT_TIMEOUT        =&gt; <span style="color: #cc66cc;">120</span>,      <span style="color: #808080; font-style: italic;">// timeout on response</span>
        CURLOPT_MAXREDIRS      =&gt; <span style="color: #cc66cc;">10</span>,       <span style="color: #808080; font-style: italic;">// stop after 10 redirects</span>
    <span style="color: #66cc66;">&#41;</span>;
&nbsp;
    <span style="color: #0000ff;">$ch</span>      = curl_init<span style="color: #66cc66;">&#40;</span> <span style="color: #0000ff;">$url</span> <span style="color: #66cc66;">&#41;</span>;
    curl_setopt_array<span style="color: #66cc66;">&#40;</span> <span style="color: #0000ff;">$ch</span>, <span style="color: #0000ff;">$options</span> <span style="color: #66cc66;">&#41;</span>;
    <span style="color: #0000ff;">$content</span> = curl_exec<span style="color: #66cc66;">&#40;</span> <span style="color: #0000ff;">$ch</span> <span style="color: #66cc66;">&#41;</span>;
    <span style="color: #0000ff;">$err</span>     = curl_errno<span style="color: #66cc66;">&#40;</span> <span style="color: #0000ff;">$ch</span> <span style="color: #66cc66;">&#41;</span>;
    <span style="color: #0000ff;">$errmsg</span>  = curl_error<span style="color: #66cc66;">&#40;</span> <span style="color: #0000ff;">$ch</span> <span style="color: #66cc66;">&#41;</span>;
    <span style="color: #0000ff;">$header</span>  = curl_getinfo<span style="color: #66cc66;">&#40;</span> <span style="color: #0000ff;">$ch</span> <span style="color: #66cc66;">&#41;</span>;
    curl_close<span style="color: #66cc66;">&#40;</span> <span style="color: #0000ff;">$ch</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
    <span style="color: #0000ff;">$header</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'errno'</span><span style="color: #66cc66;">&#93;</span>   = <span style="color: #0000ff;">$err</span>;
    <span style="color: #0000ff;">$header</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'errmsg'</span><span style="color: #66cc66;">&#93;</span>  = <span style="color: #0000ff;">$errmsg</span>;
    <span style="color: #0000ff;">$header</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'content'</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #0000ff;">$content</span>;
    <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">$header</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p>Additional Reading:<br />
<a title="Reading a Remote File With PHP" href="http://www.php-mysql-tutorial.com/wikis/php-tutorial/reading-a-remote-file-using-php.aspx" target="_blank">Reading a Remote File Using PHP</a><br />
<a title="How to get a webpage using CURL" href="http://nadeausoftware.com/articles/2007/06/php_tip_how_get_web_page_using_curl" target="_blank">How to get a webpage using CURL</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ben.lobaugh.net/blog/592/php-downloading-remote-content-with-curl/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Retrieve remote JSON content with jQuery</title>
		<link>http://ben.lobaugh.net/blog/586/retrieve-remote-json-content-with-jquery</link>
		<comments>http://ben.lobaugh.net/blog/586/retrieve-remote-json-content-with-jquery#comments</comments>
		<pubDate>Wed, 30 Jun 2010 20:03:58 +0000</pubDate>
		<dc:creator>blobaugh</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://ben.lobaugh.net/blog/?p=586</guid>
		<description><![CDATA[I am currently working on an iPhone app using the PhoneGap project as a base. PhoneGap allows me to use my current web development knowledge to develop an application using HTML, CSS, and Javascript. A key component in almost all iPhone applications is retrieval of remote content. I am going to walk you through the [...]]]></description>
			<content:encoded><![CDATA[<p>I am currently working on an iPhone app using the <a title="PhoneGap" href="http://www.phonegap.com/" target="_blank">PhoneGap</a> project as a base. PhoneGap allows me to use my current web development knowledge to develop an application using HTML, CSS, and Javascript. A key component in almost all iPhone applications is retrieval of remote content. I am going to walk you through the steps I took while developing the<a href="http://www.nnu.edu/iphone"> iPhone app</a> for <a title="Northwest Nazarene University" href="http://www.nnu.edu" target="_blank">Northwest Nazarene University</a>.</p>
<p>For ease of development purposes I have downloaded the <a title="jQuery" href="http://jquery.com/" target="_blank">jQuery</a> library, version 1.4.2, to my local machine.</p>
<p>Let's start by creating a basic HTML file that we will manipulate as we go.</p>
<pre>&nbsp;
&lt;html&gt;
&lt;head&gt;
        &lt;title&gt;JSON Demo&lt;/title&gt;
&nbsp;
        &lt;script type=&quot;text/javascript&quot; src=&quot;jquery-1.4.2.min.js&quot;&gt;&lt;/script&gt;
&nbsp;
        &lt;script type=&quot;text/javascript&quot;&gt;
                // We will fill in our code here
         &lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;/body&gt;
&lt;/html&gt;
&nbsp;</pre>
<p>We could statically build our own JSON string here, but since we are building an app to retreive remote content why don't we use an external source. There is a weather module in the NNU iPhone app that will do nicely. You can find it here<a href="http://www.nnu.edu/iphone/api/weather.php" target="_blank"> http://www.nnu.edu/iphone/api/weather.php</a> and the output should look something like</p>
<pre class="javascript"><span style="color: #66cc66;">&#123;</span><span style="color: #3366CC;">&quot;temp&quot;</span>:<span style="color: #66cc66;">&#91;</span><span style="color: #3366CC;">&quot;70&quot;</span><span style="color: #66cc66;">&#93;</span>,<span style="color: #3366CC;">&quot;condition&quot;</span>:<span style="color: #66cc66;">&#91;</span><span style="color: #3366CC;">&quot;Fair&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p>(At the time of writing this was correct, but the site is still in development and may change slightly)</p>
<p>Great, we have our source, now we need to pull the content from it. Luckily jQuery provides some handy tools for grabbing remote content, and specifically for JSON data. Here is where the first trick comes in, cross site scripting (XSS). XSS happens when a Javascript service attempts to pull content from another server. XSS has been used for malicious purposes in the past and is therefore tightly controlled. jQuery is supposed to be able to legitimately access remote content, but if you are having problems see my post <a href="http://ben.lobaugh.net/blog/578/phpapache-enabling-xss-for-iphone-apps-with-phonegap-and-jqtouch">Enabling XSS for iPhone apps with PhoneGap and jQTouch</a> to learn how to configure your Apache server to allow the remote pull.</p>
<p>Let's see what the jQuery code looks like</p>
<pre class="javascript">$.<span style="color: #006600;">getJSON</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'http://www.nnu.edu/iphone/api/weather.php'</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>data<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'body'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">html</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'
&nbsp;
'</span> + data.<span style="color: #006600;">temp</span> + <span style="color: #3366CC;">'
&nbsp;
'</span>
    + <span style="color: #3366CC;">'
&nbsp;
'</span> + data.<span style="color: #006600;">condition</span> + <span style="color: #3366CC;">'
&nbsp;
'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<p>Using $.getJSON we can provide a callback for the returned JSON. I am going to use a dynamic function in this example, however you can also point it to a function name you define elsewhere. See <a href="http://api.jquery.com/jQuery.getJSON/" target="_blank">http://api.jquery.com/jQuery.getJSON/</a> for more information regarding the $.getJSON function.</p>
<p>After previewing the index.html file in your browser you should see</p>
<pre>73
&nbsp;
Fair
&nbsp;</pre>
<p>Congratulations, you have successfully pulled remote JSON into your app!</p>
<p>You can download the complete source code <a href="http://ben.lobaugh.net/blog/wp-content/uploads/2010/06/json_demo_weather.zip">here</a></p>
<pre>&nbsp;
&lt;html&gt;
&lt;head&gt;
        &lt;title&gt;JSON Demo&lt;/title&gt;
&nbsp;
        &lt;script type=&quot;text/javascript&quot; src=&quot;jquery-1.4.2.min.js&quot;&gt;&lt;/script&gt;
&nbsp;
        &lt;script type=&quot;text/javascript&quot;&gt;
                // We will fill in our code here
           $(document).ready(function() {
               $('body').html('
&nbsp;
' + data.temp + '
&nbsp;
'
                                + '
&nbsp;
' + data.condition + '
&nbsp;
');
               });
            }); 
        &lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;/body&gt;
&lt;/html&gt;
&nbsp;</pre>
<p><strong>Complex Objects</strong><br />
Let's take it a step further now and work with some complex objects. We will be using the <a href="http://www.nnu.edu/iphone" target="_blank">NNU iPhone app</a>'s JSON news feed located here <a href="http://www.nnu.edu/iphone/api/rssproxy.php?url=nnu_news" target="_blank">http://www.nnu.edu/iphone/api/rssproxy.php?url=nnu_news</a> . I am not going to post the JSON string because it gets quite long. You can view it by loading that URI into your browser.</p>
<p>Again, create your initial basic HTML index file. We will reuse the one listed in the above section.</p>
<p>Now the code for this section is going to be a little more intense. The object we are getting back contains multiple array of information. We will need to loop over the array in order to grab the individual news elements and display their contents. jQuery provides us with the $.each function (See <a href="http://api.jquery.com/each/" target="_blank">http://api.jquery.com/each/</a>) which we can hand the JSON data off to and get to the good stuff. Let's see what this code will look like</p>
<pre class="javascript">$.<span style="color: #006600;">getJSON</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'http://www.nnu.edu/iphone/api/rssproxy.php?url=nnu_news'</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>data<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        $.<span style="color: #006600;">each</span><span style="color: #66cc66;">&#40;</span>data, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>i,<span style="color: #000066; font-weight: bold;">item</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
                $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'body'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">append</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'&lt;strong&gt;'</span> + <span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #006600;">title</span> + <span style="color: #3366CC;">'&lt;/strong&gt;'</span><span style="color: #66cc66;">&#41;</span>;
                $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'body'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">append</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'&lt;br/&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt;Published:'</span> + <span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #006600;">pubDate</span> + <span style="color: #3366CC;">'&lt;/span&gt;'</span><span style="color: #66cc66;">&#41;</span>;
                $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'body'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">append</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'
&nbsp;
'</span> + <span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #006600;">description</span> + <span style="color: #3366CC;">'
&nbsp;
&lt;br/&gt;'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
        <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<p>If everything was written correctly you should now see a listing of the news items when you refresh the index.html file in your browser.</p>
<p>You can download the full source <a href="http://ben.lobaugh.net/blog/wp-content/uploads/2010/06/json_demo_news.zip">here</a></p>
<p>Having Trouble?<br />
If you are receiving a denied error from the server, or a 200 success message with no content you may be experiencing cross site scripting (XSS) issues. Take a gander at my post<a href="http://ben.lobaugh.net/blog/578/phpapache-enabling-xss-for-iphone-apps-with-phonegap-and-jqtouch"> Enabling XSS for iPhone apps with PhoneGap and jQTouch</a> to prevent this behavior in the future</p>
]]></content:encoded>
			<wfw:commentRss>http://ben.lobaugh.net/blog/586/retrieve-remote-json-content-with-jquery/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PHP+Apache: Enabling XSS for iPhone apps with PhoneGap and jQTouch</title>
		<link>http://ben.lobaugh.net/blog/578/phpapache-enabling-xss-for-iphone-apps-with-phonegap-and-jqtouch</link>
		<comments>http://ben.lobaugh.net/blog/578/phpapache-enabling-xss-for-iphone-apps-with-phonegap-and-jqtouch#comments</comments>
		<pubDate>Thu, 24 Jun 2010 17:40:22 +0000</pubDate>
		<dc:creator>blobaugh</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://ben.lobaugh.net/blog/?p=578</guid>
		<description><![CDATA[I am currently working on developing an iPhone app for Northwest Nazarene University. Part of this app will need to connect to the school's webserver to retreive items such as news feeds and shared photo galleries. Being primarily a web developer I have turned to two projects created by Nitobi persons, PhoneGap and jQTouch. PhoneGap [...]]]></description>
			<content:encoded><![CDATA[<p>I am currently working on developing an <a title="NNU iPhone App" href="http://www.nnu.edu/iphone" target="_blank">iPhone app</a> for<a title="Northwest Nazarene University" href="http://www.nnu.edu" target="_blank"> Northwest Nazarene University</a>. Part of this app will need to connect to the school's webserver to retreive items such as news feeds and shared photo galleries. Being primarily a web developer I have turned to two projects created by <a title="Nitobi" href="http://www.nitobi.com/" target="_blank">Nitobi</a> persons, <a title="PhoneGap" href="http://www.phonegap.com/" target="_blank">PhoneGap</a> and <a title="jQTouch" href="http://www.jqtouch.com/" target="_blank">jQTouch</a>.</p>
<p><a title="PhoneGap" href="http://www.phonegap.com/" target="_blank">PhoneGap</a> allows me to use my current HTML, CSS, and Javascript knowledge to build a site. Then using the PhoneGap xcode project I simply drop the web files into a directory and PhoneGap transforms them into a glorious iPhone app.</p>
<p><a title="jQTouch" href="http://www.jqtouch.com/" target="_blank">jQTouch</a> is a jQuery based library that makes the app look and feel like a real iPhone app.</p>
<p>This setup worked beautifully until I needed to connect to the school's webserver and retreive content. I began to run into cross site scripting (XSS) headaches. After days of pounding my head into my desk I ran across a neat little feature in <a title="Apache HTTP Server" href="http://httpd.apache.org/" target="_blank">Apache</a> that allows you to turn off the XSS protection on the server. You may be thinking that sounds insecure, and you would be right, but if you are trying to pull content off your server with Javascript from remote locations it may be just the thing you need to get it working. This does not come built in Apache, it is a module you have to add in. It was pretty trivial. Here are the <a title="mod_headers in Ubuntu" href="http://harthur.wordpress.com/2009/10/15/configure-apache-to-accept-cross-site-xmlhttprequests-on-ubuntu/" target="_blank">directions for setting up mod_headers in Ubuntu</a></p>
<p>To check and see if mod_headers was actually loaded save the following to a <a title="PHP" href="http://php.net" target="_blank">PHP</a> file and view it from the server in your browser</p>
<pre class="php"><a href="http://www.php.net/print_r"><span style="color: #000066;">print_r</span></a><span style="color: #66cc66;">&#40;</span>apache_get_modules<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<p>If that was successful mod_headers should be listed. You can now move on to the more fun stuff.</p>
<p>There are two ways in which you can allow XSS. The first is through a .htaccess file. This method works great, however it enables XSS for all files in the directory. The second is through PHP header(). The PHP method allows you to target more specifically what files are XSS capable, and even would allow you to do some other safety checks in your code before setting the XSS header.</p>
<p>.htaccess</p>
<pre class="bash">Header add Access-Control-Allow-Origin <span style="color: #ff0000;">&quot;*&quot;</span>
&nbsp;</pre>
<p>PHP</p>
<pre class="php"><a href="http://www.php.net/header"><span style="color: #000066;">header</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Access-Control-Allow-Origin: *'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<p>Another thing to take note of is the *. The * means anyone from anywhere may do XSS. You can however specify specific hosts that have access. See the link at the bottom of this post for more information on that.</p>
<p>Congratulations! You should now have an XSS compatible website. Make extra sure that all of your security is in place because XSS opens up a whole new can of worms for crackers. Ensure all input from users is cleaned before it touches your database or anything else remotely sensitive.</p>
<p>Articles that helped me along the way:<br />
<a href="http://stackoverflow.com/questions/1653308/access-control-allow-origin-multiple-origin-domains" target="_blank">Access-Control-Allow-Origin Multiple Origin  Domains?</a><br />
<a title="Permanent Link to &quot;Configure Apache To  Accept Cross-Site XMLHttpRequests on Ubuntu&quot;" rel="bookmark" href="http://harthur.wordpress.com/2009/10/15/configure-apache-to-accept-cross-site-xmlhttprequests-on-ubuntu/" target="_blank">Configure Apache To  Accept Cross-Site XMLHttpRequests on Ubuntu</a><br />
<a title="HTTP Access Control - Mozilla" href="https://developer.mozilla.org/en/http_access_control" target="_blank">HTTP Access Control</a><br />
<a title="Server Side Access Control - Mozilla" href="https://developer.mozilla.org/En/Server-Side_Access_Control" target="_blank">Server-Side Access Control</a><br />
<a href="http://www.hunlock.com/blogs/Social_Javascript_%28cross-site_ajax%29" target="_blank">Social Javascript (cross-site ajax)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ben.lobaugh.net/blog/578/phpapache-enabling-xss-for-iphone-apps-with-phonegap-and-jqtouch/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
