PHP Classes

fopen() disabled

Recommend this page to a friend!

      PHP Universal Feed Parser  >  All threads  >  fopen() disabled  >  (Un) Subscribe thread alerts  
Subject:fopen() disabled
Summary:if fopen() is disabled, what can i do?
Messages:4
Author:Abbey W
Date:2008-05-09 05:35:56
Update:2008-05-15 07:32:59
 

  1. fopen() disabled   Reply   Report abuse  
Picture of Abbey W Abbey W - 2008-05-09 05:35:56
So my hosting provider has fopen() disabled and I get Warning: fopen(): URL file-access is disabled in the server configuration.

Is there some alternative function or way I can modify your class to get it to work on my server? Thanks!

  2. Re: fopen() disabled   Reply   Report abuse  
Picture of Abbey W Abbey W - 2008-05-09 06:38:06 - In reply to message 1 from Abbey W
Hello again!

My host was helpful and provided me some code to change. It works, but I don't know if it is the best way, I am no expert programmer.

Take a look:

/* ORIGINAL CODE
$fp = fopen($url,"r") or die("Error reading RSS data.");

while($data = fread($fp, 4096))
{
xml_parse($this->xmlParser, $data, feof($fp))
or die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($this->xmlParser)),
xml_get_current_line_number($this->xmlParser)));
}

fclose($fp);
xml_parser_free($this->xmlParser);
*/

/* NEW CODE */
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$xmldata = curl_exec($ch);
curl_close($ch);

$xmldata = split("\n",$xmldata);

foreach ($xmldata as $data) {
if (!xml_parse($this->xmlParser, $data)) {
die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($this->$xml_parser)),
xml_get_current_line_number($this->$xml_parser)));
}
}
xml_parser_free($this->xmlParser);

  3. Re: fopen() disabled   Reply   Report abuse  
Picture of Anis uddin ahmad Anis uddin ahmad - 2008-05-09 08:34:31 - In reply to message 2 from Abbey W
Hi Friend,
Thanks a lot for your help to find out this problem.

Ya.. here is this problem in some hosting.
And, though the alternate code u r using is working, it's not the best way.
There r 2 licks in this way. Firstly, cURL can be disabled in some servers. Secondly, Your code id breaking the xml file with the '\n' character what is not appropriate here.

I m editing this portion of class and hope to update within 2/3 days.
Hope, It will then evolute to work in any server configuration.

Thanks again.
-------
Anis uddin Ahmad
Web Application Developer
ajaxray.com

  4. Re: fopen() disabled   Reply   Report abuse  
Picture of Anis uddin ahmad Anis uddin ahmad - 2008-05-15 07:33:01 - In reply to message 3 from Anis uddin ahmad
Hello everybody!

Yes, the url fopen() problem is solved now.
I've added the cURL support.

I am planning to add fsockopen and caching support ASAP.

Thanks.