$bf, "bannedmanually" => false ); file_put_contents($bansfp, json_encode($ipbans, JSON_PRETTY_PRINT)); } else if(!$_POST["name"]) { $returnCode = "noname"; } else if(!$_POST["message"]) { $returnCode = "nomessage"; } else if( $_POST["website"] and !preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $_POST["website"]) or $_POST["cool"] and !preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $_POST["cool"]) ) { $returnCode = "invalidlink"; } else { date_default_timezone_set("America/Edmonton"); $modstatus = $defaultmodstatus; $bannedwords = json_decode(file_get_contents($datadir."bannedwords.json")); $bwspotted = false; foreach($bannedwords as $word) { if(preg_grep($word, $_POST)) { $modstatus = 0; } } if(isset($ipbans[$sourceip]) and $ipbans[$sourceip]["botfails"] >= 5) { $modstatus = 0; } if($modstatus < 1) { $returnCode = "review"; } $button = ""; // URL for the submitter's .well-known/button.json if($_POST["website"]) { $buttonjson = ""; $buttonjsonurl = 'https://'.parse_url($_POST["website"], PHP_URL_HOST).'/.well-known/button.json'; $ch = curl_init($buttonjsonurl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, 0); $buttonjson = curl_exec($ch); if(curl_error($ch)) { //echo curl_error($ch); $buttonjson = ""; } curl_close($ch); if($buttonjson) { $buttonobj = json_decode($buttonjson); if($buttonobj->default) { foreach ($buttonobj->buttons as $btn) { if($btn->id === $buttonobj->default) { $button = $btn->uri; break; } } } else { $button = $buttonobj->buttons[0]->uri; } } } $currentPost = array( "entry" => $_POST["entry"], "sourceip" => $sourceip, "date" => time(), "name" => $_POST["name"], "message" => $_POST["message"], "found" => $_POST["found"], "website" => $_POST["website"], "button" => $button, "cool" => $_POST["cool"], "reply" => "", "modstatus" => $modstatus ); $filename = $datadir."posts.json"; $extantPosts = json_decode(file_get_contents($filename)); array_push($extantPosts, $currentPost); file_put_contents($filename, json_encode($extantPosts, JSON_PRETTY_PRINT)); } } $referrer = preg_replace("/\?.*/", "", $_SERVER['HTTP_REFERER']); header("Location: $referrer?return=$returnCode"); ?>
Your post has been submitted! It's weird that you're seeing this page though. Maybe your browser can't process location headers? At any rate, click here"; ?> to get where you're supposed to be right now.