forked from lolcat/4get
ASN whitelisting
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user