La readdir dovrebbe ordinare i file in base a come sono salvati nel file system. Per ordinarli in modo diverso devi farlo tramite php, es:
Codice PHP:
/*Show files in the folder*/
$dir = opendir($Directorio);
$files = array();
while ($file = readdir($dir)) {
if ($file!=".." && $file!=".") {
$files[filemtime($file)] = $file;
}
}
krsort($files);
echo ("<table>");
foreach($files as $file){
echo "<a href=\"modules.php?name=$name&file=download&archivo=$file\">$file</a> (".getSize(filesize($Directorio.$file)).")
";
}
echo ("</table>");
closedir($dir);
In poche parole, metti i file in array, usando come chiave il timestamp del'ultima MODIFICA del file. Dopo di che ordini l'array in modo decrescente in base alla chiave (che sarebbe la data di modifica).
Piccola nota: la filemtime() dovrebbe restituire un unix timestamp (i secondi passati da 1-1-1970), valuta se c'è la possibilità che due o più file possono avere lo stesso timestamp. in tal caso dovresti modificare il codice in modo che $files[filemtime($file)] diventi un array.