Tengo un script para leer xml. el codigo es este (al final os pongo el problema):
Código PHP:
$forecast_url = "http://api.wunderground.com/auto/wui/geo/ForecastXML".$loc_id;
$url = $forecast_url;
$fp = @fopen($url,"r");
if($fp != FALSE || $fp != NULL){
$mensaje = "OK";
while (!feof ($fp))
$xml .= fgets($fp, 4096);
fclose ($fp);
$fw = fopen($cachefilename, 'w');
fwrite($fw, $xml);
fclose($fw);
} else{
$mensaje = "ERROR: $php_errormsg";
}
$parser = xml_parser_create( );
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parse_into_struct($parser,$xml,$values,$index);
xml_parser_free($parser);
$maxima1 = htmlspecialchars($values[$index[celsius][0]][value]);
$minima1 = htmlspecialchars($values[$index[celsius][1]][value]);
$counter = 0;
$row_counter = 2;
$xml="";
[06-Nov-2008 20:58:09] PHP Warning: fopen(http://api.wunderground.com/auto/wui/geo/ForecastXML/global/stations/08306.html) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: Connection refused in /home/public_html/weather/functions_forecast.php on line 16
[06-Nov-2008 20:58:09] PHP Warning: feof(): supplied argument is not a valid stream resource in /home/public_html/weather/functions_forecast.php on line 17
[06-Nov-2008 20:58:09] PHP Warning: fgets(): supplied argument is not a valid stream resource in /home/public_html/weather/functions_forecast.php on line 18
[06-Nov-2008 20:58:09] PHP Warning: feof(): supplied argument is not a valid stream resource in /home/public_html/weather/functions_forecast.php on line 17
[06-Nov-2008 20:58:09] PHP Warning: fgets(): supplied argument is not a valid stream resource in /home/public_html/weather/functions_forecast.php on line 18
Y asi hacia abajo, generando mensajes de error de feof y fgets hasta formar ficheros de error de mas de un giga. Tengo la web en jaguarpc y el otro dia les pete el servidor, me escribieron esto:
Hi,
Your domain midominio.com hosted on the shared server is running vulnerable scripts due to which the /tmp directory is filled up with temporary files and all sites on the server start showing blank pages.
I emptied the /tmp directory when it was 100% full but after almost 6 minutes the entire directory was filled up again. So upon investigation it was prominent that your account is having either vulnerable scritps or your scripts are broken badly.
A file of almost 1 GB contained the following sort of warnings all over.
---
a5
<br />
<b>Warning</b>: feof(): supplied argument is not a valid stream resource in <b>/home/public_html/weather/functions2.php</b> on line <b>21</b><br />
a6
<br />
<b>Warning</b>: fgets(): supplied argument is not a valid stream resource in <b>/home/public_html/weather/functions2.php</b> on line <b>22</b><br />
El script falla cuando por cualquier motivo (por ej un fallo del servidor de datos) no puede leer el xml. He intentado parar estos errores con la linea
Código PHP:
if($fp != FALSE || $fp != NULL){
Gracias, espero que podais ayudarme. Empiezo a desesperarme.