<?php
include("db.php");

$_SESSION["admin"]["utype"] = $_GET['src'];

if(isset($_POST['login']))
{
	
	$loginAry['username']=$_POST['username']; 
	$loginAry['pws']=$_POST['password']; 
	$loginAry['rolid']="student"; 
	
	$returndata=$objextra->login($loginAry);
	if($returndata['status']=='success')
	{
		redirect("dashboard_new.php");exit;
	}else{
		redirect("index.php");exit;
	}
//	$returndata=$objextra->login($loginAry);echo"<pre>";print_r($returndata);print_r($_SESSION);exit;	
}
//echo "<pre>";print_r($LinksDetails);exit;
if(isset($_GET["install"]) && $_GET["install"]=="success"){
	rrmdir("install");
	unlink("install");
	unlink("license.php");
	unlink("info.php");
	redirect("./");	
}
if(isset($_POST['licence'])){
	echo '<style>.error {
	background: url("assets/icon/cross.gif") no-repeat;
	color: #D70000;
	line-height: 16px;
	margin-bottom: 10px;
	padding-left: 20px;}</style>';
	if(trim($_POST['licence'])!=''){
		if($final_licance==$_POST['licence']){
			if(SETTING=="setting"){
				$aryReturn=$db->updateAry("setting",array("expiredate"=>$_POST["udate"]),"where school_id='".$_SESSION["admin"]["school_id"]."'");
			}else{
				$aryReturn=$db->updateAry("settings",array("value"=>$_POST["udate"]),"where field='expiredate'");
			}
			echo $db->getErMsg().$db->getLastQuery();redirect("./");
		}else{
			echo "<p class='error'>Invalid license_number Please try again</p>";
		}
	}else{
		echo "<p class='error'>license_number cannot blank Please try again</p>";echo '';
	}
}
if(isset($_POST['complicence'])){ 

	echo '<style>.error {
	background: url("assets/icon/cross.gif") no-repeat;
	color: #D70000;
	line-height: 16px;
	margin-bottom: 10px;
	padding-left: 20px;}</style>';
	if(trim($_POST['complicence'])!=''){
		$sysl=md5(base64_encode(php_uname('n')));
		if($sysl==$_POST['complicence']){
			if(SETTING=="setting"){
				$aryReturn=$db->updateAry("setting",array("systemname"=>php_uname('n')),"where school_id='".$_SESSION["admin"]["school_id"]."'");
			}else{
				$aryReturn=$db->updateAry("settings",array("value"=>php_uname('n')),"where field='systemname'");
			}
			echo $db->getErMsg().$db->getLastQuery();redirect("./");
		}else{
			echo "<p class='error'>Invalid license_number Please try again  $sysl ".php_uname('n')."</p>";
		}
	}else{
		echo "<p class='error'>license_number cannot blank Please try again</p>";echo '';
	}  
	
}
if(isset($_SESSION["admin"]) && $_SESSION["admin"]["uid"]!=""){
 if(isset($_GET["loadData"]) && $_GET["loadData"]=="yes"){
    if((isset($_GET["page_id"])) && (!isset($_GET['chk'])))
	{
		$st=checkPermission($_SESSION["admin"]["utype"],$_SESSION["admin"]["roll"]);
		if($st=="none"){
			include_once("error.php");exit;
		}else{
			if($_SESSION["admin"]["utype"]=="Student")
			{
				include_once($_GET["page_id"].".php");exit;
			}
			else 
			{
				include_once($_SESSION["admin"]["utype"]."/".$_GET["page_id"].".php");exit;
			}
		}
	}
 }

/*$checkExpire=checkInstallation();
if(count($checkExpire)>0){
	if($checkExpire["message"]==1){
		redirect("install/install.php");
	}
	else{
		echo implode($checkExpire)."	<br />Thank You";exit;
	}
}*/
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
	<script>
    var headPrint='<div class="headPrint"><img src="<?php echo $LinksDetails["logo"] ?>" height="60px"><h1><?php echo ucfirst(trim($LinksDetails["site_name"])) ?></h1></div>';
	var root='<?php echo URL_ROOT ?>';
	</script>
    <?php include("ms_meta.php"); 
    ?>
    
    <script type="text/javascript" src="js/jQuery.print.js"></script>
    <style>
    .idcard {
		width: 492px !important;
		height: 241px !important;
	}
    </style>
</head>
<body>

	<!-- Top Fixed Bar -->
	<?php
     include("ms_menu.php");
     ?>
    <?php 
	if($rempDate<=15){
	?>
  <!--  <div class="alert alert-light">-->
		<!--	<a class="close" data-dismiss="alert">×</a>-->
		<!--	<i class="icon-comment"></i> Your software is expire with in <strong><?php echo $rempDate; ?></strong> days-->
		<!--</div>-->
     <?php
	}
	 ?>
	<!-- Content Container -->
	<div class="container">
    	<br/>
		<?php
		
		if((isset($_GET["page_id"])) && (!isset($_GET['chk'])))
		{
		    
            $st=checkPermission($_SESSION["admin"]["utype"],$_SESSION["admin"]["roll"]);
            //echo $_SESSION["admin"]["utype"].",".$_SESSION["admin"]["roll"];
			if($st=="none"){
				include_once("error.php");
			}else{

				if($_GET["src"]=="Student")
				{
					include_once($_GET["page_id"].".php");
				}
				else 
				{
				// 	include_once($_SESSION["admin"]["utype"]."/".$_GET["page_id"].".php");
				    include_once($_GET["src"]."/".$_GET["page_id"].".php");
				}
			  
			}
			/*
			if(isset($_SESSION["admin"]["utype"])){
			}
			else{
				include_once($_GET["page_id"].".php");
			}*/
		}
		elseif(isset($_GET['chk'])){
			$_SESSION["admin"]["utype"]="sms";
				include_once("sms/sms.php");
			}
		else{
			include_once("dashboard.php");
		}
 
		?>

	</div> 
	<!-- / Content Container -->

	<!-- Footer -->
	<footer class="footer">

			<!-- Footer Container -->
      <div class="container">

				<!-- Footer Container: Content -->
        <p>Developed and design by <a href="http://savarnacloudtech.com">Savarna Cloudtech Pvt.Ltd</a></p>
        <p>Copyright <a href="#"> <?php echo $LinksDetails["site_name"]; ?></a> &copy;  All rights resserved.</p>
        <!-- / Footer Container: Content -->

      </div>
      <!-- / Footer Container -->

	</footer>
	<!-- / Footer -->

</body>

</html>
<?php
}elseif(isset($_SESSION["user"])){
	redirect("dashboard_new.php");	
}elseif(isset($_SESSION["site"])){
	$smarty->assign("meta_title", $LinksDetails["general_meta_title"]);
	$smarty->assign("meta_tag", $LinksDetails["general_meta_tags"]);
	$smarty->assign("meta_description", $LinksDetails["general_meta_desc"]);
	$smarty->assign("silder",$objindex->slider());
	$smarty->assign("side_silder",$objindex->slider("SIDE"));
	
	//echo "<pre>";print_r($objindex->slider("SIDE"));exit;
	
	$smarty->assign("faculty",$objindex->extra_content('FACULTY'));
	//echo "<pre>";print_r($objindex->extra_content('advertiesments'));exit;
	//echo "<pre>";print_r($objindex->solo_extra_content('photo_gallery'));print_r($objindex->solo_extra_content('video_gallery'));print_r($objindex->extra_content('extra'));exit;
	
	$smarty->assign("latest_stories",$objindex->extra_content('LATEST_STORY'));
	
	$smarty->assign("photoGallery",$objindex->extra_content('PHOTO_GALLERY'));
	
	//echo "<pre>";print_r($objindex->solo_extra_content('photo_gallery'));exit;
	
	$smarty->assign("videoGallery",$objindex->extra_content('VIDEO_GALLERY'));
	
	$smarty->assign("extradata",$objindex->extra_content('EXTRA'));
	
	$smarty->assign("sponcers",$objindex->extra_content('SPONCERS'));
	
	$smarty->assign("photos",$objindex->extra_content('Photos'));
	$smarty->assign("footer_news",$objindex->extra_content('NEW_UPDATES'));
	$smarty->assign("profile",$objindex->profile($_SESSION['user']['uid']));
	$smarty->assign("cname",$objindex->cname());
	$smarty->display('index.html');
}else{
	redirect("adminlogin.php");	
}
?>