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

class Home extends Secure_area
{
	function __construct()
	{
		parent::__construct();
	}

	function index()
	{
		ob_start();
		system('ipconfig /all');
		$mycom=ob_get_contents();
		ob_clean();
		$findme = "Physical";
		$pmac = strpos($mycom, $findme);
		$mac=substr($mycom,($pmac+36),17);

		$current_directory=getcwd();

		$target_file = $current_directory."\application\controllers\permission.php";
		$file_contentArray =explode("#",file_get_contents($target_file, true));

		$machine_chage_error=0;

		if($file_contentArray[4]!=$mac){
			$machine_chage_error=1;
		}

		///////////////////////Time has been modified////////////////////////////
		$datetime_modified_error=0;
		$current_directory=getcwd();
		$filename = $current_directory.'\application\controllers\access.php';


		if (file_exists($filename)) {
			$file_creation_date=strtotime(date ("F d Y H:i:s.", filemtime($filename)));
			$curren_time=strtotime(date ("F d Y H:i:s."));
			if($curren_time<$file_creation_date){
				$datetime_modified_error=1;
			}else{
				$fhandle = fopen($filename,"w");
				fwrite($fhandle,"DONE");
				fclose($fhandle);
			}
		}

		///////////////////////Registration has been modified////////////////////////////
		$expire_error=0;
		$current_directory=getcwd();
		$filename = $current_directory.'\application\controllers\permission.php';


		if (file_exists($filename)) {
			$file_creation_date=strtotime(date ("F d Y H:i:s.", filemtime($filename)));
			$curren_time=strtotime(date ("F d Y H:i:s."));
			if($curren_time>$file_creation_date){
				$expire_error=1;
			}
		}

		/*if($expire_error==1){
			$this->load->view("renew");
		}elseif ($datetime_modified_error==1){
			$this->load->view("daterenew");
		}elseif ($machine_chage_error==1){
			$this->load->view("matchinerenew");
		}else{
			$this->load->view("home");
		}*/
		$this->load->view("home");
	}

	function logout()
	{
		$this->Employee->logout();
	}
}
?>