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/submit.php | 81 ++++++++++++++++++++++------------------------------ 1 file changed, 34 insertions(+), 47 deletions(-) (limited to 'guestbook/submit.php') diff --git a/guestbook/submit.php b/guestbook/submit.php index 09d0404..7fab0d5 100644 --- a/guestbook/submit.php +++ b/guestbook/submit.php @@ -1,69 +1,56 @@ $_POST["entry"], + "sourceip" => $_SERVER['REMOTE_ADDR'], "date" => time(), - "name" => htmlentities($_POST["name"]), - "message" => htmlentities($_POST["message"]), - "found" => htmlentities($_POST["found"]), + "name" => $_POST["name"], + "message" => $_POST["message"], + + "found" => $_POST["found"], "website" => $_POST["website"], "cool" => $_POST["cool"], - "reply" => "" + "reply" => "", + "modstatus" => $modstatus ); - $filename = "posts.json"; - - $handle = @fopen($filename, 'r+'); - - // create the file if needed - if ($handle === null) - { - $handle = fopen($filename, 'w+'); - } - - if ($handle) - { - // seek to the end - fseek($handle, 0, SEEK_END); - - // are we at the end of is the file empty - if (ftell($handle) > 0) - { - // move back a byte - fseek($handle, -2, SEEK_END); - - // add the trailing comma - fwrite($handle, ",\n", 2); - - // add the new json string - fwrite($handle, json_encode($currentPost) . "]\n"); - } - else - { - // write the first event inside an array - fwrite($handle, json_encode(array($currentPost))); - } - - // close the handle on the file - fclose($handle); - } + $filename = $datadir."posts.json"; + $extantPosts = json_decode(file_get_contents($filename)); + array_push($extantPosts, $currentPost); + file_put_contents($filename, json_encode($extantPosts, JSON_PRETTY_PRINT)); + } } - header("Location: ./?return=$returnCode"); + $referrer = preg_replace("/\?.*/", "", $_SERVER['HTTP_REFERER']); + header("Location: $referrer?return=$returnCode"); ?> -- cgit v1.2.3