From d007101e088a8aa7de678230a5625d8784e69ecf Mon Sep 17 00:00:00 2001 From: quenousimporte Date: Wed, 14 Feb 2024 16:59:19 +0100 Subject: [PATCH] change sort by date --- index.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/index.php b/index.php index 71d8297..0233231 100644 --- a/index.php +++ b/index.php @@ -93,21 +93,23 @@ '; echo '
'; - if ($dh = opendir($dir)) + $files = glob($dir . '/*'); + usort($files, function($a, $b) { - while (($file = readdir($dh)) !== false) + return filemtime($b) - filemtime($a); + }); + + foreach($files as $path) + { + if (!str_ends_with($path, '.del')) { - if (!str_ends_with($file, '.del') && $file != '.' && $file != '..') - { - $mod = date("F d Y H:i:s", filemtime($dir . '/' . $file)); - echo '
' . $mod . ' ' . $file .'
'; - } + $name = basename($path); + $mod = date("F d Y H:i:s", filemtime($path)); + echo '
' . $mod . ' ' . $name .'
'; } - closedir($dh); } echo '
'; } - ?>