1
0
forked from lolcat/4get

ASN whitelisting

This commit is contained in:
cynic
2024-10-11 17:09:21 -04:00
parent 6eabc3edf4
commit 815223b9dc
3 changed files with 72 additions and 8 deletions

View File

@@ -1,20 +1,36 @@
<?php
include "lib/asn.php";
class bot_protection{
public function __construct($frontend, $get, $filters, $page, $output){
// check if we're operating on an ASN whitelist
if (config::ASN_WHITELIST == 1){
$response = check_asn($_SERVER["REMOTE_ADDR"], config::ASN_WHITELIST_LIST, config::WHOIS_SERVER, config::WHOIS_PORT);
if (!$response){
http_response_code(401);
echo json_encode([
"status" => "the ASN whitelist is enabled, and you ain't on it."
]);
die();
}
else{
apcu_inc("real_requests");
if($output === true){
$frontend->loadheader(
$get,
$filters,
$page
);
}
}
return;
}
// check if we want captcha
if(config::BOT_PROTECTION !== 1){
apcu_inc("real_requests");
if($output === true){
$frontend->loadheader(
$get,
$filters,
$page
);
}
return;
}