1 | <?php |
---|
2 | |
---|
3 | // Default number of letters = 3 |
---|
4 | if (!$GLOBALS['phpgw_info']['server']['num_letters_userpass']) |
---|
5 | $GLOBALS['phpgw_info']['server']['num_letters_userpass'] = 3; |
---|
6 | // Default number of special letters = 0 |
---|
7 | if (!$GLOBALS['phpgw_info']['server']['num_special_letters_userpass']) |
---|
8 | $GLOBALS['phpgw_info']['server']['num_special_letters_userpass'] = 0; |
---|
9 | if (! $GLOBALS['phpgw']->auth->authenticate($GLOBALS['phpgw_info']['user']['account_lid'], $a_passwd)) |
---|
10 | { |
---|
11 | $errors[] = lang('Your actual password is wrong'); |
---|
12 | } |
---|
13 | else if ($n_passwd != $n_passwd_2) |
---|
14 | { |
---|
15 | $errors[] = lang('The two passwords are not the same'); |
---|
16 | } |
---|
17 | else if ($a_passwd == $n_passwd) |
---|
18 | { |
---|
19 | $errors[] = lang('Your old password and your new password are the same. Choose a different new password'); |
---|
20 | } |
---|
21 | else if (! $n_passwd) |
---|
22 | { |
---|
23 | $errors[] = lang('You must enter a password'); |
---|
24 | } |
---|
25 | else if ( strlen( $n_passwd ) < $GLOBALS['phpgw_info']['server']['num_letters_userpass'] ) |
---|
26 | { |
---|
27 | $errors[] = lang('Your password must contain %1 or more letters', $GLOBALS['phpgw_info']['server']['num_letters_userpass']); |
---|
28 | } |
---|
29 | |
---|
30 | // Special Letters |
---|
31 | $speccial_letter = 0; |
---|
32 | for ($i=0; $i<strlen($n_passwd); $i++) |
---|
33 | { |
---|
34 | $letter = $n_passwd[$i]; |
---|
35 | if (! ereg ("[a-zA-Z]", $letter ) ) |
---|
36 | $speccial_letter++; |
---|
37 | } |
---|
38 | if ($speccial_letter < $GLOBALS['phpgw_info']['server']['num_special_letters_userpass']) |
---|
39 | { |
---|
40 | $errors[] = lang('Your password must contain at least %1 numbers or characters special', $GLOBALS['phpgw_info']['server']['num_special_letters_userpass']); |
---|
41 | } |
---|
42 | |
---|
43 | if(is_array($errors)) |
---|
44 | { |
---|
45 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
46 | echo parse_navbar(); |
---|
47 | $GLOBALS['phpgw']->template->set_var('messages',$GLOBALS['phpgw']->common->error_list($errors)); |
---|
48 | $GLOBALS['phpgw']->template->pfp('out','form'); |
---|
49 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
50 | } |
---|
51 | |
---|
52 | $o_passwd = $GLOBALS['phpgw_info']['user']['passwd']; |
---|
53 | $passwd_changed = $GLOBALS['phpgw']->auth->change_password($o_passwd, $n_passwd); |
---|
54 | if(!$passwd_changed) |
---|
55 | { |
---|
56 | $errors[] = lang('Failed to change password') . ". " . lang('Please contact your administrator') . '.'; |
---|
57 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
58 | echo parse_navbar(); |
---|
59 | $GLOBALS['phpgw']->template->set_var('messages',$GLOBALS['phpgw']->common->error_list($errors)); |
---|
60 | $GLOBALS['phpgw']->template->pfp('out','form'); |
---|
61 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
62 | } |
---|
63 | else |
---|
64 | { |
---|
65 | $GLOBALS['phpgw_info']['user']['passwd'] = $passwd_changed; |
---|
66 | $_SESSION['phpgw_info']['expresso']['user']['account_lid'] = $GLOBALS['phpgw_info']['user']['account_lid']; |
---|
67 | include(dirname( __FILE__ ).'/../../../expressoAdmin1_2/inc/class.db_functions.inc.php'); |
---|
68 | $db_functions = new db_functions(); |
---|
69 | $db_functions->write_log('modified user password','User change its own password in preferences'); |
---|
70 | $GLOBALS['hook_values']['account_id'] = $GLOBALS['phpgw_info']['user']['account_id']; |
---|
71 | $GLOBALS['hook_values']['old_passwd'] = $o_passwd; |
---|
72 | $GLOBALS['hook_values']['new_passwd'] = $n_passwd; |
---|
73 | $GLOBALS['phpgw']->hooks->process('changepassword'); |
---|
74 | |
---|
75 | if($GLOBALS['phpgw_info']['server']['certificado']) |
---|
76 | { |
---|
77 | // Vai criptografar senha com o certificado digital(para uso no login com certificado) .... |
---|
78 | $RR = @grava_senha_criptografada_com_certificado_no_ldap($GLOBALS['phpgw_info']['user']['account_id'],$n_passwd); |
---|
79 | } |
---|
80 | |
---|
81 | if ( (!empty($GLOBALS['phpgw_info']['server']['ldap_master_host'])) && |
---|
82 | (!empty($GLOBALS['phpgw_info']['server']['ldap_master_root_dn'])) && |
---|
83 | (!empty($GLOBALS['phpgw_info']['server']['ldap_master_root_pw'])) ) |
---|
84 | { |
---|
85 | sleep(5); |
---|
86 | } |
---|
87 | if ($GLOBALS['phpgw_info']['server']['use_https'] == 1) |
---|
88 | Header('Location: http://' . $_SERVER['HTTP_HOST'] . $GLOBALS['phpgw_info']['server']['webserver_url'] . '/preferences/index.php'); |
---|
89 | else |
---|
90 | $GLOBALS['phpgw']->redirect_link('/preferences/index.php','cd=18'); |
---|
91 | } |
---|
92 | |
---|
93 | ?> |
---|