I want to display the last date that a file in a specific directory was modified/updated.
This way I can show visitor when a part of the site was last updated.
I found this piece of code somewhere:
<?
// last update
$newFile=""; // init newFile
$handle=opendir('./'); // open dir
while (false!==($file = readdir($handle))) { // read all files in dir
if ($file != "." && $file != "..") { // only if file is not . or ..
$fileDate = filemtime($file); // get date from file
$newDate = filemtime($newFile); // get date from newFile
if ($newDate < $fileDate) { // if file is newer
$newFile = $file; // replace newFile with newer file
}
}
}
closedir($handle); // close file
$newDate = filemtime($newFile); // get date from newFile
$fileModDate = date("d-m-Y",$newDate); // convert date
Print("$fileModDate"); // print date
?>
But this only works in the dir the script is in. If you include the script in a file in another dir or run the script from another dir it gives the date 01-01-1970 (on the F2S servers). What is wrong with the script? Is it possible to change the script so that it works from within all dirs? Maybe another script?
Thanks in advance,
Maarten