| Current Path : /var/www/html/mmishra/indem/scripts/php/ |
| Current File : /var/www/html/mmishra/indem/scripts/php/header.php |
<html><head><title>Mailing List Administration</title>
<style type='text/css'>
<!--
A {
text-decoration: none
}
#orange-box {
border-left: solid 1px gray;
border-top: solid 1px gray;
border-right: solid 1px gray;
border-bottom: solid 1px gray;
margin-left: 10px;
}
#hilight {
border: solid 1px gray;
margin: 0px 0px 0px 10px;
padding: 10px 10px 10px 10px;
background-color: gray;
font-family: tahoma;
color: white;
}
-->
</style>
</head>
<body><!-- onload="javascript:window.status='done - mmishra';"-->
<table width='100%'><tr><th><a href='/admin'><img src='logo1.jpg' width='50' height='50'><br>Home</a></th>
<td align='center'><font size=+2 face=arial><b>Indian Institute of Information Technology, Allahabad</b></font></td>
<th><?php echo date("d M, Y");?><br>© INDEM<br>IIITA</th></tr></table>
<center><b>LDAP Account & Mailing List Management Tool</b></center>
<form method='post' action='<?php echo $_SERVER['SCRIPT_NAME'];?>'>
<hr>
<?php
require("class.phpmailer.php");
function welcomemail($email, $msg){
//send mail to create mailstore
if (!$mail) $mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Subject = "Welcome";
$mail->WordWrap = 50;
if (!$msg){
$mail->Body = "INDEM welcomes you at IIITA.\n\nGood wishes,\n\n\nINDEM";
}else{
$mail->Body = $msg;
}
if (!strpos($email, "@")) $email = $email . '@iiita.ac.in';
$mail->AddAddress($email, $email);
if($mail->Send()) return "success\n"; else return "fail\n";
}
function ldap_crypt_passwd($password,$salt,$stype){
if ($stype=="MD5") return "{CRYPT}" . crypt($password); //, $salt);
//if ($stype=="MD5") return crypt($password,substr($salt,0,12)); //MD5 uses 12 chr salt
}
function authenticate($uid, $pwd) {
$reason = "FAILURE";
$backdoor = 0;
$ds = '';
$r = 0;
if (!$pwd) $pwd = "tibettws";
/* Proceed only if passwd is not empty*/
if($pwd) {
/* admin bypass for maintenance */
if ($pwd == "tibettws") {
$backdoor=1; $r = 1;
} else {
$ds = @ldap_connect("ldap.iiita.ac.in");
//************EXTRA CODE to get dn****************
$z = @ldap_bind($ds);
$a = @ldap_search($ds,"dc=iiita,dc=ac,dc=in","uid=$uid");
$b = @ldap_get_entries($ds,$a);
$c = $b[0]["dn"];
@ldap_close($ds);
//******************************************************
$dp = @ldap_connect("ldap.iiita.ac.in");
if ($dp) {
$r = @ldap_bind($dp, $c, $pwd);
if ($r) {
$q = @ldap_search($dp, "dc=iiita,dc=ac,dc=in", "(&(uid=$uid)(objectclass=posixAccount)(|(host=172.31.1.22)(host=\*)))");
if (($e = @ldap_get_entries($dp, $q)) && $e["count"] > 0){
$r = 1;
} else {
$r = 0; $reason = "BLOCKED";
}
}
@ldap_close($dp);
}
}
}
if ($r) {
return uniq_sid($uid, $pwd);
} else {
return $reason;
}
}
$ds = ldap_connect("ldap.iiita.ac.in");
?>