<?php
include 'anti.php';
include 'konak.php';
if(!isset($_POST['id']))
{
    $jsonarray = ["status"=> "error","message" => "you dont send id"];
    echo json_encode($jsonarray);
    die();
}
$ID = anti_injection($_POST['id']);
if(!isset($_POST['imei']))
{
    $jsonarray = ["status"=> "error","message" => "you dont send imei"];
    echo json_encode($jsonarray);
    die();
}
if(!isset($_POST['timestam']))
{
    $jsonarray = ["status"=> "error","message" => "you dont send timestam"];
    echo json_encode($jsonarray);
    die();
}
$IMEI = anti_injection($_POST['imei']);
$STAMP = anti_injection($_POST['timestam']);
$info = json_encode(["IMEI"  => $IMEI,"Stamp" => $STAMP]);
$data = mysqli_query($koneksi, "SELECT * FROM data_sucses WHERE info='".$info."'");
$cek = mysqli_num_rows($data);
if($cek > 0){ 
    $user = mysqli_fetch_array($data);
    $myname = $user["username"];
    $token =$user["token"];
    if ( $token == 'none'){
        $jsonarray = ["status"=> "OK","message" => "The token has been generated previously, please wait and check periodically."];
        echo json_encode($jsonarray);
        die();
    }
    else
    {  
        $jsonarray = ["status"=> "OK","message" => "The Token Has Been Generated.","token" => $token];
        echo json_encode($jsonarray);
        die();
    }
    
}
else
{  
    $jsonarray = ["status"=> "error","message" => "IMEI is not registered. Please make a request.."];
    echo json_encode($jsonarray);
    die();
    
}
function telebot($message) {
$url = 'https://api.telegram.org/bot8527938197:AAEEn0qWL4g8ZIPC23RdlMW5csMVtskuRrw/sendMessage?chat_id=7066855724&text='.urlencode($message)  ;
$result = file_get_contents($url, false, $context);
if ($result === false) {

}
return $result;
}
?>