commit 71546b1bb973ac3738811c233a2730e2545977cc Author: Shannon Kay Date: Sun Feb 23 16:27:55 2025 -0800 Guestbook files added diff --git a/README.md b/README.md new file mode 100644 index 0000000..4eeea05 --- /dev/null +++ b/README.md @@ -0,0 +1,51 @@ +#A Guestbook +This is Shannon's edition of a PHP guestbook. It's a very light fork of the [original php guestbook by baccyflap](http://baccyflap.com/res/gbdl/). + +Here is the [demo guestbook](https://guestbook.pixels.pink). + +## Requirements +php support on your web host + +## Installation and Setup +- Download the files +- Make a `guestbook` directory(or subdomain) wherever you want your guestbook to be. +- Put `data.txt`, `style.css`, and `index.php` in your `guestbook` directory. +- Give the `data.txt` file read and write permissions(CHMOD 666) +- It should work after that, and you can fill out the form to sign the guestbook. +- I've left my first post in the guestbook `data.txt` so that you can see how the guestbook entries will look and not start with an empty guestbook, but you can delete it from the text file if you want. +- Optionally, you can edit `style.css` to style the page however you want. I used color variables, listed at the top of `style.css` to make it really simple to just change your color scheme if you like. +- You can edit `index.php` to change things like the `` and the page header. +- I've included some comments in the code to help you find the welcome message to more easily edit that if you want. +- You'll find the footer down at the bottom, again with a comment to help you find where you might want to add a footer, like a link back to your website. + +From the original ReadMe, included in full below. +> Somewhere in the PHP code, you'll also find some commented out lines (lines preceded by //); if you uncomment those and input your email address, you'll receive an email for each new message. + +## Shannon Edition +I've very lightly forked this from the [original php guestbook by baccyflap](http://baccyflap.com/res/gbdl/). + +The original is a beautifully simple guestbook which uses only two files and works with very little setup. + +The changes I made were mostly structure and style of the index page html, making it more mobile friendly, and making the stylesheet external for easier style changes. Now it's three files instead of two, but I think it's easier to style with the external stylesheet. I even put in color variables to make it extra simple to pick your own color scheme. + +I also added some comments on the index page to help people find where to edit some text on the page they might want to edit. + +2025-02-23 +Shannon Kay +https://web.pixelshannon.com/aguestbook/ + +*** +## Original Readme +I wrote this guestbook in PHP, as simple as I could make it. It's almost ready to use straight out of the box; all you need to do to get it working is to place all files in the same directory and ensure that data.txt has the appropriate permissions: CHMOD 666. + +The guestbook data is written directly to a textfile, data.txt, from which it also reads data to reproduce on the same page. There's a cheeky little PHP redirect involved that makes it so that refreshing the page doesn't repost the message. There's also an even cheekier little field in the form that appears 1000 pixels left of your viewport. You don't see it, but bots do, and if they put a value in that field, nothing is posted - it's primitive spam control. + +Somewhere in the PHP code, you'll also find some commented out lines (lines preceded by //); if you uncomment those and input your email address, you'll receive an email for each new message. Neat stuff. + +Thanks to Gus for catching bugs and instructing me on how to clean up and improve some of the code. + +I hereby publish this guestbook into the public domain. If you want to use and adapt it, go forth and be merry, no credits required - although a link is always appreciated. + +2024-05-16 +rmf +baccyflap.com diff --git a/data.txt b/data.txt new file mode 100644 index 0000000..d2c86e9 --- /dev/null +++ b/data.txt @@ -0,0 +1 @@ +<a href="http://www.shannonkay.com" target="_blank">Shannon</a>,1739570732,First Guest 🦄. diff --git a/index.php b/index.php new file mode 100644 index 0000000..1b3ae86 --- /dev/null +++ b/index.php @@ -0,0 +1,119 @@ +<html> +<head> +<meta charset="utf-8"/> +<meta name="viewport" content="width=device-width, initial-scale=1.0"> + +<title>Guestbook + + + + + 1) { + $posts[] = array('user' => $parts[0], + 'time' => date('Y-m-d', $parts[1]), + 'message' => $parts[2]); + } + } +} + +$error = false; + +if (isset($_POST['userpost']) && empty($_POST['email'])) { + $name = trim($_POST['userpost']); + $name = str_replace(',', ',', $name); + $name = filter_var($_POST['userpost'], FILTER_SANITIZE_STRING); + + $url = filter_var($_POST['urlpost'], FILTER_SANITIZE_STRING); + $url = trim($url); + $url = str_replace('http://','',$url); + $url = str_replace('https://','',$url); + $url = rtrim($url,"/"); + + $time = time(); + + $message = filter_var($_POST['messagepost'], FILTER_SANITIZE_STRING); + $message = str_replace("\r\n", "
", $message); + $message = str_replace(',', ',', $message); + + if (($name != '') AND ($message != '') + ) { + if (!empty($url)) { + $user = '' . $name . ''; + } else { + $user = $name; + } + + $line = $user . ',' . $time . ',' . $message . "\n"; + +// uncomment the two lines below and add your email address if you want to receive an email when you get a new message +// $mailline = "a message by " . $name . " @ " . date('Y-m-d H:i', $time) . "\n" . $url . "\n\n" . $_POST['messagepost']; +// mail('your@email.com', 'guestbook entry', $mailline); + + header('Location:./'); + $file = fopen($data, 'a'); + if (!fwrite($file, $line)) { + $error = '
I could not post your message, probably a problem with serverside file permissions.
'; + } + fclose($file); + unset($_POST); + } else { + $error = '
It looks to me like you did not fill in a name or a message.
'; + } +} +?> + + + +

Guestbook

+ +

+ + Welcome to my guestbook. +

+

Please use only plain text when writing your message; your <html> has no power in this place.

+ +
+
+ + +

+

+

+ + + +

+
+ +

Guests

+
Signed by ',$post['user'], +' (',$post['time'],')
', +stripslashes($post['message']),'', "\n"; +endforeach;} else {echo '
I could not post your message, probably a problem with serverside file permissions.
';} +?> + + + + + diff --git a/style.css b/style.css new file mode 100644 index 0000000..2955dec --- /dev/null +++ b/style.css @@ -0,0 +1,111 @@ +:root { + --background-color: #f9dee1; + --text-color: #000000; + --header-color: #f87dac; + --form-border: #a48ac9; + --button-color: #f87dac; + --button-border: #a48ac9; + --button-text: #ffffff; + --message-background: #ffffff; + --message-border: #f87dac; + --info-background: #fbeaec; + --link-color: #8c5ca5; + --link-hover-color: #f76ca2; + --guest-name: #a48ac9; + --footer-border: #a48ac9; +} +body { + background-color: var(--background-color); + text-align: center; + font-family: Verdana, sans-serif; + font-size: 1.25rem; + line-height: 1.5; + min-height: 100vh; + color: var(--text-color); + } +#rules { + font-size: 1rem; +} +textarea { + border-color: var(--form-border); + border-style: solid; + border-width: 0.15rem; + padding: 0.5rem; + font-size: 1rem; + width: 350px; + max-width: 400px; + height: 150px; +} +input { + border-color: var(--form-border); + border-style: solid; + border-width: 0.15rem; + padding: 0.5rem; + font-size: 1rem; +} +.button { + background-color: var(--button-color); + border: 0.2rem solid var(--button-border); + font-weight: bold; + color: var(--button-text); +} +.info { + font-weight: normal; + text-align: justify; + background-color: var(--info-background); + padding: 0.2rem; + font-size: 1rem; +} +.small { + font-size: 1rem; +} +.mssg { + margin: 0.5rem; + padding: 1rem; + padding-top: 0.5rem; + background-color: var(--message-background); + border-color: var(--message-border); + border-style: solid; + border-width: 0.2rem; +} +.user { + font-weight: bold; + font-size: 1.2rem; + color: var( --guest-name); +} +.date { + font-size: 1rem; +} +h1 { + text-align: center; + font-size: 2.75rem; + color: var(--header-color); + margin-top: 1pt; + margin-bottom: 5pt; +} +h2 { + text-align: left; + font-size: 2rem; + color: var(--header-color); + margin-top: 1pt; + margin-bottom: 0.2rem; + margin-left: 1rem; +} +a, a:visited { + color: var(--link-color); +} + +a:hover, a:active { + font-weight: bold; + color: var(--link-hover-color); +} +code { + font-family: Menlo, Monaco, 'Courier New', monospace; +} +footer { + font-size: 1rem; + border-top: 0.2rem solid var(--footer-border); + text-align: center; + padding: 1rem; + margin-top: 0; +} \ No newline at end of file