aboutsummaryrefslogtreecommitdiffstats
path: root/visitors.php
diff options
context:
space:
mode:
Diffstat (limited to 'visitors.php')
-rw-r--r--visitors.php63
1 files changed, 57 insertions, 6 deletions
diff --git a/visitors.php b/visitors.php
index d50082d..92abedb 100644
--- a/visitors.php
+++ b/visitors.php
@@ -7,6 +7,13 @@ define('GIT_REPO', 'https://git.aleteoryx.me/cgit/visitors_dot_php/');
/* CONFIG OPTIONS - COSMETIC */
+// Title: string
+//
+// The title for the page and <title> element.
+
+$config['title'] = 'Guestbook';
+
+
// Custom CSS: ?string
//
// Will be injected after the builtin CSS. Respects `use_path_info` when being served.
@@ -41,7 +48,7 @@ $config['form_mode'] = 0;
// 3 - Show the text `[e-mail]` with a `mailto:` link, or use the username text for the link if no website is present
// 4 - Show the e-mail as escaped text, e.g. 'alyx at aleteoryx dot me'
-$config['email_display'] = 2;
+$config['email_display'] = 1;
// E-Mail icon/link: ?string
@@ -61,7 +68,7 @@ $config['email_display'] = 2;
// Otherwise, inline them into a single HTML document.
// Only enable this if your webserver supports PATH_INFO.
-$config['use_path_info'] = false;
+$config['use_path_info'] = true;
// Database path: string
@@ -92,6 +99,41 @@ if (!isset($config['email_link'])) { // stolen from <https://forum.melonland.net
}
}
+
+/* BUILTIN_CSS */
+
+define('BUILTIN_CSS', <<<EOT
+
+EOT);
+
+
+/* PATH_INFO HANDLING */
+
+if (@$_SERVER['PATH_INFO']) {
+ switch ($_SERVER['PATH_INFO']) {
+ case '/email_icon':
+ [$mime, $base64] = explode(':', $config['email_icon'], 2);
+ header('Content-Type: '.$mime);
+ echo base64_decode($base64);
+ break;
+ case '/builtin_css':
+ header('Content-Type: text/css');
+ echo BUILTIN_CSS;
+ break;
+ case '/custom_css':
+ header('Content-Type: text/css');
+ echo $config['custom_css']??'';
+ break;
+ default:
+ http_response_code('404');
+ header('Content-Type: text/html');
+ echo "<h1>404: Asset Not Found.</h1>";
+ break;
+ }
+ exit();
+}
+
+
/* DATABASES */
// db_row: ['id' => int (only for list_rows), 'name' => string, 'message' => string, 'email' => ?string, 'website' => ?string, 'timestamp' => string (or DateTimeInterface for list_rows)]
@@ -268,10 +310,14 @@ $ed_1_or_3 = $config['email_display'] == 1 || $config['email_display'] == 3;
<!doctype html>
<html>
<head>
-<?php ?>
+<meta charset='utf-8' />
+<title><?= $config['title'] ?></title>
+<?= $config['use_path_info'] ?
+ '<link rel=stylesheet href="'.$_SERVER['REQUEST_URI'].'/builtin_css"/><link rel=stylesheet href="'.$_SERVER['REQUEST_URI'].'/custom_css"/>' :
+ '<style>'.BUILTIN_CSS.'</style>'.(@$config['custom_css'] ? '<style>'.$config['custom_css'].'</style>' : '') ?>
</head>
<body>
- <h1>Guestbook</h1>
+ <h1><?= $config['title'] ?></h1>
<main>
<?php foreach($db->list_rows() as $row):
$author_link = $row['website'] ?
@@ -281,11 +327,16 @@ $ed_1_or_3 = $config['email_display'] == 1 || $config['email_display'] == 3;
$row['name']);
$email_element = $row['email'] && (($row['website'] && $ed_1_or_3) || !$ed_1_or_3) ?
match ($config['email_display']) {
- 0, 1 => '<a href="mailto:'.$row['email'].'"><img alt="e-mail icon" src="'.($config['email_link']??'./email_icon').'" /></a>',
+ 0, 1 => '<a href="mailto:'.$row['email'].'"><img alt="e-mail icon" src="'.($config['email_link']??$_SERVER['REQUEST_URI'].'/email_icon').'" /></a>',
2, 3 => '<a href="mailto:'.$row['email'].'">[e-mail]</a>',
4 => 'mail:&nbsp<u>'.str_replace(['@', '.'], [' at ', ' dot '], $row['email']).'</u>'
} : ''; ?>
- <article id=visit-<?= $row['id'] ?> data-visit-id=<?= $row['id'] ?> data-visit-name="<?= $row['name'] ?>" data-visit-message="<?= $row['message'] ?>" data-visit-email="<?= $row['email'] ?>" data-visit-website="<?= $row['website'] ?>">
+ <article id=visit-<?= $row['id'] ?>
+ data-visit-id=<?= $row['id'] ?>
+ data-visit-name="<?= $row['name'] ?>"
+ data-visit-message="<?= $row['message'] ?>"
+ data-visit-email="<?= $row['email'] ?>"
+ data-visit-website="<?= $row['website'] ?>">
<div class='visit-info'>
<span class='author-link'><?= $author_link ?></span>&nbsp;&nbsp;<span class='email'><?= $email_element ?></span>
<span class='wide'>