dotbody
Joined: 21 Dec 2007 Posts: 2
|
Posted: Fri Dec 21, 2007 8:11 am Post subject: cURL (PHP 5.2 URL file-access and fopen woes) |
|
|
After spending several hours trying to implement this on a server that uses PHP5, i figured out that Feed2Html's current method of caching the XML file is a possible security risk (using fopen instead of curl)...
I noticed this when the script would only work if I put the .xml file in the same directory as the script. But calling other website scripts, or even different directories would give me Error: An error occured while parsing RSS file.
Have you guys heard of this? Is there an update you could make to the script that would fix this? |
|
Lukaslo
Joined: 20 Sep 2008 Posts: 1
|
Posted: Sat Sep 20, 2008 12:16 pm Post subject: |
|
|
I had the same problem and here is how I fixed it:
open rss_export.php
find
| Code: | if ($f = @fopen($cache_file, 'w')) {
fwrite ($f, $serialized, strlen($serialized));
fclose($f);
}
if ($result) $result['cached'] = 0; |
replace with
| Code: | $ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $rss_url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$f = curl_exec($ch);
curl_close($ch); |
find
| Code: | if ($f = @fopen($rss_url, 'r')) {
$rss_content = '';
while (!feof($f)) {
$rss_content .= fgets($f, 4096);
}
fclose($f); |
replace with
| Code: | $ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $rss_url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$f = curl_exec($ch);
curl_close($ch); |
|
|