<?php
error_reporting(E_ALL ^ E_DEPRECATED);
mysqli_report(MYSQLI_REPORT_OFF);
if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) && substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) {
if (ob_get_length()) ob_end_clean();
ob_start("ob_gzhandler");
}
else ob_start();
include "include/variables.php";
include "include/functions.php";
include "include/errors.php";
include "include/getip.php";
include "include/sqlwrapper.php";
$PHP_SELF=$_SERVER['PHP_SELF'];
if (!empty($_SERVER['HTTPS'])) {
$session_options = array(
"secure" => true,
"SameSite" => "None"
);
session_set_cookie_params($session_options);
}
session_start();
include "include/bots.php";
ob_start();
$action="";
?><!DOCTYPE html>
<html>
<head>
<title>TRESPASSERS WILL BE SHOT. SURVIVORS WILL BE SHOT AGAIN</title>
</head>
<body><h3>TRESPASSERS WILL BE SHOT. SURVIVORS WILL BE SHOT AGAIN</h3>
If You are here this means you violated the main internet rule for not visiting places where is strictly forbidden.
<hr><?php
include "include/ipwhitelist.php";
if (!file_exists("include/db.php")) {
$action="DB Not Ready";
$msg="Warning: Database not ready, auto-banning disabled.";
header ($_SERVER['SERVER_PROTOCOL']." 503 Service Unavailable");
} elseif (isset($whitelist) && in_array($ip, $whitelist)) {
$action = "Ignore";
$msg="Your IP is in exclusion list. Watch Out For Mines Here and There Around.";
} else {
header($_SERVER['SERVER_PROTOCOL']." 403 Forbidden");
$evt="403";
include "include/db.php";
if($db_link){
mysqli_select_db($db_link,$db);
$table="bans";
//create ban list table
if(!mysqli_query($db_link,"desc $table")){
$result=mysqli_query($db_link,"create table $table (id int not null auto_increment primary key, ip varchar(48) not null default '', timestamp int not null default 0, expires int not null default 0, exclude int not null default 0, comment text not null) default charset=utf8mb4 collate=utf8mb4_bin") or die(mysqli_error($db_link));
}
$update = false;
if (mysqli_num_rows(mysqli_query_wrapper($db_link,"select * from $table where ip='$ip'",false))>0){ //ip in db
$msg= "Warning: Duplicate IP Found: Possibly already banned and/or invalid IP Detected";
$action="Dupe Found";
} else {
$action = "Ban";
$msg="Killed (whitch means Automatically Banned) for violating the main rule of thy internet.";
$update = true;
$timestamp=time();
mysqli_query_wrapper($db_link,"insert into $table (ip,timestamp,comment) values ('$ip','$timestamp','')");
}
$result=mysqli_query($db_link,"select * from $table order by ip");
if (mysqli_num_rows($result) > 0) {
while($ban=mysqli_fetch_assoc($result)){
//bans expiration
if ($ban['expires'] > -1 && $ban['expires'] < time()) {
mysqli_query($db_link,"delete from $table where ip='".$ban['ip']."'");
$update = true;
}
}
}
if ($update) {
//update .htaccess
include "include/badbots.php";
$result=mysqli_query_wrapper($db_link,"select ip from $table order by ip",false);
$bans="";
if (mysqli_num_rows($result) > 0) {
while($ban=mysqli_fetch_assoc($result)){
$bans.= "Deny from ".$ban['ip']."\n";
}
}
//update htaccess
$out="$htaccess_header\n$errordoc\n$rewrite_rules\n$badbots\nOrder Allow,Deny\nAllow from all\nDeny from env=bad_bot\n$badips\n$bans";
$file=fopen("$prefix/.htaccess","w");
fwrite($file, $out);
fclose($file);
}
mysqli_close($db_link);
}
abuseipdbreportip($ip,"19","Automatic Report: Ignores robots.txt, visited bot-trap page linked through a hidden link, auto-banned");
}
echo "Detected IP and User Agent (Logged): $ip ".(isset($_SERVER['HTTP_USER_AGENT'])?$_SERVER['HTTP_USER_AGENT']:"")."<br>\n";
include "include/iplog.php";
echo "$msg<br>\n";
$log=fopen("$prefix/logs/bottrap.txt", "a");
fwrite($log, "[".date("Y-m-d H:i:s")."] [".$ip.(!empty($host)?(" ".$host):"")."] [$action]\n".(isset($_SERVER['HTTP_USER_AGENT'])?$_SERVER['HTTP_USER_AGENT']:"")."\n\n");
fclose($log);
ob_end_flush();
?>
You can also check other includes below (some files are hidden as they are in exclusion list):
functions.php
errors.php
getip.php
sqlwrapper.php
bots.php
iplog.php