Your IP : 216.73.216.40


Current Path : /var/www/html/mmishra/iws8/html/ilight/mybp/
Upload File :
Current File : /var/www/html/mmishra/iws8/html/ilight/mybp/index.php

<?php
include "functions.inc";

dbConnect();

$categories = array('faculty','officer','staff','scholar','student','common','office','hostel','shop','contractor','none');
$statuss = array('online','offline');
$modes = array('rupees','units');

$remoteip = $_SERVER["REMOTE_ADDR"];

$pg = $_REQUEST["pg"];
if (!$pg) $pg = 'home';

//initialize session variables and session
session_start();

if (isset($_SESSION['user'])) {        
        $sessionid = $_SESSION['sessionid'];
        $user = $_SESSION['user'];
        $mybp = $_SESSION['mybp'];

} else if (isset($_POST["login"])) { //authenticate sign in
        $uid = $_POST["txtID"];
        $pwd = $_POST["txtPWD"];

	if (ldapAuth($uid, $pwd)) {
                $sessionid = base64_encode($uid.'-'.$pwd);
                $_SESSION["user"] = "$uid";
                $_SESSION["sessionid"] = "$sessionid";
		if ($uid == 'grsingh' || $uid == 'mmishra') 
			$_SESSION["mybp"] = TRUE;
		else 
			$_SESSION["mybp"] = FALSE;
                //session information
		mysql_query("insert into el_session(user,sessionid,datelogin,remoteip)
		values('$uid','$sessionid',now(),'$remoteip')");
                
		header("Location: index.php?pg=home");
        }
}

//check for singout signal
if ($_GET["logout"] == 1) {
        //clear session information
        mysql_query("update el_session set datelogout=now() where sessionid='$sessionid'");

        //abondon session
        session_unset();
        session_destroy();

        //reset session variables
        $HTTP_SESSION_VARS['user'] = "";
        $HTTP_SESSION_VARS['sessionid'] = "";
        $HTTP_SESSION_VARS['mybp'] = "";

        $user = "";
	$sessionid = "";
	$mybp = "";

        //redirect to home page
        header("Location: index.php?pg=home");
}

if ($mybp) {
	$flatno = strtoupper($_REQUEST["flatno"]);
	$sr = mysql_query("select * from el_licensee where flatno='$flatno'");
} else {
	$sr = mysql_query("select * from el_licensee where email='$user@iiita.ac.in'");
}
//get licensee details
while ($q = mysql_fetch_object($sr)) {
        $flatno = $q->flatno;
        $fullname = $q->fullname;
        $designation = $q->designation;
        $email = $q->email;
        $category = $q->category;
        $admissibility = $q->admissibility;
}

//get admissibility mode
$sr = mysql_query("select * from el_config");
while ($q = mysql_fetch_object($sr)) {
        $subsidymode = $q->subsidymode;
}

//if (!$flatno) $pg = 'home';


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
  	<title>MyBillPower</title>
  	<style type="text/css">
		@import "layout.css";
  	</style>
	<?php include "classes/editor.php"; ?>
</head>
<body>
<div id="mainpage">
	<div id="header">
		<div class="box">
			<div id="logo">
				<h1>MyBillPower</h1>
				<h2><img src='images/iiitalogo.gif' width='35' height='28' /></h2>
			</div>
		</div>
	</div>


	<div id="box1">
		<div class="box">
			<img src='images/bulb3.jpg' height='20' />
			<b>Electrical Billing System<br>
			Indian Institute of Information Technology Allahabad</b>
		</div>
	</div>


	<div id="box2">
		<div class="box">
			<form method="POST" action="?pg=elsearch">
  			<h1>Consumption By FlatNo</h1>
			<div id="find">
				<input type="text" name="flatno" size="20" value="<?php echo $flatno; ?>" />
				<input type="image" src="images/submit.gif" value="Search" name="B1" />
			</div>
			</form>
		</div>
	</div>

	<div id="content">
		<div class="box">
			<form method="POST" action="?pg=<?php echo $pg; ?>">
			<?php
			include "{$pg}.inc";
			?>
			<div align='right'><a href='printit.php?pg=<?php echo $pg; ?>'><img src='images/printit.jpg' width='20' height='20'>&nbsp;Print This Page</a></div>
			</form>
			<img src='images/light.jpg' width='648' height='150' style="margin: 0px">
			&nbsp;A bulb can be powered on using voltage/current of natural lightening, provided, it is tapped electronically.
			<div align='right'>-- MyBillPower</div>
		</div>
	</div>
			
	<div id="sidebar2">
		<ul>
			<li><a href="/">Home</a></li>
		</ul>
		<div class="box">
			<h1>Data</h1>
			<?php
			echo "<ul>";
			if ($mybp  == TRUE) {
				echo "
				<li><a href='?pg=elconfig'>Configuration</a></li>
				<li><a href='?pg=elsubsidy'>Admissibility</a></li>
				<li><a href='?pg=elflats'>Buildings / Flats</a></li>
				<li><a href='?pg=ellicensee'>Current Licensees</a></li>
				<li><a href='?pg=elreading'>Meter Readings</a></li>
				<li><a href='?pg=elreadingnext'>Meter Readings+</a></li>
				";
			} else {
				echo "<li><a href='?pg=login'>Links are locked</a></li>";
			}
			echo "</ul>";
			?>
		</div>
		
		<div class="box">
			<h1>Report</h1>
			<?php
			echo "<ul>";
			if ($mybp  == TRUE) {
				echo "
				<li><a href='?pg=elbilling'>Meter Billing</a></li>
				<li><a href='?pg=elreceipt'>Licensee Receipts</a></li>
				<li><a href='?pg=elcsummary'>Consumption Chart</a></li>
				<li><a href='?pg=elpsummary'>Payable Summary</a></li>
				<li><a href='?pg=elsession'>Login Sessions</a></li>
				";
			} else {
				echo "<li><a href='?pg=login'>Links are locked</a></li>";
			}
			echo "</ul>";
			?>
		</div>
		
		<div class="box">
			<h1>Mailing</h1>
			<?php
			echo "<ul>";
			if ($mybp  == TRUE) {
				echo "
				<li><a href='?pg=elrmailing'>Receipt Mailing</a></li>
				<li><a href='?pg=elsmailing'>Summary Mailing</a></li>
				";
			} else {
				echo "<li><a href='?pg=login'>Links are locked</a></li>";
			}
			echo "</ul>";
			?>
		</div>
	</div>

	<div id="footer">
		<div class="box"><p>
			<?php if ($user) echo "User $user from $remoteip, Please <a href='?pg=logout&logout=1'>Logout</a> here."; ?><br />
			&copy; 2011 IIIT Allahabad&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			Developed By <a href="http://profile.iiita.ac.in/mmishra" target="_blank">Mithilesh Kr. Mishra</a></p>
		</div>
	</div>
</div>
</body>
</html>