<?php require_once('Connections/osense.php'); ?>
<?php
// *** Validate request to login to this site.
session_start();

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($accesscheck)) {
  $GLOBALS['PrevUrl'] = $accesscheck;
  session_register('PrevUrl');
}

if (isset($_POST['loginid'])) {
  $loginUsername=$_POST['loginid'];
  $password=$_POST['password'];
  $MM_fldUserAuthorization = "type";
  $MM_redirectLoginSuccess = "myjobs.php";
  $MM_redirectLoginFailed = "login.php";
  $MM_redirecttoReferrer = false;
  #mysql_select_db($database_osense, $osense);
  	

  $LoginRS__query="SELECT loginid, password, type FROM auth WHERE BINARY loginid='" . $loginUsername . "' AND BINARY password='" . $password . "'";

 //$LoginRS__query=sprintf("SELECT loginid, password, type FROM auth WHERE BINARY loginid='%s' AND password='%s'",  get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); 
   
  $LoginRS = mysqli_query($osense,$LoginRS__query);# or die(mysql_error());
  $loginFoundUser = mysqli_num_rows($LoginRS);
//echo($loginFoundUser);
  if ($loginFoundUser) {
    
    //$loginStrGroup  = mysql_result($LoginRS,0,'type');
	$loginStrGroup  = mysqli_fetch_object($LoginRS)->type;#mysqli_result($LoginRS,0,'type');
// echo($loginStrGroup);   
    //declare two session variables and assign them
    //$GLOBALS['MM_Username'] = $loginUsername;
    //$GLOBALS['MM_UserGroup'] = $loginStrGroup;	      

    //register the session variables
    //session_register("MM_Username");
    //session_register("MM_UserGroup");
	$_SESSION['ilog'] = "yes";
        $_SESSION['MM_Username'] = $loginUsername;
        $_SESSION['MM_UserGroup'] = $loginStrGroup;

    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];	
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else 
{
        //header("Location: ". $MM_redirectLoginFailed );
echo("no pass");
   if ($_SESSION['ilog']!="yes")
		{
                                     
                  echo "Invalid Username or Password.";

                 }
  }
}
 
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style1 {
	font-size: xx-large;
	font-weight: bold;
	color: #336666;
}
.border {
	border: medium solid #336666;
}
-->
</style>
<link rel="stylesheet" type="text/css" href="sdmenu/sdmenu.css" />
	<script type="text/javascript" src="sdmenu/sdmenu.js"></script>
	<script type="text/javascript">
	// <![CDATA[
	var myMenu;
	window.onload = function() {
	myMenu = new SDMenu("my_menu");
	myMenu.init();
	};
	// ]]>
	</script>
</head>

<body>
<table width="1000" height="693" align="center" class="border">
  <tr>
    <td width="157"><div align="center"><img src="wname.jpg" width="150"><span class="style1"> </span></div></td>
    <td width="672"><div align="center"><span class="style1">NetEye </span></div></td>
    <td width="149"><span class="style1"><img src="wicon.jpg"></span></td>
  </tr>
  <tr height="640">
    <td width="157">
	<div style="float: left" id="my_menu" class="sdmenu">
      <div>
            <span>NetEye</span>
                <a href="home.php">Home</a>
        <a href="topology.php">Topology</a>
        <!--a href="opictures.html">Pictures</a-->
      </div>
      <div>
        <span>MySpace</span>
        <a href="login.php">Login</a> 
      </div>

      <div> <!--class="collapsed"> -->
        <span>Support</span>
        <a href=http://www.cs.wayne.edu/saifullah/CRI_Lab.html>CRI Research Lab</a>
<!--<a href=./KanseiGenieClonePackage.tar >KanseiGenie Installation Package</a> -->
      </div>

    </div>
	</td>
	<td colspan="2">
      <form action="<?php echo $loginFormAction; ?>" method="POST" name="auth" id="auth">
        <table width="313" border="0" align="center" class="border" >
        <tr>
          <td width="71" height="42">loginID:</td>
          <td width="119"><input name="loginid" type="text" id="loginid"></td>
        </tr>
        <tr>
          <td height="43">password:</td>
          <td><input name="password" type="password" id="password"></td>
        </tr>
        <tr>
          <td colspan="2"><div align="center">
            <input type="submit" name="Submit" value="Login">
          </div></td>
        </tr>
      </table>
      </form></td>
  </tr>
</table>
</body>
</html>
