passfail = 0; // beter way to filter input data $_POST = filter_var_array($_POST, FILTER_SANITIZE_STRING); $_GET = filter_var_array($_GET, FILTER_SANITIZE_STRING); } private function fromtest() { if ($_SERVER['HTTP_REFERER'] = "https://urandom.link/contactform.php"){ $this->passfail++; } } private function ratetest() { if (!$_SESSION['last_submit']){ $_SESSION['last_submit'] = time(); // May not stick to a bot but doing it anyhow $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.'); }else{ $_SESSION['last_submit'] = time(); $this->passfail++; } } } private function traptest() { if($_POST['website']){ $this->passfail = 0; }else{ $this->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) { // First clean the data $fname = $_POST["fname"]; $lname = $_POST["lname"]; $email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL); $comments = $_POST["comments"]; // compile cleaned message $msg = "From $fname Subject $lname email $email with message $comments"; mail($target,"Website Form Submission",$msg); } public function do_tests(){ $this->fromtest(); $this->ratetest(); $this->traptest(); $this->emptytest(); if($this->passfail == 4) { $this->sndmsg("webmaster@pngpst.net"); return 4; }else{ return 0; } } } $antibot = new antibot(); if ($_SERVER["REQUEST_METHOD"] == "POST") { // Check if the CSRF token is present if (isset($_POST['csrf_token'])) { $user_token = $_POST['csrf_token']; // Check if the submitted token matches the stored session token if ($user_token === $_SESSION['csrf_token']) { // Token is valid, process the form // ... Your form processing logic goes here ... $winner = $antibot->do_tests(); if ($winner == 4){ echo "Form Submitted thank you!"; }else{ echo "Error: Send failed, please try again. -1"; } } else { // Invalid token, handle accordingly (e.g., log the incident, reject the form) die("Error: Send failed, please try again. -2"); } } else { // CSRF token is not present, handle accordingly die("Error: Send failed, please try again. -3"); } } //else { // Handle non-POST requests accordingly //die("Invalid request method."); //} // $winner = $lcheck->do_tests(); //if ($winner == 3){ // echo "Form Submitted thank you!"; // }else{ // echo "Error: Send failed, please try again."; //} ?> Urandom.link contact form

URANDOM.LINK Contact Form

Embrace the random

This field is required

This field is required