<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

	<title>Comments on: RSS to HTML: Why can't my PHP file open remote RSS files?</title>
	<link>http://ask.metafilter.com/30113/RSS-to-HTML-Why-cant-my-PHP-file-open-remote-RSS-files/</link>
	<description>Comments on Ask MetaFilter post RSS to HTML: Why can't my PHP file open remote RSS files?</description>
	<pubDate>Tue, 03 Jan 2006 14:13:35 -0800</pubDate>
	<lastBuildDate>Tue, 03 Jan 2006 14:13:35 -0800</lastBuildDate>
	<language>en-us</language>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>60</ttl>

	<item>
		<title>Question: RSS to HTML: Why can&apos;t my PHP file open remote RSS files?</title>
		<link>http://ask.metafilter.com/30113/RSS-to-HTML-Why-cant-my-PHP-file-open-remote-RSS-files</link>	
		<description>RSS to HTML: Why can&apos;t my PHP file open remote RSS files? &lt;br /&gt;&lt;br /&gt; I&apos;m trying to implement the &lt;a href=&quot;http://lastrss.webdot.cz/&quot;&gt;lastRSS&lt;/a&gt; parser. I&apos;m pretty sure I&apos;ve followed the (simple) directions to a T, but no matter which code sample I try, I get the &quot;Feed cannot be read&quot; error.&lt;br&gt;
&lt;br&gt;
I know the RSS URLs I&apos;m trying are good -- is there some simple server-side trickery that the directions assume I know about? Some way to allow PHP to grab a remote file?</description>
		<guid isPermaLink="false">post:ask.metafilter.com,2006:site.30113</guid>
		<pubDate>Tue, 03 Jan 2006 13:59:58 -0800</pubDate>
		<dc:creator>o2b</dc:creator>
		
			<category>rss</category>
		
			<category>php</category>
		
			<category>parsing</category>
		
			<category>webdev</category>
		
	</item> <item>
		<title>By: revgeorge</title>
		<link>http://ask.metafilter.com/30113/RSS-to-HTML-Why-cant-my-PHP-file-open-remote-RSS-files#473992</link>	
		<description>lastRSS appears to use &lt;a href=&quot;http://php.net/fopen&quot;&gt;fopen()&lt;/a&gt; to grab URLs, which can be turned off in the php.ini file with &lt;a href=&quot;http://us2.php.net/manual/en/ref.filesystem.php#ini.allow-url-fopen&quot;&gt;allow_url_fopen&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;
Check your PHP installation to see if allow_url_fopen is enabled.  You may also want to try &lt;a href=&quot;http://magpierss.sourceforge.net/&quot;&gt;Magpie RSS&lt;/a&gt; as an alternative parsing lib if you can&apos;t get lastRSS working, although I don&apos;t know enough about lastRSS to say which is better.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.30113-473992</guid>
		<pubDate>Tue, 03 Jan 2006 14:13:35 -0800</pubDate>
		<dc:creator>revgeorge</dc:creator>
	</item><item>
		<title>By: null terminated</title>
		<link>http://ask.metafilter.com/30113/RSS-to-HTML-Why-cant-my-PHP-file-open-remote-RSS-files#473994</link>	
		<description>The setting &quot;allow_url_fopen&quot; most likely needs to be enabled.&lt;br&gt;
&lt;br&gt;
I cannot find the string &quot;Feed cannot be read&quot; in teh lastRSS code. Are you sure this is a PHP error (and not a Firefox/formatting issue)?&lt;br&gt;
&lt;br&gt;
Can we see your page?</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.30113-473994</guid>
		<pubDate>Tue, 03 Jan 2006 14:15:04 -0800</pubDate>
		<dc:creator>null terminated</dc:creator>
	</item><item>
		<title>By: o2b</title>
		<link>http://ask.metafilter.com/30113/RSS-to-HTML-Why-cant-my-PHP-file-open-remote-RSS-files#474016</link>	
		<description>I suspect you&apos;re both right about &quot;allow_url_fopen&quot; needing to be enabled. I&apos;ll get on the horn with the host and make that happen.&lt;br&gt;
&lt;br&gt;
Thanks.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.30113-474016</guid>
		<pubDate>Tue, 03 Jan 2006 14:41:23 -0800</pubDate>
		<dc:creator>o2b</dc:creator>
	</item><item>
		<title>By: 31d1</title>
		<link>http://ask.metafilter.com/30113/RSS-to-HTML-Why-cant-my-PHP-file-open-remote-RSS-files#474018</link>	
		<description>i ran into problems when i got a dreamhost account. they have file_get_contents() disabled. The workaround is they have curl compiled into php. so instead of doing file_get_contents(&quot;url&quot;) you do more like:&lt;br&gt;
&lt;pre&gt;&lt;br&gt;
$ch = curl_init();&lt;br&gt;
curl_setopt ($ch, CURLOPT_URL, &quot;$url&quot;);&lt;br&gt;
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);&lt;br&gt;
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 0);&lt;br&gt;
curl_setopt ($ch, CURLOPT_USERAGENT, $_ENV[&apos;HTTP_USER_AGENT&apos;]);&lt;br&gt;
$file = curl_exec($ch);&lt;br&gt;
curl_close($ch);  &lt;br&gt;
&lt;/pre&gt;</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.30113-474018</guid>
		<pubDate>Tue, 03 Jan 2006 14:44:43 -0800</pubDate>
		<dc:creator>31d1</dc:creator>
	</item><item>
		<title>By: drstein</title>
		<link>http://ask.metafilter.com/30113/RSS-to-HTML-Why-cant-my-PHP-file-open-remote-RSS-files#474113</link>	
		<description>&quot;allow_url_fopen&quot; = gaping security hole. Your host is smart to leave it off.&lt;br&gt;
&lt;br&gt;
Use the Curl method instead.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.30113-474113</guid>
		<pubDate>Tue, 03 Jan 2006 16:11:30 -0800</pubDate>
		<dc:creator>drstein</dc:creator>
	</item><item>
		<title>By: ph00dz</title>
		<link>http://ask.metafilter.com/30113/RSS-to-HTML-Why-cant-my-PHP-file-open-remote-RSS-files#474148</link>	
		<description>How exactly is allow_url_fopen a security hole when curl isn&apos;t?&lt;br&gt;
&lt;br&gt;
Don&apos;t get me wrong -- I really dig curl, but it&apos;s hard to see why fopen would really cause any additional problems.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.30113-474148</guid>
		<pubDate>Tue, 03 Jan 2006 17:09:00 -0800</pubDate>
		<dc:creator>ph00dz</dc:creator>
	</item><item>
		<title>By: weston</title>
		<link>http://ask.metafilter.com/30113/RSS-to-HTML-Why-cant-my-PHP-file-open-remote-RSS-files#474332</link>	
		<description>If you have any file names that are held in variables, and any of those variables are user-supplied *or* potentially taintable through various variable injection techniques, having allow_url_fopen gives attackers an extra angle. &lt;br&gt;
&lt;br&gt;
Example:  I wrote a form mail script in PHP a while back. When I first started doing things like this, most form mail scripts either (a) had you specify the recipient as a hidden value in the form or (b) had you modify the script itself to contain the recipient&apos;s address. Option (a) was obviously an invitation to get hijacked by spammers. Option (b) is  decent, but having people wade through script code seems less than ideal.&lt;br&gt;
&lt;br&gt;
So I decided to write one where you could use the form to specify a configuration file that lived on the server. Keeps the data out of the script, keeps the data out of the form, and is therefore secure, right? Well... no. With allow_url_fopen on, a spammer who had figured out my script could exploit it by specifying a configuration file on any location he chose. &lt;br&gt;
&lt;br&gt;
I realized this at some point and added some filtering code for that contingency when updating the script against header injection attacks too, but it might still be vulnerable to oddly encoded urls or something like that. &lt;br&gt;
&lt;br&gt;
Now, curl has something of the same problem -- but the thing is, the nature of curl is such that the coder has to be aware the script is fetching remote material. The big problem with allow_url_fopen is not that it has that power in particular, but that it&apos;s sortof underneath the radar. The person using fopen may not be aware of the remote feature and associated potential trouble, or may not be thinking about it.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.30113-474332</guid>
		<pubDate>Tue, 03 Jan 2006 22:14:38 -0800</pubDate>
		<dc:creator>weston</dc:creator>
	</item>
	</channel>
</rss>
