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

class Download extends MY_Controller {

	public function __construct(){
		parent::__construct();
		$this->load->helper('url_helper');
	}

	public function index()
	{
		$data['page_title'] = "Download";
		$data['whatsapp'] = $this->contacts['HP_No_Formatted'];
		$data['whatsapp_api'] = $this->contacts['Whatsapp_API'];
		$data['wechat'] = $this->contacts['Wechat'];
		$agent = $this->contacts['Account'];
		
		if(!empty($_POST)){ 
			$phoneNumber = $_POST['phoneNumber'];
			$millis = round(microtime(true) * 1000);
			$secret = sha1($millis . 'YhrT4Ca35jvHHf7N');

			$url = 'http://api.12wincasino.info/API_V2/api/landing_page_register';
			$myvars = 'phoneNumber=' . $phoneNumber . '&source=royald888.com&language=en&agent='.$agent.'&company=LD&millis=' . $millis . '&secret=' . $secret;

			$headers = array(
				'Content-type: application/x-www-form-urlencoded',
				'Authorization: UXMXLmXMUmep7mDN'
			);

			$ch = curl_init();
			curl_setopt($ch, CURLOPT_URL,$url);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
			curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 
			curl_setopt($ch, CURLOPT_POST, 7);
			curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars); 

			$output=curl_exec($ch);

			curl_close($ch);
			$response = json_decode($output);
			$data['message'] = $response->message;
			// echo $response->message;
		}

		$this->load->view('templates/header', $data);
		$this->load->view('download');
		$this->load->view('templates/footer');
	}
}