Ne ho trovato uno in giro e l'ho adattato per mostrare a video il risultato, mostrando il prima e il dopo della funziona, per capire se effettivamente facesse il suo lavoro, e convertito il timestamp in data...
Ora devo solo capire come scrivere il valore in un file... la funzione cerca anche nelle subdir, e impiega circa un secondo a mostrare l'output, con 3200 files.
http://www.flapane.com/time.php
Codice PHP:
<?php
// Only take into account those files whose extensions you want to show.
$allowedExtensions = array(
'gif',
'rar',
'pdf',
'txt'
);
function filemtime_r($path)
{
global $allowedExtensions;
if (!file_exists($path))
return 0;
$extension = end(explode(".", $path));
if (is_file($path) && in_array($extension, $allowedExtensions))
return filemtime($path);
$ret = 0;
foreach (glob($path."/*") as $fn)
{
if (filemtime_r($fn) > $ret)
$ret = filemtime_r($fn);
// This will return a timestamp, you will have to use date().
}
return $ret;
}
$mostra = 0;
echo "Before the function, mostra = ". $mostra ."
";
$mostra = filemtime_r("/home/flapanec/public_html/");
echo "After the function, mostra = " . $mostra ."
";
echo date("r",$mostra);
?>