Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/03/2005, 10:00
Avatar de tralara
tralara
 
Fecha de Ingreso: diciembre-2003
Mensajes: 230
Antigüedad: 20 años, 4 meses
Puntos: 0
Eliminar archivos especificos:

Me podriais decir si es correcta la parte ultima de este codigo, concretamente en esta linea:
Código PHP:
if (filemtime($listado[files][$i])>$TIEMPO){ 
No me respeta el valor de tiempo entonces no se.

Mira os pongo el script entero, es de php.net y un poco modificado, a ver si lo veis bien.
Código PHP:
<?
function recursive_dirlist($base_dir)
{
global 
$getDirList_alldirs,$getDirList_allfiles;
function 
getDirList($base)
{
global 
$getDirList_alldirs,$getDirList_allfiles;
if(
is_dir($base))
   {
     
$dh opendir($base);
   while (
false !== ($dir readdir($dh)))
     {
     if (
is_dir($base ."/"$dir) && $dir !== '.' && $dir !== '..'//note the change in this line
       
{
         
$subs $dir;
         
$subbase $base ."/"$dir;//note the change in this line
         
$getDirList_alldirs[]=$subbase;
         
getDirList($subbase);
       }
     elseif(
is_file($base ."/"$dir) && $dir !== '.' && $dir !== '..')//change in this line too
       
{
       
$getDirList_allfiles[]=$base ."/"$dir;//change in this line too
       
}
     }
     
closedir($dh);
   }
 }

getDirList($base_dir);
$retval['dirs']=$getDirList_alldirs;
$retval['files']=$getDirList_allfiles;
return 
$retval;
}
?>
<?
$TIEMPO 
86400;
$listado=recursive_dirlist('html');
$num_filescount($listado[files]);
for (
$i=0$i<$num_files$i++)
{
if (
filemtime($listado[files][$i])>$TIEMPO){
unlink ($listado[files][$i]);
}else{
echo 
"nonono";
}
}
?>
Gracias