<?PHP
$sys_cat = "SMP";
include_once("../upmidsso/CAS.php");
//phpCAS::client(CAS_VERSION_2_0,'upm-id.upm.edu.my',443,'/sso_dev/');
phpCAS::client(SAML_VERSION_1_1, 'upm-id.upm.edu.my', 443, '/sso/');
//phpCAS::setCasServerCACert("../upmidsso/root.crt");//this is relative to the cas client.php file
phpCAS::setNoCasServerValidation();
if (phpCAS::isAuthenticated())
 {
	if(isset($_REQUEST['logout'])){
		session_destroy();
		$url = (isset($_SERVER['HTTPS']) ? "https" : "http")."://$_SERVER[HTTP_HOST]".strtok($_SERVER["REQUEST_URI"],'?');
	phpCAS::logoutWithRedirectService("$url");
 }
//echo (isset($_SERVER['HTTPS']) ? "https" : "http")."://$_SERVER[HTTP_HOST]".strtok($_SERVER["REQUEST_URI"],'?');
?>
<style type="text/css">
  ul {list-style: none;padding: 0px;margin: 0px;}
  ul li {display: block;position: relative;float: right;border:0px solid #000}
  li ul {display: none;}
  ul li a {display: block;padding: 5px 10px 5px 10px;text-decoration: none;
           white-space: nowrap;color: black;font-size:12px;font-family: "Times New Roman", Verdena, Serif;}
  ul li a:hover {}
  li:hover ul {display: block; position: absolute;}
  li:hover li {float: left;}
  li:hover a {background: #D8D8D8;}
  li:hover li a:hover {background: red;}
  #drop-nav li ul li {border-top: 0px;}
</style>

	<?php
	if(!$_SESSION['fullname']){
		include ("ldap.php");
	}

	echo "<body style=\"margin:0;padding:0\">";
	echo "<table cellspacing=1 cellpadding=1 bgcolor=#D8D8D8 width=100% border=0><tr><td align=left><img height=15 src='../upmidsso/images/upmidlogo_tran.png'></td><td align=right valign=absmiddle>
		<div><ul id=\"drop-nav\">
		<li><a href='?logout'>LOGOUT</a></li>
  		<li><a href=\"#\"><img valign=middle height=15 src='../upmidsso/images/Apps.png'></a>
   		<ul>
      		<li><a href=\"\">SMP</a></li>
      		<li><a href=\"\">JUBAH</a></li>
    		</ul>
  		</li>
		<li><a href=#>".$_SESSION['fullname']."</a></li>
		</ul>
		</div></td></tr></table>";
		echo "<br></body>";
		if(strcmp($_SESSION['hidsource'], $sys_cat) !== 0){
			echo "<center>".$_SESSION['hidsource']." User: You are not authorized to access this page...</center>";
			$url = (isset($_SERVER['HTTPS']) ? "https" : "http")."://$_SERVER[HTTP_HOST]".strtok($_SERVER["REQUEST_URI"],'?');
        		phpCAS::logoutWithRedirectService("$url");
			exit;
		}
 	}else{
		phpCAS::handleLogoutRequests(false);
		phpCAS::forceAuthentication();
 	}
?>

