<?php
include '../includes/connection.php';

$businessid=$_SESSION['business_id'];
if ($_SESSION['role']!='General Admin') {
	

 $checkdate="SELECT * FROM zhizhao where business_id=$businessid";

// function GetVolumeLabel($drive) {
//   // Try to grab the volume name
//   if (preg_match('#Volume Serial Number is (.*)\n#i', shell_exec('dir '.$drive.':'), $m)) {
//     $volname = ' ('.$m[1].')';
//   } else {
//     $volname = '';
//   }
// return $volname;
// }
// $serial =  str_replace("(","",str_replace(")","",GetVolumeLabel("c")));
// $snumber=str_replace(" ", "", $serial);
// $seri=md5($snumber);


$check=mysqli_query($conn,$checkdate) or die("ERROR : " . mysqli_error($conn));
if (mysqli_num_rows($check)==0) {
	echo "<script>window(location='../includes/licence_code.php?businessid=$businessid')</script>";
}else{


while ($checkdate = mysqli_fetch_array($check)) {
			$start = $checkdate['Kaishi'];
			$then = $checkdate['Jieshu'];
			$serr = $checkdate['disquedur'];
			
			
}
// if ($seri!=$serr) {
// 	$a=strlen($seri);
// 	$b=strlen($serr);
// 	echo "<script>alert('You are not copyrighted to use this system. contact the support team, click ok to update your licence')</script>";
// 	echo "<script>window(location='../includes/licence_code.php?businessid=$businessid')</script>";
	
// }else{
$now = time();
if($now<$start){
	
}else{

$update=mysqli_query($conn,"UPDATE  zhizhao SET Kaishu='$now' where business_id=$businessid"); 
		
		if ($update){
		}
$check =floor( ($then-$now)/(60*60*60));

//echo "then is $then ,start is $start now is $now and diff is $check ";
if($now>$then){
	echo "<marquee behavior='alternate' scrollamount ='2' scrolldelay=''><font color='#d53939'>Today is ".date('d-M-Y').". This Software Expired $check days ago.Please Contact Your Software Provider To Reactivate  <a href='../includes/licence_code.php?businessid=$businessid'>Click here to  re-activate</a></a></font></marquee>";
exit();
	
}
}


$remainingdays = floor( ($then-$now) / (60*60*24) );

if($remainingdays<10 && $remainingdays>0){
echo "<marquee behavior='alternate' scrollamount ='2' scrolldelay=''><font color='red'>Today is ".date('d-M-Y').". 
This System will expire in  $remainingdays days.Consider re-activating your System  to avoid Inconvenience   <a href='../includes/licence_code.php?businessid=$businessid'>Click here to re-activate </a>.</font></marquee>";
}
//}
}
}
?>