2 function reset_password() {
4 $login = $_POST['login'];
5 $login_type = $_POST['login_type'];
6 $vercode = $_POST['vercode'];
7 $password1 = $_POST['new_password1'];
8 $password2 = $_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!";
47 $password = md5($password1);
48 $q="update users set password='$password' where user_id='$user_id'";
51 require(INCLUDE_DIR.'ldap.inc');
52 LDAPuser::change_pass_forced($user_id,$password1);
54 $error="Password changed. Now you can login with your new password.";