From fdc354d8023a36bce032f73e014dfbd237c96ec5 Mon Sep 17 00:00:00 2001 From: "Evan G." <evan@mail.fbievan.live> Date: Sat, 18 May 2024 17:54:05 -0500 Subject: [PATCH] Make Guestbook A SubModule --- .gitmodules | 3 ++ guestbook | 1 + guestbook/guestbook.css | 21 ------------ guestbook/index.html | 48 -------------------------- guestbook/index.xml | 18 ---------- guestbook/submit.php | 76 ----------------------------------------- 6 files changed, 4 insertions(+), 163 deletions(-) create mode 100644 .gitmodules create mode 160000 guestbook delete mode 100644 guestbook/guestbook.css delete mode 100644 guestbook/index.html delete mode 100644 guestbook/index.xml delete mode 100644 guestbook/submit.php diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..97b3582 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "guestbook"] + path = guestbook + url = https://git.fbievan.live/fbievan/guestbook.git diff --git a/guestbook b/guestbook new file mode 160000 index 0000000..3c7bd7a --- /dev/null +++ b/guestbook @@ -0,0 +1 @@ +Subproject commit 3c7bd7aa909519d9b927a8053b135b5305a91de1 diff --git a/guestbook/guestbook.css b/guestbook/guestbook.css deleted file mode 100644 index 1562ea5..0000000 --- a/guestbook/guestbook.css +++ /dev/null @@ -1,21 +0,0 @@ -.guestbookpost { - padding: 10px; - border: var(--line-width) solid; - border-left-style: none; - border-right-style: none; - border-top-style: solid; - border-bottom-style: none; - text-align: left; - padding-bottom: 20px; - padding-top: 10px; - } -.date { - padding-top: 0px; - padding-bottom: 15px; -} -h4 { - margin-top: 0px; -} -p { - padding-left: 4px; -} diff --git a/guestbook/index.html b/guestbook/index.html deleted file mode 100644 index 940b381..0000000 --- a/guestbook/index.html +++ /dev/null @@ -1,48 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8"> - <title>My Cool Guestbook!</title> - <link rel="stylesheet" href="../readable.css"</link> - <link rel="stylesheet" href="./guestbook.css"</link> - <meta name="viewport" content="width=device-width, initial-scale=1.0"> -</head> -<body> - <header> - <h1>Guestbook</h1> - <p>This is a guestbook, made by fbievan</p> - </header> - <nav> - <a href="../index.html">Back Home</a> - </nav> - <main> - <form action="./submit.php" method="post"> - <input type="text" name="fname" placeholder="name"></input> - <input type="text" name="fmessage" placeholder="Message"></input> - <input type="submit"></input> - </form> - <?php - $data = json_decode(file_get_contents('test.json'), true); - echo "<div>"; - foreach($data as $post) { - echo '<section class="guestbookpost">'; - echo "<h4>"; - echo $post["name"] . "<br>"; - echo "</h4>"; - echo '<h4 class="date">'; - echo $post["date"] . "<br>"; - echo "</h4>"; - echo "<p>"; - echo $post["message"] . "<br>"; - echo "</p>"; - echo "</section>"; - } - echo "</div>"; - - ?> -</main> -<footer> - I'm cool -</footer> -</body> -</html> diff --git a/guestbook/index.xml b/guestbook/index.xml deleted file mode 100644 index 9c671f7..0000000 --- a/guestbook/index.xml +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<rss version="2.0"> - -<channel> - <title>Fbi's Epic Guestbook RSS Feed</title> - <link>https://www.w3schools.com</link> - <description>A cool Guestbook made by fbievan</description> - <?php - $data = json_decode(file_get_contents('test.json'), true); - ?> - <?php foreach($data as $post): ?> -<item> - <title><?php echo $post["name"];?></title> - <description><?php echo htmlspecialchars($post["message"]);?></description> - </item> - <?php endforeach; ?> -</channel> -</rss> diff --git a/guestbook/submit.php b/guestbook/submit.php deleted file mode 100644 index b02516d..0000000 --- a/guestbook/submit.php +++ /dev/null @@ -1,76 +0,0 @@ -<?php -class data { - public $name; - public $message; - public $date; - public $mlength; - public $nlength; - function set_date() { - $this->date = date("Y M d"); - } - function set_mlength() { - $this->mlength = strlen($this->message); - } - function set_nlength() { - $this->nlength = strlen($this->name); - } -} -$ndata = new data(); - - - - -$name = $ndata->name = htmlspecialchars($_POST["fname"]); -$message = $ndata->message = htmlspecialchars($_POST["fmessage"]); -$ndata->set_date(); -$ndata->set_mlength(); -$ndata->set_nlength(); -$mlength = $ndata->mlength; -$nlength = $ndata->nlength; - -# Setup JSON - -$newURL = "https://" . $_SERVER['SERVER_NAME'] . "/guestbook/index.html"; - -# Check name and message -if ($name == "") { - header('Refresh:2; url=' . $newURL ); - echo "There is no name, Try again with a name"; - exit(); -} -if ($message == "") { - header('Refresh:2; url=' . $newURL ); - echo "There is no message, Try again with a message"; - exit(); -} -if($mlength > 200) { - header('Refresh:2; url=' . $newURL ); - echo "This message is too long"; - exit(); -} -if($nlength > 25 ) { - header('Refresh:2; url=' . $newURL ); - echo "The name is too long"; - exit(); -} - - - -$data = json_decode(file_get_contents('test.json'), true); - - -foreach($data as $post) { - if ($post["message"] == $message) { - echo "Another message with this text already exists"; - header('Refresh:2; url=' . $newURL ); - exit(); - } -} - - -array_unshift($data , $ndata); -file_put_contents('test.json', json_encode($data, JSON_PRETTY_PRINT)); - -header('Refresh:2; url=' . $newURL ); -echo "Your submisson has been added"; -exit();