From dd2058442589e9285ba91f6abc587c79ddd97040 Mon Sep 17 00:00:00 2001 From: alyx Date: Sat, 25 May 2024 02:01:11 -0400 Subject: custom css, assets, done --- visitors.php | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 57 insertions(+), 6 deletions(-) (limited to 'visitors.php') 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 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'] ?> +' : + ''.(@$config['custom_css'] ? '' : '') ?> -

Guestbook

+

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 => 'e-mail icon', + 0, 1 => 'e-mail icon', 2, 3 => '[e-mail]', 4 => 'mail: '.str_replace(['@', '.'], [' at ', ' dot '], $row['email']).'' } : ''; ?> -
data-visit-id= data-visit-name="" data-visit-message="" data-visit-email="" data-visit-website=""> +
+ data-visit-id= + data-visit-name="" + data-visit-message="" + data-visit-email="" + data-visit-website="">
   -- cgit v1.2.3-54-g00ecf