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