<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>benwatts.ca &#187; PHP</title>
	<atom:link href="http://benwatts.ca/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://benwatts.ca</link>
	<description>Designer and Frontend Developer in Ottawa, Canada</description>
	<lastBuildDate>Fri, 22 Jul 2011 19:00:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Unleashing SecretSantaBot</title>
		<link>http://benwatts.ca/2009/unleashing-secretsantabot/</link>
		<comments>http://benwatts.ca/2009/unleashing-secretsantabot/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 20:36:18 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[oop]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[secret santa]]></category>

		<guid isPermaLink="false">http://www.benwatts.ca/?p=522</guid>
		<description><![CDATA[About two years ago the occasion arose for a Secret Santa with people who, for whatever reason, couldn&#8217;t find themselves in the same room to draw names from a hat. Determined, I soldiered on and wrote a script to email all parties with a randomly selected name. It worked, it drives a slow trickle of [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.benwatts.ca/sandbox/secret-santa/"><img class="alignnone size-full wp-image-524" title="secretsantabot-banner" src="http://www.benwatts.ca/wp-content/uploads/2009/12/secretsantabot-banner1.jpg" alt="" width="560" height="153" /></a></p>
<p>About two years ago the occasion arose for a Secret Santa with people who, for whatever reason, couldn&#8217;t find themselves in the same room to draw names from a hat. Determined, I soldiered on and wrote a script to email all parties with a randomly selected name. It worked, it drives a slow trickle of traffic to the site every December.</p>
<p>I decided to give it a bit of an OOP makeover this year and go <em>ALL-OUT</em> and get in on the git action, too. What I have ended up with is bizarrely tacked-on front-end to an otherwise super straightforward SecretSantaBot class.</p>
<p>I&#8217;m going to set up a site in the future to forgo the need to have a web server in order to use the script. That&#8217;s not as fun, eh? For now, it&#8217;s targeted at the developer.</p>
<p><a href="http://github.com/benwatts/SecretSantaBot">Source @ Github</a> | <a href="http://www.benwatts.ca/sandbox/secret-santa/">Demo</a></p>
<p><small>Oh, I should mention that before you ream me &#8212; this is the first PHP class I&#8217;ve written, and I&#8217;m sure it&#8217;s not the most optimally written thing out there. <em>That&#8217;s what forking is for! Forking and reaming in the same sentence &#8230; </em></small></p>
]]></content:encoded>
			<wfw:commentRss>http://benwatts.ca/2009/unleashing-secretsantabot/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Redirecting Based Upon Referer</title>
		<link>http://benwatts.ca/2008/redirecting-based-upon-referer/</link>
		<comments>http://benwatts.ca/2008/redirecting-based-upon-referer/#comments</comments>
		<pubDate>Fri, 11 Apr 2008 00:44:14 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[redirect]]></category>

		<guid isPermaLink="false">http://www.rainiscold.ca/seaturtle/?p=5</guid>
		<description><![CDATA[I didn&#8217;t want to get hits from facebook for a URL that I noticed someone posted on facebook. Added this to the index file, works like a charm: if( strpos($_SERVER['HTTP_REFERER'], 'facebook.com') > 0 ){ header('Referer: http://www.facebook.com'); header('Location: http://www.facebook.com'); }]]></description>
			<content:encoded><![CDATA[<p>I didn&#8217;t want to get hits from facebook for a URL that I noticed someone posted on facebook. Added this to the index file, works like a charm:</p>
<pre lang="php">
if( strpos($_SERVER['HTTP_REFERER'], 'facebook.com') > 0 ){
	header('Referer: http://www.facebook.com');
	header('Location: http://www.facebook.com');
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://benwatts.ca/2008/redirecting-based-upon-referer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Secret Santa Script</title>
		<link>http://benwatts.ca/2007/secret-santa-script/</link>
		<comments>http://benwatts.ca/2007/secret-santa-script/#comments</comments>
		<pubDate>Sat, 15 Dec 2007 20:45:30 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[sandbox]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[secret santa]]></category>

		<guid isPermaLink="false">http://www.benwatts.ca/?p=13</guid>
		<description><![CDATA[Every year my friends and I typically have a little &#8220;Secret Santa&#8221; (we call it &#8220;Secret Satan&#8221;, but that&#8217;s neither here nor there) &#8212; you know, where you are randomly pick a person&#8217;s name out of a hat and it becomes your job to buy a present for said person. In previous years it was [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.benwatts.ca/sandbox/secret-santa/"><img class="alignnone size-full wp-image-524" title="secretsantabot-banner" src="http://www.benwatts.ca/wp-content/uploads/2009/12/secretsantabot-banner1.jpg" alt="" width="560" height="153" /></a></p>
<p>Every year my friends and I typically have a little &#8220;Secret Santa&#8221; (we call it &#8220;Secret Satan&#8221;, but that&#8217;s neither here nor there) &#8212; you know, where you are randomly pick a person&#8217;s name out of a hat and it becomes your job to buy a present for said person.</p>
<p>In previous years it was always easier because we were able to meet up to do the hat-selection. The past two years have not been so easy, due to conflicting schedules and what-not. Last year&#8217;s solution was to get someone&#8217;s mom to send out the emails.</p>
<p>This year I opted for a PHP-based solution. If you&#8217;re thinking &#8220;THAT&#8217;S AMAZING&#8221;, you are correct, it is amazing. Because of the rush I was in to make it, it&#8217;s not as user-friendly as it should be. There&#8217;s two things you need to do to get this working out of the box:</p>
<ol>
<li>Edit the array containing names and emails. This is the most critical part.</li>
<li>When you first run the script it will be in no-email mode, so you can preview the how the script might work (remember, it&#8217;s random &#8230;). Change the <strong>$noemail</strong> variable to <strong>false</strong> for it to send emails. You will NOT see who is paired up with who after debug mode is turned off.</li>
</ol>
<p>It randomly pairs people up, making sure not to pair up the same person twice, or pairing the same person. Then it sounds out the emails! It&#8217;s just that easy (I hope).</p>
<p><strong>Edit: this has been updated as of December 2009.  </strong></p>
<p><a href="http://www.benwatts.ca/sandbox/secret-santa/">Demo</a> | <a href="http://github.com/benwatts/SecretSantaBot">Source (on Github)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://benwatts.ca/2007/secret-santa-script/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

