isDir() && !$dirinfo->isDot()) {
$yeardirs[] = $dirinfo->getFilename();
}
}
rsort($yeardirs);
// iterate through years
if (is_array($yeardirs)) {
foreach ($yeardirs as $key => $dirname) {
echo "" . $dirname . "
";
echo "";
$items = [];
$thisdir = new DirectoryIterator("./articles/" . $dirname);
// iterate through files
foreach ($thisdir as $file) {
if (!$file->isDot()) {
$flag = "";
$articledate = date("Y-m-d");
$filemodified = date("Y-m-d", filemtime("./articles/".$dirname."/".$file));
$content = file_get_contents($file->getPathname());
preg_match("/(.*?)<\/h5>/s", $content, $date);
if (isset($date[1]) && strtotime($date[1])) {
$articledate = date("Y-m-d", strtotime($date[1]));
}
// 2025-04-18 was the last global update
if (($filemodified > $articledate) &&
($filemodified != "2025-04-18") &&
($filemodified >= date('Y-m-d', strtotime(date("Y-m-d"). ' - 7 days')))) $flag = "Updated";
if ($articledate >= date('Y-m-d', strtotime(date("Y-m-d"). ' - 2 days'))) $flag = "New";
preg_match("/(.*?)<\/h2>/s", $content, $titre);
$title = "?";
if (isset($titre[1])) {
$title = ucfirst($titre[1]);
}
$items[] =
'
- ' .
substr($articledate, -5 ) . ' ' .
'' .
$title .
" " . $flag . "
";
}
}
rsort($items);
foreach ($items as $key => $val) {
echo $val;
}
echo "
";
}
} else {
echo "Not an array";
}
?>
§