<?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"
	>

<channel>
	<title>danforys.com &#187; php</title>
	<atom:link href="http://www.danforys.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.danforys.com</link>
	<description>Dan is a web developer in London. He is interested in all things Internet, Linux and Mac.</description>
	<pubDate>Wed, 06 Aug 2008 15:28:03 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language>en</language>
			<item>
		<title>Unsetting http headers in PHP</title>
		<link>http://www.danforys.com/2008/08/06/unsetting-http-headers-in-php/</link>
		<comments>http://www.danforys.com/2008/08/06/unsetting-http-headers-in-php/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 15:28:03 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
		
		<category><![CDATA[browsers]]></category>

		<category><![CDATA[php]]></category>

		<category><![CDATA[header]]></category>

		<category><![CDATA[ie7]]></category>

		<guid isPermaLink="false">http://www.danforys.com/?p=40</guid>
		<description><![CDATA[I just came across a subtle issue affecting Internet Explorer users (well, fancy that!) and HTTPS connections.
One of my clients has a site that downloads a series of results as a CSV file, which they open in Excel. Unfortunately, Internet Explorer was refusing to download the file, and was presenting an error message reading &#8220;Internet [...]]]></description>
			<content:encoded><![CDATA[<p>I just came across a subtle issue affecting Internet Explorer users (well, fancy that!) and HTTPS connections.</p>
<p>One of my clients has a site that downloads a series of results as a CSV file, which they open in Excel. Unfortunately, Internet Explorer was refusing to download the file, and was presenting an error message reading &#8220;Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found.&#8221;</p>
<p>To add to my confusion, this was happening on the live server (PHP4), but not on my dev server (PHP5) <em>which both use the same code</em>.</p>
<p>In the end, I happened upon a Microsoft Knowledge Base article that <a href="http://support.microsoft.com/kb/316431" onclick="javascript:pageTracker._trackPageview ('/outbound/support.microsoft.com');">explained the problem</a>. Basically, IE obeys any &#8220;no-cache&#8221; headers you send to the browser. Without caching the file, Office applications cannot open the file when served over HTTPS.</p>
<p>How to solve the issue? Remove the cache header(s) - but how?</p>
<p>The <a href="http://uk2.php.net/manual/en/function.header.php" onclick="javascript:pageTracker._trackPageview ('/outbound/uk2.php.net');">PHP manual</a> doesn&#8217;t make it entirely clear, and I found the solution by accident. To remove a header, use the same syntax as for setting a header, but only include a space after the colon.</p>
<p>For example, for the &#8220;Pragma&#8221; header:</p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="">'pragma: '</span><span style="color: #009900;">&#41;</span>;</pre></div></div>

<p><strong>Note:</strong> You must include the space after the &#8220;:&#8221; or the header will not be unset.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danforys.com/2008/08/06/unsetting-http-headers-in-php/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Step by step: Moving code between Subversion repositories</title>
		<link>http://www.danforys.com/2008/07/23/moving-svn-code-step-by-step/</link>
		<comments>http://www.danforys.com/2008/07/23/moving-svn-code-step-by-step/#comments</comments>
		<pubDate>Wed, 23 Jul 2008 15:14:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[php]]></category>

		<category><![CDATA[programming]]></category>

		<category><![CDATA[subversion]]></category>

		<category><![CDATA[svn]]></category>

		<category><![CDATA[svnadmin]]></category>

		<guid isPermaLink="false">http://www.danforys.com/?p=9</guid>
		<description><![CDATA[As many coders will tell you, there reaches a point where you realise that you absolutely, positively must keep your code in a a revision control system. In my working life, I&#8217;ve used Microsoft&#8217;s ageing SourceSafe and more recently the vastly superior SubVersion (SVN).
There&#8217;s many powerful GUIs out there which you can use to interact [...]]]></description>
			<content:encoded><![CDATA[<p>As many coders will tell you, there reaches a point where you realise that you absolutely, positively <em>must</em> keep your code in a a revision control system. In my working life, I&#8217;ve used Microsoft&#8217;s ageing SourceSafe and more recently the vastly superior SubVersion (SVN).</p>
<p>There&#8217;s many powerful GUIs out there which you can use to interact with SVN, and make the checking out and checking in very easy. If you primarily use a desktop GUI (like me), then chances are you use a SVN client GUI to interact with SVN on a day-to-day basis.</p>
<p>But what happens when you need to move code between repositories?</p>
<p><span id="more-9"></span></p>
<p>I first realised I needed to reorganise my repositories when my single &#8220;clients&#8221; repository was growing unwieldy. It was one large repository, with all my client work organised into folders by the project name. This method keeps things very tidy, but increments the version numbers with every commit on <em>every project</em> and means you have a very long root log.</p>
<p>A better way, I realised, is to keep the unrelated projects organised in their own repositories - but how to move the code out of my client repository into a new one?</p>
<p>To do this, you&#8217;ll need shell access to your SVN server (surely you do - otherwise, how do you create your repositories?)</p>
<p>SVN provides the <strong>svnadmin dump</strong> command to export data from your repository. In my case, to dump the contents of my entire clients repository, I did the following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">svnadmin</span> dump clients <span style="color: #000000; font-weight: bold;">&gt;</span> clients-dumpfile</pre></div></div>

<p>which creates a text file called clients-dumpfile containing all the revision data for my clients repository. Note that this can create a very large file, as it&#8217;s not stored in the ultra-efficient space-saving SVN database any longer.</p>
<p>Say I want to move all my code from a folder called client-1, and put it in its own repository. First thing I need to do, is to create the destination repository:</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">svnadmin</span> create client-<span style="color: #000000;">1</span>-repository</pre></div></div>

<p>Now - the dumpfile contains <em>all</em> the code for all the projects, so how do I filter out the other projects? (this is all one line)</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cat</span> clients-dumpfile | <span style="color: #c20cb9; font-weight: bold;">svndumpfilter</span> include client-<span style="color: #000000;">1</span> <span style="color: #660033;">--drop-empty-revs</span> <span style="color: #660033;">--renumber-revs</span> <span style="color: #000000; font-weight: bold;">&gt;</span> client-<span style="color: #000000;">1</span>-filtered-dumpfile</pre></div></div>

<p>What does this do? It takes the previously created clients-dumpfile and sends it through the svndumpfilter program. I&#8217;ve told it to <em>include</em> the client-1 folder (and throw away everything else). I&#8217;ve told it to drop the empty revisions left behind by the thrown away data, and renumber the rest of the revisions so my new repository is nicely sequentially numbered. The results from svndumpfilter are output into a new file called client-1-filtered-dumpfile.</p>
<p>Finally, you simply load the data into the new repository:</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">svnadmin</span> load client-<span style="color: #000000;">1</span>-repository <span style="color: #000000; font-weight: bold;">&lt;</span> client-<span style="color: #000000;">1</span>-filtered-dumpfile</pre></div></div>

<p>Hopefully, you now have a populated repository with your clients&#8217; code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danforys.com/2008/07/23/moving-svn-code-step-by-step/feed/</wfw:commentRss>
		</item>
		<item>
		<title>HTTP Authentication in PHP</title>
		<link>http://www.danforys.com/2007/06/12/http-authentication-in-php/</link>
		<comments>http://www.danforys.com/2007/06/12/http-authentication-in-php/#comments</comments>
		<pubDate>Tue, 12 Jun 2007 14:08:45 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
		
		<category><![CDATA[browsers]]></category>

		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.danforys.com/2007/06/12/http-authentication-in-php/</guid>
		<description><![CDATA[I&#8217;ve just discovered, totally by accident, how to get HTTP Authentication (when the browser pops up a dialog asking for the username and password - usually set with a .htaccess file) values within PHP. Previously, I&#8217;d just assumed that the authentication was a &#8220;black box&#8221; and I was unable to use it within my scripts. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just discovered, totally by accident, how to get <a href="http://en.wikipedia.org/wiki/Basic_authentication_scheme" onclick="javascript:pageTracker._trackPageview ('/outbound/en.wikipedia.org');">HTTP Authentication</a> (when the browser pops up a dialog asking for the username and password - usually set with a .htaccess file) values within PHP. Previously, I&#8217;d just assumed that the authentication was a &#8220;black box&#8221; and I was unable to use it within my scripts. I had done some experimentation to see if any of the information was present in the _POST or _COOKIE arrays to no avail.</p>
<p><span id="more-5"></span>At work, we were using some software which, somewhat curiously, seemed to automatically log users in without them supplying the correct credentials. After much digging, inserting debug messages and experimentation, I found that PHP had the authentication values in the superglobal $_REQUEST array. The values you can use are as follows:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Superglobal showing the username supplied</span>
<span style="color: #990000;">print</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="">'PHP_AUTH_USER'</span><span style="color: #009900;">&#93;</span>;
&nbsp;
<span style="color: #666666; font-style: italic;">// Superglobal showing the password</span>
<span style="color: #990000;">print</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="">'PHP_AUTH_PW'</span><span style="color: #009900;">&#93;</span>;
&nbsp;
<span style="color: #666666; font-style: italic;">// Authentication type (Basic or digest in PHP5)</span>
<span style="color: #990000;">print</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="">'AUTH_TYPE'</span><span style="color: #009900;">&#93;</span>;</pre></td></tr></table></div>

<p>This is immensely useful for me, because it opens all sorts of possibilities for single sign-on style systems. It also means I can work with non PHP files, without having to authenticate twice or rely on PHP sessions alone.</p>
<p>Of course, perhaps I should have looked at the <a href="http://uk.php.net/manual/en/features.http-auth.php" onclick="javascript:pageTracker._trackPageview ('/outbound/uk.php.net');">PHP manual on HTTP authentication</a> first! <img src='http://www.danforys.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.danforys.com/2007/06/12/http-authentication-in-php/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
