| Current Path : /var/www/html/mmishra/sip/ |
| Current File : /var/www/html/mmishra/sip/init.inc.php~ |
<?php
//include configuration and function library
require("config.inc.php");
require("functions.inc.php");
//call database connection
dbConnect("irp");
//some enumerated values
$statuss = array('active','inactive');
$referer = $_SERVER['HTTP_REFERER'];
$url = $_SERVER['REQUEST_URI'];
$remoteip = getIP();
//$_SERVER["REMOTE_ADDR"];
//initialize session variables and session
session_start();
if (isset($_SESSION['sessionid'])) {
//check session and session variables
$sessionid = $_SESSION['sessionid'];
$user = $_SESSION['user'];
$role = $_SESSION['role'];
} else if (isset($_POST['login'])) {
//authenticate sign in
$uid = $_POST["txtID"];
$pwd = $_POST["txtPWD"];
//echo (ldapAuth($uid, $pwd));
$role = localAuth($uid);
//else
// $role = 'user';
if ($role == 'guest') {
header("Location: /guest/");
} else {
$sessionid = base64_encode($user.'-'.$pwd);
$_SESSION["user"] = "$uid";
$_SESSION["role"] = "$role";
$_SESSION["sessionid"] = "$sessionid";
//session information
mysql_query("insert into websessions(userid,remoteip,action,datesession)
values('$uid','$remoteip','login',now())");
if ($role == 'admin') {
header("Location: /admin/");
} else if ($role == 'operator') {
header("Location: /operator/");
} else {
header("Location: /user/");
}
}
}
if ($_REQUEST['logout'] == 1) {
//check for sing out signal
//session information
mysql_query("insert into websessions(userid,remoteip,action,datesession)
values('$user','$remoteip','logout',now())");
//reset session variables
$_SESSION['user'] = "";
$_SESSION['role'] = "";
$user = "";
$role = "";
//finally destroy current session
session_destroy();
header("Location: /");
}
//session_destroy();
//log activity in access log database
accessLog($user, $referer, $url, $remoteip);
$header = "<html>
<head>
<title>SIP Ver. 1.0</title>
<base href='http://sip.iiita.ac.in/'></base>
<link href='css/style.css' rel='stylesheet' />
</head>
<body>
<center>
<img src='images/iLogo.png' width='50' height='50' border='0' />
<h1>Indian Institute of Information Technology Allahabad</h1>
<h2>(Student Information Portal)</h2>
</center>
";
if ($user)
$header .= "<div align='right'>
Welcome! $user ($role),
please go [ <a href='javascript: window.history.back()'>Back</a> ] or
[ <a href='?logout=1'>Logout</a> ] here.
</div>
";
$header .= "<form method='POST' action='".$_SERVER['PHP_SELF']."'>";
$footer = "</form>
<br><br><br><br>
<div id='footer' align='center'>
Developed by: Mithilesh Kr. Mishra (System Analyst), IIIT Allahabad
</div>
</body>
</html>";
?>