aboutsummaryrefslogtreecommitdiff
path: root/guestbook/submit.php
diff options
context:
space:
mode:
authorHannah Isopod <me@bathynomus.xyz>2025-06-13 01:13:52 -0600
committerHannah Isopod <me@bathynomus.xyz>2025-06-13 01:13:52 -0600
commit4ace83da3951c37f18fbb9676542239be4d051ee (patch)
treed079e79bd76cb2575faee5e64de4b44e96477b98 /guestbook/submit.php
parent9b88bf8e5fe84b41918cacca69df191e0de3a7b1 (diff)
various minor changes + blog post
a bunch of minor alterations, of particular import is the new blog post and the IP banning function I added to the guestbook
Diffstat (limited to 'guestbook/submit.php')
-rw-r--r--guestbook/submit.php28
1 files changed, 26 insertions, 2 deletions
diff --git a/guestbook/submit.php b/guestbook/submit.php
index 7fab0d5..0e53fb3 100644
--- a/guestbook/submit.php
+++ b/guestbook/submit.php
@@ -1,10 +1,31 @@
<?php
+
+ini_set('display_errors', 1);
+ini_set('display_startup_errors', 1);
+error_reporting(E_ALL);
+
include($_SERVER['DOCUMENT_ROOT'] . '/common.php');
if ($_SERVER["REQUEST_METHOD"] == "POST") {
+ $bansfp = '/var/www/data/ipbans.json';
+ $ipbans = json_decode(file_get_contents($bansfp), $assoc = true);
+ $sourceip = $_SERVER['REMOTE_ADDR'];
+
$returnCode = "success";
- if($_POST["botcheck"] != "isopod" or $_POST['msg']) {
+ if(isset($ipbans[$sourceip]) and $ipbans[$sourceip]["bannedmanually"]) {
+ $returnCode = "banned";
+ header("Location: https://www.youtube.com/watch?v=dQw4w9WgXcQ");
+ die();
+ } else if($_POST["botcheck"] != "isopod" or $_POST['msg']) {
$returnCode = "botcheckfailed";
+
+ $bf = 1;
+ if(isset($ipbans[$sourceip])) {
+ $bf = $ipbans[$sourceip]["botfails"] + 1;
+ }
+ $ipbans[$sourceip] = array( "botfails" => $bf, "bannedmanually" => false );
+ file_put_contents($bansfp, json_encode($ipbans, JSON_PRETTY_PRINT));
+
} else if(!$_POST["name"]) {
$returnCode = "noname";
} else if(!$_POST["message"]) {
@@ -24,13 +45,16 @@
$modstatus = 0;
}
}
+ if(isset($ipbans[$sourceip]) and $ipbans[$sourceip]["botfails"] >= 5) {
+ $modstatus = 0;
+ }
if($modstatus < 1) {
$returnCode = "review";
}
$currentPost = array(
"entry" => $_POST["entry"],
- "sourceip" => $_SERVER['REMOTE_ADDR'],
+ "sourceip" => $sourceip,
"date" => time(),
"name" => $_POST["name"],
"message" => $_POST["message"],