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 --- motd/index.php | 150 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 motd/index.php (limited to 'motd/index.php') diff --git a/motd/index.php b/motd/index.php new file mode 100644 index 0000000..23e0a8d --- /dev/null +++ b/motd/index.php @@ -0,0 +1,150 @@ + '', + 'body' => '', + 'updated' => '', + 'rev' => 0, + 'history' => [], +]; +$page_file = __DIR__ . '/motd-data.php'; +$json_file = __DIR__ . '/motd.json'; +if (is_file($page_file)) { + $data = require $page_file; + if (is_array($data)) $motd = array_merge($motd, $data); +} elseif (is_file($json_file)) { + $raw = file_get_contents($json_file); + $data = is_string($raw) ? json_decode($raw, true) : null; + if (is_array($data)) $motd = array_merge($motd, $data); +} + +$title = trim((string)($motd['title'] ?? '')); +$heading = trim((string)($motd['heading'] ?? '')); +if ($title === '') $title = $heading; +$body = trim((string)($motd['body'] ?? '')); +$live = $body !== ''; +$updated = trim((string)($motd['updated'] ?? '')); +$rev = (int)($motd['rev'] ?? 0); +$history = is_array($motd['history'] ?? null) ? $motd['history'] : []; + +$page_title = $live && $title !== '' + ? $title . ' — SillyLaird' + : 'MOTD — SillyLaird'; +$page_desc = $live + ? ($title !== '' ? $title . '. ' : '') . preg_replace('/\s+/', ' ', $body) + : 'Pinned message of the day for the SillyLaird XMPP room, posted by waifu.'; +if (strlen($page_desc) > 200) { + $page_desc = substr($page_desc, 0, 197) . '...'; +} + +$h = static fn(string $s): string => htmlspecialchars($s, ENT_QUOTES, 'UTF-8'); + +$link_body = static function (string $text) use ($h): string { + $esc = $h($text); + return preg_replace( + '~(https?://[^\s<]+)~', + '$1', + $esc + ) ?? $esc; +}; + +$fmt_when = static function (string $iso): string { + if ($iso === '') return ''; + try { + $dt = new DateTimeImmutable($iso); + return $dt->format('Y-m-d H:i T'); + } catch (Exception $e) { + return $iso; + } +}; + +$past = []; +foreach ($history as $row) { + if (!is_array($row)) continue; + $pbody = trim((string)($row['body'] ?? '')); + if ($pbody === '') continue; + $past[] = $row; +} +?> + + + + + + <?= $h($page_title) ?> + 'en', + 'title' => $page_title, + 'desc' => $page_desc, + 'base' => 'motd/index', + 'self_url' => 'https://www.sillylaird.ca/motd/', + 'en_url' => 'https://www.sillylaird.ca/motd/', + 'ja_url' => 'https://www.sillylaird.ca/motd/', + 'zh_url' => 'https://www.sillylaird.ca/motd/', + 'x_default' => 'https://www.sillylaird.ca/motd/', + 'updated' => $updated !== '' ? substr($updated, 0, 10) : '', + ]; + include __DIR__ . '/../partials/head_meta.php'; +?> + + + + + + + + + +
+
+

MOTD

+

Pinned notice for the XMPP room. Type !motd to read it. waifu posts it to the room only when it is announced from admin.

+ +

Current notice

+ +
+ +
+ +

+ 0) $bits[] = 'rev ' . $rev; + if ($bits): + ?> +

+ +
+ +

Nothing pinned right now.

+ + +

Room

+ + + +

Previous notices

+ +
+ +

+
+ + +
+
+ + + + -- cgit v1.2.3