Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/11/2008, 12:37
Atreyuk
 
Fecha de Ingreso: enero-2002
Mensajes: 21
Antigüedad: 22 años, 3 meses
Puntos: 0
Codigo malicioso?

Hola, buenas. Tengo un problema serio y a ver si me podeis ayudar.

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($fp4096);
        
fclose ($fp);
        
$fw fopen($cachefilename'w'); 
        
fwrite($fw$xml); 
        
fclose($fw); 
    } else{
        
$mensaje "ERROR: $php_errormsg";
    } 
    
    
$parser xml_parser_create(  ); 
    
xml_parser_set_option($parserXML_OPTION_CASE_FOLDING0);
    
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=""
Es un script que lee informacion meteorologica. El caso es que a veces genera mensajes de error de este tipo:

[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){ 
que antes no la tenia. Pero aun asi me sigue generando esos ficheros de error tan bestias. ¿Como puedo pararlo?? ¿Hay alguna razon para esto? La verdad no me parece que el codigo este mal o sea malicioso. Son funciones creo que habituales en PHP. ¿No sera una mala configuracion del servidor?¿Como puedo hacer para que no se generen esos ficheros de error tan bestias?

Gracias, espero que podais ayudarme. Empiezo a desesperarme.