";
}else{
    // echo "Connection could not be established.
";
     //die( print_r( sqlsrv_errors(), true));
}
//$password=md5($_POST['tbPassword']);
//$login=$_POST['tbUsername'];
$sql= "select HeaderImageUrl,ID,ServiceEndDate,WebSiteUrl from dbo.Customers where UUID='".$cid."'";
//$sql = "SELECT ID,FirstName,LastName,Email,Company,Login,ServiceStartDate,ServiceEndDate,AFM,Address,PostalCode,Area,WebSiteUrl,Telephone,Mobile  FROM [OdigosSpoudon].[dbo].[Customers] order by id desc";
$params = array();
$options =  array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
$stmt = sqlsrv_query( $conn, $sql , $params, $options );
while( $row = sqlsrv_fetch_array( $stmt) ) {
$a1=$row[0];
    $a2=$row[1];
//  echo $row[2];
$a3=date_format($row[2],'d/m/Y');
    $a4=$row[3];
//o$a2=$row[1];
 }  
 
$current=time();
$date1 = strtr($a3, '/', '-'); 
$date2=date('Y-m-d', strtotime($date1));
$date21=date("jS F, Y", strtotime($date2));
$datediff =strtotime($date2) - $current;
$dated=round($datediff / (60 * 60 * 24));
 
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
if (strpos($actual_link, 'gel5.php')==true || strpos($actual_link, 'epal5.php')==true) { 
    $true1=true;
}else{
	$true1=false;
}
 if($a2=='' && $true1==false){
header("Location: https://stadiodromia.gr/denied.htm");  
 }
 
 if($dated<0 && $true1==false){ 
header("Location: https://stadiodromia.gr/denied.htm"); 
 }
 
 $url='https://admin.stadiodromia.gr/images/'.$a1;
$handle = curl_init($url);
        curl_setopt($handle,  CURLOPT_RETURNTRANSFER, TRUE);
        /* Get the HTML or whatever is linked in $url. */
        $response = curl_exec($handle);
       /* Check for 404 (file not found). */
       $httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
       if($httpCode == 404) {
        $url='http://admin.stadiodromia.gr/data/cust/'.$a2.'/'.$a1;
        }
if($a1==''){$url='https://odigos.stadiodromia.gr/public/img_login/stratos.png';}
curl_close($handle);
 
 
?>