From 898b52edcb47bcb3e9d6106e74ca73e74ea01e70 Mon Sep 17 00:00:00 2001 From: sillylaird Date: Thu, 3 Sep 2026 00:33:59 +0000 Subject: import live www.sillylaird.ca webroot --- partials/site_status.php | 70 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 partials/site_status.php (limited to 'partials/site_status.php') diff --git a/partials/site_status.php b/partials/site_status.php new file mode 100644 index 0000000..c758186 --- /dev/null +++ b/partials/site_status.php @@ -0,0 +1,70 @@ + true, 'html' => true, 'css' => true, 'js' => true, 'txt' => true]; + $skipDirs = ['.git' => true, '.agents' => true, 'node_modules' => true, 'vendor' => true]; + + $iterator = new RecursiveIteratorIterator( + new RecursiveCallbackFilterIterator( + new RecursiveDirectoryIterator($root, FilesystemIterator::SKIP_DOTS), + static function (SplFileInfo $current) use ($skipDirs): bool { + if ($current->isDir()) { + return !isset($skipDirs[$current->getFilename()]); + } + return true; + } + ) + ); + + foreach ($iterator as $file) { + if (!$file->isFile()) { + continue; + } + $extension = strtolower($file->getExtension()); + if (!isset($extensions[$extension])) { + continue; + } + $mtime = @filemtime($file->getPathname()); + if ($mtime && $mtime > $latest) { + $latest = $mtime; + } + } + + return $latest; +} + +function site_update_status(): array +{ + $timezone = new DateTimeZone('America/New_York'); + $latest = site_latest_update_timestamp(); + $date = $latest + ? (new DateTimeImmutable('@' . $latest))->setTimezone($timezone)->format('Y-m-d') + : (new DateTimeImmutable('now', $timezone))->format('Y-m-d'); + $today = (new DateTimeImmutable('now', $timezone))->format('Y-m-d'); + + return [ + 'date' => $date, + 'updated_today' => $date === $today, + ]; +} + +function render_site_update_status(string $class = 'site-status-row'): void +{ + $status = site_update_status(); + $date = htmlspecialchars($status['date'], ENT_QUOTES, 'UTF-8'); + $label = $status['updated_today'] ? 'Updated today: check the changelog' : 'View changelog'; + ?> +
+ Last updated: + +
+