diff options
Diffstat (limited to '')
| -rw-r--r-- | journal/render_entries.php | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/journal/render_entries.php b/journal/render_entries.php new file mode 100644 index 0000000..68915e4 --- /dev/null +++ b/journal/render_entries.php @@ -0,0 +1,13 @@ +<?php +if (realpath(__FILE__) === realpath($_SERVER['SCRIPT_FILENAME'] ?? '')) { http_response_code(404); exit; } + +$journal_entries = is_file(__DIR__ . '/entries.php') ? require __DIR__ . '/entries.php' : []; +foreach ($journal_entries as $entry) { + $date = $entry['date'] ?? ''; + $body = $entry['body'] ?? ''; + if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $date) || trim((string)$body) === '') continue; + echo ' <div class="entry"><time datetime="' . htmlspecialchars($date, ENT_QUOTES, 'UTF-8') . '">' + . htmlspecialchars($date, ENT_QUOTES, 'UTF-8') . '</time><p>' + . nl2br(htmlspecialchars((string)$body, ENT_QUOTES, 'UTF-8'), false) + . "</p></div>\n"; +} |
