diff --git a/tkr/classes/Config.php b/tkr/classes/Config.php index bf760d5..5b103bf 100644 --- a/tkr/classes/Config.php +++ b/tkr/classes/Config.php @@ -9,6 +9,7 @@ class Config { // properties and default values public string $siteTitle = 'My tkr'; public string $siteDescription = ''; + public string $baseUrl = 'http://localhost'; //TODO - make this work public string $basePath = '/'; public int $itemsPerPage = 25; public string $timezone = 'relative'; diff --git a/tkr/public/atom/index.php b/tkr/public/atom/index.php new file mode 100644 index 0000000..34e01c0 --- /dev/null +++ b/tkr/public/atom/index.php @@ -0,0 +1,57 @@ +itemsPerPage)); +$siteTitle = htmlspecialchars($config->siteTitle); +$siteUrl = htmlspecialchars($config->baseUrl); +$basePath = $siteUrl . htmlspecialchars($config->basePath); +$updated = date(DATE_ATOM, strtotime($ticks[0]['timestamp'] ?? 'now')); + +header('Content-Type: application/atom+xml; charset=utf-8'); + +echo << + + {$siteTitle} + + + {$updated} + {$siteUrl} + + {$siteTitle} + +XML; + +foreach ($ticks as $tick) { + [$date, $time] = explode(' ', $tick['timestamp']); + $dateParts = explode('-', $date); + $timeParts = explode(':', $time); + + [$year, $month, $day] = $dateParts; + [$hour, $minute, $second] = $timeParts; + + $tickPath = "$year/$month/$day/$hour/$minute/$second"; + $tickUrl = htmlspecialchars($basePath . "tick.php?path=" . $tickPath); + $tickTime = date(DATE_ATOM, strtotime($tick['timestamp'])); + $tickText = htmlspecialchars($tick['tick']); + + + echo << + {$tickText} + + {$tickUrl} + {$tickTime} + {$tickText} + + +ENTRY; +} + +echo ""; diff --git a/tkr/public/rss/index.php b/tkr/public/rss/index.php index 2a01832..2eedf68 100644 --- a/tkr/public/rss/index.php +++ b/tkr/public/rss/index.php @@ -34,7 +34,7 @@ echo '' . "\n"; <?php echo htmlspecialchars($tick['tick']); ?> - basePath/tick.php?path=$tickPath"); ?> + basePath . "tick.php?path=$tickPath"); ?> diff --git a/tkr/public/tick.php b/tkr/public/tick.php index cbc56fa..0d258d2 100644 --- a/tkr/public/tick.php +++ b/tkr/public/tick.php @@ -1,5 +1,9 @@ Tick from $timestamp on $y-$m-$d"; - echo "

" . htmlspecialchars(explode('|', $line)[1]) . "

"; + echo "

" . escape_and_linkify(explode('|', $line)[1]) . "

"; exit; } }