<?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" version="2.0">

<channel>
	<title>Denham Coote</title>
	
	<link>http://www.denhamcoote.com</link>
	<description>student :: geek :: photographer :: legend</description>
	<pubDate>Thu, 27 Nov 2008 13:16:17 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/denhamcoote" type="application/rss+xml" /><item>
		<title>Getting inked!</title>
		<link>http://www.denhamcoote.com/inked</link>
		<comments>http://www.denhamcoote.com/inked#comments</comments>
		<pubDate>Fri, 07 Nov 2008 10:04:01 +0000</pubDate>
		<dc:creator>Denham Coote</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[geek]]></category>

		<category><![CDATA[idiocracy]]></category>

		<category><![CDATA[linux]]></category>

		<category><![CDATA[tattoo]]></category>

		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.denhamcoote.com/?p=119</guid>
		<description><![CDATA[Amongst a number of other uncharacteristic decisions I&#8217;ve recently made, I went off and got myself a tattoo yesterday.
Some (geeks) may recognise it right away.  For those of you that don&#8217;t, other than it being a cool design (I think so, anyway), there&#8217;s a bunch of meaning to it.
The symbol is that of Ubuntu Linux.  [...]]]></description>
			<content:encoded><![CDATA[<p>Amongst a number of other uncharacteristic decisions I&#8217;ve recently made, I went off and got myself a tattoo yesterday.</p>
<div id="attachment_120" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.denhamcoote.com/wp-content/uploads/2008/11/tat.jpg"><img class="size-medium wp-image-120" title="Tattoo" src="http://www.denhamcoote.com/wp-content/uploads/2008/11/tat-300x225.jpg" alt="Tattoo" width="300" height="225" /></a><p class="wp-caption-text">Circle of Friends</p></div>
<p>Some (geeks) may recognise it right away.  For those of you that don&#8217;t, other than it being a cool design (I think so, anyway), there&#8217;s a bunch of meaning to it.</p>
<p>The symbol is that of Ubuntu Linux.  From their website:</p>
<blockquote><p>Ubuntu is an African word meaning &#8216;Humanity to others&#8217;, or &#8216;I am what I am because of who we all are&#8217;. The Ubuntu distribution brings the spirit of Ubuntu to the software world.</p></blockquote>
<p>It&#8217;s about community, caring, sharing, acceptance, diversity, and the ideologies that the culture embraces.</p>
<p>In addition to that, I&#8217;ve gone up 10 points in a) geekiness b) coolness or c) both! Hehe.</p>
<p>The photo doesn&#8217;t quite show it off properly yet, since the light grey areas are still a little dark (and look black).  Look <a href="http://www.denhamcoote.com/tattoo.jpg" target="_self">here</a> to understand it better.</p>
<p>A big thanks to Kay from Skin Deep Tattoos who left his mark on my virgin skin.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.denhamcoote.com/inked/feed</wfw:commentRss>
		</item>
		<item>
		<title>Stormhoek promotion</title>
		<link>http://www.denhamcoote.com/stormhoek-promotion</link>
		<comments>http://www.denhamcoote.com/stormhoek-promotion#comments</comments>
		<pubDate>Mon, 27 Oct 2008 14:07:01 +0000</pubDate>
		<dc:creator>Denham Coote</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[cape town]]></category>

		<category><![CDATA[drinking]]></category>

		<category><![CDATA[facebook]]></category>

		<category><![CDATA[idiocracy]]></category>

		<category><![CDATA[promotion]]></category>

		<category><![CDATA[Stormhoek]]></category>

		<category><![CDATA[twitter]]></category>

		<category><![CDATA[web]]></category>

		<category><![CDATA[wine]]></category>

		<category><![CDATA[wordcamp]]></category>

		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.denhamcoote.com/?p=116</guid>
		<description><![CDATA[As some may recall, Stormhoek were kind enough to let us spend the day on the farm when we were down in Cape Town for WordCamp 2008.  Good food, good company and good wine! A perfect Sunday.  As if this wasn&#8217;t enough to convince me just how awesome these guys are, they are now running [...]]]></description>
			<content:encoded><![CDATA[<p>As some may recall, <a href="http://www.stormhoek.co.za/" target="_blank">Stormhoek</a> were kind enough to let us spend the day on the farm when we were down in Cape Town for WordCamp 2008.  Good food, good company and good wine! A perfect Sunday.  As if this wasn&#8217;t enough to convince me just how awesome these guys are, they are now running a <a href="http://www.stormhoek.co.za/christmas-coming-early/" target="_blank">promotion</a> where they will send wine and photos to just about anywhere in the World, to users who engage with them online.</p>
<p>I&#8217;m sure not gonna miss out on the opportunity to get myself some of their awesome wine!  (I opened my last bottle of Stormhoek last week)</p>
<p>Hope you&#8217;re all well!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.denhamcoote.com/stormhoek-promotion/feed</wfw:commentRss>
		</item>
		<item>
		<title>MobilePress</title>
		<link>http://www.denhamcoote.com/mobilepress</link>
		<comments>http://www.denhamcoote.com/mobilepress#comments</comments>
		<pubDate>Wed, 22 Oct 2008 18:09:02 +0000</pubDate>
		<dc:creator>Denham Coote</dc:creator>
		
		<category><![CDATA[WordPress]]></category>

		<category><![CDATA[mobile]]></category>

		<category><![CDATA[blog]]></category>

		<category><![CDATA[iPhone]]></category>

		<category><![CDATA[MobilePress]]></category>

		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.denhamcoote.com/?p=111</guid>
		<description><![CDATA[Today marks the release of a little project we&#8217;ve been working on for the WordPress community.
Basically, what MobilePress does is take your current WordPress blog and re-renders it when being viewed from a mobile device in more mobile-friendly way.  So, instead of hoping that your (user&#8217;s) phone&#8217;s browser is smart enough to display a site [...]]]></description>
			<content:encoded><![CDATA[<p>Today marks the release of a little project we&#8217;ve been working on for the WordPress community.</p>
<p>Basically, what <a href="http://wordpress.org/extend/plugins/mobilepress/" target="_blank">MobilePress</a> does is take your current WordPress blog and re-renders it when being viewed from a mobile device in more mobile-friendly way.  So, instead of hoping that your (user&#8217;s) phone&#8217;s browser is smart enough to display a site that was meant for a 1024&#215;768 display on a 320&#215;240 mobile display, you can now make sure it renders the way you want it to.</p>
<p>This is done as follows:</p>
<ol>
<li>Detect if the site is being accessed from a mobile device</li>
<li>If so, the plugin kicks in and determines <em>which</em> device is being used</li>
<li>We then &#8216;hijack&#8217; WordPress&#8217;s rendering, and switch to an alternate theme (one designed just for a mobile device)</li>
<li>Control is returned to WordPress, so that the rest of your site/plugins get to run, as per normal.</li>
</ol>
<p>There are a few other cool things happening here.  If you design WordPress themes, you can now design a mobile theme that matches, and not have to worry about mobile domains and custom routing.  Just activate the plugin and it takes care of the rest.</p>
<p>In addition to &#8216;generic&#8217; mobile devices, we&#8217;ve provided the ability to specify custom themes for the iPhone, Opera Mini &amp; Windows CE.  This allows for a tiered approach, allowing the designer to take advantage of a device&#8217;s capabilities, and still have a failsafe for simpler devices.</p>
<p>Some have pointed out that there are already plugins to render your site for mobile.  This is true.  Why did we choose to write our own?  Well, for one, the existing plugins just didn&#8217;t cut it.</p>
<p>The &#8216;WordPress Mobile&#8217; plugin does not pass control back to WordPress, and uses a custom, hardcoded theme.  In other words, you need to hack php to customise it.  In addition to that, the author has a bunch of sneaky ads and backlinks all over the place which will render on your blog.  Want to get rid of the ads? You&#8217;ll have to pay for that privilege.</p>
<p>WPTouch gets closer, but is geared only to the iPhone, and has a lot of hard coded elements in the code.  Also not quite up to the standards WordPress advocates.</p>
<p>MobilePress aims to provide standards-based flexibility to the designer, with no financial implications for the user.</p>
<p>Hope you guys find this useful.  Go check out the official <a href="http://mobilepress.co.za/" target="_blank">MobilePress site</a> or grab your copy directly from the WordPress repository,  <a href="http://downloads.wordpress.org/plugin/mobilepress.zip">here</a>.</p>
<p>PS: Any feedback and comment are appreciated - we will use them to improve the next release!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.denhamcoote.com/mobilepress/feed</wfw:commentRss>
		</item>
		<item>
		<title>Hard at work</title>
		<link>http://www.denhamcoote.com/hard-work</link>
		<comments>http://www.denhamcoote.com/hard-work#comments</comments>
		<pubDate>Wed, 10 Sep 2008 12:24:58 +0000</pubDate>
		<dc:creator>Denham Coote</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[drinking]]></category>

		<category><![CDATA[life]]></category>

		<category><![CDATA[office]]></category>

		<category><![CDATA[web]]></category>

		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://www.denhamcoote.com/?p=106</guid>
		<description><![CDATA[There are certain benefits to being your own boss.  Right now, I am sitting outside by the pool, under the lapa, sipping on a cold beer.  Don&#8217;t you love life?
]]></description>
			<content:encoded><![CDATA[<p>There are certain benefits to being your own boss.  Right now, I am sitting outside by the pool, under the lapa, sipping on a cold beer.  Don&#8217;t you love life?</p>
<div id="attachment_107" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.denhamcoote.com/wp-content/uploads/2008/09/image_00016.jpg"><img class="size-medium wp-image-107" title="My office" src="http://www.denhamcoote.com/wp-content/uploads/2008/09/image_00016-300x240.jpg" alt="My office" width="300" height="240" /></a><p class="wp-caption-text">My office</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.denhamcoote.com/hard-work/feed</wfw:commentRss>
		</item>
		<item>
		<title>The weekend that was - WordCamp SA 2008</title>
		<link>http://www.denhamcoote.com/wordcamp-sa-2008-2</link>
		<comments>http://www.denhamcoote.com/wordcamp-sa-2008-2#comments</comments>
		<pubDate>Tue, 26 Aug 2008 22:44:29 +0000</pubDate>
		<dc:creator>Denham Coote</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[WordPress]]></category>

		<category><![CDATA[drinking]]></category>

		<category><![CDATA[geek]]></category>

		<category><![CDATA[Jason Bagley]]></category>

		<category><![CDATA[Matt Mullenweg]]></category>

		<category><![CDATA[Project Wolf]]></category>

		<category><![CDATA[Stormhoek]]></category>

		<category><![CDATA[Tyler Reed]]></category>

		<category><![CDATA[Vincent Maher]]></category>

		<category><![CDATA[Warwick Poole]]></category>

		<category><![CDATA[Wordcampsa]]></category>

		<category><![CDATA[younique]]></category>

		<guid isPermaLink="false">http://www.denhamcoote.com/?p=98</guid>
		<description><![CDATA[What do geeks, code, blogs, Matt Mullenweg and I all have in common?  Well, for one, we were all in Cape Town this weekend for WordCamp SA.  The glue that holds it all together? WordPress.
Friday, 22nd August, 2008
WordCamp weekend kicked off with Tyler and I heading out to the airport on Friday morning at 5am, [...]]]></description>
			<content:encoded><![CDATA[<p>What do geeks, code, blogs, Matt Mullenweg and I all have in common?  Well, for one, we were all in Cape Town this weekend for <a href="http://www.wordcamp.co.za/" target="_blank">WordCamp SA</a>.  The glue that holds it all together? <a href="http://www.wordpress.org" target="_blank">WordPress</a>.</p>
<p><strong>Friday, 22nd August, 2008</strong></p>
<p>WordCamp weekend kicked off with <a href="http://www.tylerreed.co.za" target="_blank">Tyler</a> and I heading out to the airport on Friday morning at 5am, meeting <a href="http://www.vincentmaher.com" target="_blank">Vincent Maher</a> on the way.  Upon landing, we were taxied around by <a href="http://www.jasonbagley.com/" target="_blank">Jason Bagley</a>.  A few client meetings later, we made our way to the hotel we were staying at, which happened to be a mere 20 meter walk from The Wild Fig (where the event took place).</p>
<p>After dropping off our luggage, we made our way back to Cape Town International to meet <a href="http://blog.linuxinternet.org/" target="_blank">Warwick Poole</a> and <a href="http://ma.tt" target="_blank">Matt Mullenweg</a>, both of <a href="http://www.automattic.com" target="_blank">Automattic</a>.  After waiting an hour or so, Warwick came out and informed us that Matt&#8217;s bags were missing.  Fantastic!  There were still held up US side.</p>
<p>After stopping to do some essential shopping for Matt, we made our way to none other than Spur.  Not quite South African gourmet, but certainly a home-grown experience.  From there we went to the pre-un-conference geek-meet at Asoka.  I&#8217;d love to be able to link to all the people we met, but I&#8217;m afraid Google might turn on me.  Needless to say it was an awesome evening, with me introducing Matt to his first Jaeger Bomb!</p>
<p>Back at the hotel, Tyler and I worked until about 2am, sorting out last minute details, and spending a bit of time on Project Wolf.</p>
<p><strong>Saturday, 23rd August, 2008</strong></p>
<p>The event that got 100+ geeks and their laptops assembled in Cape Town: WordCamp SA 2008.  Organised by <a href="http://www.younique.co.za" target="_blank">Younique</a>, with the likes of Matt and Warwick as guest speakers, it was a day of note.</p>
<p>Kicking off at 9am, with coffee and muffins, the venue quickly filled up.  Prominent bloggers and entrepreneurs alike were crammed into the The Wild Fig.  An awesome line up of speakers kept everyone interested (and awake) throughout the day.</p>
<p>Matt is a very natural speaker.  He spoke about running a business, and making money, utilising a business model based of free software.  Warwick, also of WordPress, gave us some incredible stats about <a href="http://www.wordpress.com" target="_blank">wordpress.com</a> - its traffic and infrastructure.</p>
<p>The day, however, was not without incident.  As Tyler was giving the closing speech, I managed to knock a glass of water over into his brand new Macbook.  It&#8217;s amazing, but in those few seconds following, I was photographed more times than all the key speakers combined.  *blush*</p>
<p>That night we went off to Sinns at Wembley Square for dinner.  Sinns is the type of place that charges twice as much as Spur, serves half the amount of food, but makes it look pretty.  It wasn&#8217;t bad at all, though.</p>
<p><a href="http://www.wonderingi.com/" target="_blank">Chris Rawlinson</a>, of <a href="http://www.stormhoek,co,za" target="_blank">Stormhoek</a> (who were kind enough to sponsor wine for the day) invited us back to his place after dinner.  A special word of thanks to him for putting up with us until 5am, even after having parts of his apartment demolished.</p>
<p><strong>Sunday, 24th August, 2008</strong></p>
<p>I managed to surface at 10:30.  I felt like ass.  Now, normally, I do not suffer the after effects of consuming too much alcohol.  This day was different.  I blame Matt.  Those Mohitos (sp) were <em>lank dodgy, oke</em>.  After dragging my sorry ass out of bed and getting showered, the only logical thing to do was to go to KFC and buy out half their shop.  After buying enough for 17 people, Tyler and I were happy that we had enough for the 2 of us.  We were also kind enough to share with the other guys when we got back to the hotel.</p>
<p>From there, we made our way to Stormhoek Wine Estate.  Graham Knox was simply awesome, giving us a private tour of the farm, and treating us to a wonderful lunch.  I have never had so many open bottles of wine in one sitting.  Stormhoek is an estate that is full of history, and really takes pride in the wine it produces.  I shall certainly be buying many many bottles from them in the future.</p>
<p>After a great day out in Wellington, Jason once again taxied Tyler and I back to the airport for the last flight back to Joburg.</p>
<p>A very big thank you goes out to Tyler, who is responsible for the weekend.  Though he will try pass credit on to other people, WordCamp would not have happened without him.  His guiding hand, his generosity, his huge personality and his ability to bring people together and enjoy themselves.  Thank you, mate!</p>
<p>This post is VERY short compared to the sum of the events of the weekend.  I think the best suggestion I can make is that you don&#8217;t miss next year&#8217;s!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.denhamcoote.com/wordcamp-sa-2008-2/feed</wfw:commentRss>
		</item>
		<item>
		<title>WordCamp SA 2008</title>
		<link>http://www.denhamcoote.com/wordcamp-sa-2008</link>
		<comments>http://www.denhamcoote.com/wordcamp-sa-2008#comments</comments>
		<pubDate>Thu, 21 Aug 2008 14:24:43 +0000</pubDate>
		<dc:creator>Denham Coote</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[cape town]]></category>

		<category><![CDATA[geek]]></category>

		<category><![CDATA[Tyler Reed]]></category>

		<category><![CDATA[web]]></category>

		<category><![CDATA[WordPress]]></category>

		<category><![CDATA[younique]]></category>

		<guid isPermaLink="false">http://www.denhamcoote.com/?p=94</guid>
		<description><![CDATA[On Saturday I&#8217;ll be attending WordCamp SA 2008.  For those who don&#8217;t know, WordCamp is a gathering (or is it gaggle?) of geeks who all have one thing in common - A passion for WordPress.
What is WordPress?  For my even less-informed friends, WordPress is primarily a blogging platform, which is very extensible.  My site is [...]]]></description>
			<content:encoded><![CDATA[<p>On Saturday I&#8217;ll be attending <a href="http://www.wordcamp.co.za/" target="_blank">WordCamp SA 2008</a>.  For those who don&#8217;t know, WordCamp is a gathering (or is it gaggle?) of geeks who all have one thing in common - A passion for WordPress.</p>
<p>What is WordPress?  For my even less-informed friends, WordPress is primarily a blogging platform, which is very extensible.  My site is built on top of WordPress.</p>
<p>The event has been organised by <a href="http://www.younique.co.za" target="_blank">Younique</a>, and takes place at The Wild Fig.  With a diverse array of guest speakers, including WordPress founder Matt Mullenweg, it&#8217;s sure to be an informative and enlightening day!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.denhamcoote.com/wordcamp-sa-2008/feed</wfw:commentRss>
		</item>
		<item>
		<title>xkcd: A few favourites - Part 3</title>
		<link>http://www.denhamcoote.com/xkcd-favourites-part-3</link>
		<comments>http://www.denhamcoote.com/xkcd-favourites-part-3#comments</comments>
		<pubDate>Thu, 07 Aug 2008 19:45:10 +0000</pubDate>
		<dc:creator>Denham Coote</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.denhamcoote.com/?p=53</guid>
		<description><![CDATA[


]]></description>
			<content:encoded><![CDATA[<p><a href="http://xkcd.com/327/" target="_blank"><img class="aligncenter size-full wp-image-45" title="exploits_of_a_mom" src="http://www.denhamcoote.com/wp-content/uploads/2008/07/exploits_of_a_mom.png" alt="" width="499" height="153" /></a></p>
<p><a href="http://xkcd.com/85/" target="_blank"><img class="aligncenter size-full wp-image-88" title="paths" src="http://www.denhamcoote.com/wp-content/uploads/2008/08/paths.jpg" alt="" width="500" height="562" /></a></p>
<p style="text-align: center;"><a href="http://xkcd.com/74/" target="_blank"><img class="size-full wp-image-89 aligncenter" title="su_doku" src="http://www.denhamcoote.com/wp-content/uploads/2008/08/su_doku.jpg" alt="" width="300" height="378" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.denhamcoote.com/xkcd-favourites-part-3/feed</wfw:commentRss>
		</item>
		<item>
		<title>PHP howto - Sanitize database inputs</title>
		<link>http://www.denhamcoote.com/php-howto-sanitize-database-inputs</link>
		<comments>http://www.denhamcoote.com/php-howto-sanitize-database-inputs#comments</comments>
		<pubDate>Thu, 24 Jul 2008 13:54:23 +0000</pubDate>
		<dc:creator>Denham Coote</dc:creator>
		
		<category><![CDATA[php]]></category>

		<category><![CDATA[databsae]]></category>

		<category><![CDATA[geek]]></category>

		<category><![CDATA[howto]]></category>

		<category><![CDATA[MySQL]]></category>

		<category><![CDATA[programming]]></category>

		<category><![CDATA[security]]></category>

		<category><![CDATA[tutorial]]></category>

		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.denhamcoote.com/?p=64</guid>
		<description><![CDATA[When accepting data from a user, any data at all, it should be sanitized before making its way to your database.
What does this mean? Well, for one, you&#8217;re going to inspect the data and make sure that it doesn&#8217;t contain any malicious code such as ill-intentioned javascript.  Another is to prepare the data so that [...]]]></description>
			<content:encoded><![CDATA[<p>When accepting data from a user, any data at all, it should be sanitized before making its way to your database.</p>
<p>What does this mean? Well, for one, you&#8217;re going to inspect the data and make sure that it doesn&#8217;t contain any malicious code such as ill-intentioned javascript.  Another is to prepare the data so that when it gets added to your insert/update SQL it doesn&#8217;t break the SQL (or do other nasty actions). Otherwise know as a SQL injection attack.</p>
<p>The technical details of the types of attacks we&#8217;re protecting against are a bit out of the scope of this post, but there are numerous resources available which will explain far better than I am able to.</p>
<p>After a form has been submitted (via get or post) it gets stored in the global array $_GET or $_POST.  Once we have this data, we can and should do a bunch of things to it, such as:</p>
<h3>Stripping out malicious code</h3>
<p>We&#8217;ll scan through the input, searching for anything that shouldn&#8217;t be there, like html code, &lt;script&gt; tags, etc.</p>

<div class="wp_syntax"><div class="code"><pre class="php-brief"><span style="color: #eeeeec;">&lt;?</span>
<span style="color: #eeeeec; font-weight: bold;">function</span> cleanInput<span style="color: #d3d7cf;">&#40;</span><span style="color: #729fcf;">$input</span><span style="color: #d3d7cf;">&#41;</span> <span style="color: #d3d7cf;">&#123;</span>
&nbsp;
<span style="color: #729fcf;">$search</span> <span style="color: #eeeeec;">=</span> <span style="color: #eeeeec;">array</span><span style="color: #d3d7cf;">&#40;</span>
    <span style="color: #edd400;">'@&lt;script[^&gt;]*?&gt;.*?&lt;/script&gt;@si'</span><span style="color: #eeeeec;">,</span>   <span style="color: #888a85; font-style: italic;">// Strip out javascript</span>
    <span style="color: #edd400;">'@&lt;[<span style="color: #edd400; font-weight: bold;">\/</span><span style="color: #edd400; font-weight: bold;">\!</span>]*?[^&lt;&gt;]*?&gt;@si'</span><span style="color: #eeeeec;">,</span>            <span style="color: #888a85; font-style: italic;">// Strip out HTML tags</span>
    <span style="color: #edd400;">'@&lt;style[^&gt;]*?&gt;.*?&lt;/style&gt;@siU'</span><span style="color: #eeeeec;">,</span>    <span style="color: #888a85; font-style: italic;">// Strip style tags properly</span>
    <span style="color: #edd400;">'@&lt;![<span style="color: #edd400; font-weight: bold;">\s</span><span style="color: #edd400; font-weight: bold;">\S</span>]*?--[ <span style="color: #edd400; font-weight: bold;">\t</span><span style="color: #edd400; font-weight: bold;">\n</span><span style="color: #edd400; font-weight: bold;">\r</span>]*&gt;@'</span>         <span style="color: #888a85; font-style: italic;">// Strip multi-line comments</span>
<span style="color: #d3d7cf;">&#41;</span><span style="color: #eeeeec;">;</span>
&nbsp;
    <span style="color: #729fcf;">$output</span> <span style="color: #eeeeec;">=</span> <span style="color: #eeeeec;">preg_replace</span><span style="color: #d3d7cf;">&#40;</span><span style="color: #729fcf;">$search</span><span style="color: #eeeeec;">,</span> <span style="color: #edd400;">''</span><span style="color: #eeeeec;">,</span> <span style="color: #729fcf;">$input</span><span style="color: #d3d7cf;">&#41;</span><span style="color: #eeeeec;">;</span>
    <span style="color: #eeeeec;">return</span> <span style="color: #729fcf;">$output</span><span style="color: #eeeeec;">;</span>
<span style="color: #d3d7cf;">&#125;</span>
<span style="color: #eeeeec; font-weight: bold;">?&gt;</span></pre></div></div>

<h3>&#8217;slashing</h3>
<p>This part can sometimes get tricky, but not to worry, the code&#8217;s not too bad.  Basically we&#8217;re adding a backslash before any of the following: <em>&#8216;</em> (single-quote), <em>&#8220;</em> (double quote), <em>\</em> (backslash) and <em>NULL</em> characters.  Depending on your server configuration, there are a bunch of ways of getting this done.  PHP has something called magic_quotes, which does this automatically.  Note, however, that as of PHP 6 this feature has been deprecated and removed.  Another PHP function, addslashes(), is the manual version of magic_quotes.  addslashes(&#8221;Where&#8217;s Wally&#8221;); will return &#8220;Where\&#8217;s Wally&#8221;.  A better option, if your server supports it, is mysql_real_escape_string().  It performs pretty much the same function, but is <a href="http://shiflett.org/blog/2006/jan/addslashes-versus-mysql-real-escape-string" target="_blank">apparently better</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="php-brief"><span style="color: #eeeeec;">&lt;?</span>
<span style="color: #eeeeec; font-weight: bold;">function</span> sanitize<span style="color: #d3d7cf;">&#40;</span><span style="color: #729fcf;">$input</span><span style="color: #d3d7cf;">&#41;</span> <span style="color: #d3d7cf;">&#123;</span>
    <span style="color: #eeeeec;">if</span> <span style="color: #d3d7cf;">&#40;</span><span style="color: #eeeeec;">is_array</span><span style="color: #d3d7cf;">&#40;</span><span style="color: #729fcf;">$input</span><span style="color: #d3d7cf;">&#41;</span><span style="color: #d3d7cf;">&#41;</span> <span style="color: #d3d7cf;">&#123;</span>
        <span style="color: #eeeeec;">foreach</span><span style="color: #d3d7cf;">&#40;</span><span style="color: #729fcf;">$input</span> <span style="color: #eeeeec;">as</span> <span style="color: #729fcf;">$var</span><span style="color: #eeeeec;">=&gt;</span><span style="color: #729fcf;">$val</span><span style="color: #d3d7cf;">&#41;</span> <span style="color: #d3d7cf;">&#123;</span>
            <span style="color: #729fcf;">$output</span><span style="color: #d3d7cf;">&#91;</span><span style="color: #729fcf;">$var</span><span style="color: #d3d7cf;">&#93;</span> <span style="color: #eeeeec;">=</span> sanitize<span style="color: #d3d7cf;">&#40;</span><span style="color: #729fcf;">$val</span><span style="color: #d3d7cf;">&#41;</span><span style="color: #eeeeec;">;</span>
        <span style="color: #d3d7cf;">&#125;</span>
    <span style="color: #d3d7cf;">&#125;</span>
    <span style="color: #eeeeec;">else</span> <span style="color: #d3d7cf;">&#123;</span>
        <span style="color: #eeeeec;">if</span> <span style="color: #d3d7cf;">&#40;</span><span style="color: #eeeeec;">get_magic_quotes_gpc</span><span style="color: #d3d7cf;">&#40;</span><span style="color: #d3d7cf;">&#41;</span><span style="color: #d3d7cf;">&#41;</span> <span style="color: #d3d7cf;">&#123;</span>
            <span style="color: #729fcf;">$input</span> <span style="color: #eeeeec;">=</span> <span style="color: #eeeeec;">stripslashes</span><span style="color: #d3d7cf;">&#40;</span><span style="color: #729fcf;">$input</span><span style="color: #d3d7cf;">&#41;</span><span style="color: #eeeeec;">;</span>
        <span style="color: #d3d7cf;">&#125;</span>
        <span style="color: #729fcf;">$input</span>  <span style="color: #eeeeec;">=</span> cleanInput<span style="color: #d3d7cf;">&#40;</span><span style="color: #729fcf;">$input</span><span style="color: #d3d7cf;">&#41;</span><span style="color: #eeeeec;">;</span>
        <span style="color: #729fcf;">$output</span> <span style="color: #eeeeec;">=</span> <span style="color: #eeeeec;">mysql_real_escape_string</span><span style="color: #d3d7cf;">&#40;</span><span style="color: #729fcf;">$input</span><span style="color: #d3d7cf;">&#41;</span><span style="color: #eeeeec;">;</span>
    <span style="color: #d3d7cf;">&#125;</span>
    <span style="color: #eeeeec;">return</span> <span style="color: #729fcf;">$output</span><span style="color: #eeeeec;">;</span>
<span style="color: #d3d7cf;">&#125;</span>
<span style="color: #eeeeec; font-weight: bold;">?&gt;</span></pre></div></div>

<p>To use, we simply pass any input to the function.  The function works on single strings, as well as deep arrays.</p>

<div class="wp_syntax"><div class="code"><pre class="php-brief"><span style="color: #eeeeec;">&lt;?</span>
<span style="color: #729fcf;">$bad_string</span> <span style="color: #eeeeec;">=</span> <span style="color: #edd400;">&quot;Hi! &lt;script src='http://www.evilsite.com/bad_script.js'&gt;&lt;/script&gt; It's a good day!&quot;</span><span style="color: #eeeeec;">;</span>
&nbsp;
<span style="color: #729fcf;">$_POST</span> <span style="color: #eeeeec;">=</span> sanitize<span style="color: #d3d7cf;">&#40;</span><span style="color: #729fcf;">$_POST</span><span style="color: #d3d7cf;">&#41;</span><span style="color: #eeeeec;">;</span>
<span style="color: #729fcf;">$_GET</span>  <span style="color: #eeeeec;">=</span> sanitize<span style="color: #d3d7cf;">&#40;</span><span style="color: #729fcf;">$_GET</span><span style="color: #d3d7cf;">&#41;</span><span style="color: #eeeeec;">;</span>
<span style="color: #729fcf;">$good_string</span> <span style="color: #eeeeec;">=</span> sanitize<span style="color: #d3d7cf;">&#40;</span><span style="color: #729fcf;">$bad_string</span><span style="color: #d3d7cf;">&#41;</span><span style="color: #eeeeec;">;</span>
<span style="color: #888a85; font-style: italic;">// $good_string returns &quot;Hi! It\'s a good day!&quot;</span>
<span style="color: #eeeeec; font-weight: bold;">?&gt;</span></pre></div></div>

<h3>Typecasting</h3>
<p>Making sure that the data we&#8217;re inserting matches the expected type;  i.e, someone&#8217;s age should be received as an integer value, and not a string.</p>

<div class="wp_syntax"><div class="code"><pre class="php-brief"><span style="color: #eeeeec;">&lt;?</span>
<span style="color: #729fcf;">$age</span> <span style="color: #eeeeec;">=</span> <span style="color: #d3d7cf;">&#40;</span>int<span style="color: #d3d7cf;">&#41;</span> <span style="color: #729fcf;">$_GET</span><span style="color: #d3d7cf;">&#91;</span><span style="color: #edd400;">'age'</span><span style="color: #d3d7cf;">&#93;</span><span style="color: #eeeeec;">;</span>
<span style="color: #eeeeec; font-weight: bold;">?&gt;</span></pre></div></div>

<p>This is a very gentle introduction to sanitizing your database input, and I would certainly recommend that you do a lot more research on these methods in order to use them correctly in your given environment.</p>
<p>That’s it for today.  If you found this useful, of would like to improve it, comments are always appreciated!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.denhamcoote.com/php-howto-sanitize-database-inputs/feed</wfw:commentRss>
		</item>
		<item>
		<title>Update: Hunting for the ideal laptop</title>
		<link>http://www.denhamcoote.com/update-hunting-ideal-laptop</link>
		<comments>http://www.denhamcoote.com/update-hunting-ideal-laptop#comments</comments>
		<pubDate>Mon, 14 Jul 2008 09:08:32 +0000</pubDate>
		<dc:creator>Denham Coote</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[computer]]></category>

		<category><![CDATA[Dell]]></category>

		<category><![CDATA[geek]]></category>

		<category><![CDATA[hardware]]></category>

		<category><![CDATA[laptop]]></category>

		<guid isPermaLink="false">http://www.denhamcoote.com/?p=46</guid>
		<description><![CDATA[Pricing on the Dell Studio 17 is available.  The Studio 17 looks like a great machine.  The pricing is even better!  It sells for less than the Vostro, looks nicer, and has more features. Awesome.
I&#8217;ve ordered the following:
Intel Core 2 Duo T9300 (2.5 GHz, 800 MHz FSB, 6 MB L2 Cache)
4096MB 667MHz [...]]]></description>
			<content:encoded><![CDATA[<p>Pricing on the Dell Studio 17 is available.  The Studio 17 looks like a great machine.  The pricing is even better!  It sells for less than the Vostro, looks nicer, and has more features. Awesome.</p>
<p>I&#8217;ve ordered the following:</p>
<blockquote><p>Intel Core 2 Duo T9300 (2.5 GHz, 800 MHz FSB, 6 MB L2 Cache)<br />
4096MB 667MHz Dual Channel DDR2 SDRAM [2x2048]<br />
17.0&#8243; Widescreen WUXGA+ CCFL (1920&#215;1200) TFT Display with TrueLife<br />
160GB Free Fall Sensor (7200RPM) Hard Drive<br />
8X DVD+/-RW Drive<br />
256MB ATI Mobility RADEON HD 3650<br />
9-cell 87 WHr Lithium Ion battery<br />
Biometric Fingerprint Reader<br />
Wireless 1510 Half Mini Card (802.11n)<br />
Wireless 370 Bluetooth Module<br />
AVerMedia AVerTV Hybrid NanoExpress DVB-T TV Tuner<br />
2.0 Mega pixel Integrated Web Camera<br />
Travel Remote Control Express Card</p></blockquote>
<p>I can&#8217;t wait for it to arrive!</p>
<p><a href="http://www.denhamcoote.com/wp-content/uploads/2008/07/laptop_studio_17_design5.jpg"><img class="size-full wp-image-56 alignnone" title="Studio 17" src="http://www.denhamcoote.com/wp-content/uploads/2008/07/laptop_studio_17_design5.jpg" alt="" width="284" height="308" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.denhamcoote.com/update-hunting-ideal-laptop/feed</wfw:commentRss>
		</item>
		<item>
		<title>xkcd: A few favourites - Part 2</title>
		<link>http://www.denhamcoote.com/xkcd-favourites-part-2</link>
		<comments>http://www.denhamcoote.com/xkcd-favourites-part-2#comments</comments>
		<pubDate>Fri, 11 Jul 2008 08:21:53 +0000</pubDate>
		<dc:creator>Denham Coote</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[debauchery]]></category>

		<category><![CDATA[facebook]]></category>

		<category><![CDATA[geek]]></category>

		<category><![CDATA[humour]]></category>

		<category><![CDATA[sex]]></category>

		<category><![CDATA[xkcd]]></category>

		<guid isPermaLink="false">http://www.denhamcoote.com/?p=41</guid>
		<description><![CDATA[




]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://xkcd.com/275/" target="_blank"><img class="size-full wp-image-42" title="thoughts" src="http://www.denhamcoote.com/wp-content/uploads/2008/07/thoughts.png" alt="" width="350" height="369" /></a></p>
<p style="text-align: center;">
<p style="text-align: center;"><a href="http://xkcd.com/276/" target="_blank"><img class="size-full wp-image-43" title="fixed_width" src="http://www.denhamcoote.com/wp-content/uploads/2008/07/fixed_width.png" alt="" width="350" height="486" /></a></p>
<p style="text-align: center;">
<p style="text-align: center;"><a href="http://xkcd.com/300/" target="_blank"><img class="aligncenter size-full wp-image-44" title="'Here, I'll put my number in your cell pho -- wait, why is it already here?'" src="http://www.denhamcoote.com/wp-content/uploads/2008/07/facebook.png" alt="" width="342" height="544" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.denhamcoote.com/xkcd-favourites-part-2/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
