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