<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Wed, 19 Jun 2013 21:08:33 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Larry Garfield's Blog: readfile() not considered harmful]]></title>
      <guid>http://www.phpdeveloper.org/news/17909</guid>
      <link>http://www.phpdeveloper.org/news/17909</link>
      <description><![CDATA[<p>
In <a href="http://www.garfieldtech.com/blog/readfile-memory">this new post</a> to his blog <i>Larry Garfield</i> tries to dispel a common misconception in the PHP development world - that the <a href="http://php.net/readfile">readfile</a> function should be considered harmful and can cause memory issues in your code.
</p>
<blockquote>
If you're like me, you've probably read a dozen or two articles about PHP performance in your career. Many of them are quite good, but some are simply flat out wrong, or misinformed. One of the old truisms that has been repeated for as long as I can recall is "don't use readfile() if you have big files, because it reads the whole file into memory and your server will explode." [...] There's just one problem with that age-old truism: It's not true.
</blockquote>
<p>
He created some benchmarks to illustrate the differences between several of the common methods for working with files via the <a href="http://php.net/fread">fread</a>, <a href="http://php.net/fpassthru">fpassthru</a>, <a href="http://php.net/stream_copy_to_stream">stream_copy_to_stream</a> and of course <a href="http://php.net/readfile">readfile</a>. He reports the results based on the runtime and the peak memory usage and noted, ironically, that while the times varied slightly, the memory consumption was exactly the same for all of the approaches. Since there's no real reason not to use "readfile", he looks at three reasons why there might be this stigma attached to it (including the issues that could come up with output buffering enabled).
</p>]]></description>
      <pubDate>Fri, 04 May 2012 09:51:38 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Kae Verens' Blog: Serving files through a script]]></title>
      <guid>http://www.phpdeveloper.org/news/11738</guid>
      <link>http://www.phpdeveloper.org/news/11738</link>
      <description><![CDATA[<p>
<i>Kae Verens</i> has <a href="http://verens.com/archives/2009/01/13/serving-files-through-a-script/">posted a quick tutorial</a> about serving up files by routing them through a "fetch" script, pulling their contents in one side and back out the other.
</p>
<blockquote>
One thing I need to do while building the multi-user version of <a href="http://webme.eu/">webme</a> is to convert it so file references such as /f/photos/an_image.jpg get transparently converted so they serve correctly, even though the actual file may be located somewhere entirely else.
</blockquote>
<p>
There's two steps involved - rewriting the URL request for the types of files you'd like to pull through the script (using some mod_rewrite magic in Apache) and make the script to do the actual work. Source for that is included too. Not only can something like this help you keep things organized but it also allows for extra security if you need to store the files outside of the webserver's document root.
</p>]]></description>
      <pubDate>Wed, 14 Jan 2009 09:37:55 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Davey Shafik's Blog: PHP Streams Rock my World!]]></title>
      <guid>http://www.phpdeveloper.org/news/8641</guid>
      <link>http://www.phpdeveloper.org/news/8641</link>
      <description><![CDATA[<p>
<i>Davey Shafik</i> has gotten <a href="http://pixelated-dreams.com/archives/319-PHP-Streams-Rock-my-World!.html">more than a little excited</a> by the streams functionality in his latest blog post:
</p>
<blockquote>
PHP streams are absolutely amazing. As mentioned by Elizabeth Smith (a great read if you don't know how to use streams) PHP streams are super powerful. Streams is something that is (to my knowledge) unique to PHP. The closest thing I've seen to it, is Linux's FUSE "user space" (i.e. not kernel module) file systems.
</blockquote>
<p>
He <a href="http://pixelated-dreams.com/archives/319-PHP-Streams-Rock-my-World!.html">shows an example</a> of a stream in action and suggests an interface he'd like to see - an automatic connection to the Amazon S3 storage.
</p>]]></description>
      <pubDate>Wed, 12 Sep 2007 14:14:12 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPClasses.org: PHP security exploit with GIF images]]></title>
      <guid>http://www.phpdeveloper.org/news/8088</guid>
      <link>http://www.phpdeveloper.org/news/8088</link>
      <description><![CDATA[<p>
On the PHPClasses site today, there's <a href="http://www.phpclasses.org/blog/post/67-PHP-security-exploit-with-GIF-images.html">a new post</a> that points out an issue that could happen with dyanamic GIF creation in a PHP script leading to a security exploit.
</p>
<p>
<i>Manuel Lemos</i> writes:
</p>
<blockquote>
The problem that was discovered is that you can insert PHP code in the middle of a GIF image. That would not be a problem if it was not for the insecure ways some developers use to serve images upload by their users. Usually, uploaded files are moved to a given directory. If the site then serves the images directly from that directory and preserve the original file name, the site may be open for security exploits.
</blockquote>
<p>
The problem comes when a user decides to upload an "image" file that's actually a PHP script (ending in PHP even) to the remote system. When this is outputted, it's placed inside the image tag and executed with each page load. <i>Manuel</i> <a href="http://www.phpclasses.org/blog/post/67-PHP-security-exploit-with-GIF-images.html">offers a suggestion</a> to prevent the issue - protecting the images directory and using readfile to grab the contents of the file to output rather than just a straight echo.
</p>]]></description>
      <pubDate>Wed, 20 Jun 2007 12:57:00 -0500</pubDate>
    </item>
  </channel>
</rss>
