From b3bb0b898d3178963fefb9c0b16a00a76cf2a034 Mon Sep 17 00:00:00 2001 From: Hannah Isopod Date: Wed, 11 Jun 2025 03:25:00 -0600 Subject: total guestbook overhaul + new blog post + etc - Added /about/pronouns/ in leiu of something like a pronouns.cc profile - New blog post about my new and improved AI opinions - Moved Stop Using Chromium to an actual blog post page - Blog posts now have previous and next buttons - New /blog/ background - Moved status.cafe widget from /blog/ to landing page - Total overhaul of guestbook: - Merged guestbook and blog comment section code - Beefed up bot protection - Added a word filter - Added a property to entries to facilitate holding comments for review and approving or denying them manually (The interface for this is somewhere else) - IP address from which a post originates is now tracked in order to IP ban malicious actors - Various new buttons - Updated /greenhouse/ - The site is now a member of the No AI Webring - a couple minor CSS fixes --- guestbook/comments.css | 136 +++++++++++++++++++++++++++++++++++ guestbook/comments.php | 46 ++++++++++++ guestbook/feed.php | 66 +++++++++-------- guestbook/index.php | 190 +++---------------------------------------------- guestbook/submit.php | 81 +++++++++------------ 5 files changed, 261 insertions(+), 258 deletions(-) create mode 100644 guestbook/comments.css create mode 100644 guestbook/comments.php (limited to 'guestbook') diff --git a/guestbook/comments.css b/guestbook/comments.css new file mode 100644 index 0000000..031320f --- /dev/null +++ b/guestbook/comments.css @@ -0,0 +1,136 @@ +table { + border-collapse: collapse; + table-layout: fixed; +} +td { + padding: 0.3rem; +} + +form > table { + width: 100%; + margin: auto; + margin-bottom: 1.5rem; +} + +article { + width: 100%; + margin: 2rem auto; + display: grid; + gap: 1rem; + grid-template-areas: + 'gb-name gb-date gb-index' + 'gb-cool gb-cool gb-cool' + 'gb-found gb-found gb-found' + 'gb-message gb-message gb-message' + 'gb-reply gb-reply gb-reply'; +} +article :is(h1,h2,h3,h4,h5,h6) { + border: none; + padding-left: initial; +} + +input, textarea { + border: none; + font-family: var(--stdfont); +} +input[type="text"], input[type="email"], textarea { + width: 100%; + background: none; + border-bottom: 2px solid #444444; + color: gainsboro; + padding: 0.35rem; + box-sizing: border-box; + font-size: .9em; +} +input[type="submit"], input[type="reset"] { + padding: 0.35rem 0.5rem; + box-shadow: 2px 2px 6px black; + margin: 0.3rem; + display: inline-block; +} +input[type="submit"]:active, input[type="reset"]:active { + transform: translate(1px, 1px); box-shadow: 0 0 2px black; +} +input[type="submit"]:hover, input[type="reset"]:hover { + cursor: pointer; +} +.error { + color: red; + font-size: 0.85em; +} +.success { + color: lime; + font-size: 0.85em; +} +.warning { + color: yellow; + font-size: 0.85em; +} +.reply { + padding: calc(var(--stdpadding) * 1.5); + margin: 0; + margin-bottom: initial; + border-left: var(--stdaccentborder); + background-color: var(--blockbg); + margin-bottom: var(--stdpadding); +} +.reply > :last-child { + margin-bottom: 0; +} +.message { + padding-top: 1.5rem; +} +.gb-date { + text-align: center; +} +.gb-index { + text-align: right; +} +.gb-cool { + word-break: break-all; +} +.gb-name, .gb-date, .gb-index { + min-width: calc((var(--bodywidth) / 3) - (var(--stdpadding) * 2)) +} +@media only screen and (hover: none) { + form td:first-child { + text-align: left; + } + form td:nth-child(2) { + padding-left: 0; + padding-right: 0; + } + input[type="text"], input[type="email"], textarea { + background: none; + border: 2px solid #00000033; + border-bottom: 2px solid #888888; + } + article { + margin: 2rem auto; + } + @media (max-width: 43rem) { + article { + grid-template-areas: + 'gb-name gb-name gb-index' + 'gb-date gb-date gb-date' + 'gb-cool gb-cool gb-cool' + 'gb-found gb-found gb-found' + 'gb-message gb-message gb-message' + 'gb-reply gb-reply gb-reply'; + } + } +} +@media (prefers-contrast: more) { + input[type="text"], input[type="email"], textarea { + outline: 1px solid white; + color: white; + } + input:focus, textarea:focus { + outline: 3px solid white; + } + input[type="submit"] { + background: none; + color: white; + outline: 1px solid white; + } +} \ No newline at end of file diff --git a/guestbook/comments.php b/guestbook/comments.php new file mode 100644 index 0000000..3f65fb9 --- /dev/null +++ b/guestbook/comments.php @@ -0,0 +1,46 @@ +setSafeMode(true); + } + + $totaloutput = ""; + $postlist = json_decode(file_get_contents($datadir."posts.json")); + $index = 1; + foreach($postlist as $post) { + if($post->entry === $page and $post->modstatus > 0) { + $output = ""; + $date = date("Y-m-d h:iA", $post->date); + $name = htmlentities($post->name); + $message = $Parsedown->text($post->message); + $found = htmlentities($post->found); + $website = $post->website; + $cool = $post->cool; + $coolsanitized = htmlentities(preg_replace("/https?:\/\//i", "", $cool)); + $reply = $Parsedown->text($post->reply); + + $output = $output."
"; + if($website) { $output = $output."$name"; } + else { $output = $output.$name; } + $output = $output."
$date
Entry #$index
"; + if($cool) { + $output = $output."
cool thing: $coolsanitized
"; + } + if($found) { + $output = $output."
How did you find me?
$found
"; + } + $output = $output."
$message
"; + if($reply) { + $output = $output."
Reply:$reply
"; + } + $output = $output."
"; + $index++; + $totaloutput = $output.$totaloutput; + } + } + echo $totaloutput; +} + diff --git a/guestbook/feed.php b/guestbook/feed.php index 7cdb62e..64d1b31 100644 --- a/guestbook/feed.php +++ b/guestbook/feed.php @@ -4,43 +4,51 @@ header('Content-Type: text/xml'); echo ''; echo 'isopod.cool guestbook'; -echo 'The guestbook on isopod.cool'; +echo 'The guestbook and blog comments on isopod.cool'; echo 'en-us'; echo 'https://isopod.cool/guestbook/'; echo 'My crappy PHP code'; -$postlist = json_decode(file_get_contents("posts.json")); + +include($_SERVER['DOCUMENT_ROOT']."/Parsedown.php"); +$Parsedown = new Parsedown(); +$Parsedown->setSafeMode(true); +include($_SERVER['DOCUMENT_ROOT'] . '/common.php'); +$postlist = json_decode(file_get_contents($datadir."posts.json")); $index = 1; $totaloutput = ""; foreach($postlist as $post) { - $output = ""; - $date = date("D, d M Y H:m:s", $post->date) . " GMT"; - $name = $post->name; - $message = $post->message; - $found = $post->found; - $website = $post->website; - $cool = $post->cool; - $coolsanitized = htmlentities(preg_replace("/https?:\/\//i", "", $cool)); - $reply = htmlentities($post->reply); - - if($website) { $output = $output."$name:

"; } - else { $output = $output.$name.":

"; } - - if($cool) { - $output = $output."cool thing: $coolsanitized

"; - } - - if($found) { - $output = $output."How did you find me?
$found

"; - } - - $output = $output.$message."

"; - - if($reply) { - $output = $output."
Reply:
$reply"; + if($post->modstatus == 1) { + $output = ""; + $entry = $post->entry; + $date = date("D, d M Y H:m:s", $post->date) . " GMT"; + $name = $post->name; + $message = $Parsedown->text($post->message); + $found = $post->found; + $website = $post->website; + $cool = $post->cool; + $reply = $Parsedown->text($post->reply); + + if($website) { $output = $output."

$name:

"; } + else { $output = $output."

$name:

"; } + + if($cool) { + $output = $output."

cool thing: $cool

"; + } + + if($found) { + $output = $output."

How did you find me?
$found

"; + } + + $output = $output.$message; + + if($reply) { + $output = $output."

Reply:

$reply"; + } + $output_sanitized = preg_replace("/&gt;/", ">", preg_replace("/&lt;/", "<", htmlspecialchars($output))); + $totaloutput = "Entry #" . $index . " on " . $entry . " - " . $name . "https://isopod.cool/guestbook/" . $date . "".$output_sanitized."" . $index . $post->date . $name . "\n".$totaloutput; + $index++; } - $totaloutput = "Entry #" . $index . " - " . $name . "https://isopod.cool/guestbook/" . $date . "".htmlentities($output)."" . $index . $post->date . $name . "".$totaloutput; - $index++; } echo $totaloutput; diff --git a/guestbook/index.php b/guestbook/index.php index 7d85fd1..77d211e 100644 --- a/guestbook/index.php +++ b/guestbook/index.php @@ -10,144 +10,17 @@ error_reporting(E_ALL); Guestbook + - +

guestbook

say hi!