= 102){ // reached limit, delete and give captcha apcu_delete($_COOKIE["pass"]); }else{ // the cookie is OK! dont die() and give results if($output === true){ $frontend->loadheader( $get, $filters, $page ); } return; } } } if($output === false){ echo json_encode([ "status" => "The \"pass\" token in your cookies is missing or has expired!!" ]); die(); } /* Validate form data */ $lines = explode( "\r\n", file_get_contents("php://input") ); $invalid = false; $answers = []; $key = false; $error = ""; foreach($lines as $line){ $line = explode("=", $line, 2); if(count($line) !== 2){ $invalid = true; break; } preg_match( '/^c\[([0-9]+)\]$/', $line[0], $regex ); if( $line[1] != "on" || !isset($regex[0][1]) ){ // check if its k if( $line[0] == "k" && strpos($line[1], "c.") === 0 ){ $key = apcu_fetch($line[1]); apcu_delete($line[1]); } break; } $regex = (int)$regex[1]; if( $regex >= 16 || $regex <= -1 ){ $invalid = true; break; } $answers[] = $regex; } if( !$invalid && $key !== false ){ $check = $key[1]; // validate answer for($i=0; $i time() + 86400, // expires in 24 hours "samesite" => "Strict", "path" => "/" ] ); $frontend->loadheader( $get, $filters, $page ); return; }else{ $error = "
You were kicked out of Mensa. Please try again.
"; } } /* Generate random grid data to pass to captcha.php */ $dataset = [ ["birds", 2263], ["fumo_plushies", 1006], ["minecraft", 848] ]; // get the positions for the answers // will return between 3 and 6 answer positions $range = range(0, 15); $answer_pos = []; array_splice($range, 0, 1); for($i=0; $i "", "right-left" => "", "right-right" => "", "left" => '
' . '

IQ test

' . 'Due to getting hit with 20,000 bot requests per day, I had to put this up. Sorry.

' . 'Solving this captcha will allow you to make 100 searches today. I will add a way for legit users to bypass the captcha later. Sorry /g/tards!!' . $error . '
' . '
' . '
' . 'Captcha image' . '
' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '
' . '
' . '
' . '' . '' . '
' . '
' ]; http_response_code(429); // too many reqs $frontend->loadheader( $get, $filters, $page ); echo $frontend->load("search.html", $payload); die(); } }