From f9cf02d1339969958cd166eb82609593698950fb Mon Sep 17 00:00:00 2001 From: Paul M Date: Fri, 17 Nov 2023 13:28:12 -0600 Subject: [PATCH] Copied form my website. This merged the HTML and PHP to support additional anti spam code, bluma was added to make it nicer and passfail got fixed --- contactform.php | 219 ++++++++++++++++++++++++++++-------------------- 1 file changed, 126 insertions(+), 93 deletions(-) diff --git a/contactform.php b/contactform.php index 1861459..ef5f465 100755 --- a/contactform.php +++ b/contactform.php @@ -1,13 +1,12 @@ passfail = 0; // beter way to filter input data $_POST = filter_var_array($_POST, FILTER_SANITIZE_STRING); $_GET = filter_var_array($_GET, FILTER_SANITIZE_STRING); @@ -32,7 +31,7 @@ class antibot { private function fromtest() { if ($_SERVER['HTTP_REFERER'] = "https://urandom.link/contactform.php"){ - $passfail = 1; + $this->passfail++; } } @@ -40,16 +39,17 @@ class antibot { private function ratetest() { if (!$_SESSION['last_submit']){ $_SESSION['last_submit'] = time(); // May not stick to a bot but doing it anyhow - $passfail = 2; + $this->passfail = 1; }else{ //print "Session found"; if (time()-$_SESSION['last_submit'] < 60){ // Purposefully not letting them know what the interval is - die('Error: Message not sent, rate limit hit. Please wait a few minutes and try again.'); - $passfail = 0; + + die('Error: Message not sent, rate limit hit. Please wait a few minutes and try again.'); + }else{ $_SESSION['last_submit'] = time(); - $passfail = 2; + $this->passfail++; } } @@ -57,11 +57,20 @@ class antibot { private function traptest() { if($_POST['website']){ - $passfail = 0; + $this->passfail = 0; }else{ - $passfail = 3; + $this->passfail++; } - return $passfail; + return $this->passfail; + } + + private function emptytest() { + if (empty($_POST['fname']) || empty($_POST['lname']) || empty($_POST['email']) || empty($_POST['comments'])){ + $this->passfail = 0; + }else{ + $this->passfail++; + } + } private function sndmsg($target) { @@ -78,10 +87,11 @@ class antibot { public function do_tests(){ $this->fromtest(); $this->ratetest(); - $result = $this->traptest(); - if($result == 3) { + $this->traptest(); + $this->emptytest(); + if($this->passfail == 4) { $this->sndmsg("webmaster@pngpst.net"); - return 3; + return 4; }else{ return 0; } @@ -107,7 +117,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { // Token is valid, process the form // ... Your form processing logic goes here ... $winner = $antibot->do_tests(); - if ($winner == 3){ + if ($winner == 4){ echo "Form Submitted thank you!"; }else{ echo "Error: Send failed, please try again. -1"; @@ -140,7 +150,9 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { - + + + Urandom.link contact form @@ -148,92 +160,113 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { +
+
+

+ URANDOM.LINK Contact Form +

+

+ Embrace the random +

+
+
-
- - - -
- - - -

- -