2 function reset_password() {
4 $login = mysql_real_escape_string($_POST['login']);
5 $login_type = mysql_real_escape_string($_POST['login_type']);
6 $vercode = mysql_real_escape_string($_POST['vercode']);
7 $password1 = mysql_real_escape_string($_POST['new_password1']);
8 $password2 = mysql_real_escape_string($_POST['new_password2']);
11 $error="Please enter name or id";
15 if ($password1 == '' || $password2 == '') {
16 $error="Please enter password";
20 if ($password1 != $password2) {
21 $error = "The two passwords that you entered do not match.";
25 switch ($login_type) {
27 $set=$db->query("select * from users where login='$login'");
29 $user_name=$set->getString('login');
30 $user_id=$set->getString('user_id');
31 $hash=$set->getString('hash');
34 $set=$db->query("select * from users where user_id='$login'");
36 $user_name=$set->getString('login');
37 $user_id=$set->getString('user_id');
38 $hash=$set->getString('hash');
42 if ($hash != $vercode) {
43 $error="Bad verification code!";
48 $password = md5($password1);
49 $q="update users set password='$password' where user_id='$user_id'";
52 // require(INCLUDE_DIR.'ldap.inc');
53 // LDAPuser::change_pass_forced($user_id,$password1);
55 $error="Password changed. Now you can login with your new password.";