| Current Path : /var/www/html/mmishra/indem/ |
| Current File : /var/www/html/mmishra/indem/recoverpwd.inc |
<h2>Password Self Recovery</h2>
<?php
require 'classes/PHPMailerAutoload.php';
$loginid = $_POST["loginid"];
?>
Email <input type='text' name='loginid' size='20' value='<?php echo $loginid; ?>'>@iiita.ac.in
<input type='submit' name='submit' value='SUBMIT'><br><br>
<?php
if ($loginid) {
$forwardmail = htmlsafe($_POST["forwardmail"]);
$secrethint = htmlsafe($_POST["secrethint"]);
$secretcode = htmlsafe($_POST["secretcode"]);
$ipaddr = $_SERVER["REMOTE_ADDR"];
$dated = date("Y-m-d H:i:s");
$ds = ldap_connect("ldap.iiita.ac.in");
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
$q = ldap_search($ds, "dc=iiita,dc=ac,dc=in", "(&(uid=$loginid)(objectclass=posixAccount))");
$info = ldap_get_entries($ds, $q);
$dn = $info[0]["dn"];
/*
echo "<div align='center'>";
for ($item = 0; $item < $info['count']; $item++) {
for ($attribute = 0; $attribute < $info[$item]['count']; $attribute++) {
$data = $info[$item][$attribute];
echo $data.": <b>".$info[$item][$data][0]."</b><br>";
}
}
echo "</div>";
*/
if ($info["count"] > 0) {
$cn = strtoupper($info[0]["cn"][0]);
$gecos = ucwords(strtolower(strtr($info[0]["gecos"][0],"-"," ")));
$eno = $info[0]["employeenumber"][0];
$email = $info[0]["mail"][0];
if (!$forwardmail) $forwardmail = $info[0]["mailforwardingaddress"][0];
if (!$mobile) $mobile = $info[0]["mobile"][0];
$secret = explode(':',$info[0]["registeredaddress"][0]);
$secrethint = $secret[0];
$secretcode1 = $secret[1];
if (!$secrethint) {
echo "<dir>It seems, secret hint/code has not been set by you.<br>
Please goto <a href='?pg=accountreg&loginid=$loginid'>Mail Account Setting</a>
to set these information.<br><br>
Thanks.</dir>";
} else if ($_POST["submit"] == 'RESET PASSWORD') {
if (strpos($forwardmail, "iiita.ac.in") || !$forwardmail) {
echo "Please mention some external email address.<br>Thanks.";
} else if ($secretcode1 == $secretcode) {
ldap_bind($ds, "cn=Manager,dc=iiita,dc=ac,dc=in","\$dollfinn");
$pwd1 = 'iiita' . rand(111,999);
//$pwd = '{CRYPT}' . crypt($pwd1);
$pwd = "{SHA}" . base64_encode(pack("H*", sha1($pwd1)));
$info1["userPassword"] = "$pwd";
if (ldap_modify($ds, $dn, $info1)) {
include "classes/class.phpmailer.php";
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
//$mail->IsHTML(true); // telling the class to use SMTP
$mail->CharSet="UTF-8";
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;//587;
$mail->FromName = "INDEM @ IIITA";
$mail->From = "indem@iiita.ac.in";
$mail->Username = "indem@iiita.ac.in";
$mail->Password = "chintan2014";
$mail->AddAddress($forwardmail, $loginid);
//$mail->AddAddress("mmishra@iiita.ac.in","$loginid");
$mail->AddCC("indem@iiita.ac.in", "INDEM @ IIITA");
$mail->Subject = "Password Self Recovery";
$mail->Body = "Dear $gecos ($eno) ! \n
Your request for PASSWORD @ IIITA Self Recovery has been recevied to INDEM @ IIITA. We are pleased to set your new password as $pwd1 so that you can get into your Mail @ IIITA. As this is a pure temporary arrangement, you are advised to change it at the very first login to avoid any inconvenience.
If needed, you will be contacted on your No. $mobile, however, if desired, you may also contact INDEM at 91-532-2922151/2/3.
$ipaddr is the IP address of your system request for PASSWORD @ IIITA Self-Recovery received from.
Happy mailing,
INDEM
IIIT - Allahabad
(auto generated)";
if ($mail->Send())
echo "<dir><font color=red>Thanks $gecos! Please goto your mailbox $forwardmail and
get the new password thereby in the sent mail.</font></dir>";
else
echo "Mail could not be sent. ".$mail->ErrorInfo;
} else {
echo "<dir><font color=red>Sorry $gecos! Mail with new password could not be sent to $forwardmail.
Try with other email address.</font></dir>";
}
} else {
echo "<dir><font color=red>Sorry $gecos! Try again as secret code did not match.</font><br>
Please set your secret code on <a href='?pg=accountreg'>Mail Account Setting</a>
or contact at 91-532-2922151/2/3<br> Thanks.</dir>";
}
} else {
echo "
<table border='0' cellspacing='0' width='100%'>
<tr><td>UID</td><td><b>$loginid </b></td></tr>
<tr><td nowrap>External Email*</td><td><input type='text' name='forwardmail' value='$forwardmail' size='20'></td></tr>
<tr><td>Mobile No.</td><td><input type='text' name='mobile' value='$mobile' size='20'></td></tr>
<tr><td nowrap>Secret Hint</td><td style='color: blue; font-size:14pt; padding:5pt'>$secrethint</td></tr>
<tr valign='top'><td nowrap>Secret Code*</td>
<td><input type='password' name='secretcode' value='' size='20'><br>(hidden text)</td></tr>
<tr><td></td><td><input type='submit' name='submit' value='RESET PASSWORD'></td></tr>
</table><br>";
}
}
ldap_close($ds);
}
?>
<br><ol>
<li>Secret hint and code is user credential for this service.</li>
<li>Forwarding email is mandatory for password self recovery.</li>
</ol>