<?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</title>
	<atom:link href="http://ben.lobaugh.net/blog/feed" rel="self" type="application/rss+xml" />
	<link>http://ben.lobaugh.net/blog</link>
	<description>/(bb&#124;[^b]{2})/</description>
	<lastBuildDate>Wed, 28 Jul 2010 20:56:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>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>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://ben.lobaugh.net/blog/605/javascript-parse-twitter-usernames-hashtags-and-uris&amp;n=Javascript%3A+Parse+Twitter+Usernames%2C+Hashtags+and+URIs&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
		<li class="shr-buzzster">
			<a href="javascript:var%20s=document.createElement('script');s.src='http://www.buzzster.com/javascripts/bzz_adv.js';s.type='text/javascript';void(document.getElementsByTagName('head')[0].appendChild(s));" rel="nofollow" title="Share this via Buzzster!">Share this via Buzzster!</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://ben.lobaugh.net/blog/605/javascript-parse-twitter-usernames-hashtags-and-uris/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://ben.lobaugh.net/blog/605/javascript-parse-twitter-usernames-hashtags-and-uris&amp;title=Javascript%3A+Parse+Twitter+Usernames%2C+Hashtags+and+URIs" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://ben.lobaugh.net/blog/605/javascript-parse-twitter-usernames-hashtags-and-uris&amp;title=Javascript%3A+Parse+Twitter+Usernames%2C+Hashtags+and+URIs" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://ben.lobaugh.net/blog/605/javascript-parse-twitter-usernames-hashtags-and-uris&amp;t=Javascript%3A+Parse+Twitter+Usernames%2C+Hashtags+and+URIs" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-friendfeed">
			<a href="http://www.friendfeed.com/share?title=Javascript%3A+Parse+Twitter+Usernames%2C+Hashtags+and+URIs&amp;link=http://ben.lobaugh.net/blog/605/javascript-parse-twitter-usernames-hashtags-and-uris" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="shr-gmail">
			<a href="https://mail.google.com/mail/?ui=2&amp;view=cm&amp;fs=1&amp;tf=1&amp;su=Javascript%3A+Parse+Twitter+Usernames%2C+Hashtags+and+URIs&amp;body=Link: http://ben.lobaugh.net/blog/605/javascript-parse-twitter-usernames-hashtags-and-uris (sent via shareaholic)%0D%0A%0D%0A----%0D%0A Twitter%20provides%20a%20plain-text%20stream%20of%20tweets.%20I%20was%20looking%20to%20add%20links%20to%20this%20stream%20for%20the%20usernames%2C%20URIs%2C%20and%20hashes.%20I%20wound%20up%20with%20the%20following%20function%20that%20hopefully%20you%20will%20find%20useful.%0D%0A%0D%0A%0D%0Afunction%20parseTwitter%28text%29%20%7B%0D%0A%20%20%20%20%20%20%20%20%2F%2F%20Parse%20URIs%0D%0A%20%20%20%20%20%20%20%20text%20%3D%20text.replace%28%2F%5BA-Za-z%5D%2B" rel="nofollow" class="external" title="Email this via Gmail">Email this via Gmail</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://ben.lobaugh.net/blog/605/javascript-parse-twitter-usernames-hashtags-and-uris&amp;title=Javascript%3A+Parse+Twitter+Usernames%2C+Hashtags+and+URIs" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://ben.lobaugh.net/blog/605/javascript-parse-twitter-usernames-hashtags-and-uris&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://ben.lobaugh.net/blog/605/javascript-parse-twitter-usernames-hashtags-and-uris&amp;title=Javascript%3A+Parse+Twitter+Usernames%2C+Hashtags+and+URIs&amp;summary=Twitter%20provides%20a%20plain-text%20stream%20of%20tweets.%20I%20was%20looking%20to%20add%20links%20to%20this%20stream%20for%20the%20usernames%2C%20URIs%2C%20and%20hashes.%20I%20wound%20up%20with%20the%20following%20function%20that%20hopefully%20you%20will%20find%20useful.%0D%0A%0D%0A%0D%0Afunction%20parseTwitter%28text%29%20%7B%0D%0A%20%20%20%20%20%20%20%20%2F%2F%20Parse%20URIs%0D%0A%20%20%20%20%20%20%20%20text%20%3D%20text.replace%28%2F%5BA-Za-z%5D%2B&amp;source=Ben Lobaugh Online" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://ben.lobaugh.net/blog/605/javascript-parse-twitter-usernames-hashtags-and-uris&amp;title=Javascript%3A+Parse+Twitter+Usernames%2C+Hashtags+and+URIs" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://ben.lobaugh.net/blog/605/javascript-parse-twitter-usernames-hashtags-and-uris&amp;title=Javascript%3A+Parse+Twitter+Usernames%2C+Hashtags+and+URIs" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fben.lobaugh.net%2Fblog%2F605%2Fjavascript-parse-twitter-usernames-hashtags-and-uris&amp;t=Javascript%3A+Parse+Twitter+Usernames%2C+Hashtags+and+URIs" rel="nofollow" class="external" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Javascript%3A+Parse+Twitter+Usernames%2C+Hashtags+and+URIs+-+http://b2l.me/adbymp&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-wikio">
			<a href="http://www.wikio.com/sharethis?url=http://ben.lobaugh.net/blog/605/javascript-parse-twitter-usernames-hashtags-and-uris&amp;title=Javascript%3A+Parse+Twitter+Usernames%2C+Hashtags+and+URIs" rel="nofollow" class="external" title="Share this on Wikio">Share this on Wikio</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://ben.lobaugh.net/blog/605/javascript-parse-twitter-usernames-hashtags-and-uris&amp;submitHeadline=Javascript%3A+Parse+Twitter+Usernames%2C+Hashtags+and+URIs&amp;submitSummary=Twitter%20provides%20a%20plain-text%20stream%20of%20tweets.%20I%20was%20looking%20to%20add%20links%20to%20this%20stream%20for%20the%20usernames%2C%20URIs%2C%20and%20hashes.%20I%20wound%20up%20with%20the%20following%20function%20that%20hopefully%20you%20will%20find%20useful.%0D%0A%0D%0A%0D%0Afunction%20parseTwitter%28text%29%20%7B%0D%0A%20%20%20%20%20%20%20%20%2F%2F%20Parse%20URIs%0D%0A%20%20%20%20%20%20%20%20text%20%3D%20text.replace%28%2F%5BA-Za-z%5D%2B&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-yahoomail">
			<a href="http://compose.mail.yahoo.com/?Subject=Javascript%3A+Parse+Twitter+Usernames%2C+Hashtags+and+URIs&amp;body=Link: http://ben.lobaugh.net/blog/605/javascript-parse-twitter-usernames-hashtags-and-uris (sent via shareaholic)%0D%0A%0D%0A----%0D%0A Twitter%20provides%20a%20plain-text%20stream%20of%20tweets.%20I%20was%20looking%20to%20add%20links%20to%20this%20stream%20for%20the%20usernames%2C%20URIs%2C%20and%20hashes.%20I%20wound%20up%20with%20the%20following%20function%20that%20hopefully%20you%20will%20find%20useful.%0D%0A%0D%0A%0D%0Afunction%20parseTwitter%28text%29%20%7B%0D%0A%20%20%20%20%20%20%20%20%2F%2F%20Parse%20URIs%0D%0A%20%20%20%20%20%20%20%20text%20%3D%20text.replace%28%2F%5BA-Za-z%5D%2B" rel="nofollow" class="external" title="Email this via Yahoo! Mail">Email this via Yahoo! Mail</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></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>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://ben.lobaugh.net/blog/597/bus-pilots-2010-family-reunion&amp;n=Bus+Pilots%3A+2010+Family+Reunion&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
		<li class="shr-buzzster">
			<a href="javascript:var%20s=document.createElement('script');s.src='http://www.buzzster.com/javascripts/bzz_adv.js';s.type='text/javascript';void(document.getElementsByTagName('head')[0].appendChild(s));" rel="nofollow" title="Share this via Buzzster!">Share this via Buzzster!</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://ben.lobaugh.net/blog/597/bus-pilots-2010-family-reunion/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://ben.lobaugh.net/blog/597/bus-pilots-2010-family-reunion&amp;title=Bus+Pilots%3A+2010+Family+Reunion" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://ben.lobaugh.net/blog/597/bus-pilots-2010-family-reunion&amp;title=Bus+Pilots%3A+2010+Family+Reunion" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://ben.lobaugh.net/blog/597/bus-pilots-2010-family-reunion&amp;t=Bus+Pilots%3A+2010+Family+Reunion" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-friendfeed">
			<a href="http://www.friendfeed.com/share?title=Bus+Pilots%3A+2010+Family+Reunion&amp;link=http://ben.lobaugh.net/blog/597/bus-pilots-2010-family-reunion" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="shr-gmail">
			<a href="https://mail.google.com/mail/?ui=2&amp;view=cm&amp;fs=1&amp;tf=1&amp;su=Bus+Pilots%3A+2010+Family+Reunion&amp;body=Link: http://ben.lobaugh.net/blog/597/bus-pilots-2010-family-reunion (sent via shareaholic)%0D%0A%0D%0A----%0D%0A I%20had%20a%20great%20time%20at%20the%20Family%20Reunion%20this%20year%21%20I%20highly%20encourage%20anyone%20reading%20this%20to%20check%20out%20the%20Bus%20Pilots%20website%20and%20attend%20next%20year.%20It%20is%20a%20weekend%20long%20event%20starting%20Friday%20evening%20and%20ending%20Sunday%20afternoon.%20On%20Friday%20we%20all%20met%20a%20Sonic%20in%20Boise%20for%20dinner.%20Afterwards%20we%20cruised" rel="nofollow" class="external" title="Email this via Gmail">Email this via Gmail</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://ben.lobaugh.net/blog/597/bus-pilots-2010-family-reunion&amp;title=Bus+Pilots%3A+2010+Family+Reunion" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://ben.lobaugh.net/blog/597/bus-pilots-2010-family-reunion&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://ben.lobaugh.net/blog/597/bus-pilots-2010-family-reunion&amp;title=Bus+Pilots%3A+2010+Family+Reunion&amp;summary=I%20had%20a%20great%20time%20at%20the%20Family%20Reunion%20this%20year%21%20I%20highly%20encourage%20anyone%20reading%20this%20to%20check%20out%20the%20Bus%20Pilots%20website%20and%20attend%20next%20year.%20It%20is%20a%20weekend%20long%20event%20starting%20Friday%20evening%20and%20ending%20Sunday%20afternoon.%20On%20Friday%20we%20all%20met%20a%20Sonic%20in%20Boise%20for%20dinner.%20Afterwards%20we%20cruised&amp;source=Ben Lobaugh Online" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://ben.lobaugh.net/blog/597/bus-pilots-2010-family-reunion&amp;title=Bus+Pilots%3A+2010+Family+Reunion" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://ben.lobaugh.net/blog/597/bus-pilots-2010-family-reunion&amp;title=Bus+Pilots%3A+2010+Family+Reunion" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fben.lobaugh.net%2Fblog%2F597%2Fbus-pilots-2010-family-reunion&amp;t=Bus+Pilots%3A+2010+Family+Reunion" rel="nofollow" class="external" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Bus+Pilots%3A+2010+Family+Reunion+-+File: /data/app/webapp/functions.php<br />Line: 23<br />Message: Incorrect key file for table './b2l_shrinker/phurl_settings.MYI'; try to repair it&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-wikio">
			<a href="http://www.wikio.com/sharethis?url=http://ben.lobaugh.net/blog/597/bus-pilots-2010-family-reunion&amp;title=Bus+Pilots%3A+2010+Family+Reunion" rel="nofollow" class="external" title="Share this on Wikio">Share this on Wikio</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://ben.lobaugh.net/blog/597/bus-pilots-2010-family-reunion&amp;submitHeadline=Bus+Pilots%3A+2010+Family+Reunion&amp;submitSummary=I%20had%20a%20great%20time%20at%20the%20Family%20Reunion%20this%20year%21%20I%20highly%20encourage%20anyone%20reading%20this%20to%20check%20out%20the%20Bus%20Pilots%20website%20and%20attend%20next%20year.%20It%20is%20a%20weekend%20long%20event%20starting%20Friday%20evening%20and%20ending%20Sunday%20afternoon.%20On%20Friday%20we%20all%20met%20a%20Sonic%20in%20Boise%20for%20dinner.%20Afterwards%20we%20cruised&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-yahoomail">
			<a href="http://compose.mail.yahoo.com/?Subject=Bus+Pilots%3A+2010+Family+Reunion&amp;body=Link: http://ben.lobaugh.net/blog/597/bus-pilots-2010-family-reunion (sent via shareaholic)%0D%0A%0D%0A----%0D%0A I%20had%20a%20great%20time%20at%20the%20Family%20Reunion%20this%20year%21%20I%20highly%20encourage%20anyone%20reading%20this%20to%20check%20out%20the%20Bus%20Pilots%20website%20and%20attend%20next%20year.%20It%20is%20a%20weekend%20long%20event%20starting%20Friday%20evening%20and%20ending%20Sunday%20afternoon.%20On%20Friday%20we%20all%20met%20a%20Sonic%20in%20Boise%20for%20dinner.%20Afterwards%20we%20cruised" rel="nofollow" class="external" title="Email this via Yahoo! Mail">Email this via Yahoo! Mail</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></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>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://ben.lobaugh.net/blog/592/php-downloading-remote-content-with-curl&amp;n=PHP%3A+Downloading+remote+content+with+CURL&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
		<li class="shr-buzzster">
			<a href="javascript:var%20s=document.createElement('script');s.src='http://www.buzzster.com/javascripts/bzz_adv.js';s.type='text/javascript';void(document.getElementsByTagName('head')[0].appendChild(s));" rel="nofollow" title="Share this via Buzzster!">Share this via Buzzster!</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://ben.lobaugh.net/blog/592/php-downloading-remote-content-with-curl/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://ben.lobaugh.net/blog/592/php-downloading-remote-content-with-curl&amp;title=PHP%3A+Downloading+remote+content+with+CURL" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://ben.lobaugh.net/blog/592/php-downloading-remote-content-with-curl&amp;title=PHP%3A+Downloading+remote+content+with+CURL" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://ben.lobaugh.net/blog/592/php-downloading-remote-content-with-curl&amp;t=PHP%3A+Downloading+remote+content+with+CURL" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-friendfeed">
			<a href="http://www.friendfeed.com/share?title=PHP%3A+Downloading+remote+content+with+CURL&amp;link=http://ben.lobaugh.net/blog/592/php-downloading-remote-content-with-curl" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="shr-gmail">
			<a href="https://mail.google.com/mail/?ui=2&amp;view=cm&amp;fs=1&amp;tf=1&amp;su=PHP%3A+Downloading+remote+content+with+CURL&amp;body=Link: http://ben.lobaugh.net/blog/592/php-downloading-remote-content-with-curl (sent via shareaholic)%0D%0A%0D%0A----%0D%0A With%20fopen%20becoming%20increasingly%20scarce%20on%20web%20hosts%2C%20CURL%20is%20becoming%20a%20better%20and%20better%20solution%20to%20retrieving%20remote%20content%20with%20PHP.%20CURL%20is%20a%20fairly%20standard%20PHP%20module%20and%20chances%20are%20if%20your%20host%20does%20not%20support%20it%20a%20simple%20ticket%20will%20have%20them%20installing%20it%20for%20you.%0D%0A%0D%0ABecause%20I%20am%20const" rel="nofollow" class="external" title="Email this via Gmail">Email this via Gmail</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://ben.lobaugh.net/blog/592/php-downloading-remote-content-with-curl&amp;title=PHP%3A+Downloading+remote+content+with+CURL" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://ben.lobaugh.net/blog/592/php-downloading-remote-content-with-curl&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://ben.lobaugh.net/blog/592/php-downloading-remote-content-with-curl&amp;title=PHP%3A+Downloading+remote+content+with+CURL&amp;summary=With%20fopen%20becoming%20increasingly%20scarce%20on%20web%20hosts%2C%20CURL%20is%20becoming%20a%20better%20and%20better%20solution%20to%20retrieving%20remote%20content%20with%20PHP.%20CURL%20is%20a%20fairly%20standard%20PHP%20module%20and%20chances%20are%20if%20your%20host%20does%20not%20support%20it%20a%20simple%20ticket%20will%20have%20them%20installing%20it%20for%20you.%0D%0A%0D%0ABecause%20I%20am%20const&amp;source=Ben Lobaugh Online" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://ben.lobaugh.net/blog/592/php-downloading-remote-content-with-curl&amp;title=PHP%3A+Downloading+remote+content+with+CURL" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://ben.lobaugh.net/blog/592/php-downloading-remote-content-with-curl&amp;title=PHP%3A+Downloading+remote+content+with+CURL" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fben.lobaugh.net%2Fblog%2F592%2Fphp-downloading-remote-content-with-curl&amp;t=PHP%3A+Downloading+remote+content+with+CURL" rel="nofollow" class="external" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=PHP%3A+Downloading+remote+content+with+CURL+-+http://b2l.me/9jscq&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-wikio">
			<a href="http://www.wikio.com/sharethis?url=http://ben.lobaugh.net/blog/592/php-downloading-remote-content-with-curl&amp;title=PHP%3A+Downloading+remote+content+with+CURL" rel="nofollow" class="external" title="Share this on Wikio">Share this on Wikio</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://ben.lobaugh.net/blog/592/php-downloading-remote-content-with-curl&amp;submitHeadline=PHP%3A+Downloading+remote+content+with+CURL&amp;submitSummary=With%20fopen%20becoming%20increasingly%20scarce%20on%20web%20hosts%2C%20CURL%20is%20becoming%20a%20better%20and%20better%20solution%20to%20retrieving%20remote%20content%20with%20PHP.%20CURL%20is%20a%20fairly%20standard%20PHP%20module%20and%20chances%20are%20if%20your%20host%20does%20not%20support%20it%20a%20simple%20ticket%20will%20have%20them%20installing%20it%20for%20you.%0D%0A%0D%0ABecause%20I%20am%20const&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-yahoomail">
			<a href="http://compose.mail.yahoo.com/?Subject=PHP%3A+Downloading+remote+content+with+CURL&amp;body=Link: http://ben.lobaugh.net/blog/592/php-downloading-remote-content-with-curl (sent via shareaholic)%0D%0A%0D%0A----%0D%0A With%20fopen%20becoming%20increasingly%20scarce%20on%20web%20hosts%2C%20CURL%20is%20becoming%20a%20better%20and%20better%20solution%20to%20retrieving%20remote%20content%20with%20PHP.%20CURL%20is%20a%20fairly%20standard%20PHP%20module%20and%20chances%20are%20if%20your%20host%20does%20not%20support%20it%20a%20simple%20ticket%20will%20have%20them%20installing%20it%20for%20you.%0D%0A%0D%0ABecause%20I%20am%20const" rel="nofollow" class="external" title="Email this via Yahoo! Mail">Email this via Yahoo! Mail</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></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>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://ben.lobaugh.net/blog/586/retrieve-remote-json-content-with-jquery&amp;n=Retrieve+remote+JSON+content+with+jQuery&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
		<li class="shr-buzzster">
			<a href="javascript:var%20s=document.createElement('script');s.src='http://www.buzzster.com/javascripts/bzz_adv.js';s.type='text/javascript';void(document.getElementsByTagName('head')[0].appendChild(s));" rel="nofollow" title="Share this via Buzzster!">Share this via Buzzster!</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://ben.lobaugh.net/blog/586/retrieve-remote-json-content-with-jquery/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://ben.lobaugh.net/blog/586/retrieve-remote-json-content-with-jquery&amp;title=Retrieve+remote+JSON+content+with+jQuery" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://ben.lobaugh.net/blog/586/retrieve-remote-json-content-with-jquery&amp;title=Retrieve+remote+JSON+content+with+jQuery" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://ben.lobaugh.net/blog/586/retrieve-remote-json-content-with-jquery&amp;t=Retrieve+remote+JSON+content+with+jQuery" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-friendfeed">
			<a href="http://www.friendfeed.com/share?title=Retrieve+remote+JSON+content+with+jQuery&amp;link=http://ben.lobaugh.net/blog/586/retrieve-remote-json-content-with-jquery" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="shr-gmail">
			<a href="https://mail.google.com/mail/?ui=2&amp;view=cm&amp;fs=1&amp;tf=1&amp;su=Retrieve+remote+JSON+content+with+jQuery&amp;body=Link: http://ben.lobaugh.net/blog/586/retrieve-remote-json-content-with-jquery (sent via shareaholic)%0D%0A%0D%0A----%0D%0A I%20am%20currently%20working%20on%20an%20iPhone%20app%20using%20the%20PhoneGap%20project%20as%20a%20base.%20PhoneGap%20allows%20me%20to%20use%20my%20current%20web%20development%20knowledge%20to%20develop%20an%20application%20using%20HTML%2C%20CSS%2C%20and%20Javascript.%20A%20key%20component%20in%20almost%20all%20iPhone%20applications%20is%20retrieval%20of%20remote%20content.%20I%20am%20going%20to%20walk" rel="nofollow" class="external" title="Email this via Gmail">Email this via Gmail</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://ben.lobaugh.net/blog/586/retrieve-remote-json-content-with-jquery&amp;title=Retrieve+remote+JSON+content+with+jQuery" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://ben.lobaugh.net/blog/586/retrieve-remote-json-content-with-jquery&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://ben.lobaugh.net/blog/586/retrieve-remote-json-content-with-jquery&amp;title=Retrieve+remote+JSON+content+with+jQuery&amp;summary=I%20am%20currently%20working%20on%20an%20iPhone%20app%20using%20the%20PhoneGap%20project%20as%20a%20base.%20PhoneGap%20allows%20me%20to%20use%20my%20current%20web%20development%20knowledge%20to%20develop%20an%20application%20using%20HTML%2C%20CSS%2C%20and%20Javascript.%20A%20key%20component%20in%20almost%20all%20iPhone%20applications%20is%20retrieval%20of%20remote%20content.%20I%20am%20going%20to%20walk&amp;source=Ben Lobaugh Online" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://ben.lobaugh.net/blog/586/retrieve-remote-json-content-with-jquery&amp;title=Retrieve+remote+JSON+content+with+jQuery" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://ben.lobaugh.net/blog/586/retrieve-remote-json-content-with-jquery&amp;title=Retrieve+remote+JSON+content+with+jQuery" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fben.lobaugh.net%2Fblog%2F586%2Fretrieve-remote-json-content-with-jquery&amp;t=Retrieve+remote+JSON+content+with+jQuery" rel="nofollow" class="external" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Retrieve+remote+JSON+content+with+jQuery+-+http://b2l.me/7vn89&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-wikio">
			<a href="http://www.wikio.com/sharethis?url=http://ben.lobaugh.net/blog/586/retrieve-remote-json-content-with-jquery&amp;title=Retrieve+remote+JSON+content+with+jQuery" rel="nofollow" class="external" title="Share this on Wikio">Share this on Wikio</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://ben.lobaugh.net/blog/586/retrieve-remote-json-content-with-jquery&amp;submitHeadline=Retrieve+remote+JSON+content+with+jQuery&amp;submitSummary=I%20am%20currently%20working%20on%20an%20iPhone%20app%20using%20the%20PhoneGap%20project%20as%20a%20base.%20PhoneGap%20allows%20me%20to%20use%20my%20current%20web%20development%20knowledge%20to%20develop%20an%20application%20using%20HTML%2C%20CSS%2C%20and%20Javascript.%20A%20key%20component%20in%20almost%20all%20iPhone%20applications%20is%20retrieval%20of%20remote%20content.%20I%20am%20going%20to%20walk&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-yahoomail">
			<a href="http://compose.mail.yahoo.com/?Subject=Retrieve+remote+JSON+content+with+jQuery&amp;body=Link: http://ben.lobaugh.net/blog/586/retrieve-remote-json-content-with-jquery (sent via shareaholic)%0D%0A%0D%0A----%0D%0A I%20am%20currently%20working%20on%20an%20iPhone%20app%20using%20the%20PhoneGap%20project%20as%20a%20base.%20PhoneGap%20allows%20me%20to%20use%20my%20current%20web%20development%20knowledge%20to%20develop%20an%20application%20using%20HTML%2C%20CSS%2C%20and%20Javascript.%20A%20key%20component%20in%20almost%20all%20iPhone%20applications%20is%20retrieval%20of%20remote%20content.%20I%20am%20going%20to%20walk" rel="nofollow" class="external" title="Email this via Yahoo! Mail">Email this via Yahoo! Mail</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></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>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://ben.lobaugh.net/blog/578/phpapache-enabling-xss-for-iphone-apps-with-phonegap-and-jqtouch&amp;n=PHP%2BApache%3A+Enabling+XSS+for+iPhone+apps+with+PhoneGap+and+jQTouch&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
		<li class="shr-buzzster">
			<a href="javascript:var%20s=document.createElement('script');s.src='http://www.buzzster.com/javascripts/bzz_adv.js';s.type='text/javascript';void(document.getElementsByTagName('head')[0].appendChild(s));" rel="nofollow" title="Share this via Buzzster!">Share this via Buzzster!</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://ben.lobaugh.net/blog/578/phpapache-enabling-xss-for-iphone-apps-with-phonegap-and-jqtouch/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://ben.lobaugh.net/blog/578/phpapache-enabling-xss-for-iphone-apps-with-phonegap-and-jqtouch&amp;title=PHP%2BApache%3A+Enabling+XSS+for+iPhone+apps+with+PhoneGap+and+jQTouch" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://ben.lobaugh.net/blog/578/phpapache-enabling-xss-for-iphone-apps-with-phonegap-and-jqtouch&amp;title=PHP%2BApache%3A+Enabling+XSS+for+iPhone+apps+with+PhoneGap+and+jQTouch" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://ben.lobaugh.net/blog/578/phpapache-enabling-xss-for-iphone-apps-with-phonegap-and-jqtouch&amp;t=PHP%2BApache%3A+Enabling+XSS+for+iPhone+apps+with+PhoneGap+and+jQTouch" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-friendfeed">
			<a href="http://www.friendfeed.com/share?title=PHP%2BApache%3A+Enabling+XSS+for+iPhone+apps+with+PhoneGap+and+jQTouch&amp;link=http://ben.lobaugh.net/blog/578/phpapache-enabling-xss-for-iphone-apps-with-phonegap-and-jqtouch" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="shr-gmail">
			<a href="https://mail.google.com/mail/?ui=2&amp;view=cm&amp;fs=1&amp;tf=1&amp;su=PHP%2BApache%3A+Enabling+XSS+for+iPhone+apps+with+PhoneGap+and+jQTouch&amp;body=Link: http://ben.lobaugh.net/blog/578/phpapache-enabling-xss-for-iphone-apps-with-phonegap-and-jqtouch (sent via shareaholic)%0D%0A%0D%0A----%0D%0A I%20am%20currently%20working%20on%20developing%20an%20iPhone%20app%20for%20Northwest%20Nazarene%20University.%20Part%20of%20this%20app%20will%20need%20to%20connect%20to%20the%20school%27s%20webserver%20to%20retreive%20items%20such%20as%20news%20feeds%20and%20shared%20photo%20galleries.%20Being%20primarily%20a%20web%20developer%20I%20have%20turned%20to%20two%20projects%20created%20by%20Nitobi%20perso" rel="nofollow" class="external" title="Email this via Gmail">Email this via Gmail</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://ben.lobaugh.net/blog/578/phpapache-enabling-xss-for-iphone-apps-with-phonegap-and-jqtouch&amp;title=PHP%2BApache%3A+Enabling+XSS+for+iPhone+apps+with+PhoneGap+and+jQTouch" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://ben.lobaugh.net/blog/578/phpapache-enabling-xss-for-iphone-apps-with-phonegap-and-jqtouch&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://ben.lobaugh.net/blog/578/phpapache-enabling-xss-for-iphone-apps-with-phonegap-and-jqtouch&amp;title=PHP%2BApache%3A+Enabling+XSS+for+iPhone+apps+with+PhoneGap+and+jQTouch&amp;summary=I%20am%20currently%20working%20on%20developing%20an%20iPhone%20app%20for%20Northwest%20Nazarene%20University.%20Part%20of%20this%20app%20will%20need%20to%20connect%20to%20the%20school%27s%20webserver%20to%20retreive%20items%20such%20as%20news%20feeds%20and%20shared%20photo%20galleries.%20Being%20primarily%20a%20web%20developer%20I%20have%20turned%20to%20two%20projects%20created%20by%20Nitobi%20perso&amp;source=Ben Lobaugh Online" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://ben.lobaugh.net/blog/578/phpapache-enabling-xss-for-iphone-apps-with-phonegap-and-jqtouch&amp;title=PHP%2BApache%3A+Enabling+XSS+for+iPhone+apps+with+PhoneGap+and+jQTouch" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://ben.lobaugh.net/blog/578/phpapache-enabling-xss-for-iphone-apps-with-phonegap-and-jqtouch&amp;title=PHP%2BApache%3A+Enabling+XSS+for+iPhone+apps+with+PhoneGap+and+jQTouch" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fben.lobaugh.net%2Fblog%2F578%2Fphpapache-enabling-xss-for-iphone-apps-with-phonegap-and-jqtouch&amp;t=PHP%2BApache%3A+Enabling+XSS+for+iPhone+apps+with+PhoneGap+and+jQTouch" rel="nofollow" class="external" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=PHP%2BApache%3A+Enabling+XSS+for+iPhone+apps+with+PhoneGap+and+jQTouch+-+http://b2l.me/6ckse&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-wikio">
			<a href="http://www.wikio.com/sharethis?url=http://ben.lobaugh.net/blog/578/phpapache-enabling-xss-for-iphone-apps-with-phonegap-and-jqtouch&amp;title=PHP%2BApache%3A+Enabling+XSS+for+iPhone+apps+with+PhoneGap+and+jQTouch" rel="nofollow" class="external" title="Share this on Wikio">Share this on Wikio</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://ben.lobaugh.net/blog/578/phpapache-enabling-xss-for-iphone-apps-with-phonegap-and-jqtouch&amp;submitHeadline=PHP%2BApache%3A+Enabling+XSS+for+iPhone+apps+with+PhoneGap+and+jQTouch&amp;submitSummary=I%20am%20currently%20working%20on%20developing%20an%20iPhone%20app%20for%20Northwest%20Nazarene%20University.%20Part%20of%20this%20app%20will%20need%20to%20connect%20to%20the%20school%27s%20webserver%20to%20retreive%20items%20such%20as%20news%20feeds%20and%20shared%20photo%20galleries.%20Being%20primarily%20a%20web%20developer%20I%20have%20turned%20to%20two%20projects%20created%20by%20Nitobi%20perso&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-yahoomail">
			<a href="http://compose.mail.yahoo.com/?Subject=PHP%2BApache%3A+Enabling+XSS+for+iPhone+apps+with+PhoneGap+and+jQTouch&amp;body=Link: http://ben.lobaugh.net/blog/578/phpapache-enabling-xss-for-iphone-apps-with-phonegap-and-jqtouch (sent via shareaholic)%0D%0A%0D%0A----%0D%0A I%20am%20currently%20working%20on%20developing%20an%20iPhone%20app%20for%20Northwest%20Nazarene%20University.%20Part%20of%20this%20app%20will%20need%20to%20connect%20to%20the%20school%27s%20webserver%20to%20retreive%20items%20such%20as%20news%20feeds%20and%20shared%20photo%20galleries.%20Being%20primarily%20a%20web%20developer%20I%20have%20turned%20to%20two%20projects%20created%20by%20Nitobi%20perso" rel="nofollow" class="external" title="Email this via Yahoo! Mail">Email this via Yahoo! Mail</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></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>1</slash:comments>
		</item>
		<item>
		<title>jQuery: Selecting only the first level children</title>
		<link>http://ben.lobaugh.net/blog/573/jquery-selecting-only-the-first-level-children</link>
		<comments>http://ben.lobaugh.net/blog/573/jquery-selecting-only-the-first-level-children#comments</comments>
		<pubDate>Tue, 22 Jun 2010 18:50:02 +0000</pubDate>
		<dc:creator>blobaugh</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://ben.lobaugh.net/blog/?p=573</guid>
		<description><![CDATA[Using the .not() operator with jQuery it is possible to select only the first level of children of an element. This could come in handy on a menu for instance. Let's see what the menu code looks like. &#160; &#60;ul&#62; &#60;li&#62;Item &#60;ul&#62; &#60;li&#62;Sub&#60;/li&#62; &#60;li&#62;Sub2&#60;/li&#62; &#60;li&#62;Sub3&#60;/li&#62; &#60;/ul&#62; &#60;/li&#62; &#60;li&#62;Item2&#60;/li&#62; &#60;li&#62;Item3&#60;/li&#62; &#60;/ul&#62; &#160; We are trying to [...]]]></description>
			<content:encoded><![CDATA[<p>Using the .not() operator with jQuery it is possible to select only the first level of children of an element. This could come in handy on a menu for instance. Let's see what the menu code looks like.</p>
<pre>&nbsp;
&lt;ul&gt;
&lt;li&gt;Item
&lt;ul&gt;
&lt;li&gt;Sub&lt;/li&gt;
&lt;li&gt;Sub2&lt;/li&gt;
&lt;li&gt;Sub3&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Item2&lt;/li&gt;
&lt;li&gt;Item3&lt;/li&gt;
&lt;/ul&gt;
&nbsp;</pre>
<p>We are trying to get ul li, but not ul li ul li. jQuery has a brilliant method to select page elements like so:</p>
<pre class="javascript">&nbsp;
$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'ul li'</span><span style="color: #66cc66;">&#41;</span>
&nbsp;</pre>
<p>However this will get ALL of the li elements not matter the depth. We only want the first level of li. Luckily jQuery again has a method to accomplish this using .not()</p>
<pre class="javascript">&nbsp;
$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'ul li'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">not</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'ul li ul li'</span><span style="color: #66cc66;">&#41;</span>
&nbsp;</pre>
<p>Voila! We now have only the first level of li elements</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://ben.lobaugh.net/blog/573/jquery-selecting-only-the-first-level-children&amp;n=jQuery%3A+Selecting+only+the+first+level+children&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
		<li class="shr-buzzster">
			<a href="javascript:var%20s=document.createElement('script');s.src='http://www.buzzster.com/javascripts/bzz_adv.js';s.type='text/javascript';void(document.getElementsByTagName('head')[0].appendChild(s));" rel="nofollow" title="Share this via Buzzster!">Share this via Buzzster!</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://ben.lobaugh.net/blog/573/jquery-selecting-only-the-first-level-children/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://ben.lobaugh.net/blog/573/jquery-selecting-only-the-first-level-children&amp;title=jQuery%3A+Selecting+only+the+first+level+children" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://ben.lobaugh.net/blog/573/jquery-selecting-only-the-first-level-children&amp;title=jQuery%3A+Selecting+only+the+first+level+children" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://ben.lobaugh.net/blog/573/jquery-selecting-only-the-first-level-children&amp;t=jQuery%3A+Selecting+only+the+first+level+children" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-friendfeed">
			<a href="http://www.friendfeed.com/share?title=jQuery%3A+Selecting+only+the+first+level+children&amp;link=http://ben.lobaugh.net/blog/573/jquery-selecting-only-the-first-level-children" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="shr-gmail">
			<a href="https://mail.google.com/mail/?ui=2&amp;view=cm&amp;fs=1&amp;tf=1&amp;su=jQuery%3A+Selecting+only+the+first+level+children&amp;body=Link: http://ben.lobaugh.net/blog/573/jquery-selecting-only-the-first-level-children (sent via shareaholic)%0D%0A%0D%0A----%0D%0A Using%20the%20.not%28%29%20operator%20with%20jQuery%20it%20is%20possible%20to%20select%20only%20the%20first%20level%20of%20children%20of%20an%20element.%20This%20could%20come%20in%20handy%20on%20a%20menu%20for%20instance.%20Let%27s%20see%20what%20the%20menu%20code%20looks%20like.%0D%0A%0D%0A%0D%0A%09Item%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%0D%0A%09%20%20%20%20%20%20%20%20Sub%0D%0A%09%20%20%20%20%20%20%20%20Sub2%0D%0A%09%20%20%20%20%20%20%20%20Sub3%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%0D%0A%0D%0A%09Item2%0D%0A%09It" rel="nofollow" class="external" title="Email this via Gmail">Email this via Gmail</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://ben.lobaugh.net/blog/573/jquery-selecting-only-the-first-level-children&amp;title=jQuery%3A+Selecting+only+the+first+level+children" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://ben.lobaugh.net/blog/573/jquery-selecting-only-the-first-level-children&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://ben.lobaugh.net/blog/573/jquery-selecting-only-the-first-level-children&amp;title=jQuery%3A+Selecting+only+the+first+level+children&amp;summary=Using%20the%20.not%28%29%20operator%20with%20jQuery%20it%20is%20possible%20to%20select%20only%20the%20first%20level%20of%20children%20of%20an%20element.%20This%20could%20come%20in%20handy%20on%20a%20menu%20for%20instance.%20Let%27s%20see%20what%20the%20menu%20code%20looks%20like.%0D%0A%0D%0A%0D%0A%09Item%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%0D%0A%09%20%20%20%20%20%20%20%20Sub%0D%0A%09%20%20%20%20%20%20%20%20Sub2%0D%0A%09%20%20%20%20%20%20%20%20Sub3%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%0D%0A%0D%0A%09Item2%0D%0A%09It&amp;source=Ben Lobaugh Online" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://ben.lobaugh.net/blog/573/jquery-selecting-only-the-first-level-children&amp;title=jQuery%3A+Selecting+only+the+first+level+children" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://ben.lobaugh.net/blog/573/jquery-selecting-only-the-first-level-children&amp;title=jQuery%3A+Selecting+only+the+first+level+children" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fben.lobaugh.net%2Fblog%2F573%2Fjquery-selecting-only-the-first-level-children&amp;t=jQuery%3A+Selecting+only+the+first+level+children" rel="nofollow" class="external" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=jQuery%3A+Selecting+only+the+first+level+children+-+http://b2l.me/53h2v&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-wikio">
			<a href="http://www.wikio.com/sharethis?url=http://ben.lobaugh.net/blog/573/jquery-selecting-only-the-first-level-children&amp;title=jQuery%3A+Selecting+only+the+first+level+children" rel="nofollow" class="external" title="Share this on Wikio">Share this on Wikio</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://ben.lobaugh.net/blog/573/jquery-selecting-only-the-first-level-children&amp;submitHeadline=jQuery%3A+Selecting+only+the+first+level+children&amp;submitSummary=Using%20the%20.not%28%29%20operator%20with%20jQuery%20it%20is%20possible%20to%20select%20only%20the%20first%20level%20of%20children%20of%20an%20element.%20This%20could%20come%20in%20handy%20on%20a%20menu%20for%20instance.%20Let%27s%20see%20what%20the%20menu%20code%20looks%20like.%0D%0A%0D%0A%0D%0A%09Item%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%0D%0A%09%20%20%20%20%20%20%20%20Sub%0D%0A%09%20%20%20%20%20%20%20%20Sub2%0D%0A%09%20%20%20%20%20%20%20%20Sub3%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%0D%0A%0D%0A%09Item2%0D%0A%09It&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-yahoomail">
			<a href="http://compose.mail.yahoo.com/?Subject=jQuery%3A+Selecting+only+the+first+level+children&amp;body=Link: http://ben.lobaugh.net/blog/573/jquery-selecting-only-the-first-level-children (sent via shareaholic)%0D%0A%0D%0A----%0D%0A Using%20the%20.not%28%29%20operator%20with%20jQuery%20it%20is%20possible%20to%20select%20only%20the%20first%20level%20of%20children%20of%20an%20element.%20This%20could%20come%20in%20handy%20on%20a%20menu%20for%20instance.%20Let%27s%20see%20what%20the%20menu%20code%20looks%20like.%0D%0A%0D%0A%0D%0A%09Item%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%0D%0A%09%20%20%20%20%20%20%20%20Sub%0D%0A%09%20%20%20%20%20%20%20%20Sub2%0D%0A%09%20%20%20%20%20%20%20%20Sub3%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%0D%0A%0D%0A%09Item2%0D%0A%09It" rel="nofollow" class="external" title="Email this via Yahoo! Mail">Email this via Yahoo! Mail</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://ben.lobaugh.net/blog/573/jquery-selecting-only-the-first-level-children/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP: Recursively convert an object to an array</title>
		<link>http://ben.lobaugh.net/blog/567/php-recursively-convert-an-object-to-an-array</link>
		<comments>http://ben.lobaugh.net/blog/567/php-recursively-convert-an-object-to-an-array#comments</comments>
		<pubDate>Wed, 16 Jun 2010 21:00:11 +0000</pubDate>
		<dc:creator>blobaugh</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://ben.lobaugh.net/blog/?p=567</guid>
		<description><![CDATA[When pulling in array from outside data sources you often receive an array back. The problem is that sometimes even though you know you should have an array your application does not and therefore assigns it to the stdObject object, which of course is nothing. To make it usable you must convert it back into [...]]]></description>
			<content:encoded><![CDATA[<p>When pulling in array from outside data sources you often receive an array back. The problem is that sometimes even though you know you should have an array your application does not and therefore assigns it to the stdObject object, which of course is nothing. To make it usable you must convert it back into an array. With a simple object that may be as simple as a cast, but when you are working with large complex datasets that may be several layers deep you need to make sure you get at all of them. Enter beautiful recursion. After playing with PHPs array_walk_recursive() for a bit I hit on a custom recursive function that does exactly the job. Simply pass it your object and it will munch away at it trying to convert it into a PHP array. Take a gander at the code for this below.</p>
<pre class="php">&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> object_to_array<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$obj</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/is_object"><span style="color: #000066;">is_object</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$obj</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #0000ff;">$obj</span> = <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#41;</span> <span style="color: #0000ff;">$obj</span>;
    <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/is_array"><span style="color: #000066;">is_array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$obj</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #0000ff;">$new</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #b1b100;">foreach</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$obj</span> <span style="color: #b1b100;">as</span> <span style="color: #0000ff;">$key</span> =&gt; <span style="color: #0000ff;">$val</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            <span style="color: #0000ff;">$new</span><span style="color: #66cc66;">&#91;</span><span style="color: #0000ff;">$key</span><span style="color: #66cc66;">&#93;</span> = object_to_array<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$val</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span>
    <span style="color: #b1b100;">else</span> <span style="color: #0000ff;">$new</span> = <span style="color: #0000ff;">$obj</span>;
    <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">$new</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://ben.lobaugh.net/blog/567/php-recursively-convert-an-object-to-an-array&amp;n=PHP%3A+Recursively+convert+an+object+to+an+array&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
		<li class="shr-buzzster">
			<a href="javascript:var%20s=document.createElement('script');s.src='http://www.buzzster.com/javascripts/bzz_adv.js';s.type='text/javascript';void(document.getElementsByTagName('head')[0].appendChild(s));" rel="nofollow" title="Share this via Buzzster!">Share this via Buzzster!</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://ben.lobaugh.net/blog/567/php-recursively-convert-an-object-to-an-array/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://ben.lobaugh.net/blog/567/php-recursively-convert-an-object-to-an-array&amp;title=PHP%3A+Recursively+convert+an+object+to+an+array" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://ben.lobaugh.net/blog/567/php-recursively-convert-an-object-to-an-array&amp;title=PHP%3A+Recursively+convert+an+object+to+an+array" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://ben.lobaugh.net/blog/567/php-recursively-convert-an-object-to-an-array&amp;t=PHP%3A+Recursively+convert+an+object+to+an+array" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-friendfeed">
			<a href="http://www.friendfeed.com/share?title=PHP%3A+Recursively+convert+an+object+to+an+array&amp;link=http://ben.lobaugh.net/blog/567/php-recursively-convert-an-object-to-an-array" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="shr-gmail">
			<a href="https://mail.google.com/mail/?ui=2&amp;view=cm&amp;fs=1&amp;tf=1&amp;su=PHP%3A+Recursively+convert+an+object+to+an+array&amp;body=Link: http://ben.lobaugh.net/blog/567/php-recursively-convert-an-object-to-an-array (sent via shareaholic)%0D%0A%0D%0A----%0D%0A When%20pulling%20in%20array%20from%20outside%20data%20sources%20you%20often%20receive%20an%20array%20back.%20The%20problem%20is%20that%20sometimes%20even%20though%20you%20know%20you%20should%20have%20an%20array%20your%20application%20does%20not%20and%20therefore%20assigns%20it%20to%20the%20stdObject%20object%2C%20which%20of%20course%20is%20nothing.%20To%20make%20it%20usable%20you%20must%20convert%20it%20b" rel="nofollow" class="external" title="Email this via Gmail">Email this via Gmail</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://ben.lobaugh.net/blog/567/php-recursively-convert-an-object-to-an-array&amp;title=PHP%3A+Recursively+convert+an+object+to+an+array" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://ben.lobaugh.net/blog/567/php-recursively-convert-an-object-to-an-array&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://ben.lobaugh.net/blog/567/php-recursively-convert-an-object-to-an-array&amp;title=PHP%3A+Recursively+convert+an+object+to+an+array&amp;summary=When%20pulling%20in%20array%20from%20outside%20data%20sources%20you%20often%20receive%20an%20array%20back.%20The%20problem%20is%20that%20sometimes%20even%20though%20you%20know%20you%20should%20have%20an%20array%20your%20application%20does%20not%20and%20therefore%20assigns%20it%20to%20the%20stdObject%20object%2C%20which%20of%20course%20is%20nothing.%20To%20make%20it%20usable%20you%20must%20convert%20it%20b&amp;source=Ben Lobaugh Online" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://ben.lobaugh.net/blog/567/php-recursively-convert-an-object-to-an-array&amp;title=PHP%3A+Recursively+convert+an+object+to+an+array" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://ben.lobaugh.net/blog/567/php-recursively-convert-an-object-to-an-array&amp;title=PHP%3A+Recursively+convert+an+object+to+an+array" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fben.lobaugh.net%2Fblog%2F567%2Fphp-recursively-convert-an-object-to-an-array&amp;t=PHP%3A+Recursively+convert+an+object+to+an+array" rel="nofollow" class="external" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=PHP%3A+Recursively+convert+an+object+to+an+array+-+http://b2l.me/53xgz&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-wikio">
			<a href="http://www.wikio.com/sharethis?url=http://ben.lobaugh.net/blog/567/php-recursively-convert-an-object-to-an-array&amp;title=PHP%3A+Recursively+convert+an+object+to+an+array" rel="nofollow" class="external" title="Share this on Wikio">Share this on Wikio</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://ben.lobaugh.net/blog/567/php-recursively-convert-an-object-to-an-array&amp;submitHeadline=PHP%3A+Recursively+convert+an+object+to+an+array&amp;submitSummary=When%20pulling%20in%20array%20from%20outside%20data%20sources%20you%20often%20receive%20an%20array%20back.%20The%20problem%20is%20that%20sometimes%20even%20though%20you%20know%20you%20should%20have%20an%20array%20your%20application%20does%20not%20and%20therefore%20assigns%20it%20to%20the%20stdObject%20object%2C%20which%20of%20course%20is%20nothing.%20To%20make%20it%20usable%20you%20must%20convert%20it%20b&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-yahoomail">
			<a href="http://compose.mail.yahoo.com/?Subject=PHP%3A+Recursively+convert+an+object+to+an+array&amp;body=Link: http://ben.lobaugh.net/blog/567/php-recursively-convert-an-object-to-an-array (sent via shareaholic)%0D%0A%0D%0A----%0D%0A When%20pulling%20in%20array%20from%20outside%20data%20sources%20you%20often%20receive%20an%20array%20back.%20The%20problem%20is%20that%20sometimes%20even%20though%20you%20know%20you%20should%20have%20an%20array%20your%20application%20does%20not%20and%20therefore%20assigns%20it%20to%20the%20stdObject%20object%2C%20which%20of%20course%20is%20nothing.%20To%20make%20it%20usable%20you%20must%20convert%20it%20b" rel="nofollow" class="external" title="Email this via Yahoo! Mail">Email this via Yahoo! Mail</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://ben.lobaugh.net/blog/567/php-recursively-convert-an-object-to-an-array/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP: Show error on screen when disabled by php.ini</title>
		<link>http://ben.lobaugh.net/blog/565/php-show-error-on-screen-when-disabled-by-php-ini</link>
		<comments>http://ben.lobaugh.net/blog/565/php-show-error-on-screen-when-disabled-by-php-ini#comments</comments>
		<pubDate>Wed, 16 Jun 2010 17:36:51 +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=565</guid>
		<description><![CDATA[It is quite common to run into situations where PHP errors are suppressed or written to a log file somewhere on a live, non-development server. If you are troubleshooting and need to see the error that can be a pain. Luckily PHP and Apache have provided us with two great workarounds. The first happens through [...]]]></description>
			<content:encoded><![CDATA[<p>It is quite common to run into situations where PHP errors are suppressed or written to a log file somewhere on a live, non-development server. If you are troubleshooting and need to see the error that can be a pain. Luckily PHP and Apache have provided us with two great workarounds. The first happens through a PHP function call in a script, the second is a .htaccess directive which does require special configuration of Apache, but the majority of servers I have worked with allow this functionality.</p>
<p>Place this code near the top of a PHP file</p>
<pre class="php">&nbsp;
<a href="http://www.php.net/ini_set"><span style="color: #000066;">ini_set</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;display_errors&quot;</span>,<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.php.net/error_reporting"><span style="color: #000066;">error_reporting</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">E_ALL</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<p>This code goes into the .htaccess file. Just be sure your .htaccess file is in the proper directory relative to the code you are trying to debug</p>
<pre class="php">&nbsp;
php_value display_errors on
&nbsp;</pre>
<p>Just be sure you turn error printing back off when you are done.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://ben.lobaugh.net/blog/565/php-show-error-on-screen-when-disabled-by-php-ini&amp;n=PHP%3A+Show+error+on+screen+when+disabled+by+php.ini&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
		<li class="shr-buzzster">
			<a href="javascript:var%20s=document.createElement('script');s.src='http://www.buzzster.com/javascripts/bzz_adv.js';s.type='text/javascript';void(document.getElementsByTagName('head')[0].appendChild(s));" rel="nofollow" title="Share this via Buzzster!">Share this via Buzzster!</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://ben.lobaugh.net/blog/565/php-show-error-on-screen-when-disabled-by-php-ini/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://ben.lobaugh.net/blog/565/php-show-error-on-screen-when-disabled-by-php-ini&amp;title=PHP%3A+Show+error+on+screen+when+disabled+by+php.ini" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://ben.lobaugh.net/blog/565/php-show-error-on-screen-when-disabled-by-php-ini&amp;title=PHP%3A+Show+error+on+screen+when+disabled+by+php.ini" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://ben.lobaugh.net/blog/565/php-show-error-on-screen-when-disabled-by-php-ini&amp;t=PHP%3A+Show+error+on+screen+when+disabled+by+php.ini" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-friendfeed">
			<a href="http://www.friendfeed.com/share?title=PHP%3A+Show+error+on+screen+when+disabled+by+php.ini&amp;link=http://ben.lobaugh.net/blog/565/php-show-error-on-screen-when-disabled-by-php-ini" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="shr-gmail">
			<a href="https://mail.google.com/mail/?ui=2&amp;view=cm&amp;fs=1&amp;tf=1&amp;su=PHP%3A+Show+error+on+screen+when+disabled+by+php.ini&amp;body=Link: http://ben.lobaugh.net/blog/565/php-show-error-on-screen-when-disabled-by-php-ini (sent via shareaholic)%0D%0A%0D%0A----%0D%0A It%20is%20quite%20common%20to%20run%20into%20situations%20where%20PHP%20errors%20are%20suppressed%20or%20written%20to%20a%20log%20file%20somewhere%20on%20a%20live%2C%20non-development%20server.%20If%20you%20are%20troubleshooting%20and%20need%20to%20see%20the%20error%20that%20can%20be%20a%20pain.%20Luckily%20PHP%20and%20Apache%20have%20provided%20us%20with%20two%20great%20workarounds.%20The%20first%20happe" rel="nofollow" class="external" title="Email this via Gmail">Email this via Gmail</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://ben.lobaugh.net/blog/565/php-show-error-on-screen-when-disabled-by-php-ini&amp;title=PHP%3A+Show+error+on+screen+when+disabled+by+php.ini" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://ben.lobaugh.net/blog/565/php-show-error-on-screen-when-disabled-by-php-ini&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://ben.lobaugh.net/blog/565/php-show-error-on-screen-when-disabled-by-php-ini&amp;title=PHP%3A+Show+error+on+screen+when+disabled+by+php.ini&amp;summary=It%20is%20quite%20common%20to%20run%20into%20situations%20where%20PHP%20errors%20are%20suppressed%20or%20written%20to%20a%20log%20file%20somewhere%20on%20a%20live%2C%20non-development%20server.%20If%20you%20are%20troubleshooting%20and%20need%20to%20see%20the%20error%20that%20can%20be%20a%20pain.%20Luckily%20PHP%20and%20Apache%20have%20provided%20us%20with%20two%20great%20workarounds.%20The%20first%20happe&amp;source=Ben Lobaugh Online" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://ben.lobaugh.net/blog/565/php-show-error-on-screen-when-disabled-by-php-ini&amp;title=PHP%3A+Show+error+on+screen+when+disabled+by+php.ini" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://ben.lobaugh.net/blog/565/php-show-error-on-screen-when-disabled-by-php-ini&amp;title=PHP%3A+Show+error+on+screen+when+disabled+by+php.ini" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fben.lobaugh.net%2Fblog%2F565%2Fphp-show-error-on-screen-when-disabled-by-php-ini&amp;t=PHP%3A+Show+error+on+screen+when+disabled+by+php.ini" rel="nofollow" class="external" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=PHP%3A+Show+error+on+screen+when+disabled+by+php.ini+-+http://b2l.me/53xg2&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-wikio">
			<a href="http://www.wikio.com/sharethis?url=http://ben.lobaugh.net/blog/565/php-show-error-on-screen-when-disabled-by-php-ini&amp;title=PHP%3A+Show+error+on+screen+when+disabled+by+php.ini" rel="nofollow" class="external" title="Share this on Wikio">Share this on Wikio</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://ben.lobaugh.net/blog/565/php-show-error-on-screen-when-disabled-by-php-ini&amp;submitHeadline=PHP%3A+Show+error+on+screen+when+disabled+by+php.ini&amp;submitSummary=It%20is%20quite%20common%20to%20run%20into%20situations%20where%20PHP%20errors%20are%20suppressed%20or%20written%20to%20a%20log%20file%20somewhere%20on%20a%20live%2C%20non-development%20server.%20If%20you%20are%20troubleshooting%20and%20need%20to%20see%20the%20error%20that%20can%20be%20a%20pain.%20Luckily%20PHP%20and%20Apache%20have%20provided%20us%20with%20two%20great%20workarounds.%20The%20first%20happe&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-yahoomail">
			<a href="http://compose.mail.yahoo.com/?Subject=PHP%3A+Show+error+on+screen+when+disabled+by+php.ini&amp;body=Link: http://ben.lobaugh.net/blog/565/php-show-error-on-screen-when-disabled-by-php-ini (sent via shareaholic)%0D%0A%0D%0A----%0D%0A It%20is%20quite%20common%20to%20run%20into%20situations%20where%20PHP%20errors%20are%20suppressed%20or%20written%20to%20a%20log%20file%20somewhere%20on%20a%20live%2C%20non-development%20server.%20If%20you%20are%20troubleshooting%20and%20need%20to%20see%20the%20error%20that%20can%20be%20a%20pain.%20Luckily%20PHP%20and%20Apache%20have%20provided%20us%20with%20two%20great%20workarounds.%20The%20first%20happe" rel="nofollow" class="external" title="Email this via Yahoo! Mail">Email this via Yahoo! Mail</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://ben.lobaugh.net/blog/565/php-show-error-on-screen-when-disabled-by-php-ini/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP: Add Google Analytics to an entire static HTML website with PHP</title>
		<link>http://ben.lobaugh.net/blog/561/php-add-google-analytics-to-an-entire-static-html-website-with-php</link>
		<comments>http://ben.lobaugh.net/blog/561/php-add-google-analytics-to-an-entire-static-html-website-with-php#comments</comments>
		<pubDate>Mon, 14 Jun 2010 21:38:41 +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=561</guid>
		<description><![CDATA[I am in a situation where I need analytics data and none is provided. The entire 35k+ file website is all static HTML running on a Windows IIS server. I am not familiar enough with Windows Server to know what sort of scripting capabilities there are, but I do have PHP available. I wrote a [...]]]></description>
			<content:encoded><![CDATA[<p>I am in a situation where I need analytics data and none is provided. The entire 35k+ file website is all static HTML running on a Windows IIS server. I am not familiar enough with Windows Server to know what sort of scripting capabilities there are, but I do have PHP available. I wrote a simple script that uses the PHP 5 RecursiveDirectorIterator to look through the entire site and append the Google Analytics code to the closing body tag. It then rewrites the file it is looking at.</p>
<p>If you are stuck in a similar situation where you do not have scripting abilities you may want to consider giving this script a go, or altering it to fit whatever language you are using. Works like a charm.</p>
<pre class="php">&nbsp;
<span style="color: #0000ff;">$directory</span> = <span style="color: #ff0000;">'where your files are'</span>;
&nbsp;
<span style="color: #0000ff;">$it</span> = <span style="color: #000000; font-weight: bold;">new</span> RecursiveIteratorIterator<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> RecursiveDirectoryIterator<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$directory</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$it</span>-&gt;<span style="color: #006600;">valid</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>!<span style="color: #0000ff;">$it</span>-&gt;<span style="color: #006600;">isDot</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #0000ff;">$c</span> = <a href="http://www.php.net/file_get_contents"><span style="color: #000066;">file_get_contents</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$it</span>-&gt;<span style="color: #006600;">key</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #0000ff;">$c</span> = <a href="http://www.php.net/str_replace"><span style="color: #000066;">str_replace</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'&lt;/body&gt;'</span>, YOUR ANALYTICS CODE HERE . <span style="color: #ff0000;">'&lt;/body&gt;'</span>, <span style="color: #0000ff;">$c</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #0000ff;">$fh</span> = <a href="http://www.php.net/fopen"><span style="color: #000066;">fopen</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$it</span>-&gt;<span style="color: #006600;">key</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #ff0000;">'w'</span><span style="color: #66cc66;">&#41;</span>;
        <a href="http://www.php.net/fwrite"><span style="color: #000066;">fwrite</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$fh</span>, <span style="color: #0000ff;">$c</span><span style="color: #66cc66;">&#41;</span>;
        <a href="http://www.php.net/fclose"><span style="color: #000066;">fclose</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$fh</span><span style="color: #66cc66;">&#41;</span>;
        <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">&quot;Replaced body in: &quot;</span> . <span style="color: #0000ff;">$it</span>-&gt;<span style="color: #006600;">key</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #0000ff;">$it</span>-&gt;<span style="color: #006600;">next</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p>Might be worth it to ensure you are looking only at .html and .htm files if you have a complex set. Additionally, if you have a very large set of files you may need to look at timeout issues.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://ben.lobaugh.net/blog/561/php-add-google-analytics-to-an-entire-static-html-website-with-php&amp;n=PHP%3A+Add+Google+Analytics+to+an+entire+static+HTML+website+with+PHP&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
		<li class="shr-buzzster">
			<a href="javascript:var%20s=document.createElement('script');s.src='http://www.buzzster.com/javascripts/bzz_adv.js';s.type='text/javascript';void(document.getElementsByTagName('head')[0].appendChild(s));" rel="nofollow" title="Share this via Buzzster!">Share this via Buzzster!</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://ben.lobaugh.net/blog/561/php-add-google-analytics-to-an-entire-static-html-website-with-php/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://ben.lobaugh.net/blog/561/php-add-google-analytics-to-an-entire-static-html-website-with-php&amp;title=PHP%3A+Add+Google+Analytics+to+an+entire+static+HTML+website+with+PHP" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://ben.lobaugh.net/blog/561/php-add-google-analytics-to-an-entire-static-html-website-with-php&amp;title=PHP%3A+Add+Google+Analytics+to+an+entire+static+HTML+website+with+PHP" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://ben.lobaugh.net/blog/561/php-add-google-analytics-to-an-entire-static-html-website-with-php&amp;t=PHP%3A+Add+Google+Analytics+to+an+entire+static+HTML+website+with+PHP" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-friendfeed">
			<a href="http://www.friendfeed.com/share?title=PHP%3A+Add+Google+Analytics+to+an+entire+static+HTML+website+with+PHP&amp;link=http://ben.lobaugh.net/blog/561/php-add-google-analytics-to-an-entire-static-html-website-with-php" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="shr-gmail">
			<a href="https://mail.google.com/mail/?ui=2&amp;view=cm&amp;fs=1&amp;tf=1&amp;su=PHP%3A+Add+Google+Analytics+to+an+entire+static+HTML+website+with+PHP&amp;body=Link: http://ben.lobaugh.net/blog/561/php-add-google-analytics-to-an-entire-static-html-website-with-php (sent via shareaholic)%0D%0A%0D%0A----%0D%0A I%20am%20in%20a%20situation%20where%20I%20need%20analytics%20data%20and%20none%20is%20provided.%20The%20entire%2035k%2B%20file%20website%20is%20all%20static%20HTML%20running%20on%20a%20Windows%20IIS%20server.%20I%20am%20not%20familiar%20enough%20with%20Windows%20Server%20to%20know%20what%20sort%20of%20scripting%20capabilities%20there%20are%2C%20but%20I%20do%20have%20PHP%20available.%20I%20wrote%20a%20simple%20scr" rel="nofollow" class="external" title="Email this via Gmail">Email this via Gmail</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://ben.lobaugh.net/blog/561/php-add-google-analytics-to-an-entire-static-html-website-with-php&amp;title=PHP%3A+Add+Google+Analytics+to+an+entire+static+HTML+website+with+PHP" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://ben.lobaugh.net/blog/561/php-add-google-analytics-to-an-entire-static-html-website-with-php&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://ben.lobaugh.net/blog/561/php-add-google-analytics-to-an-entire-static-html-website-with-php&amp;title=PHP%3A+Add+Google+Analytics+to+an+entire+static+HTML+website+with+PHP&amp;summary=I%20am%20in%20a%20situation%20where%20I%20need%20analytics%20data%20and%20none%20is%20provided.%20The%20entire%2035k%2B%20file%20website%20is%20all%20static%20HTML%20running%20on%20a%20Windows%20IIS%20server.%20I%20am%20not%20familiar%20enough%20with%20Windows%20Server%20to%20know%20what%20sort%20of%20scripting%20capabilities%20there%20are%2C%20but%20I%20do%20have%20PHP%20available.%20I%20wrote%20a%20simple%20scr&amp;source=Ben Lobaugh Online" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://ben.lobaugh.net/blog/561/php-add-google-analytics-to-an-entire-static-html-website-with-php&amp;title=PHP%3A+Add+Google+Analytics+to+an+entire+static+HTML+website+with+PHP" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://ben.lobaugh.net/blog/561/php-add-google-analytics-to-an-entire-static-html-website-with-php&amp;title=PHP%3A+Add+Google+Analytics+to+an+entire+static+HTML+website+with+PHP" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fben.lobaugh.net%2Fblog%2F561%2Fphp-add-google-analytics-to-an-entire-static-html-website-with-php&amp;t=PHP%3A+Add+Google+Analytics+to+an+entire+static+HTML+website+with+PHP" rel="nofollow" class="external" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=PHP%3A+Add+Google+Analytics+to+an+entire+static+HTML+website+with+PHP+-+http://b2l.me/53xg4&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-wikio">
			<a href="http://www.wikio.com/sharethis?url=http://ben.lobaugh.net/blog/561/php-add-google-analytics-to-an-entire-static-html-website-with-php&amp;title=PHP%3A+Add+Google+Analytics+to+an+entire+static+HTML+website+with+PHP" rel="nofollow" class="external" title="Share this on Wikio">Share this on Wikio</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://ben.lobaugh.net/blog/561/php-add-google-analytics-to-an-entire-static-html-website-with-php&amp;submitHeadline=PHP%3A+Add+Google+Analytics+to+an+entire+static+HTML+website+with+PHP&amp;submitSummary=I%20am%20in%20a%20situation%20where%20I%20need%20analytics%20data%20and%20none%20is%20provided.%20The%20entire%2035k%2B%20file%20website%20is%20all%20static%20HTML%20running%20on%20a%20Windows%20IIS%20server.%20I%20am%20not%20familiar%20enough%20with%20Windows%20Server%20to%20know%20what%20sort%20of%20scripting%20capabilities%20there%20are%2C%20but%20I%20do%20have%20PHP%20available.%20I%20wrote%20a%20simple%20scr&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-yahoomail">
			<a href="http://compose.mail.yahoo.com/?Subject=PHP%3A+Add+Google+Analytics+to+an+entire+static+HTML+website+with+PHP&amp;body=Link: http://ben.lobaugh.net/blog/561/php-add-google-analytics-to-an-entire-static-html-website-with-php (sent via shareaholic)%0D%0A%0D%0A----%0D%0A I%20am%20in%20a%20situation%20where%20I%20need%20analytics%20data%20and%20none%20is%20provided.%20The%20entire%2035k%2B%20file%20website%20is%20all%20static%20HTML%20running%20on%20a%20Windows%20IIS%20server.%20I%20am%20not%20familiar%20enough%20with%20Windows%20Server%20to%20know%20what%20sort%20of%20scripting%20capabilities%20there%20are%2C%20but%20I%20do%20have%20PHP%20available.%20I%20wrote%20a%20simple%20scr" rel="nofollow" class="external" title="Email this via Yahoo! Mail">Email this via Yahoo! Mail</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://ben.lobaugh.net/blog/561/php-add-google-analytics-to-an-entire-static-html-website-with-php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript: Forward user to new page</title>
		<link>http://ben.lobaugh.net/blog/559/javascript-forward-user-to-new-page</link>
		<comments>http://ben.lobaugh.net/blog/559/javascript-forward-user-to-new-page#comments</comments>
		<pubDate>Mon, 07 Jun 2010 04:00:45 +0000</pubDate>
		<dc:creator>blobaugh</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://ben.lobaugh.net/blog/?p=559</guid>
		<description><![CDATA[I often find myself needing to forward a user through Javascript for various reasons. Here are a couple quick snippets of Javascript to accomplish that task. This one is supposed to block the Back button from tracking the change &#160; window.location.replace&#40;&#34;http://example.com&#34;&#41;; &#160; &#160; window.location = &#34;http://www.example.com&#34;; &#160; Blog this on Blogger Share this via Buzzster! [...]]]></description>
			<content:encoded><![CDATA[<p>I often find myself needing to forward a user through Javascript for various reasons. Here are a couple quick snippets of Javascript to accomplish that task.</p>
<p>This one is supposed to block the Back button from tracking the change</p>
<pre class="javascript">&nbsp;
window.<span style="color: #006600;">location</span>.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;http://example.com&quot;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<pre class="javascript">&nbsp;
window.<span style="color: #006600;">location</span> = <span style="color: #3366CC;">&quot;http://www.example.com&quot;</span>;
&nbsp;</pre>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://ben.lobaugh.net/blog/559/javascript-forward-user-to-new-page&amp;n=Javascript%3A+Forward+user+to+new+page&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
		<li class="shr-buzzster">
			<a href="javascript:var%20s=document.createElement('script');s.src='http://www.buzzster.com/javascripts/bzz_adv.js';s.type='text/javascript';void(document.getElementsByTagName('head')[0].appendChild(s));" rel="nofollow" title="Share this via Buzzster!">Share this via Buzzster!</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://ben.lobaugh.net/blog/559/javascript-forward-user-to-new-page/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://ben.lobaugh.net/blog/559/javascript-forward-user-to-new-page&amp;title=Javascript%3A+Forward+user+to+new+page" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://ben.lobaugh.net/blog/559/javascript-forward-user-to-new-page&amp;title=Javascript%3A+Forward+user+to+new+page" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://ben.lobaugh.net/blog/559/javascript-forward-user-to-new-page&amp;t=Javascript%3A+Forward+user+to+new+page" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-friendfeed">
			<a href="http://www.friendfeed.com/share?title=Javascript%3A+Forward+user+to+new+page&amp;link=http://ben.lobaugh.net/blog/559/javascript-forward-user-to-new-page" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="shr-gmail">
			<a href="https://mail.google.com/mail/?ui=2&amp;view=cm&amp;fs=1&amp;tf=1&amp;su=Javascript%3A+Forward+user+to+new+page&amp;body=Link: http://ben.lobaugh.net/blog/559/javascript-forward-user-to-new-page (sent via shareaholic)%0D%0A%0D%0A----%0D%0A I%20often%20find%20myself%20needing%20to%20forward%20a%20user%20through%20Javascript%20for%20various%20reasons.%20Here%20are%20a%20couple%20quick%20snippets%20of%20Javascript%20to%20accomplish%20that%20task.%0D%0A%0D%0AThis%20one%20is%20supposed%20to%20block%20the%20Back%20button%20from%20tracking%20the%20change%0D%0A%0D%0Awindow.location.replace%28%22http%3A%2F%2Fexample.com%22%29%3B%0D%0A%0D%0A%0D%0A%0D%0Awindow.loca" rel="nofollow" class="external" title="Email this via Gmail">Email this via Gmail</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://ben.lobaugh.net/blog/559/javascript-forward-user-to-new-page&amp;title=Javascript%3A+Forward+user+to+new+page" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://ben.lobaugh.net/blog/559/javascript-forward-user-to-new-page&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://ben.lobaugh.net/blog/559/javascript-forward-user-to-new-page&amp;title=Javascript%3A+Forward+user+to+new+page&amp;summary=I%20often%20find%20myself%20needing%20to%20forward%20a%20user%20through%20Javascript%20for%20various%20reasons.%20Here%20are%20a%20couple%20quick%20snippets%20of%20Javascript%20to%20accomplish%20that%20task.%0D%0A%0D%0AThis%20one%20is%20supposed%20to%20block%20the%20Back%20button%20from%20tracking%20the%20change%0D%0A%0D%0Awindow.location.replace%28%22http%3A%2F%2Fexample.com%22%29%3B%0D%0A%0D%0A%0D%0A%0D%0Awindow.loca&amp;source=Ben Lobaugh Online" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://ben.lobaugh.net/blog/559/javascript-forward-user-to-new-page&amp;title=Javascript%3A+Forward+user+to+new+page" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://ben.lobaugh.net/blog/559/javascript-forward-user-to-new-page&amp;title=Javascript%3A+Forward+user+to+new+page" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fben.lobaugh.net%2Fblog%2F559%2Fjavascript-forward-user-to-new-page&amp;t=Javascript%3A+Forward+user+to+new+page" rel="nofollow" class="external" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Javascript%3A+Forward+user+to+new+page+-+http://b2l.me/53xg7&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-wikio">
			<a href="http://www.wikio.com/sharethis?url=http://ben.lobaugh.net/blog/559/javascript-forward-user-to-new-page&amp;title=Javascript%3A+Forward+user+to+new+page" rel="nofollow" class="external" title="Share this on Wikio">Share this on Wikio</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://ben.lobaugh.net/blog/559/javascript-forward-user-to-new-page&amp;submitHeadline=Javascript%3A+Forward+user+to+new+page&amp;submitSummary=I%20often%20find%20myself%20needing%20to%20forward%20a%20user%20through%20Javascript%20for%20various%20reasons.%20Here%20are%20a%20couple%20quick%20snippets%20of%20Javascript%20to%20accomplish%20that%20task.%0D%0A%0D%0AThis%20one%20is%20supposed%20to%20block%20the%20Back%20button%20from%20tracking%20the%20change%0D%0A%0D%0Awindow.location.replace%28%22http%3A%2F%2Fexample.com%22%29%3B%0D%0A%0D%0A%0D%0A%0D%0Awindow.loca&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-yahoomail">
			<a href="http://compose.mail.yahoo.com/?Subject=Javascript%3A+Forward+user+to+new+page&amp;body=Link: http://ben.lobaugh.net/blog/559/javascript-forward-user-to-new-page (sent via shareaholic)%0D%0A%0D%0A----%0D%0A I%20often%20find%20myself%20needing%20to%20forward%20a%20user%20through%20Javascript%20for%20various%20reasons.%20Here%20are%20a%20couple%20quick%20snippets%20of%20Javascript%20to%20accomplish%20that%20task.%0D%0A%0D%0AThis%20one%20is%20supposed%20to%20block%20the%20Back%20button%20from%20tracking%20the%20change%0D%0A%0D%0Awindow.location.replace%28%22http%3A%2F%2Fexample.com%22%29%3B%0D%0A%0D%0A%0D%0A%0D%0Awindow.loca" rel="nofollow" class="external" title="Email this via Yahoo! Mail">Email this via Yahoo! Mail</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://ben.lobaugh.net/blog/559/javascript-forward-user-to-new-page/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
