<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/rss2full.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>DEVTRENCH: Web Development from the Front Lines</title>
	
	<link>http://www.devtrench.com</link>
	<description>Web Development from the Front Lines</description>
	<pubDate>Thu, 20 Nov 2008 16:46:19 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/devtrench" type="application/rss+xml" /><feedburner:emailServiceId>975612</feedburner:emailServiceId><feedburner:feedburnerHostname>http://www.feedburner.com</feedburner:feedburnerHostname><item>
		<title>One Thing You Should Never Do In PHP</title>
		<link>http://feeds.feedburner.com/~r/devtrench/~3/459748022/</link>
		<comments>http://www.devtrench.com/one-thing-you-should-never-do-in-php/#comments</comments>
		<pubDate>Thu, 20 Nov 2008 16:46:19 +0000</pubDate>
		<dc:creator>James Ehly</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[affiliate marketing]]></category>

		<category><![CDATA[php]]></category>

		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.devtrench.com/?p=256</guid>
		<description><![CDATA[I take security pretty seriously because I've had about a handful of sites hacked on my watch (luckily none of it was code that I'd written).  Over the years I've gotten used to programming with security in mind and there are a few PHP 'nevers' that I don't do any more.
A few days ago [...]]]></description>
			<content:encoded><![CDATA[<p>I take security pretty seriously because I've had about a handful of sites hacked on my watch (luckily none of it was code that I'd written).  Over the years I've gotten used to programming with security in mind and there are a few PHP 'nevers' that I don't do any more.</p>
<p>A few days ago I read a post on Browie.com about <a href="http://www.browie.com/rotate-your-offers" target="_blank">rotating affiliate marketing offers</a>.  The logic behind this is great and everyone in affiliate marketing should be doing this, so kudos to Browie for reminding us and showing the noobs how it's done.  However, I noticed a glaring PHP security flaw that I wanted to point out.</p>
<p>Here is the code that Browie gives as an example:</p>
<div class="igBar"><span id="lphp-4"><a href="#" onclick="javascript:showPlainTxt('php-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-4">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/extract"><span style="color:#000066;">extract</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$_REQUEST</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// offer.php</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$offer</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC66CC;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span> = “affiliatelink.com”;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$offer</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC66CC;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#93;</span> = “affiliatelink.com”;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$goto</span> = <span style="color:#0000FF;">$offer</span><span style="color:#006600; font-weight:bold;">&#91;</span><a href="http://www.php.net/rand"><span style="color:#000066;">rand</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC66CC;color:#800000;">1</span>, <a href="http://www.php.net/sizeof"><span style="color:#000066;">sizeof</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$offer</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/header"><span style="color:#000066;">header</span></a><span style="color:#006600; font-weight:bold;">&#40;</span>”Location: <span style="color:#0000FF;">$goto</span>”<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The problem lies in the first line of code.  One thing I have learned is NEVER do an extract() on $_REQUEST, $_GET, $_POST or any other global variable.  In this particular case I'm not really sure why extract() is being used or why the $_REQUEST var is needed, but I do know that it opens up the script to be used as a jump page for anyone (albeit not really reliable).  For instance, if you knew the location of the jump page, which you could find out from the ad link, then all you would have to do is construct a url like example.com/jumppage.php?offer[3]=http://mylink.com&#038;offer[4]=http://mylink2.com and your urls would be added to the $offer array and be randomly jumped to.  So unless you are super evil and can think of a way to really exploit this (messing with their stats?), then this isn't a huge security risk.  However, the point is that it allows anyone to inject variables into the script and make the script do things it was not intended to do.  So even though the risk in this script is minimal, it's best to just avoid it all together so that it doesn't start to become a habit.  Case in point: Just last week I came across some custom third party code on a client site that allowed me to login to their system without a username or password because of a combination of doing an extract() on $_REQUEST and not escaping variables in an sql query.  Not a very fun thing to find.  </p>
<p>In case you are wondering, here is how I would rewrite the script:</p>
<div class="igBar"><span id="lphp-5"><a href="#" onclick="javascript:showPlainTxt('php-5'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-5">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$offers</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'http://example.com/offer1.html'</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'http://example.com/offer2.html'</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/header"><span style="color:#000066;">header</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Location:'</span>.<span style="color:#0000FF;">$offers</span><span style="color:#006600; font-weight:bold;">&#91;</span><a href="http://www.php.net/array_rand"><span style="color:#000066;">array_rand</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$offers</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Notice that the $_REQUEST variable is missing since I don't see why it is needed, but if you have to use $_REQUEST variables then make sure that you call them like so:</p>
<div class="igBar"><span id="lphp-6"><a href="#" onclick="javascript:showPlainTxt('php-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-6">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$get_variable</span> = <span style="color:#0000FF;">$_GET</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'get_variablename'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$post_variable</span> = <span style="color:#0000FF;">$_POST</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'post_variablename'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$lazy_variable</span> = <span style="color:#0000FF;">$_REQUEST</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'get_or_post_variablename'</span><span style="color:#006600; font-weight:bold;">&#93;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>I suggest you use either $_GET or $_POST since you should know where your variables are coming from (ie don't be lazy).</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/devtrench?a=3NoZN"><img src="http://feeds.feedburner.com/~f/devtrench?i=3NoZN" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=Hhjyn"><img src="http://feeds.feedburner.com/~f/devtrench?i=Hhjyn" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=oyD1n"><img src="http://feeds.feedburner.com/~f/devtrench?i=oyD1n" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=RhMAn"><img src="http://feeds.feedburner.com/~f/devtrench?i=RhMAn" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=m7zLn"><img src="http://feeds.feedburner.com/~f/devtrench?i=m7zLn" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/devtrench/~4/459748022" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.devtrench.com/one-thing-you-should-never-do-in-php/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.devtrench.com/one-thing-you-should-never-do-in-php/</feedburner:origLink></item>
		<item>
		<title>Fix Permissions After WordPress SVN Install</title>
		<link>http://feeds.feedburner.com/~r/devtrench/~3/459175179/</link>
		<comments>http://www.devtrench.com/fix-permissions-after-wordpress-svn-install/#comments</comments>
		<pubDate>Thu, 20 Nov 2008 04:58:08 +0000</pubDate>
		<dc:creator>James Ehly</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[phpsuexe]]></category>

		<category><![CDATA[shell]]></category>

		<category><![CDATA[ssh]]></category>

		<category><![CDATA[svn]]></category>

		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.devtrench.com/?p=254</guid>
		<description><![CDATA[If you use WordPress for a lot of sites, installing it with SVN is really the way to go.  I've been switching over all of my blogs to use SVN since it makes updating sooooo much easier.  In fact, updating WordPress used to be my biggest gripe about the program, and now I [...]]]></description>
			<content:encoded><![CDATA[<p>If you use <a href="http://wordpress.org" target="_blank">WordPress </a>for a lot of sites, <a href="http://codex.wordpress.org/Installing/Updating_WordPress_with_Subversion" target="_blank">installing it with SVN</a> is really the way to go.  I've been switching over all of my blogs to use SVN since it makes updating sooooo much easier.  In fact, updating WordPress used to be my biggest gripe about the program, and now I don't even give it a second thought - it really makes it that easy.</p>
<p>However if you are on a shared host like I am, then the checked out files might not have the right permissions for your setup.  My host is running PHPSuExe and that means that all executable files can only be writable by the user (644 for files and 755 for directories).  But the checked out files and directories are all writable by the group (664 and 775).  What to do?</p>
<p>I just SSH in, cd to the blog directory, and do a recursive chmod that removes the group write privilege from all files and folders.  For example if your blog is in the typical cpanel root:</p>
<p><code>cd public_html<br />
chmod -R g-w .</code></p>
<p>Works every time.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/devtrench?a=CNRIN"><img src="http://feeds.feedburner.com/~f/devtrench?i=CNRIN" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=ystAn"><img src="http://feeds.feedburner.com/~f/devtrench?i=ystAn" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=P3gln"><img src="http://feeds.feedburner.com/~f/devtrench?i=P3gln" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=if5Qn"><img src="http://feeds.feedburner.com/~f/devtrench?i=if5Qn" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=K7f1n"><img src="http://feeds.feedburner.com/~f/devtrench?i=K7f1n" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/devtrench/~4/459175179" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.devtrench.com/fix-permissions-after-wordpress-svn-install/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.devtrench.com/fix-permissions-after-wordpress-svn-install/</feedburner:origLink></item>
		<item>
		<title>Anything but Photoshop - 10 Free Image Editors</title>
		<link>http://feeds.feedburner.com/~r/devtrench/~3/430392593/</link>
		<comments>http://www.devtrench.com/anything-but-photoshop-10-free-image-editors/#comments</comments>
		<pubDate>Fri, 24 Oct 2008 06:00:21 +0000</pubDate>
		<dc:creator>Guest</dc:creator>
		
		<category><![CDATA[Design]]></category>

		<category><![CDATA[design programs]]></category>

		<category><![CDATA[guest post]]></category>

		<category><![CDATA[image editors]]></category>

		<category><![CDATA[photoshop]]></category>

		<guid isPermaLink="false">http://www.devtrench.com/?p=249</guid>
		<description><![CDATA[This article is contributed by Sarah Scrafford, who regularly writes on the topic   of web design colleges. She   invites your questions, comments and freelancing job inquiries at her email address: sarah.scrafford25@gmail.com.
Adobe Photoshop and Corel PhotoPaint are useful tools, no doubt, but there's   more to image editors than determined by [...]]]></description>
			<content:encoded><![CDATA[<p><em>This article is contributed by Sarah Scrafford, who regularly writes on the topic   of <a target="_blank" href="http://www.webdesignschoolsguide.com/">web design colleges</a>. She   invites your questions, comments and freelancing job inquiries at her email address: <a target="_blank" href="mailto:sarah.scrafford25@gmail.com">sarah.scrafford25@gmail.com</a>.</em></p>
<p>Adobe Photoshop and Corel PhotoPaint are useful tools, no doubt, but there's   more to image editors than determined by the price tag alone. I know they say   you get what you paid for, but there are times when the best things in life   are free, like these web-based alternatives to Photoshop. Check them out if you need efficient editors on a low budget:</p>
<ul>
<li><strong><a target="_blank" href="http://www.gimp.org/">The GIMP</a>: </strong>It may rhyme with wimp, but it's certainly far from one. The GNU Image Manipulation Program is one of the hottest free image editors you'll find out there. It comes with almost all the features that pricey design packages have, and as for those that are missing, the open developing community for the GIMP will soon take care of that. This promising package is available for Windows, Mac, Linux and UNIX users.  </li>
<li><strong><a target="_blank" href="http://www.piknik.com/">Piknik</a>:</strong> Its integration with the popular photo sharing application Flickr has only added to the appeal of this image editor – Piknik allows you to edit and add special effects to your photos on Mac, Windows and Linux systems. </li>
<li><strong><a target="_blank" href="http://www.pixia.net/">Pixia</a>: </strong>lets you add layers, insert text, apply filters, resize, draw, crop, adjust color and brightness, and do a few other things as well to your pictures. A good tool to work with images and email them to all your friends. </li>
<li><strong><a target="_blank" href="http://www.serif.com/photoplus/photoplus7/">PhotoPlus</a>: </strong>This versatile photo editor opens Photoshop files, supports layers just like Photoshop, has a cool “undo” option that lets you take care of any number of blunders, and lets you add links to graphics through the Image Maps tool. </li>
<li><strong><a target="_blank" href="http://www.serif.com/photoplus/photoplus7/">Seashore</a>: </strong>A fast photo editor specifically for Mac users, this program lets you gradients and textures for text and brush strokes and supports multiple layers and alpha channel editing. It uses the same file format as the GIMP.  </li>
<li><strong><a target="_blank" href="http://www.getpaint.net/">Paint.NET</a>: </strong>This package which is based on the .NET framework and runs on computers that use the Windows operating systems and have Microsoft .NET Framework 2.0 installed. It features filters to handle blurring and sharpening and color control among other options, and allows layers. </li>
<li><strong><a target="_blank" href="http://www.koffice.org/krita/">Krita</a>: </strong>Available for use on systems that run the UNIX or Linux operating systems, this image editor which is a part of the KOffice suite, offers support for 16-bit images. It supports various filters, color management, CMYK and high dynamic resolution images. </li>
<li><strong><a target="_blank" href="picasa.google.com/">Picasa 2</a>: </strong>You could use this program just because it's from Google even if you are not too sure of the features and tools. The integrated Hello account (which has unfortunately been disabled now) allowed you to send any number of photos through email in a very short time. </li>
<li><strong><a target="_blank" href="http://fotoflexer.com/">FotoFlexr</a>:</strong> A comprehensive image editor, this tool lets you edit photos from Flickr, myspace, facebook,   and Picasa among other online album applications. </li>
<li><strong><a target="_blank" href="http://pixenate.com/">Pixenate</a>:</strong> This free online photo editing tool allows you to print, share or upload pictures to an online album. You can use standard editing tools and even apply fun effects.</li>
</ul>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/devtrench?a=hLCHM"><img src="http://feeds.feedburner.com/~f/devtrench?i=hLCHM" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=v7opm"><img src="http://feeds.feedburner.com/~f/devtrench?i=v7opm" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=wjLgm"><img src="http://feeds.feedburner.com/~f/devtrench?i=wjLgm" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=UTkFm"><img src="http://feeds.feedburner.com/~f/devtrench?i=UTkFm" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=H6lkm"><img src="http://feeds.feedburner.com/~f/devtrench?i=H6lkm" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/devtrench/~4/430392593" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.devtrench.com/anything-but-photoshop-10-free-image-editors/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.devtrench.com/anything-but-photoshop-10-free-image-editors/</feedburner:origLink></item>
		<item>
		<title>The Advantage of Developing with Blueprint CSS</title>
		<link>http://feeds.feedburner.com/~r/devtrench/~3/397262456/</link>
		<comments>http://www.devtrench.com/the-advantages-of-developing-with-blueprint-css/#comments</comments>
		<pubDate>Fri, 19 Sep 2008 14:39:08 +0000</pubDate>
		<dc:creator>James Ehly</dc:creator>
		
		<category><![CDATA[Design]]></category>

		<category><![CDATA[blueprint]]></category>

		<category><![CDATA[css]]></category>

		<category><![CDATA[grid systems]]></category>

		<category><![CDATA[html]]></category>

		<guid isPermaLink="false">http://www.devtrench.com/?p=232</guid>
		<description><![CDATA[Recently I've been developing websites using the Bluprint CSS framework.  Blueprint itself is not new (it's a little over a year old), but I hadn't really committed to using it as a standard for my business until about a month ago. 
So What's the Advantage?
The main advantage to using a css framework is speed. [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I've been developing websites using the <a href="http://www.blueprintcss.org/" target="_blank"><strong>Bluprint CSS framework</strong></a>.  Blueprint itself is not new (it's a little over a year old), but I hadn't really committed to using it as a standard for my business until about a month ago. </p>
<h3>So What's the Advantage?</h3>
<p>The main advantage to using a <u>css framework</u> is speed.  Once you figure out what the framework can do, it speeds up development quite a bit by helping to standardize the <em>web development workflow</em>.  Blueprint can be the bridge between design and code.  </p>
<p>So often it's the designer that creates the problems in web development...I know because I am one.  A simple stroke of design genius can snowball into a usability nightmare or make HTML/CSS markup a living hell.  A grid system like Blueprint gives a designer definite bounds to work within, and puts them on the same page with the CSS developer and information architect.  </p>
<p>Now if your designer doesn't totally screw things up with a stroke of genius, then the guy or gal that marks up the HTML and CSS probably will.  They'll think of ultra clever semantic names that later end up being not so semantic.  They'll invent a new layout system because the last ones they did just weren't good enough.  They'll probably take whatever whimsical approach seems appropriate for the design that was presented to them. </p>
<p>With Blueprint, the approach is different.  A web developer can now layout the basic structure of the page (ie header, columns, footer,etc) using CSS that's provided by the framework.  The best part about this is that it takes thinking out of structural layout.  You'll be surprised at how much time you wasted thinking about what to name things like columns let alone the time it actually took to write the CSS for it.  After using Blueprint for layout I wondered why I tortured myself by starting with a blank slate each time I started marking up a site.</p>
<p>If you're lucky enough to have an information architect in your workflow, then Blueprint is going to be a dream come true.  Instead of using an image editor like PhotoShop to make wireframes, the information architect can just use Blueprint to make them.  In fact, if your designer is also the IA, then why not have them start there.  If you can establish your grid and layout with CSS before design then you will be twice as prepared when you actually get to designing.  Plus, there's the added benefit of being able to reuse the code that the IA started at the CSS phase.</p>
<p>Hopefully, by now, the advantage of using a css framework is obvious.  The IA starts the design process with Blueprint, hands the grid system and wireframes to the designer who now has a real template to work from, and then the design and basic grid system gets handed to the CSS developer to put it all together.   Blueprint helps to standardize your workflow, and standards speed things up by automating simple tasks.</p>
<p>Jef Croft, one of the guys that helped write Blueprint, wrote:</p>
<blockquote><p>They’re especially great for those working on tight deadlines and those working in teams (teams wherein multiple people work on the same CSS — they benefit from having a consistent set of coding patterns), and also for those working on several sites of a similar nature (for example, a team working at a news company which runs 20+ newspaper sites).</p></blockquote>
<p>In my experience Blueprint is the best grid system out there right now. It has the cleanest, most flexible, and most supported code to allow your team to work together.  However, any grid system can speed up development and there are a few to choose from: <a href="http://960.gs/">960</a>, <a href="http://www.yaml.de/en/">YAML</a>, <a href="http://grid.mindplay.dk/">Grid Designer</a>, <a href="http://developer.yahoo.com/yui/grids/">YUI Grids CSS</a>.  The main point is that if you can standardize on a common way to layout pages then all of your developers will work better together.  </p>
<h3>You Want More?</h3>
<p><strong>Here are some more in depth articles...</strong></p>
<ul>
<li><a href="http://nettuts.com/html-css-techniques/which-css-grid-framework-should-you-use-for-web-design/" target=_blank>Which CSS Grid Framework Should You Use for Web Design?</a> - A pretty in depth look at CSS Grids and Blueprint</li>
<li><a href="http://jeffcroft.com/blog/2007/nov/17/whats-not-love-about-css-frameworks/" target="_blank">What’s not to love about CSS frameworks?</a> - A casual and humorous overview.</li>
<li><a href="http://www.markboulton.co.uk/articles/detail/five_simple_steps_to_designing_grid_systems/" target="_blank">Five Simple Steps to designing grid systems</a> - A very in depth look at Grid Systems</li>
</ul>
<p><strong>...and here are some great tools for Blueprint CSS...</strong></p>
<ul>
<li><a href="http://kematzy.com/blueprint-generator/" target="_blank">Blueprint Grid CSS Generator</a> - This tool will help you generate more flexible versions of Blueprint's grid.css and compressed.css and grid.png files.</li>
<li><a href="http://sprymedia.co.uk/article/Grid">Grid</a> - Grid is a highly configurable JavaScript bookmarklet which overlays a layout grid on any web-site you wish</li>
<li><a href="http://www.andrewingram.net/articles/introducing_gridmaker/">Photoshop GridMaker Script</a> - Creates guides in Photoshop for css grids.</li>
</ul>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/devtrench?a=4FYUL"><img src="http://feeds.feedburner.com/~f/devtrench?i=4FYUL" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=CFafl"><img src="http://feeds.feedburner.com/~f/devtrench?i=CFafl" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=NP9ll"><img src="http://feeds.feedburner.com/~f/devtrench?i=NP9ll" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=W4Myl"><img src="http://feeds.feedburner.com/~f/devtrench?i=W4Myl" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=lUHVl"><img src="http://feeds.feedburner.com/~f/devtrench?i=lUHVl" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/devtrench/~4/397262456" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.devtrench.com/the-advantages-of-developing-with-blueprint-css/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.devtrench.com/the-advantages-of-developing-with-blueprint-css/</feedburner:origLink></item>
		<item>
		<title>Adding Linux to Your Web Development Arsenal</title>
		<link>http://feeds.feedburner.com/~r/devtrench/~3/362045026/</link>
		<comments>http://www.devtrench.com/adding-linux-to-your-web-development-arsenal/#comments</comments>
		<pubDate>Mon, 11 Aug 2008 15:53:55 +0000</pubDate>
		<dc:creator>James Ehly</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.devtrench.com/?p=183</guid>
		<description><![CDATA[If you're a web developer or designer, chances are you've come in contact with the Linux operating system - most likely at the web server level.  My first experience with Linux was in 1998 when I worked at the University of Nebraska-Lincoln where our sys admins built web servers using this cool open source [...]]]></description>
			<content:encoded><![CDATA[<p>If you're a web developer or designer, chances are you've come in contact with the Linux operating system - most likely at the web server level.  My first experience with Linux was in 1998 when I worked at the University of Nebraska-Lincoln where our sys admins built web servers using this cool open source OS.  What's not cool about a free operating system?</p>
<p>Anyway, it's a good idea to run a server out of your office or home just to get familiar with how it works and what it can do.  That's what I finally set up this week and now my web development arsenal is pretty complete with a Windows laptop and desktop, Apple G4, and Ubuntu Linux on an old Pentium 3.  </p>
<p>What will I do with my Linux box?  Plans are to run PHP and Perl server applications off of it that are too memory intensive for a shared host web server.  I've been getting more into running php and perl programs from the command line interface, and want to move that development to Linux.  </p>
<h3>So how do you get it?</h3>
<p>First of all you need a decent computer, and I think the Pentium 3 with 512 MB of RAM that I have is about the slowest thing you're going to want to run it on (I got it for free).  However, if you are just running a web server that won't get a lot of use, then a slower computer is not all that bad.  It's when you get into running the various desktop apps  (KDE or Gnome) that you need at least 1GB of memory.  </p>
<p>The flavor of Linux I chose is <a href="http://ww.ubuntu.com">Ubuntu</a> and I picked it because it came with an <a href="http://www.ubuntu.com/products/WhatIsUbuntu/serveredition">easy web server install</a>.  You can pick whatever flavor you want but the most popular ones seem to be Debian, Ubuntu, Fedora, and SUSE.  There are lots of comparison sites (<a href="http://en.wikipedia.org/wiki/Comparison_of_Linux_distributions">here</a>  and <a href="http://www.linux.com/distributions/">here</a>)out there on the net, just Google it.</p>
<p>Once you get your distribution downloaded, installing it is usually pretty easy.  They've really come a long way to make the process of installing Linux easier for everyone and if your hardware is common then you shouldn't have a problem.  I have to admit that I had a bit of a problem because I decided to remove the DVD drive before installing and messed up the Master/Slave drive hierarchy.  I don't know a lot about putting computers together, but now I know about that <img src='http://www.devtrench.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Live and learn.</p>
<h3>What to do once it is installed?</h3>
<p>So if you get Linux installed, what the heck do you do with it?  If you've installed a 'normal' version with a <acronym title="Graphical User Interface">GUI</acronym> then you can pretty much use it like any other computer.  Linux is a great, cheap alternative to purchasing an OS if you need an extra computer for basic tasks like word processing or browsing the web. </p>
<p>If you are like me and installed a web server, then it doesn't come with a GUI.  Get ready to type some command line instructions.  Really though, once I installed the Ubuntu web server it was ready to go with Apache, PHP, Perl, and mySQL and I didn't have to configure anything special to start using it right away.  Any programmer can use this setup to start building web spiders and other fun stuff, and deploy it right out their home office like I do (just don't do anything too spammy or your ISP might shut you down).</p>
<p>I know this hasn't been a tutorial on the specifics of how to set up Linux but you can find those on the distribution site that you download from.  That is the best place to find that kind of information along with support if you run into trouble.  If you end up setting up Linux or already have it set up, post a comment and tell us how you use it in your development arsenal. </p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/devtrench?a=srzCBK"><img src="http://feeds.feedburner.com/~f/devtrench?i=srzCBK" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=cjx86k"><img src="http://feeds.feedburner.com/~f/devtrench?i=cjx86k" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=f99N2k"><img src="http://feeds.feedburner.com/~f/devtrench?i=f99N2k" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=96cITk"><img src="http://feeds.feedburner.com/~f/devtrench?i=96cITk" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=cuhiOk"><img src="http://feeds.feedburner.com/~f/devtrench?i=cuhiOk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/devtrench/~4/362045026" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.devtrench.com/adding-linux-to-your-web-development-arsenal/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.devtrench.com/adding-linux-to-your-web-development-arsenal/</feedburner:origLink></item>
		<item>
		<title>Extending a WordPress Site: Core Hijack</title>
		<link>http://feeds.feedburner.com/~r/devtrench/~3/350522837/</link>
		<comments>http://www.devtrench.com/extending-a-wordpress-site-core-hijack/#comments</comments>
		<pubDate>Wed, 30 Jul 2008 14:00:34 +0000</pubDate>
		<dc:creator>James Ehly</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.devtrench.com/?p=189</guid>
		<description><![CDATA[It's pretty easy to hijack some core WordPress code and use it to extend the functionality of your WordPress site while keeping a cohesive look and feel.  Basically, this technique creates a WordPress 'shell' that you can code inside of; utilizing all of WordPress's functions and themes, but leaving out the blog.  I [...]]]></description>
			<content:encoded><![CDATA[<p>It's pretty easy to hijack some core <a href="http://www.wordpress.org">WordPress </a>code and use it to extend the functionality of your WordPress site while keeping a cohesive look and feel.  Basically, this technique creates a WordPress 'shell' that you can code inside of; utilizing all of WordPress's functions and themes, but leaving out the blog.  I use this technique to add on functionality to my WordPress sites that don't fit within the WordPress framework, such as zip code locators and other custom database applications.  You can even use this technique to build custom includes based on WordPress functions.  Lets get to it...</p>
<h3>Assumtions</h3>
<p>First I need to tell you about how my WordPress blogs are set up.  I usually set up my blogs in the root directory, and that is how this tutorial assumes you have done it as well.  This means all of our coding will be going on inside of the WordPress install.  Of course, your setup may be different than this, so just keep that in mind.</p>
<p>I'm also assuming that you've been good and have <a href="http://wordpress.org/download/">upgraded to WordPress 2.6</a>.  The WP developers have changed how the core code is included in WP 2.6 and this tutorial reflects that.</p>
<h3>Set Up</h3>
<p>To begin create a directory in your WordPress install for testing (this directory should be parallel to the wp-content folder).  You can call it anything you like - I'm calling mine 'tool'.  Next, create a blank index.php file in that folder.  </p>
<p><em><a href="/extending-a-wordpress-site-core-hijack/2/">Go on to learn how to include the WordPress core code...</a></em></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/devtrench?a=GPqTaJ"><img src="http://feeds.feedburner.com/~f/devtrench?i=GPqTaJ" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=Lqbkhj"><img src="http://feeds.feedburner.com/~f/devtrench?i=Lqbkhj" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=ZkztOj"><img src="http://feeds.feedburner.com/~f/devtrench?i=ZkztOj" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=BMlGKj"><img src="http://feeds.feedburner.com/~f/devtrench?i=BMlGKj" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=OdXcRj"><img src="http://feeds.feedburner.com/~f/devtrench?i=OdXcRj" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/devtrench/~4/350522837" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.devtrench.com/extending-a-wordpress-site-core-hijack/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.devtrench.com/extending-a-wordpress-site-core-hijack/</feedburner:origLink></item>
		<item>
		<title>Top Affiliate Challenge is Over</title>
		<link>http://feeds.feedburner.com/~r/devtrench/~3/341768848/</link>
		<comments>http://www.devtrench.com/top-affiliate-challenge-is-over/#comments</comments>
		<pubDate>Mon, 21 Jul 2008 18:23:29 +0000</pubDate>
		<dc:creator>James Ehly</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.devtrench.com/?p=188</guid>
		<description><![CDATA[I was finally able to watch episodes 5-14 of TAC over a 3 day stretch last week.  Overall I was pretty impressed with the show, even though my initial impressions left me wanting more.  The acting got better, and they actually showed how some things were done, and some of the contestants shared [...]]]></description>
			<content:encoded><![CDATA[<p>I was finally able to watch episodes 5-14 of TAC over a 3 day stretch last week.  Overall I was pretty impressed with the show, even though my initial impressions left me wanting more.  The acting got better, and they actually showed how some things were done, and some of the contestants shared pretty good details about how they got started and how they make money.  Just the fact that Thor was able to pull it off while running his business and other things he does is pretty amazing to me.    </p>
<p>Big surprise that <a href="http://tooltrainer.com/tools/blog/and-uh-its-over">Jonathan van Clute won</a>, but he deserved it since he really knows his stuff.  I was glad to see <a href="http://carlzetterlund.com/blog/quick-update-from-the-airport/">Carl come in 2nd</a>; he's a smart guy.  I think <s>Ian</s> Jani got lucky in third place and it could have been anyone else.  </p>
<p>As far as the Gurus go, it was very unfortunate for Shoemoney that his baby had such <a href="http://www.shoemoney.com/2008/07/12/the-craziest-week-of-my-life-baby-update/">problems after she was born</a>.  Not exactly the best way to enter this world, but I'm glad that she's doing better now and hopefully Shoe and his wife can get into the groove of being parents of 2 kids soon (if there is such a groove <img src='http://www.devtrench.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ).  John Chow got voted off and I'm not really sure I agreed with that.  I think he gives the most honest view of the show in his <a href="http://www.johnchow.com/what-i-learned-from-the-top-affiliate-challenge/">shocking behind the scenes take on TAC.</a>  So since Shoe and John were out, Ken McArthur had the show all to himself to promote the JV Alert conference and his book...good for him.</p>
<p>It sounds like there could be a TAC 2 in the works already so I'm excited to see that if it happens.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/devtrench?a=nYiPmJ"><img src="http://feeds.feedburner.com/~f/devtrench?i=nYiPmJ" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=KtGA5j"><img src="http://feeds.feedburner.com/~f/devtrench?i=KtGA5j" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=deMvnj"><img src="http://feeds.feedburner.com/~f/devtrench?i=deMvnj" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=TT04rj"><img src="http://feeds.feedburner.com/~f/devtrench?i=TT04rj" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=1hxrVj"><img src="http://feeds.feedburner.com/~f/devtrench?i=1hxrVj" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/devtrench/~4/341768848" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.devtrench.com/top-affiliate-challenge-is-over/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.devtrench.com/top-affiliate-challenge-is-over/</feedburner:origLink></item>
		<item>
		<title>How to Scrape an Entire Wordpress Blog</title>
		<link>http://feeds.feedburner.com/~r/devtrench/~3/329128328/</link>
		<comments>http://www.devtrench.com/how-to-scrape-an-entire-wordpress-blog/#comments</comments>
		<pubDate>Mon, 07 Jul 2008 19:24:13 +0000</pubDate>
		<dc:creator>James Ehly</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.devtrench.com/?p=186</guid>
		<description><![CDATA[When I find a new blog that I really like or think has some good information I usually want to read the whole thing, and in the past, I've been frustrated by how annoying it is to do it online.  I just want all posts in one document, free of ads, that I can [...]]]></description>
			<content:encoded><![CDATA[<p>When I find a new blog that I really like or think has some good information I usually want to read the whole thing, and in the past, I've been frustrated by how annoying it is to do it online.  I just want all posts in one document, free of ads, that I can read from start to finish.  </p>
<p>I've also been having the itch to learn the <a href="httpL://www.perl.org">Perl</a> programming language, and I thought this would be a good project to get my feet wet.</p>
<h3>Strategy</h3>
<p>Since the majority of blogs I read are in written in <a href="http://www.wordpress.org">WordPress</a>, it's pretty easy to take advantage of the GET string that can be used to access each post.  The GET string looks like <a href="http://www.devtrench.com/?p=2">http://www.devtrench.com/?p=2</a>.  Normally, post id's start with 1 and auto increment from there, so all we have to do is figure out what the id is of the latest post, and write some code that will loop over a scraper that many times.  Sometimes the latest post id will be hidden in the HTML of the post somewhere, and other times you just have to guess at it for a while until you figure it out.</p>
<h3>Code</h3>
<p>Here's the Perl code that I'm currently using to do this.  It's meant to be run from the command line, and I output the data to a file using '> output.txt' after the command.  Also, I ripped off most of this code from <a href="http://pleac.sourceforge.net/pleac_perl/">PLEAC-Perl</a>, which is an online Perl cookbook.  Cookbooks can really accelerate learning a language when you want to do specific tasks like this.</p>
<p>Hopefully this code is commented enough for you to understand what is going on.</p>
<div class="igBar"><span id="lperl-8"><a href="#" onclick="javascript:showPlainTxt('perl-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PERL:</span>
<div id="perl-8">
<div class="perl">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">#!/usr/bin/perl -w </span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># http://www.devtrench.com - How to Scrape a Wordpress Blog </span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># These packages are required so load them</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">use</span> LWP::<span style="color: #006600;">UserAgent</span>; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">use</span> HTTP::<span style="color: #006600;">Request</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">use</span> HTTP::<span style="color: #006600;">Response</span>; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">use</span> URI::<span style="color: #006600;">Heuristic</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># Usage: perl fetch_blog.pl http://www.domain.com highest_post_id start_pattern end_pattern</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$raw_url</span>&nbsp; = <a href="http://www.perldoc.com/perl5.6/pod/func/shift.html"><span style="color: #000066;">shift</span></a>; <span style="color: #808080; font-style: italic;"># should be the domain with http:// and no trailing slash</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$post_num</span> = <a href="http://www.perldoc.com/perl5.6/pod/func/shift.html"><span style="color: #000066;">shift</span></a>; <span style="color: #808080; font-style: italic;"># this is the highest id number that you can find in the blog</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$start_pattern</span> = <a href="http://www.perldoc.com/perl5.6/pod/func/shift.html"><span style="color: #000066;">shift</span></a>; <span style="color: #808080; font-style: italic;"># a start pattern to match. we don't want the entire page so find some unique text before the blog post. it's best to put the pattern in single quotes</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$end_pattern</span> = <a href="http://www.perldoc.com/perl5.6/pod/func/shift.html"><span style="color: #000066;">shift</span></a>; <span style="color: #808080; font-style: italic;"># some unique text that signifies the end of a blog post</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$url</span> = URI::<span style="color: #006600;">Heuristic</span>::<span style="color: #006600;">uf_urlstr</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$raw_url</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$| = <span style="color: #cc66cc;color:#800000;">1</span>; <span style="color: #808080; font-style: italic;">#to flush next line </span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># fire up a new user agent that can browse the web for us</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$ua</span> = LWP::<span style="color: #006600;">UserAgent</span>-&gt;<span style="color: #006600;">new</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$ua</span>-&gt;<span style="color: #006600;">agent</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"DEVTRENCH.COM WordPress Post Fetcher v0.1"</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;"># give it time, it'll get there</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># now loop through all posts</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$i</span>=<span style="color: #cc66cc;color:#800000;">1</span>;<span style="color: #0000ff;">$i</span>&lt;=<span style="color: #0000ff;">$post_num</span>;<span style="color: #0000ff;">$i</span>++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #808080; font-style: italic;"># here we request each post from the site using the get string common to wordpress blogs</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$req</span> = HTTP::<span style="color: #006600;">Request</span>-&gt;<span style="color: #006600;">new</span><span style="color: #66cc66;">&#40;</span>GET =&gt; <span style="color: #0000ff;">$url</span>.<span style="color: #ff0000;">'/?p='</span>.<span style="color: #0000ff;">$i</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #0000ff;">$req</span>-&gt;<span style="color: #006600;">referer</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"http://www.devtrench.com"</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;"># perplex the log analysers</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$response</span> = <span style="color: #0000ff;">$ua</span>-&gt;<span style="color: #006600;">request</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$req</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$response</span>-&gt;<span style="color: #006600;">is_error</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;"># uh oh there was an error, probably a 404 which is caused by deleted or non published posts</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<a href="http://www.perldoc.com/perl5.6/pod/func/printf.html"><span style="color: #000066;">printf</span></a> <span style="color: #ff0000;">"&lt;p&gt;ERROR POST #$i: %s&lt;/p&gt;&lt;hr&gt;"</span>, <span style="color: #0000ff;">$response</span>-&gt;<span style="color: #006600;">status_line</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$content</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">$content</span> = <span style="color: #0000ff;">$response</span>-&gt;<span style="color: #006600;">content</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$test</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">$_</span> = <span style="color: #0000ff;">$content</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;"># this is the regular expression that will match the start and end pattern</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$test</span> = /\Q<span style="color: #0000ff;">$start_pattern</span>\E<span style="color: #66cc66;">&#40;</span>.*<span style="color: #66cc66;">&#41;</span>\Q<span style="color: #0000ff;">$end_pattern</span>\E/<a href="http://www.perldoc.com/perl5.6/pod/func/s.html"><span style="color: #000066;">s</span></a><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">$content</span> = $<span style="color: #cc66cc;color:#800000;">1</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;"># this line prints out what the regex found as html, but it could easily be modified to print as plain text as well</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<a href="http://www.perldoc.com/perl5.6/pod/func/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">"&lt;div class='fetcher_content'&gt;&lt;p&gt;&lt;b&gt;Post #$i&lt;/b&gt;&lt;/p&gt;"</span>.<span style="color: #0000ff;">$content</span>.<span style="color: #ff0000;">"&lt;/div&gt;&lt;hr&gt;"</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#125;</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>This was a fun experiment for me and a great way to finally get around to learning Perl.  I always find that if I create small tasks like this for myself that learning a language or framework is much more interesting and rewarding.  Now if you want to do this in PHP, which is what I usually program in, you can follow the same logic using <a href="http://us.php.net/curl">curl</a> as your user agent.</p>
<p>Hint 1: If you use this code as is it will print out HTML.  Surround the HTML that it generates with basic &lt;html&gt; and &lt;body&gt; tags and create your own styles in the &lt;head&gt;. Then you can view it in a web browser and print to PDF.  </p>
<p>Hint 2: The blog I was trying to scrape did not allow me to hotlink images from my HTML file, but saving the page as HTML from FireFox was a workaround for that, and then I saved that created page as a PDF.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/devtrench?a=kyLrFJ"><img src="http://feeds.feedburner.com/~f/devtrench?i=kyLrFJ" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=9a576j"><img src="http://feeds.feedburner.com/~f/devtrench?i=9a576j" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=kgIqZj"><img src="http://feeds.feedburner.com/~f/devtrench?i=kgIqZj" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=oKzZrj"><img src="http://feeds.feedburner.com/~f/devtrench?i=oKzZrj" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=q0TR1j"><img src="http://feeds.feedburner.com/~f/devtrench?i=q0TR1j" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/devtrench/~4/329128328" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.devtrench.com/how-to-scrape-an-entire-wordpress-blog/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.devtrench.com/how-to-scrape-an-entire-wordpress-blog/</feedburner:origLink></item>
		<item>
		<title>Top Affiliate Challenge Episodes 2,3 and 4</title>
		<link>http://feeds.feedburner.com/~r/devtrench/~3/327912732/</link>
		<comments>http://www.devtrench.com/top-affiliate-challenge-episodes-two-three-and-four/#comments</comments>
		<pubDate>Sun, 06 Jul 2008 07:44:45 +0000</pubDate>
		<dc:creator>James Ehly</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.devtrench.com/?p=185</guid>
		<description><![CDATA[I've finally got the chance to view TAC episodes 2, 3, and 4 along with reading other people's comments of the show.  I really don't want to add to the negativity of the show that seems to be in everyone's posts because I really don't see the point.  I mean, yeah, the production [...]]]></description>
			<content:encoded><![CDATA[<p>I've finally got the chance to view <a href="http://topaffiliatechallenge.com/index.php">TAC episodes 2, 3, and 4</a> along with reading other people's comments of the show.  I really don't want to add to the <a href="http://uberaffiliate.com/industry-news/top-affiliate-challenge-sucks/">negativity</a> of the show that seems to be in everyone's posts because I really don't see the point.  I mean, yeah, the production isn't first class, the host leaves a lot to be desired (except for the wizard of oz songs at the end of episode four, can I get more of that wierdness please?), and it doesn't teach a lot, but to be honest I'm hooked on it, and I hate reality shows.</p>
<p>So why am I hooked?  I think it's mainly because of the people on the show.  I've followed the blogs of <a href="http://www.johnchow.com/top-affiliate-challenge-4th-of-july-edition/">John Chow</a> and Jeremy Schoemaker for quite some time and I've met Jeremy a few times now through NPMMO meetings so just seeing them on camera is fun.  As for the rest of the contestants, I didn't know who any of them were before the show (not even the apparently infamous Jonathan van Clute guy), so it's been cool to see who they are and what they can do.  I guess I think it is interesting to see how people are networked and who they are friends with.  It really shows that part of affiliate marketing is about who you know.</p>
<p>It's also pretty interesting to see how people will whine when put into a position like this. I think that team XY7 whines more than my 4 year old daughter.  It's hilarious and think that's probably why they are losing.  They pretty much screw themselves in episodes 3 and 4 because they can't play with the punches being thrown at them, and instead of stepping up to the challenge they totally whine about it.  If you do that in real life you lose too.</p>
<p>Things really got interesting in Episode 4 when Jeremy's team pulled ahead and got the #1 spot for the day, team XY7 lost another member, and team XY7 and team Toolbarn were combined.  Jeremy is apparently stepping down for a bit or indefinitely since his wife went into labor 3 weeks early and gave birth to a <a href="http://www.shoemoney.com/2008/07/05/so-much-in-a-name/">yet unnamed little girl</a>.  It will be cool to see if he comes back on the show and what his role will be.</p>
<p>Looking forward to more episodes tomorrow and all next week.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/devtrench?a=gTVtcJ"><img src="http://feeds.feedburner.com/~f/devtrench?i=gTVtcJ" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=MV6U9j"><img src="http://feeds.feedburner.com/~f/devtrench?i=MV6U9j" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=BgktPj"><img src="http://feeds.feedburner.com/~f/devtrench?i=BgktPj" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=T3UmCj"><img src="http://feeds.feedburner.com/~f/devtrench?i=T3UmCj" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=DBcKxj"><img src="http://feeds.feedburner.com/~f/devtrench?i=DBcKxj" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/devtrench/~4/327912732" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.devtrench.com/top-affiliate-challenge-episodes-two-three-and-four/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.devtrench.com/top-affiliate-challenge-episodes-two-three-and-four/</feedburner:origLink></item>
		<item>
		<title>Top Affiliate Challenge Launched Today</title>
		<link>http://feeds.feedburner.com/~r/devtrench/~3/324670169/</link>
		<comments>http://www.devtrench.com/top-affiliate-challenge-launched-today/#comments</comments>
		<pubDate>Wed, 02 Jul 2008 07:20:05 +0000</pubDate>
		<dc:creator>James Ehly</dc:creator>
		
		<category><![CDATA[Announcements]]></category>

		<guid isPermaLink="false">http://www.devtrench.com/?p=184</guid>
		<description><![CDATA[I just finished watching the first episode of TAC and I think it is going to be a pretty interesting show.  I live in Lincoln NE, where it is being filmed, so it is pretty cool to see my hometown as the backdrop for this show.
My first impressions were that I expected a little [...]]]></description>
			<content:encoded><![CDATA[<p>I just finished watching the <a href="http://topaffiliatechallenge.com/">first episode of TAC</a> and I think it is going to be a pretty interesting show.  I live in Lincoln NE, where it is being filmed, so it is pretty cool to see my hometown as the backdrop for this show.</p>
<p>My first impressions were that I expected a little bit more professional production (the opening credits were really bad), but overall the people involved and challenges they are facing are very interesting to me.  There were no affiliate marketing secrets revealed in this first episode, and I guess time will tell if it holds true that some will be. I think a major factor in this show will be the fact that a new show will air every day. The players seemed very reluctant to talk knowing that that their competitors might know their plans the very next day. </p>
<p>So we'll see how it goes, I know I'm looking forward to tomorrow at 1:00 <img src='http://www.devtrench.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/devtrench?a=FmhvHJ"><img src="http://feeds.feedburner.com/~f/devtrench?i=FmhvHJ" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=9qfbjj"><img src="http://feeds.feedburner.com/~f/devtrench?i=9qfbjj" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=n3D0Kj"><img src="http://feeds.feedburner.com/~f/devtrench?i=n3D0Kj" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=YuNdUj"><img src="http://feeds.feedburner.com/~f/devtrench?i=YuNdUj" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/devtrench?a=BHuaEj"><img src="http://feeds.feedburner.com/~f/devtrench?i=BHuaEj" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/devtrench/~4/324670169" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.devtrench.com/top-affiliate-challenge-launched-today/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.devtrench.com/top-affiliate-challenge-launched-today/</feedburner:origLink></item>
	</channel>
</rss>
