<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Made of Everything You're Not</title>
	
	<link>http://blog.ericlamb.net</link>
	<description>Thoughts on programming, people and life</description>
	<lastBuildDate>Thu, 11 Mar 2010 20:59:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/MadeOfEverythingYoureNot" /><feedburner:info uri="madeofeverythingyourenot" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Remove Boonex Footer From Dolphin CMS</title>
		<link>http://feedproxy.google.com/~r/MadeOfEverythingYoureNot/~3/5gbdBkJI58o/</link>
		<comments>http://blog.ericlamb.net/2010/03/remove-boonex-footer-from-dolphin-cms/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 08:00:56 +0000</pubDate>
		<dc:creator>Eric Lamb</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[boonex]]></category>
		<category><![CDATA[dolphin cms]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.ericlamb.net/?p=2962</guid>
		<description><![CDATA[After the server lockout and subsequent move last week I had to setup all my old sites on the new server. Aside from the loss of a few posts my blog (which I could restore from Google cache) and a few comments (which I couldn&#8217;t restore unfortunately) everything was pretty smooth. That was until I [...]]]></description>
			<content:encoded><![CDATA[<p>After the <a href="http://blog.ericlamb.net/2010/03/a-new-kind-of-failure-point/" onclick="return TrackClick('http%3A%2F%2Fblog.ericlamb.net%2F2010%2F03%2Fa-new-kind-of-failure-point%2F','A+New+Kind+of+Failure+Point')" title="A New Kind of Failure Point">server lockout</a> and subsequent move last week I had to setup all my old sites on the new server. Aside from the loss of a few posts my blog (which I could restore from Google cache) and a few comments (which I couldn&#8217;t restore unfortunately) everything was pretty smooth. That was until I had to move over one of my clients sites that was using <a title="Code Like It’s 1999 With Dolphin CMS" href="http://blog.ericlamb.net/2009/12/code-like-its-1999-with-dolphin-cms/" onclick="return TrackClick('http%3A%2F%2Fblog.ericlamb.net%2F2009%2F12%2Fcode-like-its-1999-with-dolphin-cms%2F','Code+Like+It%E2%80%99s+1999+With+Dolphin+CMS')">Dolphin CMS</a>.</p>
<div id="attachment_2966" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.ericlamb.net/wp-content/uploads/2010/03/closed-lock.jpg" onclick="return TrackClick('http%3A%2F%2Fblog.ericlamb.net%2Fwp-content%2Fuploads%2F2010%2F03%2Fclosed-lock.jpg','Remove+Boonex+Footer+From+Dolphin+CMS')"><img class="size-medium wp-image-2966" title="Remove Boonex Footer From Dolphin CMS" src="http://blog.ericlamb.net/wp-content/uploads/2010/03/closed-lock-300x219.jpg" alt="Remove Boonex Footer From Dolphin CMS" width="300" height="219" /></a><p class="wp-caption-text">Remove Boonex Footer From Dolphin CMS</p></div>
<p>The issue was that the client&#8217;s site was now being tagged with a Powered By Boonex footer; not cool because the client had purchased a license and shouldn&#8217;t have the callout to Boonex. It looked like the site couldn&#8217;t reach the licensing server so it was acting like the site wasn&#8217;t a valid and licensed version.</p>
<p>I had set up the new server in a pretty locked down way, using a pretty paranoid strategy with firewalls and port changes and all that fun stuff. Unfortunately for my client, this included mod_security which Dolphin requires <a title="Dolphin Technical Requirements" href="http://www.boonex.com/trac/dolphin/wiki/DolTech" onclick="return TrackClick('http%3A%2F%2Fwww.boonex.com%2Ftrac%2Fdolphin%2Fwiki%2FDolTech','Dolphin+Technical+Requirements')" target="_blank">special configuration for</a>:</p>
<blockquote><p>If some security module is installed on the server (such as mod_security  for Apache), it should be able to be disabled or set up for specific folders.</p></blockquote>
<p>Not wanting to allow such a blatant security hole into my server following the above just wasn&#8217;t acceptable. Instead I decided to just remove the call to the licensing server in the code; it&#8217;s just php so I didn&#8217;t think it would be too difficult. It wasn&#8217;t but it was a little confusing though so here&#8217;s the code and process in case anyone else has the need.</p>
<p>BECAUSE I DON&#8217;T WANT TO GET SUED: only use this if you&#8217;ve already purchased a license. Blah, blah, blah. Oh, and this has only been tested in Dolphin 6.1.</p>
<ol>
<li>First, open up &#8220;/inc/design.inc.php&#8221;</li>
<li>look for a HUGE base64 encoded line (one really long and one underneath is short). You&#8217;re going to need to remove both lines.<br />
It should be around line 500 and indented a few pages in. If you can&#8217;t find it search for &#8220;base64_decode&#8221; and it&#8217;ll come up.</li>
<li>Replace the both lines with the below:</li>
</ol>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$s813518</span><span style="color: #339933;">=</span><span style="color: #0000ff;">'Y3JlYXRlX2Z1bmN0aW9u'</span><span style="color: #339933;">;</span><span style="color: #000088;">$s534634</span><span style="color: #339933;">=</span><span style="color: #0000ff;">'base64_decode'</span><span style="color: #339933;">;</span><span style="color: #000088;">$s434741</span><span style="color: #339933;">=</span><span style="color: #0000ff;">'YmFzZTY0X2RlY29kZQ=='</span><span style="color: #339933;">;</span><span style="color: #000088;">$s865127</span><span style="color: #339933;">=</span><span style="color: #0000ff;">'ZWNobw=='</span><span style="color: #339933;">;</span><span style="color: #000088;">$s734874</span><span style="color: #339933;">=</span><span style="color: #0000ff;">'Z2xvYmFsICRfcGFnZTsNCg0KJHM0MzUyMzYgPSBiYXNlNjRfZGVjb2RlKCAnWW1GelpUWTBYMlJsWTI5a1pRPT0nICk7DQokczU4OTM1NSA9ICdYMTlpYjI5dVpYaGZabTl2ZEdWeWMxOWYnOw0KJHM3NDM3NjUgPSAnWjJ4dlltRnNJQ1J6YVhSbE93MEtaMnh2WW1Gc0lDUjBiWEJzT3cwS0RRb2tjMFp2YjNSbGNuTWdQU0FuSnpzTkNtbG1JQ2huWlhSUVlYSmhiU2duWlc1aFlteGxYMlJ2YkhCb2FXNWZabTl2ZEdWeUp5a3BJSHNOQ2lBZ0lDQU5DaUFnSUNBa2MwRm1aa2xFSUQwZ2RISnBiU2huWlhSUVlYSmhiU2duWW05dmJtVjRRV1ptU1VRbktTazdEUW9nSUNBZ2FXWW9JSE4wY214bGJpZ2dKSE5CWm1aSlJDQXBJQ2tnSkhOQlptWkpSQ0F1UFNBbkxtaDBiV3duT3cwS0RRb2dJQ0FnYjJKZmMzUmhjblFvS1RzTkNnMEtJQ0FnSUNSelJtOXZkR1Z5Y3lBOUlDY25PdzBLZlEwS0RRcHlaWFIxY200Z0pITkdiMjkwWlhKek93PT0nOw0KJHM1ODYyODQgPSAnVkcxd2JFdGxlWE5TWlhCc1lXTmwnOw0KJHM5ODU0OTUgPSAnTDE5ZktGdGhMWHBCTFZvd0xUbGZMVjByS1Y5Zkx3PT0nOw0KJHM3ODI0ODYgPSAnYzNSeWNHOXonOw0KJHM5NTAzMDQgPSAnYzNSeVgzSmxjR3hoWTJVPSc7DQokczk0Mzk4NSA9ICdjSEpsWjE5eVpYQnNZV05sWDJOaGJHeGlZV05yJzsNCiRzNjc3NDM0ID0gJ1dXOTFJR2hoZG1VZ2JXRnVkV0ZzYkhrZ2NtVnRiM1psWkNBOFlTQm9jbVZtUFNKb2RIUndPaTh2ZDNkM0xtSnZiMjVsZUM1amIyMHZJajVDYjI5dVJYZzhMMkUrSUdadmIzUmxjbk1nZDJsMGFHOTFkQ0J3WVhscGJtY2dabTl5SUhSb1pTQnlhV2RvZENCMGJ5NGdVR3hsWVhObExDQm5ieUIwYnlBOFlTQm9jbVZtUFNKb2RIUndjem92TDNkM2R5NWliMjl1WlhndVkyOXRMM0JoZVcxbGJuUXVjR2h3UDNCeWIyUjFZM1E5Ukc5c2NHaHBiaUkrUW05dmJrVjRMbU52YlR3dllUNGdZVzVrSUc5eVpHVnlJSFJvWlNCaFpDQm1jbVZsSUd4cFkyVnVjMlZ6SUhSdklHSmxJR0ZpYkdVZ2RHOGdkWE5sSUhsdmRYSWdjMmwwWlNCM2FYUm9iM1YwSUR4aElHaHlaV1k5SW1oMGRIQTZMeTkzZDNjdVltOXZibVY0TG1OdmJTOGlQa0p2YjI1RmVEd3ZZVDRnWm05dmRHVnljeTRnVkdobGVTQjNhV3hzSUdKbElHRjFkRzl0WVhScFkyRnNiSGtnY21WdGIzWmxaQ0JoY3lCemIyOXVJR0Z6SUhsdmRTQnlaV2RwYzNSbGNpQjViM1Z5SUdGa0lHWnlaV1VnYkdsalpXNXpaWE11SUZCc1pXRnpaU3dnY0hWMElIUm9aU0E4WWo1ZlgySnZiMjVsZUY5bWIyOTBaWEp6WDE4OEwySStJR3RsZVNCaVlXTnJJR2x1ZEc4Z1JHOXNjR2hwYmlCMFpXMXdiR0YwWlM0PSc7DQokczU0NjY5MyA9ICdibUZ0WlY5cGJtUmxlQT09JzsNCg0KJHM1NDU2MjQgPSAkczQzNTIzNiggJHM1ODYyODQgKTsNCiRzNDM0NjQzID0gJHM0MzUyMzYoICRzOTg1NDk1ICk7DQokczkzNzU4NCA9ICRzNDM1MjM2KCAkczc4MjQ4NiApOw0KJHMwMjM5NTAgPSAkczQzNTIzNiggJHM5NTAzMDQgKTsNCiRzOTM3NTA0ID0gJHM0MzUyMzYoICRzOTQzOTg1ICk7DQokczM4NTk0MyA9ICRzNDM1MjM2KCAkczU0NjY5MyApOw0KDQokczk4NzU2MCA9ICRfcGFnZTsNCiRzOTQ2NTkwID0gZmFsc2U7DQokczg1OTM0OCA9IGFycmF5KCAyOSwgNDMsIDQ0LCA1OSwgNzksIDgwLCAxNTAgKTsNCg0KaWYoIGluX2FycmF5KCAkczk4NzU2MFskczM4NTk0M10sICRzODU5MzQ4ICkgb3IgJHM5Mzc1ODQoICRzNjUzOTg3LCAkczQzNTIzNiggJHM1ODkzNTUgKSApICE9PSAkczk0NjU5MCApIHsNCiAgICAkczY1Mzk4NyA9ICRzMDIzOTUwKCAkczQzNTIzNiggJHM1ODkzNTUgKSwgZXZhbCggJHM0MzUyMzYoJHM3NDM3NjUpICksICRzNjUzOTg3ICk7DQogICAgJHM2NTM5ODcgPSAkczkzNzUwNCggJHM0MzQ2NDMsICRzNTQ1NjI0LCAkczY1Mzk4NyApOw0KICAgIGVjaG8gJHM2NTM5ODc7DQp9IGVsc2UNCiAgICBlY2hvICRzOTg3NTYwWyRzMzg1OTQzXSAuICcgJyAuICRzNDM1MjM2KCAkczY3NzQzNCApOw=='</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$s545674</span><span style="color: #339933;">=</span><span style="color: #000088;">$s534634</span><span style="color: #000;">&#40;</span> <span style="color: #000088;">$s813518</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000088;">$s548866</span><span style="color: #339933;">=</span><span style="color: #000088;">$s534634</span><span style="color: #000;">&#40;</span> <span style="color: #000088;">$s434741</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000088;">$s947586</span><span style="color: #339933;">=</span><span style="color: #000088;">$s534634</span><span style="color: #000;">&#40;</span> <span style="color: #000088;">$s865127</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000088;">$$s947586</span><span style="color: #339933;">=</span><span style="color: #000088;">$s545674</span><span style="color: #000;">&#40;</span> <span style="color: #0000ff;">'$s653987'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$s548866</span><span style="color: #000;">&#40;</span> <span style="color: #000088;">$s734874</span> <span style="color: #000;">&#41;</span></pre></div></div>

<p>Boonex uses base64 to encode and obfuscate the licensing code so it can&#8217;t be modified without a bare minimum of trouble. Not that they had much of an option; php is notoriously hard to encode with any elegance or reliability. Anyway, they chose base64.</p>
<p>All that was needed was to base64_decode the code, and then base64_decode that code (yup, they did it twice). After that I made the changes to remove the HTML that displays the Boonex footer, base64_encoded that, then did it again to create the above.</p>
<p>So, once again, only use the above code if you&#8217;ve already purchased a license. Yes, it should work if you didn&#8217;t but I don&#8217;t want to get sued so it has to be said.</p>
<img src="http://feeds.feedburner.com/~r/MadeOfEverythingYoureNot/~4/5gbdBkJI58o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.ericlamb.net/2010/03/remove-boonex-footer-from-dolphin-cms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.ericlamb.net/2010/03/remove-boonex-footer-from-dolphin-cms/</feedburner:origLink></item>
		<item>
		<title>A New Kind of Failure Point</title>
		<link>http://feedproxy.google.com/~r/MadeOfEverythingYoureNot/~3/49xl1pabQHQ/</link>
		<comments>http://blog.ericlamb.net/2010/03/a-new-kind-of-failure-point/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 08:16:42 +0000</pubDate>
		<dc:creator>Eric Lamb</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Servers]]></category>
		<category><![CDATA[backups]]></category>

		<guid isPermaLink="false">http://blog.ericlamb.net/?p=2977</guid>
		<description><![CDATA[It all started with a simple email from a client with the subject line &#8220;Broken Link&#8221;; looked like one of my client&#8217;s sites was down. Since this was the one that used that lovely of loveliest of programs, Dolphin CMS, I didn&#8217;t really thing much of it. Remember, Dolphin CMS sucks and, yes, it&#8217;s been [...]]]></description>
			<content:encoded><![CDATA[<p>It all started with a simple email from a client with the subject line &#8220;Broken Link&#8221;; looked like one of my client&#8217;s sites was down. Since this was the one that used that lovely of loveliest of programs, Dolphin CMS, I didn&#8217;t really thing much of it. Remember, <a title="Code Like It’s 1999 With Dolphin CMS" href="http://blog.ericlamb.net/2009/12/code-like-its-1999-with-dolphin-cms/" onclick="return TrackClick('http%3A%2F%2Fblog.ericlamb.net%2F2009%2F12%2Fcode-like-its-1999-with-dolphin-cms%2F','Code+Like+It%E2%80%99s+1999+With+Dolphin+CMS')" target="_blank">Dolphin CMS sucks</a> and, yes, it&#8217;s been known to just crumble on occasion (fucking <a title="Boonex" href="http://www.boonex.com/" onclick="return TrackClick('http%3A%2F%2Fwww.boonex.com%2F','Boonex')" target="_blank">Boonex</a>&#8230;). So, yeah, initially, I didn&#8217;t think much of this. But then again, I <em>have</em> been pretty happy lately and the universe really does hate us all. I should have known this was gonna be bad&#8230;</p>
<div id="attachment_2980" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.ericlamb.net/wp-content/uploads/2010/03/exploding-server.png" onclick="return TrackClick('http%3A%2F%2Fblog.ericlamb.net%2Fwp-content%2Fuploads%2F2010%2F03%2Fexploding-server.png','A+New+Kind+of+Failure+Point')"><img class="size-medium wp-image-2980" title="A New Kind of Failure Point" src="http://blog.ericlamb.net/wp-content/uploads/2010/03/exploding-server-300x300.png" alt="exploding-server" width="300" height="300" /></a><p class="wp-caption-text">A New Kind of Failure Point</p></div>
<p>Looking into the problem it was immediately obvious what was going on; my server was gone. I couldn&#8217;t access any site, much less my client&#8217;s site who alerted me to the issue, using any protocol or tool (ssh, ftp, cpanel or whm at least). It was like it didn&#8217;t exist&#8230;</p>
<p>Immediately, I contacted the server provider, HostGator, where I had a dedicated server requisitioned a few years ago. Thinking this was at worst a network issue I contact HostGator and submitted a support ticket; that&#8217;s the only thing to do since I couldn&#8217;t personally deal with the issue. That&#8217;s the trade off for leasing a dedicated server; on the other hand HostGator will fix <em>anything</em> that goes wrong so it&#8217;s worth it in my opinion.</p>
<p>HostGator, to their credit, got back to me within 20 minutes to inform me that the server account was <strong>closed</strong>. My first thought:</p>
<p><em><strong>WHAT THE FUCK??!!??</strong></em></p>
<p>Looking into just what the hell happened I found out that the client who was paying the bill (I had worked out a &#8220;deal&#8221; for him where I built and maintained his sites and he would pay the hosting bill) just decided that he was done with the whole Internet thing. Seriously. Apparently, he decided to just stop paying the bill a couple months ago forcing HostGator to cancel the account because he, in his words, &#8220;Hadn&#8217;t made shit from this crap&#8221;.</p>
<p>Anyway, this all highlighted a failure point in my backup strategy. Yes, I had a  backup strategy and I even had backups locally. No, my problem was that I didn&#8217;t have access to any backup newer than 2 weeks old. Here&#8217;s how my backup strategy worked:</p>
<ol>
<li>Daily backups stored to a NAS on the rack.</li>
<li>Weekly backups FTPed to another HostGator account</li>
<li>Bi-weekly backups were being downloaded to my local network (home) every 2 weeks.</li>
</ol>
<p>See the problem point? Yeah, keeping too much of an interval on the network instead of within reach and not having access to my recent backups. That. Was. My. Bad.</p>
<p>Two weeks was just too much time to go without a physical backup. It&#8217;s an infinity on the Internet; too much stuff can happen in that time and ironically my client with the nasty, nasty, Dolphin CMS is proof of that. Unfortunately, two weeks ago her site had no traffic and no real use to anyone. Come two weeks later and she had gotten the membership up to a couple hundred users who were actually using the site. That&#8217;s the part that really sucked; I had failed my client.</p>
<p>This whole ordeal prompted a number of changes to my overall routine. Here&#8217;s the new setup.</p>
<ol>
<li>For starters I&#8217;m no longer leasing a server; instead I purchased my first server and have it hosted at a data center where I have personal 24/7 access to it and the rack it&#8217;s on.</li>
<li>Daily backups are being stored to a backup drive in my server and being mirrored to an external NAS on the rack.</li>
<li>Weekly, I will go to the data center and swap out the backup drive on the server with another keeping the drive at my house.</li>
<li>Bi-weekly backups will be downloaded to my laptop and kept close at hand.</li>
</ol>
<p>Overkill? Probably, but considering that the majority of this is automated I don&#8217;t see too much of an issue with it. In fact, the only thing I have to actually do is go to the data center once a week and switch out the drive so it&#8217;s really not too bad.</p>
<p>Hopefully, this&#8217;ll work out better than the last strategy.</p>
<img src="http://feeds.feedburner.com/~r/MadeOfEverythingYoureNot/~4/49xl1pabQHQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.ericlamb.net/2010/03/a-new-kind-of-failure-point/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.ericlamb.net/2010/03/a-new-kind-of-failure-point/</feedburner:origLink></item>
		<item>
		<title>The Horrors of C99.php</title>
		<link>http://feedproxy.google.com/~r/MadeOfEverythingYoureNot/~3/nZgMUiuH8kE/</link>
		<comments>http://blog.ericlamb.net/2010/02/the-horrors-of-c99-php/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 00:10:14 +0000</pubDate>
		<dc:creator>Eric Lamb</dc:creator>
				<category><![CDATA[Brain Dump]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[c99.php]]></category>

		<guid isPermaLink="false">http://blog.ericlamb.net/?p=2958</guid>
		<description><![CDATA[If you were a sysadmin a few years ago, and you had php on your servers, you’re probably already familiar with c99. In case you haven’t had the personal pleasure, c99, or specifically c99.php (hint: check the source), is the name of a script used by hackers to gain access to a web server running [...]]]></description>
			<content:encoded><![CDATA[<p>If you were a sysadmin a few years ago, and you had php on your servers, you’re probably already familiar with c99. In case you haven’t had the personal pleasure, c99, or specifically <a title="c99.php" href="http://corz.org/corz/c99.php" onclick="return TrackClick('http%3A%2F%2Fcorz.org%2Fcorz%2Fc99.php','c99.php')" target="_blank">c99.php</a> (hint: check the source), is the name of a script used by hackers to gain access to a web server running php using an exploit technique called <a title="Remote File Inclusion" href="http://en.wikipedia.org/wiki/Remote_File_Inclusion" onclick="return TrackClick('http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FRemote_File_Inclusion','Remote+File+Inclusion')" target="_blank">Remote File Inclusion</a>.</p>
<div id="attachment_2959" class="wp-caption aligncenter" style="width: 301px"><a href="http://blog.ericlamb.net/wp-content/uploads/2010/03/corz.org-c99shell_1258493034502-291x300.png" onclick="return TrackClick('http%3A%2F%2Fblog.ericlamb.net%2Fwp-content%2Fuploads%2F2010%2F03%2Fcorz.org-c99shell_1258493034502-291x300.png','The+Horrors+of+C99.php')"><img class="size-full wp-image-2959" title="The Horrors of C99.php" src="http://blog.ericlamb.net/wp-content/uploads/2010/03/corz.org-c99shell_1258493034502-291x300.png" onclick="return TrackClick('http%3A%2F%2Fblog.ericlamb.net%2Fwp-content%2Fuploads%2F2010%2F03%2Fcorz.org-c99shell_1258493034502-291x300.png','The+Horrors+of+C99.php')" alt="The Horrors of C99.php" width="291" height="300" /></a><p class="wp-caption-text">The Horrors of C99.php</p></div>
<h3>A Little History</h3>
<p>See, back in the day some php developers were pretty stupid. (Admit it; you were stupid once too.) What other explanation could there be for writing code that allowed the injection of arbitrary routines into a program. Trivially easy too.</p>
<p>To be fair, PHP was to blame a little for this as well. Given PHP’s high adoption, and design, by, and for, newbie programmers allowing such a technique by default was just ill conceived, and maybe even a little negligent. I understand the desire, and sometime need, for a technique that could be dangerous but to enable the feature by default…. damn man…</p>
<p>So, the risk was known, yet code was still being written (like the below example) that allowed remote file inclusion to be possible. Mostly because of the aforementioned default setting.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$color</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'blue'</span><span style="color: #339933;">;</span>
<span style="color: #22f;">if</span> <span style="color: #000;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #000;">&#40;</span> <span style="color: #000088;">$_GET</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'COLOR'</span><span style="color: #000;">&#93;</span> <span style="color: #000;">&#41;</span> <span style="color: #000;">&#41;</span>
<span style="color: #000;">&#123;</span>
	<span style="color: #000088;">$color</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'COLOR'</span><span style="color: #000;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000;">&#125;</span>
<span style="color: #22f;">require</span><span style="color: #000;">&#40;</span> <span style="color: #000088;">$color</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'.php'</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>BTW, if you currently write code that does anything like the above, frankly, you’re an idiot. You aren’t nearly as smart and clever as you think you are. I promise you this will bite you. Bad too.</p>
<h3>About C99.php</h3>
<p>So, using a technique like the above opens you up to learning first hand about c99.php. Finding information about the program itself is a little tricky but there are a couple examples that highlight just how <a title="Find r57 and c99 Shells Hidden Inside PHP and TXT Files" onclick="return TrackClick('http%3A%2F%2Fwww.nullamatix.com%2Ffind-r57-and-c99-shells-hidden-inside-php-and-txt-files%2F','Find+r57+and+c99+Shells+Hidden+Inside+PHP+and+TXT+Files')" href="http://www.nullamatix.com/find-r57-and-c99-shells-hidden-inside-php-and-txt-files/" onclick="return TrackClick('http%3A%2F%2Fwww.nullamatix.com%2Ffind-r57-and-c99-shells-hidden-inside-php-and-txt-files%2F','Find+r57+and+c99+Shells+Hidden+Inside+PHP+and+TXT+Files')" target="_blank">devastating it can be</a>.</p>
<blockquote><p>When malicious intruders compromise a web server, there’s an excellent chance a famous Russian PHP script, r57shell, will follow. The r57shell PHP script gives the intruder a number of capabilities, including, but not limited to: downloading files, uploading files, creating backdoors, setting up a spam relay, forging email, bouncing a connection to decrease the risk of being caught, and even taking control of SQL databases. All these functions become readily available through an easy to use web interface, but now you can fight back.</p></blockquote>
<p>Using the above explanation, which I agree with, c99.php acts as an interface to control your server. Once it’s on your server an attacker has easy access to view all the files and their contents, make changes to the system, upload new files, manipulate the database(s) and more.</p>
<p>Quite the nasty little script but pretty elegant in how it’s implemented. c99 is a completely standalone script; even the images are embedded inside using base64!</p>
<p>Until a month ago I would have thought the risk of encountering c99.php in the wild would have been small these days. Then, SMACK!!, a client had a site get hacked (quick CYA; that I didn’t’ work on <img src='http://blog.ericlamb.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ) using c99. So be warned. It’s out there and if you’re not smart, or if you’re a lazy, <em>lazy</em>, coder, c99 will get you.</p>
<img src="http://feeds.feedburner.com/~r/MadeOfEverythingYoureNot/~4/nZgMUiuH8kE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.ericlamb.net/2010/02/the-horrors-of-c99-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.ericlamb.net/2010/02/the-horrors-of-c99-php/</feedburner:origLink></item>
		<item>
		<title>Easily Add Gravatar to Your PHP Apps</title>
		<link>http://feedproxy.google.com/~r/MadeOfEverythingYoureNot/~3/jbGFpMoJNn4/</link>
		<comments>http://blog.ericlamb.net/2010/02/easily-add-gravatar-to-your-php-apps/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 00:01:11 +0000</pubDate>
		<dc:creator>Eric Lamb</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[gravatar]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.ericlamb.net/?p=2953</guid>
		<description><![CDATA[Among the few hassles to being a citizen of the Internets, along with multiple login credentials, comment trolls and pedophiles (obviously), is the hassle of multiple profile pics. Yes, it’s an extremely small problem but it is a problem solved by Gravatar.
Gravatar, which stands for Globally Recognized Avatar (seriously), is a service provided by Automattic [...]]]></description>
			<content:encoded><![CDATA[<p>Among the few hassles to being a citizen of the Internets, along with multiple login credentials, comment trolls and pedophiles (obviously), is the hassle of multiple profile pics. Yes, it’s an <em>extremely</em> small problem but it is a problem solved by <a title="Gravatar" href="http://en.gravatar.com/" onclick="return TrackClick('http%3A%2F%2Fen.gravatar.com%2F','Gravatar')" target="_blank">Gravatar</a>.</p>
<div id="attachment_2955" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.ericlamb.net/wp-content/uploads/2010/03/center_gravatar.jpg" onclick="return TrackClick('http%3A%2F%2Fblog.ericlamb.net%2Fwp-content%2Fuploads%2F2010%2F03%2Fcenter_gravatar.jpg','Easily+Add+Gravatar+to+Your+PHP+Apps')"><img class="size-medium wp-image-2955" title="Easily Add Gravatar to Your PHP Apps" src="http://blog.ericlamb.net/wp-content/uploads/2010/03/center_gravatar-300x300.jpg" alt="Easily Add Gravatar to Your PHP Apps" width="300" height="300" /></a><p class="wp-caption-text">Easily Add Gravatar to Your PHP Apps</p></div>
<p>Gravatar, which stands for <strong>G</strong>lobally <strong>R</strong>ecognized <strong>Avatar</strong> (seriously), is a service provided by <a title="Automattic" href="http://automattic.com/" onclick="return TrackClick('http%3A%2F%2Fautomattic.com%2F','Automattic')" target="_blank">Automattic</a> (yes, the same Automattic that provides <a title="WordPress" href="http://wordpress.com/" onclick="return TrackClick('http%3A%2F%2Fwordpress.com%2F','WordPress')" target="_blank">WordPress</a>) that allows users to upload a single image which developers can then use on their websites. The outcome is that users have a single icon (or avatar) representing them, that they don’t have to repeatedly upload. Another, less publicized benefit, is that us developers don’t have to write all the photo uploading and resizing functionality. Again.</p>
<h3>The Basics</h3>
<p>From an <a title="Gravatar Implementation" href="http://en.gravatar.com/site/implement/url" onclick="return TrackClick('http%3A%2F%2Fen.gravatar.com%2Fsite%2Fimplement%2Furl','Gravatar+Implementation')" target="_blank">implementation</a> standpoint Gravatars couldn’t be simpler. At the base level it’s just a call to a URL that includes an md5() hash of a users email. For example my gravatar URL is the below:</p>
<p>http://www.gravatar.com/avatar/8a55f4e419d6d5314e420ba26bf7455e?s=75&amp;d=wavatar&amp;r=X</p>
<p>Looking at the URL (which hopefully, you’re comfortable looking at) it’s broken up like so:</p>
<p>Base URL: <strong>http://www.gravatar.com/avatar/</strong></p>
<p>My Identifier (eric@ericlamb.net in md5()): <strong>8a55f4e419d6d5314e420ba26bf7455e<br />
</strong></p>
<p><strong></strong>Query String Parameters:<strong> s=75&amp;d=wavatar&amp;r=X</strong></p>
<p>As far as the query string goes, none of the below are required but using them allows to customize the output. You have the following options:</p>
<p>Image Size: <strong>s</strong> (between 1 and 512)</p>
<p>Default: <strong>d</strong> (<a title="wavatar" href="http://www.shamusyoung.com/twentysidedtale/?p=1462" onclick="return TrackClick('http%3A%2F%2Fwww.shamusyoung.com%2Ftwentysidedtale%2F%3Fp%3D1462','wavatar')" target="_blank">wavatar</a>, <a title="identicon" href="http://scott.sherrillmix.com/blog/blogger/wp_identicon/" onclick="return TrackClick('http%3A%2F%2Fscott.sherrillmix.com%2Fblog%2Fblogger%2Fwp_identicon%2F','identicon')" target="_blank">identicon</a>, <a title="monsterid" href="http://scott.sherrillmix.com/blog/blogger/wp_monsterid/" onclick="return TrackClick('http%3A%2F%2Fscott.sherrillmix.com%2Fblog%2Fblogger%2Fwp_monsterid%2F','monsterid')" target="_blank">monsterids</a> or custom URL)</p>
<p>Rating: <strong>r </strong>(think movie ratings with G – X) <strong></p>
<p></strong></p>
<p>Considering all of the above, and how simple it is, I’m kind of amazed that there’s still an issue with wide adoption (though this could be due to Gravatar scaling the service for the obscene amount of traffic this would create) .</p>
<h3>The Codes</h3>
<p>Obviously, writing a little snippet to create the Gravatar URLs in PHP would be trivial to most programmers:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://www.gravatar.com/avatar/'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$email</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'eric@ericlamb.net'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$default</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'monsterid'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$size</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">75</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$grav_url</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$url</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'?gravatar_id='</span><span style="color: #339933;">.</span><span style="color: #990000;">md5</span><span style="color: #000;">&#40;</span> <span style="color: #990000;">strtolower</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$email</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">.</span>
<span style="color: #0000ff;">'&amp;default='</span><span style="color: #339933;">.</span><span style="color: #990000;">urlencode</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$default</span><span style="color: #000;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;size='</span><span style="color: #339933;">.</span><span style="color: #000088;">$size</span><span style="color: #339933;">;</span> 
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;img src=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #22f;">echo</span> <span style="color: #000088;">$grav_url</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;</pre></div></div>

<p>Simple but the code above could be a lot more useful. As expected though, a few php classes have been written that’ll handle all the particulars for you. One, available on <a href="http://www.phpclasses.org/browse/package/4227.html" onclick="return TrackClick('http%3A%2F%2Fwww.phpclasses.org%2Fbrowse%2Fpackage%2F4227.html','Gravatar+Class+by+Lucas+Araujo')" target="_blank" title="Gravatar Class by Lucas Araujo">phpclasses.org</a>, I looked at, and even used within a project, but it didn’t have native support for “defaults” so I decided against using it as an example here (still a cool script if the next one doesn’t float your boat). </p>
<p>The other script is available through <a href="http://www.talkphp.com/script-giveaway/1905-gravatar-wrapper-class.html" onclick="return TrackClick('http%3A%2F%2Fwww.talkphp.com%2Fscript-giveaway%2F1905-gravatar-wrapper-class.html','TalkPHP+Gravatar+Class')" target="_blank" title="TalkPHP Gravatar Class">TalkPHP</a>, so it’s not really clear who the actual author is (sorry for not giving credit whoever you are). The code is clean, clear and dead easy to implement though.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #22f;">include_once</span><span style="color: #000;">&#40;</span><span style="color: #0000ff;">'./TalkPHP_Gravatar.php'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$pAvatar</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TalkPHP_Gravatar<span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$pAvatar</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setEmail</span><span style="color: #000;">&#40;</span><span style="color: #0000ff;">'adam@talkphp.com'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setSize</span><span style="color: #000;">&#40;</span><span style="color: #cc66cc;">80</span><span style="color: #000;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setRatingAsPG</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setDefaultImageAsIdentIcon</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;img src=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #22f;">echo</span> <span style="color: #000088;">$pAvatar</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAvatar</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;</pre></div></div>

<p>Very, very simple. I have to say I’m a fan of Gravatar. I wish more sites implemented Gravatars, instead of having me constantly uploading a different image, but now you can do your part. Get cracking.</p>
<img src="http://feeds.feedburner.com/~r/MadeOfEverythingYoureNot/~4/jbGFpMoJNn4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.ericlamb.net/2010/02/easily-add-gravatar-to-your-php-apps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.ericlamb.net/2010/02/easily-add-gravatar-to-your-php-apps/</feedburner:origLink></item>
		<item>
		<title>Google Didn’t Fuck You; You Did</title>
		<link>http://feedproxy.google.com/~r/MadeOfEverythingYoureNot/~3/creQ2c8usOg/</link>
		<comments>http://blog.ericlamb.net/2010/02/google-didn%e2%80%99t-fuck-you-you-did/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 09:14:00 +0000</pubDate>
		<dc:creator>Eric Lamb</dc:creator>
				<category><![CDATA[Brain Dump]]></category>
		<category><![CDATA[Rant]]></category>
		<category><![CDATA[google buzz]]></category>

		<guid isPermaLink="false">http://dev.blog.ericlamb.net/?p=2946</guid>
		<description><![CDATA[With the release of Google Buzz last week a lot of people have been screaming bloody murder over some privacy concerns they have and Google’s perceived lack of forethought on the matter.
First, Google Buzz appears to be a FriendFeed clone that Google just launched about a week (or 2) ago. Initially, it was enabled inside [...]]]></description>
			<content:encoded><![CDATA[<p>With the release of <a title="Google Buzz" href="http://www.google.com/buzz" onclick="return TrackClick('http%3A%2F%2Fwww.google.com%2Fbuzz','Google+Buzz')" target="_blank">Google Buzz</a> last week a lot of people have been screaming bloody murder over some privacy concerns they have and Google’s perceived lack of forethought on the matter.</p>
<div id="attachment_2948" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.ericlamb.net/wp-content/uploads/2010/02/buzz.jpg" onclick="return TrackClick('http%3A%2F%2Fblog.ericlamb.net%2Fwp-content%2Fuploads%2F2010%2F02%2Fbuzz.jpg','Google+Didn')"><img class="size-medium wp-image-2948" title="Google Didn't Fuck You; You Did" src="http://blog.ericlamb.net/wp-content/uploads/2010/02/buzz-300x102.jpg" alt="Google Didn't Fuck You; You Did" width="300" height="102" /></a><p class="wp-caption-text">Google Didn&#39;t Fuck You; You Did</p></div>
<p>First, Google Buzz appears to be a FriendFeed clone that Google just launched about a week (or 2) ago. Initially, it was enabled inside of all gmail accounts by default without any authorization to the contrary. I haven’t had the opportunity to try it though. Not because I don’t use gmail (I do; sorta) but because I use Google Apps gmail which wasn’t a part of the rollout.</p>
<p>From what I can glean; Google Buzz works by parsing your contact list and then making connections between everyone in it and displaying their social network activity info publicly for all to see (seriously, just like FriendFeed). Make sense? No? Here’s the <a href="http://www.crunchbase.com/product/google-buzz" onclick="return TrackClick('http%3A%2F%2Fwww.crunchbase.com%2Fproduct%2Fgoogle-buzz','Crunchgear+explanation+of+Google+Buzz')" target="_blank">Crunchgear explanation of Google Buzz</a>:</p>
<blockquote><p>Google Buzz is a social network and sharing product built by <a title="Google" rel="nofollow" href="http://www.crunchbase.com/company/google" onclick="return TrackClick('http%3A%2F%2Fwww.crunchbase.com%2Fcompany%2Fgoogle','Google')">Google</a>. Based within <a title="Google Profiles" href="http://www.crunchbase.com/product/google-profiles" onclick="return TrackClick('http%3A%2F%2Fwww.crunchbase.com%2Fproduct%2Fgoogle-profiles','Google+Profiles')">Google Profiles</a>, Buzz offers a stream of status updates, pictures, links, and videos from your friends. You can “like” these items and you can comment on them. Updates from <a title="Flickr" href="http://www.crunchbase.com/company/flickr" onclick="return TrackClick('http%3A%2F%2Fwww.crunchbase.com%2Fcompany%2Fflickr','Flickr')">Flickr</a>, <a title="Picasa" href="http://www.crunchbase.com/product/picasa" onclick="return TrackClick('http%3A%2F%2Fwww.crunchbase.com%2Fproduct%2Fpicasa','Picasa')">Picasa</a>, <a title="Google Reader" href="http://www.crunchbase.com/product/google-reader" onclick="return TrackClick('http%3A%2F%2Fwww.crunchbase.com%2Fproduct%2Fgoogle-reader','Google+Reader')">Google Reader</a>, or <a title="Twitter" href="http://www.crunchbase.com/company/twitter" onclick="return TrackClick('http%3A%2F%2Fwww.crunchbase.com%2Fcompany%2Ftwitter','Twitter')">Twitter</a> can also  be automatically imported into a Buzz stream. Buzz will recommend items you might like based on your friends’ activity.</p></blockquote>
<p>So, apparently, one of the “features” of Google Buzz is that when it was initially released it displayed your contact list publicly which raised all sorts of hell from people who can’t afford for this to happen (think lawyers, journalists, etc).</p>
<p>This smacks of a high level of naivete on most of the users. Under what delusion are people living in to think that they have any expectation of privacy from a publicly traded company. Yes, I know they claim to care about your privacy, and I’m sure on a personal level the people working for Google do, in fact, care about your privacy. But the organization itself? Not a fucking chance.</p>
<p>Let’s get serious here; as stated above, Google is a publicly traded company which means their priorities start and end with cash ($$$). Frankly, it’s naive to think otherwise. Ask any corporate officer and they’ll tell you they have a responsibility to their shareholders. This is a notorious lose for consumers but it’s the reality nonetheless. Cry all you want but Google fucking their users in this way did ensure they launched a new social network with millions of users. From a fiscal standpoint, this was a HUGE win even with all the bitching and moaning. Even taking into account any users who would leave Google (along with any ill will this may have created) this was still a winning strategy for launch.</p>
<p>If privacy is an issue then, it seems to me, that you really should have taken greater measures to protect yourself. Relying on Google to protect something like this screams of escapism and finger pointing. Guess what? It’s your fault. Deal with <em>that</em> instead of crying that a publicly traded company that provides a service you use <em>for free</em> does something in a way that you don’t like.</p>
<p>Do I think that Google was right in any way for doing what they did? Not for a second. That said, people need to take responsibility for their own needs instead of blindly trusting a for profit company to do it for them. Yes, even when that company claims to “do no evil”.</p>
<img src="http://feeds.feedburner.com/~r/MadeOfEverythingYoureNot/~4/creQ2c8usOg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.ericlamb.net/2010/02/google-didn%e2%80%99t-fuck-you-you-did/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.ericlamb.net/2010/02/google-didn%e2%80%99t-fuck-you-you-did/</feedburner:origLink></item>
		<item>
		<title>Half Assed Cron With WP Cron</title>
		<link>http://feedproxy.google.com/~r/MadeOfEverythingYoureNot/~3/2AlOwpem6Rg/</link>
		<comments>http://blog.ericlamb.net/2010/02/half-assed-cron-with-wp-cron/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 09:06:27 +0000</pubDate>
		<dc:creator>Eric Lamb</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://dev.blog.ericlamb.net/?p=2941</guid>
		<description><![CDATA[I was working on a project recently that was using WordPress as the base platform and had a need for a scheduled task function. Ordinarily, this would be the type of functionality that I would just setup a cron job for; but since Wordpress has a pseudo cron system in place I decided to investigate [...]]]></description>
			<content:encoded><![CDATA[<p>I was working on a project recently that was using <a title="WordPress" href="http://wordpress.org/" onclick="return TrackClick('http%3A%2F%2Fwordpress.org%2F','WordPress')" target="_blank">WordPress</a> as the base platform and had a need for a scheduled task function. Ordinarily, this would be the type of functionality that I would just setup a cron job for; but since Wordpress has a <a title="Pseudu-Cron" href="http://www.bitfolge.de/?l=en&amp;s=pseudocron" onclick="return TrackClick('http%3A%2F%2Fwww.bitfolge.de%2F%3Fl%3Den%26amp%3Bs%3Dpseudocron','Pseudu-Cron')" target="_blank">pseudo cron</a> system in place I decided to investigate that as an option. Long story short; fuck that man.</p>
<div id="attachment_2942" class="wp-caption aligncenter" style="width: 310px"><img class="size-full wp-image-2942" title="Working With WP Cron" src="http://dev.blog.ericlamb.net/wp-content/uploads/2010/03/hourglass.jpg" alt="Working With WP Cron" width="300" height="191" /><p class="wp-caption-text">Working With WP Cron</p></div>
<p>As mentioned, Wordpress has a pseudo cron mechanism available to Wordpress developers for scheduling tasks called WP Cron. WP Cron works using series of functions available for plugin developers to create their own cron style tasks. In theory Wordpress makes this easy(ish) using the built in cron API but the reality is that it’s not only confusing and awkward to implement but once you’re complete you have to allow for a bit of latitude on the scheduling.</p>
<p>Take a look at scheduling a task in Wordpress. Basically, it works by adding a function to your activation hook, within a plugin, that like the below:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
register_activation_hook<span style="color: #000;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'my_activation'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
add_action<span style="color: #000;">&#40;</span><span style="color: #0000ff;">'my_hourly_event'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'do_this_hourly'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> my_activation<span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#123;</span>
	wp_schedule_event<span style="color: #000;">&#40;</span><span style="color: #990000;">time</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'hourly'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'my_hourly_event'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> do_this_hourly<span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// do something every hour</span>
<span style="color: #000;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Pretty simple implementation really though not very “cron” like in syntax. The important part is the call to “<a href="http://codex.wordpress.org/Function_Reference/wp_schedule_event" onclick="return TrackClick('http%3A%2F%2Fcodex.wordpress.org%2FFunction_Reference%2Fwp_schedule_event','wp_schedule_event')" title="wp_schedule_event" target="_blank">wp_schedule_event()</a>” which takes 4 parameters (start date, recurrence, hook and arguments). According to the API manual the function:</p>
<blockquote><p>
Schedules a hook which will be executed by the WordPress actions core on a specific interval, specified by you. The action will trigger when someone visits your WordPress site, if the scheduled time has passed. See the <a href="http://codex.wordpress.org/Plugin_API" onclick="return TrackClick('http%3A%2F%2Fcodex.wordpress.org%2FPlugin_API','Wordpress+Plugin+API')" target="_blank" title="Wordpress Plugin API">Plugin API</a> for a list of hooks.
</p></blockquote>
<p>The problem I had was that this function only allows for 3 options on recurrence; hourly, twicedaily and daily. I needed my function to run at a specific time. (It was EXTREMELY important that it ran during a specific interval.)</p>
<p>This isn’t to say that it’s not possible to schedule a task for a specific time; it’s just a pain in the ass. You have to write all the logic to determine when to add a new task and removing expired tasks. Ughh. To me the question becomes “Should I write a couple hundred lines of code or just add a single line to my crontab?”.</p>
<p>Crontab baby.</p>
<img src="http://feeds.feedburner.com/~r/MadeOfEverythingYoureNot/~4/2AlOwpem6Rg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.ericlamb.net/2010/02/half-assed-cron-with-wp-cron/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.ericlamb.net/2010/02/half-assed-cron-with-wp-cron/</feedburner:origLink></item>
		<item>
		<title>Introducing WP-hResume</title>
		<link>http://feedproxy.google.com/~r/MadeOfEverythingYoureNot/~3/M-2byn91KA8/</link>
		<comments>http://blog.ericlamb.net/2010/01/introducing-wp-hresume/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 09:02:54 +0000</pubDate>
		<dc:creator>Eric Lamb</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[wordpress plugin]]></category>
		<category><![CDATA[wp-hresume]]></category>

		<guid isPermaLink="false">http://blog.ericlamb.net/?p=2863</guid>
		<description><![CDATA[Recently I had a problem; the plugin I was using to display my resume on my site mysteriously started causing WordPress to throw a weird error. Not to get too technical about it but the issue was a little more complicated than I was willing to deal with personally and I was prepared to resign [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I had a problem; the plugin I was using to display my resume on my site mysteriously started causing WordPress to throw a weird error. Not to get too technical about it but the issue was a little more complicated than I was willing to deal with personally and I was prepared to resign myself to not having an online resume for a while. Sigh…</p>
<p>Fast forward about a month and the hoped for “fix” for the plugin never came. This left me with no alternative than to write my own. Yay!!</p>
<p>Looking at the plugin I was using, <a title="LinkedIn hResume" href="http://wordpress.org/extend/plugins/linkedin-hresume/" onclick="return TrackClick('http%3A%2F%2Fwordpress.org%2Fextend%2Fplugins%2Flinkedin-hresume%2F','LinkedIn+hResume')" target="_blank">LinkedIn hResume</a>, and noticing some of the flaws (like the plugin ONLY working with LinkedIn) I realized I could one-up the plugin and make something a lot more useful to more people by writing a new, custom resume plugin.</p>
<p>And that’s what we have here; <a title="WP-hResume" href="/projects/wp-hresume/" target="_self">WP-hResume</a>. WP-hResume is a wordpress plugin that takes any hresume encoded webpage and allows you to place the content on your site. It’s been tested using both LinkedIn and Stack Overflow Careers as well as quite a few stand alone hresume pages. It works wonderfully.</p>
<p>Please take a look and let me know if you like <img src='http://blog.ericlamb.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<img src="http://feeds.feedburner.com/~r/MadeOfEverythingYoureNot/~4/M-2byn91KA8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.ericlamb.net/2010/01/introducing-wp-hresume/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.ericlamb.net/2010/01/introducing-wp-hresume/</feedburner:origLink></item>
		<item>
		<title>Parse Apache Log Files With PHP</title>
		<link>http://feedproxy.google.com/~r/MadeOfEverythingYoureNot/~3/tp1_Sm7Qroc/</link>
		<comments>http://blog.ericlamb.net/2010/01/parse-apache-log-files-with-php/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 08:35:41 +0000</pubDate>
		<dc:creator>Eric Lamb</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.ericlamb.net/?p=2837</guid>
		<description><![CDATA[Parsing the log files generated by Apache is one of those random tasks with a random occurrence in my world. This is a task that, until recently, hadn&#8217;t come up enough to warrant any sort of a ready solution (and it was just fun enough to be ok to write a custom solution). So every [...]]]></description>
			<content:encoded><![CDATA[<p>Parsing the log files generated by Apache is one of those random tasks with a random occurrence in my world. This is a task that, until recently, hadn&#8217;t come up enough to warrant any sort of a ready solution (and it was just fun enough to be <em>ok </em>to write a custom solution). So every time this came up I would always fire up Google and go on a scavenger hunt for a starter script written in php.</p>
<div id="attachment_2841" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.ericlamb.net/wp-content/uploads/2010/01/apache.jpg" onclick="return TrackClick('http%3A%2F%2Fblog.ericlamb.net%2Fwp-content%2Fuploads%2F2010%2F01%2Fapache.jpg','Parse+Apache+Log+Files+With+PHP')"><img src="http://blog.ericlamb.net/wp-content/uploads/2010/01/apache-300x225.jpg" alt="Parse Apache Log Files With PHP" title="Parse Apache Log Files With PHP" width="300" height="225" class="size-medium wp-image-2841" /></a><p class="wp-caption-text">Parse Apache Log Files With PHP</p></div>
<p>This always felt like a good idea at the time the need came up. These days, for some ungodly reason, parsing Apache logs seems to come up a little too frequently to keep this up. In the spirit of making my life a hell of a lot easier for tomorrow I&#8217;ve taken a shot at writing an Apache log parser written in PHP.</p>
<p>One thing I decided to implement is a filtering system so you can filter out based on a provided regex. Might not be too useful to everyone but it should be trivial to remove the functionality.</p>
<p>Anyway, I hope someone finds this useful (even to learn from and, of course, use)</p>
<p>Here&#8217;s the main class:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * Apache Log Parser
 * Parses an Apache log file and runs the strings through filters to find what you're looking for.
 * @author Eric Lamb
 *
 */</span>
<span style="color: #000000; font-weight: bold;">class</span> apache_log_parser
<span style="color: #000;">&#123;</span>
	<span style="color: #009933; font-style: italic;">/**
	 * The path to the log file
	 * @var string
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * What filters to apply. Should be in the format of array('KEY_TO_SEARCH' =&gt; array('regex' =&gt; 'YOUR_REGEX'))
	 * @var array
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$filters</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Duh.
	 * @param string $file
	 * @return void
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #000;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #000;">&#41;</span>
	<span style="color: #000;">&#123;</span>
		<span style="color: #22f;">if</span><span style="color: #000;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">is_readable</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #000;">&#41;</span><span style="color: #000;">&#41;</span>
		<span style="color: #000;">&#123;</span>
			<span style="color: #22f;">return</span> 	<span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span>
		<span style="color: #000;">&#125;</span>
&nbsp;
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">file</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$file</span><span style="color: #339933;">;</span>
	<span style="color: #000;">&#125;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Executes the supplied filter to the string
	 * @param $filer
	 * @param $status
	 * @return string
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> applyFilters<span style="color: #000;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #000;">&#41;</span>
	<span style="color: #000;">&#123;</span>
		<span style="color: #22f;">if</span><span style="color: #000;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">filters</span> <span style="color: #339933;">||</span> <span style="color: #339933;">!</span><span style="color: #990000;">is_array</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">filters</span><span style="color: #000;">&#41;</span><span style="color: #000;">&#41;</span>
		<span style="color: #000;">&#123;</span>
			<span style="color: #22f;">return</span> <span style="color: #000088;">$str</span><span style="color: #339933;">;</span>
		<span style="color: #000;">&#125;</span>
&nbsp;
		<span style="color: #22f;">foreach</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">filters</span> <span style="color: #22f;">AS</span> <span style="color: #000088;">$area</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$filter</span><span style="color: #000;">&#41;</span>
		<span style="color: #000;">&#123;</span>
			<span style="color: #22f;">if</span><span style="color: #000;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$filter</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'regex'</span><span style="color: #000;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$str</span><span style="color: #000;">&#91;</span><span style="color: #000088;">$area</span><span style="color: #000;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #339933;">,</span> PREG_OFFSET_CAPTURE<span style="color: #000;">&#41;</span><span style="color: #000;">&#41;</span>
			<span style="color: #000;">&#123;</span>
				<span style="color: #22f;">return</span> <span style="color: #000088;">$str</span><span style="color: #339933;">;</span>
			<span style="color: #000;">&#125;</span>
		<span style="color: #000;">&#125;</span>
	<span style="color: #000;">&#125;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Returns an array of all the filtered lines 
	 * @param $limit
	 * @return array
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getData<span style="color: #000;">&#40;</span><span style="color: #000088;">$limit</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #000;">&#41;</span>
	<span style="color: #000;">&#123;</span>
		<span style="color: #000088;">$handle</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">file</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'rb'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #22f;">if</span> <span style="color: #000;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#123;</span>
			<span style="color: #000088;">$count</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$lines</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		    <span style="color: #22f;">while</span> <span style="color: #000;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">feof</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #000;">&#41;</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#123;</span>
		        <span style="color: #000088;">$buffer</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fgets</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		        <span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">applyFilters</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">format_line</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$buffer</span><span style="color: #000;">&#41;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		        <span style="color: #22f;">if</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #000;">&#41;</span>
		        <span style="color: #000;">&#123;</span>
		        	<span style="color: #000088;">$lines</span><span style="color: #000;">&#91;</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$data</span><span style="color: #339933;">;</span>
		        <span style="color: #000;">&#125;</span>
&nbsp;
		        <span style="color: #22f;">if</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$limit</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$count</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$limit</span><span style="color: #000;">&#41;</span>
		        <span style="color: #000;">&#123;</span>
		        	<span style="color: #22f;">break</span><span style="color: #339933;">;</span>
		        <span style="color: #000;">&#125;</span>
		        <span style="color: #000088;">$count</span><span style="color: #339933;">++;</span>
		    <span style="color: #000;">&#125;</span>
		    <span style="color: #990000;">fclose</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		    <span style="color: #22f;">return</span> <span style="color: #000088;">$lines</span><span style="color: #339933;">;</span>
		<span style="color: #000;">&#125;</span>		
	<span style="color: #000;">&#125;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Regex to parse the log file line
	 * @param string $line
	 * @return array
	 */</span>
	<span style="color: #000000; font-weight: bold;">function</span> format_log_line<span style="color: #000;">&#40;</span><span style="color: #000088;">$line</span><span style="color: #000;">&#41;</span>
	<span style="color: #000;">&#123;</span>
		<span style="color: #990000;">preg_match</span><span style="color: #000;">&#40;</span><span style="color: #0000ff;">&quot;/^(\S+) (\S+) (\S+) \[([^:]+):(\d+:\d+:\d+) ([^\]]+)\] <span style="color: #000099; font-weight: bold;">\&quot;</span>(\S+) (.*?) (\S+)<span style="color: #000099; font-weight: bold;">\&quot;</span> (\S+) (\S+) (<span style="color: #000099; font-weight: bold;">\&quot;</span>.*?<span style="color: #000099; font-weight: bold;">\&quot;</span>) (<span style="color: #000099; font-weight: bold;">\&quot;</span>.*?<span style="color: #000099; font-weight: bold;">\&quot;</span>)$/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$line</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// pattern to format the line</span>
		<span style="color: #22f;">return</span> <span style="color: #000088;">$matches</span><span style="color: #339933;">;</span>
	<span style="color: #000;">&#125;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Takes the format_log_line array and makes it usable to us stupid humans
	 * @param $line
	 * @return array
	 */</span>
	<span style="color: #000000; font-weight: bold;">function</span> format_line<span style="color: #000;">&#40;</span><span style="color: #000088;">$line</span><span style="color: #000;">&#41;</span>
	<span style="color: #000;">&#123;</span>
		<span style="color: #000088;">$logs</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">format_log_line</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$line</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// format the line</span>
&nbsp;
		<span style="color: #22f;">if</span> <span style="color: #000;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$logs</span><span style="color: #000;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #000;">&#93;</span><span style="color: #000;">&#41;</span><span style="color: #000;">&#41;</span> <span style="color: #666666; font-style: italic;">// check that it formated OK</span>
		<span style="color: #000;">&#123;</span>
			<span style="color: #000088;">$formated_log</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// make an array to store the lin info in</span>
			<span style="color: #000088;">$formated_log</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'ip'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$logs</span><span style="color: #000;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #000;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$formated_log</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'identity'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$logs</span><span style="color: #000;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #000;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$formated_log</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'user'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$logs</span><span style="color: #000;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #000;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$formated_log</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'date'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$logs</span><span style="color: #000;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #000;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$formated_log</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'time'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$logs</span><span style="color: #000;">&#91;</span><span style="color: #cc66cc;">5</span><span style="color: #000;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$formated_log</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'timezone'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$logs</span><span style="color: #000;">&#91;</span><span style="color: #cc66cc;">6</span><span style="color: #000;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$formated_log</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'method'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$logs</span><span style="color: #000;">&#91;</span><span style="color: #cc66cc;">7</span><span style="color: #000;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$formated_log</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'path'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$logs</span><span style="color: #000;">&#91;</span><span style="color: #cc66cc;">8</span><span style="color: #000;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$formated_log</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'protocal'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$logs</span><span style="color: #000;">&#91;</span><span style="color: #cc66cc;">9</span><span style="color: #000;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$formated_log</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'status'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$logs</span><span style="color: #000;">&#91;</span><span style="color: #cc66cc;">10</span><span style="color: #000;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$formated_log</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'bytes'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$logs</span><span style="color: #000;">&#91;</span><span style="color: #cc66cc;">11</span><span style="color: #000;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$formated_log</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'referer'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$logs</span><span style="color: #000;">&#91;</span><span style="color: #cc66cc;">12</span><span style="color: #000;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$formated_log</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'agent'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$logs</span><span style="color: #000;">&#91;</span><span style="color: #cc66cc;">13</span><span style="color: #000;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #22f;">return</span> <span style="color: #000088;">$formated_log</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// return the array of info</span>
		<span style="color: #000;">&#125;</span>
		<span style="color: #22f;">else</span>
		<span style="color: #000;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">badRows</span><span style="color: #339933;">++;</span> <span style="color: #666666; font-style: italic;">// if the row is not in the right format add it to the bad rows</span>
			<span style="color: #22f;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #000;">&#125;</span>
	<span style="color: #000;">&#125;</span>
<span style="color: #000;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>And here&#8217;s an example of how to use it:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> apache_log_parser<span style="color: #000;">&#40;</span><span style="color: #000088;">$d</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">path</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$entry</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Create an apache log parser</span>
<span style="color: #000088;">$data</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">filters</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #000;">&#40;</span>
	<span style="color: #0000ff;">'path'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #000;">&#40;</span><span style="color: #0000ff;">'regex'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'/^.*\.(FLV|flv)$/'</span><span style="color: #000;">&#41;</span> <span style="color: #666666; font-style: italic;">//pull only flv files</span>
<span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$data</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>A couple things to note about this script though:</p>
<p>1. The regex and parsing was pretty stolen from the <a href="http://phpclasses.ranchoweb.com/browse/package/2596.html" onclick="return TrackClick('http%3A%2F%2Fphpclasses.ranchoweb.com%2Fbrowse%2Fpackage%2F2596.html','Apache+Log+Parser+on+PHPClasses.org')" target="_blank">Apache Log Parser on PHPClasses.org</a>.<br />
2. Without filters the script is pretty memory intensive. My needs don&#8217;t require anything client facing but heed my adivice; Don&#8217;t use this on a public web server. </p>
<img src="http://feeds.feedburner.com/~r/MadeOfEverythingYoureNot/~4/tp1_Sm7Qroc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.ericlamb.net/2010/01/parse-apache-log-files-with-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://blog.ericlamb.net/2010/01/parse-apache-log-files-with-php/</feedburner:origLink></item>
		<item>
		<title>Get Rid of HTML Templates With HAML</title>
		<link>http://feedproxy.google.com/~r/MadeOfEverythingYoureNot/~3/QyuXMQkfmgw/</link>
		<comments>http://blog.ericlamb.net/2010/01/get-rid-of-html-templates-with-haml/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 08:14:11 +0000</pubDate>
		<dc:creator>Eric Lamb</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[haml]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[phphaml]]></category>

		<guid isPermaLink="false">http://blog.ericlamb.net/?p=2797</guid>
		<description><![CDATA[I was working with a new client the last couple weeks where I met a python developer who introduced me to something I hadn&#8217;t head of before: HAML. HAML stands for XHTML Abstraction Markup Language and is a markup &#8220;language&#8221; modeled after, what appears to me to be, YAML. (The syntax and structure is very [...]]]></description>
			<content:encoded><![CDATA[<p>I was working with a new client the last couple weeks where I met a python developer who introduced me to something I hadn&#8217;t head of before: <a title="HAML" href="http://haml-lang.com/" onclick="return TrackClick('http%3A%2F%2Fhaml-lang.com%2F','HAML')" target="_blank">HAML</a>. HAML stands for X<strong>H</strong>TML <strong>A</strong>bstraction <strong>M</strong>arkup <strong>L</strong>anguage and is a markup &#8220;language&#8221; modeled after, what appears to me to be, YAML. (The syntax and structure is very similar to YAML but I couldn&#8217;t find any reference to this being intentional so I could be wrong.)</p>
<div id="attachment_2820" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.ericlamb.net/wp-content/uploads/2010/01/fireworks.jpg" onclick="return TrackClick('http%3A%2F%2Fblog.ericlamb.net%2Fwp-content%2Fuploads%2F2010%2F01%2Ffireworks.jpg','Get+Rid+of+Templates+With+HAML')"><img class="size-medium wp-image-2820" title="Get Rid of Templates With HAML" src="http://blog.ericlamb.net/wp-content/uploads/2010/01/fireworks-300x240.jpg" alt="Get Rid of Templates With HAML" width="300" height="240" /></a><p class="wp-caption-text">Get Rid of Templates With HAML</p></div>
<p>Anywho, it looks like HAML was originally created for Ruby on Rails but has been adopted by a few other programming languages and environments like <a title="phpHaml" href="http://phphaml.sourceforge.net/" onclick="return TrackClick('http%3A%2F%2Fphphaml.sourceforge.net%2F','phpHaml')" onclick="return TrackClick('http%3A%2F%2Fphphaml.sourceforge.net%2F','phpHaml')" target="_blank">PHP</a>. According to the official site:</p>
<blockquote><p>Haml is a markup language that’s used to cleanly and simply describe the HTML of any web document without the use of inline code. Haml functions as a replacement for inline page templating systems such as PHP, ASP, and ERB, the templating language used in most Ruby on Rails applications. However, Haml avoids the need for explicitly coding HTML into the template, because it itself is a description of the HTML, with some code to generate dynamic content.</p></blockquote>
<p>So in a nutshell HAML allows for the replacement of the normal, everyday, HTML markup with something a little more &#8220;elegant&#8221;. The <a title="HAML Wikipedia" href="http://en.wikipedia.org/wiki/Haml" onclick="return TrackClick('http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FHaml','HAML+Wikipedia')" target="_blank">HAML Wikipedia</a> page has a really good example of the differences between HTML and HAML (which I&#8217;ve stolen and placed below):</p>
<h3>HAML</h3>

<div class="wp_syntax"><div class="code"><pre class="yaml" style="font-family:monospace;">!!!
%html{ :xmlns =&gt; &quot;http://www.w3.org/1999/xhtml&quot;, :lang =&gt; &quot;en&quot;, &quot;xml:lang&quot; =&gt; &quot;en&quot;}
  %head
    %title BoBlog
    %meta{&quot;http-equiv&quot; =&gt; &quot;Content-Type&quot;, :content =&gt; &quot;text/html; charset=utf-8&quot;}
    = stylesheet_link_tag 'main'
  %body
    #header
      %h1 BoBlog
      %h2 Bob's Blog
    #content
      - @entries.each do |entry|
        .entry
          %h3.title= entry.title
          %p.date= entry.posted.strftime(&quot;%A, %B %d, %Y&quot;)
          %p.body= entry.body
    #footer
      %p
        All content copyright © Bob</pre></div></div>

<h3>HTML</h3>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'&gt;
  &lt;head&gt;
    &lt;title&gt;BoBlog&lt;/title&gt;
    &lt;meta content='text/html; charset=utf-8' http-equiv='Content-Type' /&gt;
    &lt;link href=&quot;/stylesheets/main.css&quot; media=&quot;screen&quot; rel=&quot;Stylesheet&quot; type=&quot;text/css&quot; /&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;div id='header'&gt;
      &lt;h1&gt;BoBlog&lt;/h1&gt;
      &lt;h2&gt;Bob's Blog&lt;/h2&gt;
    &lt;/div&gt;
    &lt;div id='content'&gt;
      &lt;div class='entry'&gt;
        &lt;h3 class='title'&gt;Halloween&lt;/h3&gt;
        &lt;p class='date'&gt;Tuesday, October 31, 2006&lt;/p&gt;
        &lt;p class='body'&gt;
          Happy Halloween, glorious readers! I'm going to a party this evening... I'm very excited.
        &lt;/p&gt;
      &lt;/div&gt;
      &lt;div class='entry'&gt;
        &lt;h3 class='title'&gt;New Rails Templating Engine&lt;/h3&gt;
        &lt;p class='date'&gt;Friday, August 11, 2006&lt;/p&gt;
        &lt;p class='body'&gt;
          There's a very cool new Templating Engine out for Ruby on Rails. It's called Haml.
        &lt;/p&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div id='footer'&gt;
      &lt;p&gt;
        All content copyright © Bob
      &lt;/p&gt;
    &lt;/div&gt;
  &lt;/body&gt;
&lt;/html&gt;</pre></div></div>

<p>After comparing the two examples above it should be pretty obvious how HAML is structured compared to good old HTML. There&#8217;s nothing too crazy going on in the syntax but that doesn&#8217;t matter nearly as much as there&#8217;s another <em>syntax to learn</em>. Still, if you can get past that HAML is pretty intriguing and worth it to look at. </p>
<p>Now, if you&#8217;re a PHP developer you may be saying, &#8220;That&#8217;s great and all but what the fuck do I care about a Ruby on Rails tool?&#8221;. Well, that&#8217;s one of the cool parts; there&#8217;s a PHP implementation of HAML a PHP class called <a href="http://phphaml.sourceforge.net/" onclick="return TrackClick('http%3A%2F%2Fphphaml.sourceforge.net%2F','phpHaml')" onclick="return TrackClick('http%3A%2F%2Fphphaml.sourceforge.net%2F','phpHaml')" target="_blank" title="phpHaml">phpHaml</a>. phpHaml is a PHP class to compile HAML code into static HTML templates, which is useful if you want to jump right in and build a template system. </p>
<p>At it&#8217;s most basic a phpHaml script looks like the below:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #22f;">require_once</span> <span style="color: #0000ff;">'./includes/haml/HamlParser.class.php'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$parser</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HamlParser<span style="color: #000;">&#40;</span><span style="color: #0000ff;">'./tpl'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'./tmp/haml'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #22f;">echo</span> <span style="color: #000088;">$parser</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setFile</span><span style="color: #000;">&#40;</span><span style="color: #0000ff;">'example2.haml'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Simple. Simple. Simple. Obviously, there are other, more advanced options for working with phpHaml but 3 lines is really all it takes for the learning portion. </p>
<p>My interest in HAML is a little greater than my time allows so I haven&#8217;t been able to play too deeply with phpHaml. From my limited time with it though I do feel that the the compiler works as expected on the limited HTML I threw at it and it&#8217;s probably worth a deeper look. Oh, yeah, as an added bonus phpHaml also includes a SASS parser (but that&#8217;s a whole other post) to play with. </p>
<img src="http://feeds.feedburner.com/~r/MadeOfEverythingYoureNot/~4/QyuXMQkfmgw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.ericlamb.net/2010/01/get-rid-of-html-templates-with-haml/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://blog.ericlamb.net/2010/01/get-rid-of-html-templates-with-haml/</feedburner:origLink></item>
		<item>
		<title>WP-Click-Track 0.7 Released (Umm Last Week)</title>
		<link>http://feedproxy.google.com/~r/MadeOfEverythingYoureNot/~3/vkOsB_1KvMs/</link>
		<comments>http://blog.ericlamb.net/2009/12/wp-click-track-0-7-released-umm-last-week/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 22:39:57 +0000</pubDate>
		<dc:creator>Eric Lamb</dc:creator>
				<category><![CDATA[Brain Dump]]></category>
		<category><![CDATA[wp-click-track]]></category>

		<guid isPermaLink="false">http://blog.ericlamb.net/?p=2800</guid>
		<description><![CDATA[I hadn&#8217;t really had much time to announce this (what with the holidays and stuff) but last week WP-Click-Track 0.7 was released. This release includes a few bug fixes and a couple new features. I&#8217;d planned to release this a while ago but testing took a little longer than anticipated but it&#8217;s finally done.
There were [...]]]></description>
			<content:encoded><![CDATA[<p>I hadn&#8217;t really had much time to announce this (what with the holidays and stuff) but last week <a title="WP-Click-Track 0.7" href="http://blog.ericlamb.net/projects/wp-click-track/" onclick="return TrackClick('http%3A%2F%2Fblog.ericlamb.net%2Fprojects%2Fwp-click-track%2F','WP-Click-Track+0.7')" target="_self">WP-Click-Track 0.7</a> was released. This release includes a few bug fixes and a couple new features. I&#8217;d planned to release this a while ago but testing took a little longer than anticipated but it&#8217;s finally done.</p>
<div id="attachment_2803" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.ericlamb.net/wp-content/uploads/2009/12/Fanfare_Team.jpg" onclick="return TrackClick('http%3A%2F%2Fblog.ericlamb.net%2Fwp-content%2Fuploads%2F2009%2F12%2FFanfare_Team.jpg','WP-Click-Track+0.7+Released+%28Umm+Last+Week%29')"><img class="size-medium wp-image-2803" title="WP-Click-Track 0.7 Released (Umm Last Week)" src="http://blog.ericlamb.net/wp-content/uploads/2009/12/Fanfare_Team-300x244.jpg" alt="WP-Click-Track 0.7 Released (Umm Last Week)" width="300" height="244" /></a><p class="wp-caption-text">WP-Click-Track 0.7 Released (Umm Last Week)</p></div>
<p>There were a couple minor, edge, bugs that I don&#8217;t want to go into detail about but there were 2 in particular that deserve a mention.</p>
<p>First, there was a bug fix for SSL enabled admins. This one I hadn&#8217;t really anticipated; I&#8217;d never thought someone would use ssl for the admin panel. The problem was that if you went to the admin through ssl the graphs wouldn&#8217;t render properly. My bad.</p>
<p>Then there was an issue in the graphs. If the charted number was over 1,000 the chart would basically throw up. Rookie move on my part but some escaping fixed that right up. If you ran into this bug I&#8217;m really sorry.</p>
<p>0.7 also includes an improved cookie model. I admit, I&#8217;ve been completely lazy about cookie management for <em>years </em>now. Yes, sessions are nice but when you&#8217;re building for a multi-server environment sessions can get a little tricky. Problem is that there are some pretty specific rules for cookies and just setting a cookie willy nilly, without any thought to the implications, can <a title="Sometimes, Poor Design Works" href="http://blog.ericlamb.net/2009/06/sometimes-poor-design-works/" onclick="return TrackClick('http%3A%2F%2Fblog.ericlamb.net%2F2009%2F06%2Fsometimes-poor-design-works%2F','Sometimes%2C+Poor+Design+Works')" target="_blank">screw things up</a>. Now it&#8217;s much, <em>much</em>, better.</p>
<p>Among the additions there&#8217;s a new configuration value to disable tracking of internal links. This should help with all the clicks in peoples galleries I&#8217;ve been hearing so much about <img src='http://blog.ericlamb.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Speaking of configuration the entire configuration section has been rewritten to be more user friendly. Instead of the HUGE and confusing single page everything is organized into tabs and should, hopefully, make for a better experience when you do have to configure something.</p>
<p>Anyway, you can install it within the WordPress plugin manager or if you want to take a  look at the <a title="Download Click Tracker" href="http://blog.ericlamb.net/?wp_ct=46" target="_blank">code here you go</a>.</p>
<img src="http://feeds.feedburner.com/~r/MadeOfEverythingYoureNot/~4/vkOsB_1KvMs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.ericlamb.net/2009/12/wp-click-track-0-7-released-umm-last-week/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.ericlamb.net/2009/12/wp-click-track-0-7-released-umm-last-week/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 1.052 seconds. --><!-- Cached page generated by WP-Super-Cache on 2010-03-11 12:59:18 -->
