<?php
require_once ("varables.php");

$myJSON['message'] = "خطای اعتبارسنجی 3";
$myJSON['mmm'] = array();
if(isset($_POST["mobile"]) && isset($_POST["an1d"])	&& isset($_POST["nekot"]))
{
		$cname =$_POST["mobile"];
		$toke =$_POST["nekot"];
		$user_id =$_POST["an1d"];

		$connect = @mysqli_connect($hostname,$username,$password,$database);
		if($connect)
		{
			@mysqli_query($connect,"SET CHARACTER SET utf8;");
			$query_token = "SELECT id FROM ".$tbl_sessions." WHERE token = '".$toke."' AND uid ='".$user_id."' AND type ='A' LIMIT 1";
			$tokres=@mysqli_query($connect,$query_token);
			if (!$tokres) {
				$myJSON['message']= "خطای پایگاه داده 1" ;

			}
			else{
				$countoft = 0;
				while($rowt = @mysqli_fetch_assoc($tokres)){
					array_push($myJSON['mmm'], $rowt);
					$countoft++;
				}
				if($countoft == 0){
					$myJSON['message']= "خطای اعتبار سنجی 2" ;


				}
				else{
					$inser_q = "SELECT ".$tbl_customer.".validation FROM ".$tbl_customer." WHERE C_mobile = '".$cname."'";
					$insres=@mysqli_query($connect,$inser_q);
					if(!$insres){
						$myJSON['message']= @mysqli_error($connect);
					}
				else{
					$kod = -1;
					while($row = @mysqli_fetch_assoc($insres))	{
						$kod = $row["validation"];
					}
					if($kod >=0 )
						$myJSON['message']= $kod;
						else
						$myJSON['message']= "یافت نشد.";

				}

				}
			}
		}
		 else
			 $myJSON['message']="خطای ارتباط";
	//}
}
    echo  json_encode($myJSON);

?>
