<?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>Undercrank &#187; PHP</title>
	<atom:link href="http://undercrank.com/posts/tagged/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://undercrank.com</link>
	<description></description>
	<lastBuildDate>Tue, 06 Jul 2010 18:05:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Yahoo! Web Services news over Atom</title>
		<link>http://undercrank.com/posts/2005/03/yahoo-web-services-news-over-atom/</link>
		<comments>http://undercrank.com/posts/2005/03/yahoo-web-services-news-over-atom/#comments</comments>
		<pubDate>Mon, 28 Mar 2005 00:41:19 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Atom]]></category>
		<category><![CDATA[Atom Enabled]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[news syndication]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[RSS]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[Yahoo!]]></category>
		<category><![CDATA[Yahoo! News]]></category>

		<guid isPermaLink="false">http://undercrank.com/?p=91</guid>
		<description><![CDATA[aka: "When you realise Yahoo! already serve their news over RSS..."
 <a href="http://undercrank.com/posts/2005/03/yahoo-web-services-news-over-atom/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Well, like a dork, I didn&#8217;t actually realise that Yahoo! News already offered up the whole <a href="http://jeremy.zawodny.com/blog/archives/001001.html" title="Yahoo! News Search via RSS">RSS feeds for news keywords</a>  thing when I started.  However, the fun thing of course with the <a href="http://developer.yahoo.net">API</a> that Yahoo! are offering is that it doesn&#8217;t take a whole lot of time to create another script that dishes out the same thing in another &#8216;rival&#8217; <a href="http://www.atomenabled.org">syndication format</a>:</p>
<p><strong>Atom enabled Yahoo! web feeds examples</strong></p>
<ul>
<li><a href="http://undercrank.com/yahoo/atom/news/3D+Animation">3D Animation</a></li>
<li><a href="http://undercrank.com/yahoo/atom/news/The+Simpsons">The Simpsons</a></li>
<li><a href="http://undercrank.com/yahoo/atom/news/Tony+Hawk">Tony Hawk</a></li>
<li><a href="http://undercrank.com/yahoo/atom/news/Nintendo">Nintendo</a></li>
</ul>
<p>The syntax of the URL is almost identical to that of the RSS feed <tt>http://undercrank.com/yahoo/atom/news/<var>&laquo;keywords&raquo;</var></tt> (the equivalent RSS version would be <tt>http://undercrank.com/yahoo/rss/news/<var>&laquo;keywords&raquo;</var></tt>.  This is a slight change to the previous syntax posted, but the old format is still perfectly valid and won&#8217;t break for those already using it.</p>
<p>As <a href="http://undercrank.com/posts/05/03/yahoo-web-services-news-over-rss" class="internal">before</a>, the feed <a href="http://feedvalidator.org/check.cgi?url=http%3A%2F%2Fundercrank.com%2Fyahoo%2Fatom%2Fnews%2Ftesting">validates nicely</a> has good friendly HTTP caching facilities built in, as as a special bonus it conforms to the <a href="http://www.taguri.org/">Tag URI</a> recommendations pretty well too.</p>
<p>Use is made of the extended Author tags for each article, and support for multiple languages for each entry is available &#8211; although it appears that Yahoo! returns &#8220;en&#8221; as the language for everything, even, if it&#8217;s not.</p>
<p>Finally, I&#8217;ll post up the source once I&#8217;m convinced I&#8217;m doing everything the &#8216;right&#8217; way.</p>
]]></content:encoded>
			<wfw:commentRss>http://undercrank.com/posts/2005/03/yahoo-web-services-news-over-atom/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Yahoo! Web Services news over RSS</title>
		<link>http://undercrank.com/posts/2005/03/yahoo-web-services-news-over-rss/</link>
		<comments>http://undercrank.com/posts/2005/03/yahoo-web-services-news-over-rss/#comments</comments>
		<pubDate>Wed, 23 Mar 2005 19:42:17 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[RSS]]></category>
		<category><![CDATA[RSS2.0]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[Yahoo!]]></category>
		<category><![CDATA[YWS]]></category>

		<guid isPermaLink="false">http://undercrank.com/?p=90</guid>
		<description><![CDATA[I've put together a small project that will create an dynamic RSS 2.0 feed based on the Yahoo! News Search hooks.
 <a href="http://undercrank.com/posts/2005/03/yahoo-web-services-news-over-rss/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Excited by the prospect of a reasonably usable search API being made available by Yahoo!, I&#8217;ve put together a small project that will create an dynamic RSS 2.0 feed based on the Yahoo! News Search hooks.</p>
<p>The feed <a href="http://feedvalidator.org/check.cgi?url=http%3A%2F%2Fundercrank.com%2Fyahoo%2Frss%2Fnews%2Ftesting">validates nicely</a>, and also deals well with the tests created by <a href="http://www.kafsemo.org/hacks/#unpolluted">Unpolluted</a>; it has GZip handling, HTTP Expires, Last-Modified, ETag and If-None-Match support built-in.</p>
<p>The usage is very simple &#8211; point your aggregator of choice at <tt>http://undercrank.com/yahoo/rss/news/<var>KEYWORD</var></tt>, replacing KEYWORD with your appropriate search term.  Some examples are given below:</p>
<ul>
<li><a href="http://undercrank.com/yahoo/rss/news/AFC+Wimbledon">AFC Wimbledon</a></li>
<li><a href="http://undercrank.com/yahoo/rss/news/Tony+Blair">Tony Blair</a></li>
<li><a href="http://undercrank.com/yahoo/rss/news/Iraq">Iraq</a></li>
<li><a href="http://undercrank.com/yahoo/rss/news/Wayne+Rooney">Wayne Rooney</a></li>
</ul>
<p>I&#8217;ll release the source when I&#8217;ve tidied it up a bit so you can host it on your own boxes, but feel free to try it here for the time being.</p>
]]></content:encoded>
			<wfw:commentRss>http://undercrank.com/posts/2005/03/yahoo-web-services-news-over-rss/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>ALA&#8217;s PHP Switcher revisited</title>
		<link>http://undercrank.com/posts/2004/05/alas-php-switcher-revisited/</link>
		<comments>http://undercrank.com/posts/2004/05/alas-php-switcher-revisited/#comments</comments>
		<pubDate>Wed, 19 May 2004 12:59:39 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[A List Apart]]></category>
		<category><![CDATA[Chris Clark]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Jeffrey Zeldman]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://undercrank.com/?p=67</guid>
		<description><![CDATA[Recently, the webzine A List Apart published an article by Chris Clark that demonstrated stylesheet switching using PHP.  However, the code used won't work on some recent installations of PHP.
 <a href="http://undercrank.com/posts/2004/05/alas-php-switcher-revisited/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Recently, the webzine <a href="http://www.alistapart.com/">A List Apart</a> published an article by <a href="http://www.decaffeinated.org"><cite>Chris Clark</cite></a> that demonstrated <a href="http://www.alistapart.com/articles/phpswitch/" title="Build a PHP Switcher">stylesheet switching using PHP</a>.</p>
<p>The technique works all fine and dandy unless you&#8217;re using a more recent installation that (sensibly) doesn&#8217;t have <a href="http://ch2.php.net/manual/en/configuration.directives.php#ini.register-globals">register_globals</a> set, whereupon nothing much happens at all.</p>
<p>Fortunately, a couple of easy modifications script using the <a href="http://ch2.php.net/reserved.variables">predefined variables</a> syntax now in use since PHP 4.1.0 will take care of this.</p>
<p>First up, the code in &#8220;STAGE ONE: Setting styles&#8221; for the <tt>switcher.php</tt> file should read:</p>
<p><code><br />
&lt;?php<br />
<var>setcookie</var>(<samp>"sitestyle"</samp>, <var>$_GET</var><samp>["set"]</samp>, <var>time</var>() + <samp>31536000</samp>, <samp>"/"</samp>, <samp>"yourdomain.com"</samp>, 0);<br />
<var>header</var>(<samp>"Location: $HTTP_REFERER"</samp>);<br />
?&gt;<br />
</code></p>
<p>Secondly, the code in &#8220;STAGE TWO: Detecting styles&#8221; should be:</p>
<p><code><br />
&lt;link <var>rel</var>=<samp>"stylesheet"</samp> <var>type</var>=<samp>"text/css"</samp> <var>media</var>=<samp>"screen"</samp> <var>title</var>=<samp>"User<br />
Defined Style"</samp> <var>href</var>="&lt;?php echo <var>isset</var>(<var>$_COOKIE</var><samp>['sitestyle']</samp>) ? <var>$_COOKIE</var><samp>['sitestyle']</samp> : 'defaultstyle' ?&gt;.css" /&gt;<br />
</code></p>
<p>And that should be just about it.</p>
]]></content:encoded>
			<wfw:commentRss>http://undercrank.com/posts/2004/05/alas-php-switcher-revisited/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP, RSS and del.icio.us</title>
		<link>http://undercrank.com/posts/2004/02/php-rss-and-delicious/</link>
		<comments>http://undercrank.com/posts/2004/02/php-rss-and-delicious/#comments</comments>
		<pubDate>Mon, 16 Feb 2004 16:08:44 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[del.icio.us]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[RSS]]></category>
		<category><![CDATA[URL]]></category>
		<category><![CDATA[UTF-8]]></category>
		<category><![CDATA[XHTML]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://undercrank.com/?p=49</guid>
		<description><![CDATA[Things to remember when doing dumb things like moving your site to PHP just to get a cool RSS feed.
 <a href="http://undercrank.com/posts/2004/02/php-rss-and-delicious/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Things to remember when doing dumb things like moving your site to <acronym title="PHP: Hypertext Preprocessor">PHP</acronym> just to get a cool <acronym title="Really Simple Syndication">RSS</acronym> feed:</p>
<dl>
<dt><acronym title="eXtensible Markup Language">XML</acronym> declarations in <acronym title="eXtensible HyperText Markup Language">XHTML</acronym> 1.1</dt>
<dd>
<p>Loons like me who set up with an XHTML 1.1 DOCTYPE declaration also need an appropriate XML declaration at the start of the document too:</p>
<p><code>&lt;?xml version="1.0" charset="UTF-8"?&gt;</code></p>
<p>Putting this into a PHP file causes the server to blindly assume that that must be PHP code and (duh) falls over at the first hurdle.  There seems to be a multitude of <a href="http://www.the-emperor.org/wiki/xml_declaration_and_php/">ways around this</a>, but the one that worked for me was the simplest:</p>
<p><code>&lt;?php <samp>echo</samp> "&lt;?xml version=\"1.0\" charset=\"UTF-8\"?&gt;</code></p>
</dd>
<dt>Fixing broken URL&#8217;s for extinct .html pages</dt>
<dd>
<p>At first, I toyed with the idea of some rules in the <code><var>httpd.conf</var></code> file but frankly I couldn&#8217;t be arsed.</p>
<p>In the event, I wrote a custom 404 ErrorDocument that looks at the <code><var>REQUEST_URI</var></code>, has a look to see if it&#8217;s got the word &#8220;archives&#8221; in it, and if so, do a quick search and replace job on it.  Something like:</p>
<p>
<code><br />
if (<samp>strstr</samp>(<var>$REQUEST_URI</var>, archives)) {<br />
&nbsp;&nbsp;<var>$oldpage</var> = <var>$REQUEST_URI</var>;<br />
&nbsp;&nbsp;<var>$newpage</var> = <samp>ereg_replace</samp>(".html", ".php", <var>$oldpage</var>);<br />
}<br />
</code>
</p>
<p>If I were I being a good person, I&rsquo;d check the local file system for the presence of the document, but in this instance, I know the documents are there for sure and so I don&#8217;t really care too much.</p>
</dd>
<dt>Escaping URL&#8217;s from del.icio.us feeds</dt>
<dd>
<p>And just as you think it&#8217;s all wrapped up&#8230; the <acronym title="World Wide Web Consortium">W3C</acronym> Validator decided to have a jolly good moan about the occasional <acronym title="Uniform Resource Locator">URL</acronym> I was pulling in from the <a href="http://del.icio.us/rss/undercrank" title="Undercrank links RSS feed powered by del.icio.us">del.icio.us RSS feed</a> that had unescaped ampersands in it.  Again, PHP and <abbr title="Regular Expression">regex</abbr> functions sorted that one out (I&#8217;m using the excellent<br />
<a href="http://magpierss.sourceforge.net" title="Magpie RSS">Magpie RSS</a> to take care of parsing the feeds otherwise):</p>
<p>
<code><var>$href</var> = <samp>ereg_replace</samp>("&amp;", "&amp;amp;", <var>$item['link']</var>);</code>
</p>
</dd>
</dl>
]]></content:encoded>
			<wfw:commentRss>http://undercrank.com/posts/2004/02/php-rss-and-delicious/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Storing the PHP session ID in a form</title>
		<link>http://undercrank.com/posts/2004/01/storing-the-php-session-id-in-a-form/</link>
		<comments>http://undercrank.com/posts/2004/01/storing-the-php-session-id-in-a-form/#comments</comments>
		<pubDate>Thu, 22 Jan 2004 19:29:34 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHPSESSID]]></category>
		<category><![CDATA[session]]></category>
		<category><![CDATA[SID]]></category>

		<guid isPermaLink="false">http://undercrank.com/?p=42</guid>
		<description><![CDATA[A tiny code snippet that helps with accessing <var>SID</var> and <var>PHPSESSID</var> in form submissions.
 <a href="http://undercrank.com/posts/2004/01/storing-the-php-session-id-in-a-form/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve chosen not to use cookies for PHP sessions, you can append the <var>SID</var> of the session to a URL link in order to keep track of it.</p>
<p>If you want to keep track of <var>SID</var> on page that&#8217;s accessed by a form submission, the little code snippet below will strip out the <var>PHPSESSID=</var> from the variable for use as a hidden form value:<br />
<code><br />
$sid = substr(SID, (strpos(SID, "=") + 1), strlen(SID));<br />
</code></p>
<p>And then to use it in your form, add the code below somewhere:<br />
<code><br />
&lt;input type="hidden" name="PHPSESSID" value="&lt;?= $sid ?&gt;" /&gt;<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://undercrank.com/posts/2004/01/storing-the-php-session-id-in-a-form/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
