Viewing file: authenticate.php (3.3 KB) -rw-rw-rw- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
//log them out
$logout=$_GET['logout'];
if ($logout=="yes"){ //destroy the session
session_start();
$_SESSION = array();
session_destroy();
}
//force the browser to use ssl (STRONGLY RECOMMENDED!!!!!!!!)
//if ($_SERVER["SERVER_PORT"]!=443){ header("Location: https://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']); exit(); }
//you should look into using PECL filter or some form of filtering here for POST variables
$username=strtoupper($_POST["username"]); //remove case sensitivity on the username
$password=$_POST["password"];
$formage=$_POST["formage"];
if ($_POST["oldform"]){ //prevent null bind
if ($username!=NULL && $password!=NULL){
//include the class and create a connection
include ("adLDAP.php");
$adldap = new adLDAP();
//authenticate the user
if ($adldap -> authenticate($username,$password)){
//establish your session and redirect
session_start();
$_SESSION["username"]=$username;
$redir="Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/../php/reqintranet.php";
header($redir);
exit;
}
}
$failed=1;
}
?>
<html>
<head>
<title>Intranet - SDA</title>
<style>
margin{0px}
html,body{height:100%;width:100%;}
/* end hide */
body {
text-align:center;
}
#outer{
height:100%;
width:100%;
display:table;
vertical-align:middle;
}
#container {
position:relative;
}
#inner {
width: 469px;
margin-left:auto;
margin-right:auto;
}
</style>
</head>
<body>
<div id="outer">
<div id="container">
<div id="inner">
<table width="469" height="235" border="0" cellpadding="1" background="fondo_forma.jpg" align="right" cellspacing="0">
<form method='post' action='<?php echo $_SERVER["PHP_SELF"]; ?>'>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"><br> <font size="2" face="Georgia, Times New Roman, Times, serif">
<font size="1" face="Verdana, Arial, Helvetica, sans-serif"><br>
Ingrese a continuación su nombre de usuario y
contraseña de RED</font></font></td>
</tr>
<tr>
<td align="right"> <input type='hidden' name='oldform' value='1'>
<font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Nombre
de usuario:</strong></font>
<?php if ($failed){ echo ("<font color=red size=1><br>Fallo de inicio de sesión!</font><br>\n"); } ?>
</td>
<td><input type='text' name='username' value='<?php echo ($username); ?>'></td>
</tr>
<tr>
<td align="right"><font size="2" face="Georgia, Times New Roman, Times, serif"><strong><font face="Verdana, Arial, Helvetica, sans-serif">Contraseña</font>:
</strong> </font></td>
<td><input type='password' name='password'></td>
</tr>
<tr align="center">
<td colspan="2"> <input type='submit' name='submit' value='Ingresar' style="font-size:11px">
<br> <br>
<br> </td>
</tr>
</form>
</table>
<?php if ($logout=="yes") { echo ("<br>You have successfully logged out."); } ?>
</div>
</div>
</div>
</body>
</html>
|