diff options
-rw-r--r-- | mlmmj-webarchiver/index.php.newlist | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/mlmmj-webarchiver/index.php.newlist b/mlmmj-webarchiver/index.php.newlist index c978936..9acd78d 100644 --- a/mlmmj-webarchiver/index.php.newlist +++ b/mlmmj-webarchiver/index.php.newlist @@ -1,12 +1,22 @@ <?php - $baselistdir = getcwd(); - $mlist = substr (strrchr ($baselistdir, "/"), 1); - $mlistdir = opendir($baselistdir); - while($file = readdir($mlistdir)) { - if(is_dir($baselistdir . "/" . $file) && $file != "." && $file != "..") { - $archived_months .= "<a href=\"$file\">$file</a><br />\n"; - } +$path = getcwd(); +$mlist = substr(strrchr($path, "/"), 1); +$handle = @opendir($path) or die("Unable to open $path"); +while($file = readdir($handle)) { + if(is_dir($path . "/" . $file) && $file != "." && $file != "..") { + $files[] = $file; } +} +closedir($handle); +rsort($files); +reset($files); +foreach($files as $k => $file) { + if (! isset($year) || $year != substr($file, 0, 4)) { + $year = substr($file, 0, 4); + $archived_months .= "<h1>$year</h1>"; + } + $archived_months .= "<a href=\"$file\">$file</a><br />\n"; +} ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html lang="en"> |