Filemtime seems to return the date of the EARLIEST modified file inside a folder, so this is a recursive function to return the date of the LAST (most recently) modified file inside a folder.
<?php
$allowedExtensions = array(
'zip',
'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);
}
return $ret;
}
?>