<?php
	function get_user() {
		$users = glob(APP_DIR.'/CONTENT/ROOT_URI/Admin/users/*');
		$user_arr = array();
		for($i = 0; $i < count($users); $i++) {
			$new_user = explode('/', $users[$i]);
			$new_user = end($new_user);
			$user_arr[$i] = $new_user;
		}
		if(isset($_SESSION['EMAIL']) && in_array($_SESSION['EMAIL'], $user_arr)){
			return true;
		} else return false;
	}
	$lnk2 = explode('?', $lnk);
  	include("ADMIN_HEADER.php");
  	if($_SESSION['EMAIL'] =="sarkar.suvankar@gmail.com" || $_SESSION['EMAIL']=="samiran.in@gmail.com" || $_SESSION['EMAIL']=="arif.kanyashree@gmail.com") {
    	include("ADMIN_nav.php");
    	echo "<br>";
    	if($lnk=="") include("home.php");
    	elseif(file_exists(__DIR__."/".$lnk.".php"))  include($lnk.".php");
    	elseif(isset($lnk2[1]) && file_exists(__DIR__."/".$lnk2[0].".php") ) include($lnk2[0].".php");
    	else include("404.php");
  	}
		elseif(get_user() == true){
		include("AGENT_nav.php");
  	echo "<br>";
  	if($lnk=="") include("home.php");
		elseif(file_exists(__DIR__."/agent_".$lnk.".php"))  include("agent_".$lnk.".php");
		elseif(isset($lnk2[1]) && file_exists(__DIR__."/agent_".$lnk2[0].".php") ) include("agent_".$lnk2[0].".php");
		else include("404.php");
	} else echo '<center><h2>Provide Details to login</h2> <a href="https://siliconpin.com/id/auth"><button class="btn btn-default">Login</button></a></center>';
  	include("ADMIN_FOOTER.php");
?>
