<?php
function SporStatus($action,$inputdate,$fineid,$sign, $secret){
    		// Проверка хеша
		$hash = md5($action.$fineid.$inputdate.$secret);
		if($sign!=$hash){
			$arr ['code'] = 103;
			$arr ['message']='Error sign';
			//$arr ['data'] = $hash;
			$result = json_encode($arr);
			echo $result;
			return;
		}
        $arr = SporInfo ($fineid);
        $result = json_encode($arr);
        echo $result;
        return;

}


function SporInfo ($fineid)
{
    global $con;
    $sql = "SELECT top 1 * from spor with (nolock)  
            where fineid = '".$fineid."'";

    try{
        $query = sqlsrv_query($con,$sql);
        $arr = ["code"=>"100","message"=>"No exists"];
        if(sqlsrv_has_rows($query))
        {
            $row = sqlsrv_fetch_array($query,SQLSRV_FETCH_ASSOC);
            $arr = ["code"=>"200","data"=>$row,"message"=>"Double spor"];
        }
        else{
            $arr = ["code"=>"100","message"=>"No exists"];
        }
        return $arr;

    }catch(Exception $ex){
        $arr = ["code"=>"102","message"=>$ex->getMessage()];
        return $arr;
    }
}

?>