<?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>Joe Fleming dot net &#187; PHP</title>
	<atom:link href="http://joefleming.net/category/software/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://joefleming.net</link>
	<description>what you see is what you get</description>
	<lastBuildDate>Tue, 17 Jan 2012 16:24:55 +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>Serving Files in Internet Explorer over HTTPS</title>
		<link>http://joefleming.net/2010/05/11/serving-files-in-internet-explorer-over-https/</link>
		<comments>http://joefleming.net/2010/05/11/serving-files-in-internet-explorer-over-https/#comments</comments>
		<pubDate>Tue, 11 May 2010 21:34:13 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Computers & Technology]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[https]]></category>

		<guid isPermaLink="false">http://joefleming.net/?p=163</guid>
		<description><![CDATA[I recently came across a problem where serving a file to Internet Explorer would result in the following error message. This affected IE6, IE7 and IE8 in my testing. The way I was serving the file was through PHP via readfile. Before sending the contents of the file, I was, of course, setting some header [...]]]></description>
			<content:encoded><![CDATA[<p>I recently came across a problem where serving a file to Internet Explorer would result in the following error message.<br />
<a href="http://joefleming.net/wp-content/uploads/2010/05/Untitled.jpg"><img src="http://joefleming.net/wp-content/uploads/2010/05/Untitled-300x200.jpg" alt="" title="IE_Error" width="300" height="200" class="alignnone size-medium wp-image-164" /></a></p>
<p>This affected IE6, IE7 and IE8 in my testing. The way I was serving the file was through PHP via <a href="http://us2.php.net/manual/en/function.readfile.php">readfile</a>. Before sending the contents of the file, I was, of course, setting some header parameters so that the browser would handle the file and the user wouldn&#8217;t just see some binary garbage on their screen. In my case, I was serving a PDF file that was being generated server-side and sent to the client. The basic header parameters are as follows:</p>
<p><code>// We'll be outputting a PDF<br />
 header('Content-type: application/pdf');<br />
 // It will be called your_file.pdf<br />
 header('Content-Disposition: attachment; filename="your_file.pdf"');<br />
 // declare Files Size here (for the sake of peoples sanity, please add this<br />
 header('Content-Length: '.filesize($filename));</code></p>
<p>This works just fine in most situations, but once you introduce a secure connection, IE fails with the above error. Of course, like most IE problems, this doesn&#8217;t happen in any other browser. Ugh.<br />
<span id="more-163"></span><br />
Luckily, I noticed some additional parameters in the first example on the readfile page, namely the &#8216;Pragma&#8217; parameter. Reading some comments on the header function, I stumbled upon <a href="http://www.php.net/manual/en/function.header.php#88038">this one</a>. It basically, says that once you add HTTPS, you need to also tell IE how to handle caching the file. So now, my headers look like this:</p>
<p><code>// Force clear cache<br />
header('Pragma: public'); // Fix for IE<br />
header("Expires: 0");  //always expire<br />
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');<br />
// We'll be outputting a PDF<br />
header('Content-type: application/pdf');<br />
// It will be called your_file.pdf<br />
header('Content-Disposition: attachment; filename="your_file.pdf"');<br />
// declare Files Size here (for the sake pf peoples sanity, please add this<br />
header('Content-Length: '.filesize($filename));</code></p>
<p>Directly following these header calls is the readfile call and a call to exit to stop the script from executing anything else and alert the browser that the entire file has been delivered. </p>
<p>It seems like the Pragma parameter controls how browsers handle caching, and adding the other cache parameters to the header are just added enforcement. Now, IE works exactly as expected and I&#8217;ve got happy clients once again!</p>
]]></content:encoded>
			<wfw:commentRss>http://joefleming.net/2010/05/11/serving-files-in-internet-explorer-over-https/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Asynchronous PHP</title>
		<link>http://joefleming.net/2009/10/16/asynchronous-php/</link>
		<comments>http://joefleming.net/2009/10/16/asynchronous-php/#comments</comments>
		<pubDate>Fri, 16 Oct 2009 18:46:53 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://joefleming.net/?p=144</guid>
		<description><![CDATA[I needed to &#8220;asynchronous PHP&#8221; recently and it took me a little while to find the solution. What my script basically does is generate a PDF file for the user to download based on some parameters they have chosen. The problem was, the PDF generate take a while and during that time I needed to [...]]]></description>
			<content:encoded><![CDATA[<p>I needed to &#8220;asynchronous PHP&#8221; recently and it took me a little while to find the solution. What my script basically does is generate a PDF file for the user to download based on some parameters they have chosen. The problem was, the PDF generate take a while and during that time I needed to show the user a screen explaining that the file was being generated, which would also show the download link once the generation was complete. My setup is as follows:</p>
<p><strong>generate.php</strong></p>
<blockquote><p>This script is where the user is sent when they click &#8220;download&#8221; on the parameter choice page. This is where the asynchronous magic has to happen. From here, the user is immediately sent to <em>download.php</em>.</p></blockquote>
<p><strong>download.php</strong></p>
<blockquote><p>This script gives the user either a &#8220;please wait&#8221; message of a &#8220;click here to download&#8221; message, depending on where the target PDF has been generated yet.
</p></blockquote>
<p>My problem was, even though was added the header redirect code (shown below) to <em>generate.php</em>, the browser would still wait for the PDF to be generated before sending the user to <em>download.php</em>. In other words, it was only synchronous PHP, which didn&#8217;t help me at all.</p>
<p><code>header("Location: download.php");</code></p>
<p>Thanks to <a href="http://www.php.net/manual/en/features.connection-handling.php#89177" rel="ext">this comment</a> on php.net, I was able to make it work! Basically, you need to tell the browser that you are done sending it data, even though the PHP script will keep executing. Code below:</p>
<p><code>//redirects the browser to the new url, but continues processing in the background<br />
        function redirect_and_continue($sURL) {<br />
                header( "Location: ".$sURL );<br />
                ob_end_clean();<br />
                header("Connection: close");<br />
                ignore_user_abort();<br />
                ob_start();<br />
                header("Content-Length: 0");<br />
                ob_end_flush();<br />
                flush();<br />
                session_write_close();<br />
        }</code></p>
<p>So, the user is sent to <em>generate.php</em>, which immediately calls <em>redirect_and_continue(&#8216;download.php&#8217;)</em>, redirecting the user to <em>download.php</em> while still continuing to execute <em>generate.php</em> (and make the PDF file). Once the user is at <em>download.php</em>, the script checks for the existence of the generated PDF file (as indicated by the filename sent through the session) and uses a <a href="http://en.wikipedia.org/wiki/Meta_refresh" rel="ext">meta refresh tag</a> in the HTML to keep reloading <em>download.php</em>. Once the PDF file exists, it provides the user with a link to the PDF file for download.</p>
]]></content:encoded>
			<wfw:commentRss>http://joefleming.net/2009/10/16/asynchronous-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drupal&#8217;s On Hold</title>
		<link>http://joefleming.net/2008/11/17/drupals-on-hold/</link>
		<comments>http://joefleming.net/2008/11/17/drupals-on-hold/#comments</comments>
		<pubDate>Mon, 17 Nov 2008 23:16:14 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[Drupal]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://joefleming.net/?p=41</guid>
		<description><![CDATA[I know I said before that I would be replacing WordPress with Drupal around here, and I did start working on that. However, the more I read about Drupal, the harder it seems to do custom things. Actually, it&#8217;s more a problem of poor documentation than it is a lack of flexibility. Still, if I [...]]]></description>
			<content:encoded><![CDATA[<p>I know I said before that <a href="http://joefleming.net/2008/08/18/farewell-wordpress/">I would be replacing WordPress with Drupal</a> around here, and I did start working on that. However, the more I read about Drupal, the harder it seems to do custom things. Actually, it&#8217;s more a problem of poor documentation than it is a lack of flexibility. Still, if I don&#8217;t know what I&#8217;m doing, it&#8217;s hard to learn anything.</p>
<p>Granted, I could easily replace WordPress for the sake of my blog here (and probably still will at some point), but that&#8217;s not why I was planning to learn it. I wanted something that would allow me to crank out new pages quickly without constantly restarting from scratch. I do have a very weak framework I&#8217;ve written to try to achieve this, but every time I start a new site, I feel compelled to re-do at least part of it, so in the end I don&#8217;t save any time. In fact, I lose time because I have to re-learn the changes I made for each site when I need to maintain them.<br />
<span id="more-41"></span><br />
A while back, I started looking into frameworks to use at work. I&#8217;m still enthralled with <a rel="ext" href="http://www.symfony-project.org/">Symfony</a>, but it&#8217;s way too hard to just jump in to. In order to take advantage of all of its niceties, there&#8217;s a lot you need to learn. It&#8217;s almost like learning a new language on its own, which is fine and all, but it doesn&#8217;t help me get things done quickly. It&#8217;s hard to be motivated to learn new frameworks and techniques unless you have something to work on, and any new projects I have need to be done in a timely manner, so I can&#8217;t take too long to jump into something new.</p>
<p>Anyway, one other framework that stood out when I we were doing our research was <a rel="ext" href="http://codeigniter.com/">CodeIgniter</a>. Not because it&#8217;s better, but because it has more of an a-la-carte mentality. Don&#8217;t want to use the full MVC design pattern? No problem, just use the parts you want to; you can use it as a simple controller mechanism only if you so choose. Don&#8217;t feel like getting into a full <a rel="ext" href="http://en.wikipedia.org/wiki/Object-relational_mapping">ORM</a>? Skip it, they have a built-in ActiveRecord style interpreter, which means you don&#8217;t need to create your own class for each table in your database. Of course, ou can write your queries completely by hand if you choose to too. Best of all, no command line magic to make your code work, and on top of it all, the entire framework is 3.3MB with the user guide included, under 2MB without it.</p>
<p>I&#8217;ve spent a couple nights reading through the documentation (which is pretty well done) and I already have a good understanding of how it all works. And, since it&#8217;s almost Christmas again, it&#8217;s time to get my annual list manager online again. So, I&#8217;ve got a new tool to play with and a simple project to do it with. As a result, Drupal&#8217;s on hold while I work on that. I&#8217;ll report back on how it goes.</p>
]]></content:encoded>
			<wfw:commentRss>http://joefleming.net/2008/11/17/drupals-on-hold/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Farewell WordPress</title>
		<link>http://joefleming.net/2008/08/18/farewell-wordpress/</link>
		<comments>http://joefleming.net/2008/08/18/farewell-wordpress/#comments</comments>
		<pubDate>Tue, 19 Aug 2008 03:09:07 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Drupal]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Site News]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://joefleming.net/?p=30</guid>
		<description><![CDATA[In an effort to save time when I put together sites for people, I&#8217;ve been working on a universal engine I can use. It is modeled loosely off the MercuryBoard code and, for the most part, has served me pretty well. Recently, I&#8217;ve tried to revamp it with more object oriented code, integrating PEAR and [...]]]></description>
			<content:encoded><![CDATA[<p>In an effort to save time when I put together sites for people, I&#8217;ve been working on a universal engine I can use. It is modeled loosely off the <a href="http://www.mercuryboard.com/">MercuryBoard</a> code and, for the most part, has served me pretty well. Recently, I&#8217;ve tried to revamp it with more object oriented code, integrating PEAR and a few other niceties. Still, the more and more I use it, the more I realize it saves me very little time. In fact, it actually costs me time when I have to go back and update the sites. It seems, sadly, the idea of a flexible CMS or framework is just too abstract for my skills.</p>
<p>I&#8217;ve spent some time reading about <a href="http://www.symfony-project.org/">Symfony</a>, which looks like an amazing project. I&#8217;m positive I can make it do anything I would need, but the learning curve is pretty steep and I&#8217;m worried that the time I&#8217;d take to learn it wouldn&#8217;t really pay off in the end. I like a lot of the concepts, but I&#8217;m just not completely sold on it.</p>
<p>So what does that have to do with WordPress? Well, I&#8217;ve recently revisited a project that I spent some time with in the past but never really did much with. That project is <a href="http://www.drupal.org/">Drupal</a>.<br />
<span id="more-30"></span><br />
While it&#8217;s not nearly as flexible as Symfony is, it seems like a very useful platform for putting a site together. I followed a quick tutorial last week that outlined just how easy it was, and after reading through their <a href="http://drupal.org/getting-started">Getting Started</a> guide, I&#8217;m pretty sure it can be bent into anything I might need. To me honest, most of the sites I&#8217;ve put together didn&#8217;t really need much of anything.</p>
<p>But, again, how does this relate to WordPress? Well, I&#8217;ve grown tired of WordPress, and it seems like Drupal would make for a great blogging tool. I have no doubt that I could add a lot more than a simple blog should I choose to as well, which makes it that much more appealing. From what I&#8217;ve seen, it also runs significantly faster than WordPress does, which is always a nice perk. </p>
<p>So, in an effort to spend more time using and learning Drupal, I&#8217;m planning to port all of my WordPress posts to Drupal and use it exclusively to run this site. Worst case scenario, I end up with nothing more than a blog running on Drupal. That&#8217;s not too different that the blog I have running on WordPress now, so that&#8217;s not too bad of a worst case. Look for the change to happen soon (hopefully this week). You&#8217;ll know when it happens as it&#8217;s unlikely I&#8217;ll spend the time working on a theme just yet, so this site will live in default Drupal mode while I continue my Drupal education. Fun stuff!</p>
]]></content:encoded>
			<wfw:commentRss>http://joefleming.net/2008/08/18/farewell-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configuring Access in MediaWiki</title>
		<link>http://joefleming.net/2007/04/12/configuring-access-in-mediawiki/</link>
		<comments>http://joefleming.net/2007/04/12/configuring-access-in-mediawiki/#comments</comments>
		<pubDate>Thu, 12 Apr 2007 16:53:56 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://joefleming.net/2007/04/12/configuring-access-in-mediawiki/</guid>
		<description><![CDATA[I&#8217;ve set up Mediawiki in a few times now, both at work and for personal use. Each time I do it, I end up having to learn how to set up access restriction again. That is, creating custom namespaces and restricting access to those namespaces to people that belong in specific groups. The reason I [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve set up <a href="http://www.mediawiki.org" rel="ext">Mediawiki</a> in a few times now, both at work and for personal use. Each time I do it, I end up having to learn how to set up access restriction again. That is, creating custom namespaces and restricting access to those namespaces to people that belong in specific groups.</p>
<p>The reason I do this is to keep of people out of articles that only privileged users should really be seeing. Articles about server configurations, software development, new ideas for sites, etc. Making a hidden namespace and allowing only specific groups to access it is the simplest way to go about this task.</p>
<p>Doing this is pretty straightforward.  I won&#8217;t get in to all the specifics though; instead I&#8217;ll post links to the exact information you&#8217;ll need to pull it off.</p>
<p><a href="http://www.mediawiki.org/wiki/LocalSettings.php#User_rights" rel="ext">User Rights</a><br />
<a href="http://www.mediawiki.org/wiki/LocalSettings.php#Custom_namespaces" rel="ext"> Custom Namespaces</a><br />
<a href="http://www.mediawiki.org/wiki/Manual:%24wgGroupPermissions" rel="ext"> Group Permissions</a><br />
<a href="http://meta.wikimedia.org/wiki/Preventing_Access#Setting_permissions_for_a_Group_on_a_whole_new_Namespace" rel="ext"> Setting permissions for a Group on a whole new Namespace</a></p>
<p>There you have it, nice and easy! Now I just need to fix/reinstall our personal wiki&#8230;.</p>
]]></content:encoded>
			<wfw:commentRss>http://joefleming.net/2007/04/12/configuring-access-in-mediawiki/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

