[2] | 1 | <?php |
---|
| 2 | /**************************************************************************\ |
---|
| 3 | * phpGroupWare - preferences * |
---|
| 4 | * http://www.phpgroupware.org * |
---|
| 5 | * Written by Joseph Engo <jengo@phpgroupware.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 | |
---|
| 14 | $GLOBALS['phpgw_info']['flags'] = array( |
---|
| 15 | 'noheader' => True, |
---|
| 16 | 'nonavbar' => True, |
---|
| 17 | 'currentapp' => 'preferences' |
---|
| 18 | ); |
---|
| 19 | |
---|
| 20 | include('../header.inc.php'); |
---|
| 21 | |
---|
[32] | 22 | $a_passwd = $_POST['a_passwd']; |
---|
[2] | 23 | $n_passwd = $_POST['n_passwd']; |
---|
| 24 | $n_passwd_2 = $_POST['n_passwd_2']; |
---|
| 25 | |
---|
| 26 | if(!$GLOBALS['phpgw']->acl->check('changepassword', 1) || $_POST['cancel']) |
---|
| 27 | { |
---|
[72] | 28 | if(($GLOBALS['phpgw_info']['user']['lastpasswd_change'] == '0') && (!$_POST['cancel'])) |
---|
| 29 | $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/login.php','cd=6')); |
---|
| 30 | |
---|
[35] | 31 | if ($GLOBALS['phpgw_info']['server']['use_https'] == 1) |
---|
| 32 | Header('Location: http://' . $_SERVER['HTTP_HOST'] . $GLOBALS['phpgw_info']['server']['webserver_url'] . '/preferences/index.php'); |
---|
| 33 | else |
---|
| 34 | $GLOBALS['phpgw']->redirect_link('/preferences/index.php'); |
---|
| 35 | |
---|
[2] | 36 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | $GLOBALS['phpgw']->template->set_file(array( |
---|
| 40 | 'form' => 'changepassword.tpl' |
---|
| 41 | )); |
---|
[32] | 42 | $GLOBALS['phpgw']->template->set_var('lang_enter_actual_password',lang('Enter your actual password')); |
---|
[2] | 43 | $GLOBALS['phpgw']->template->set_var('lang_enter_password',lang('Enter your new password')); |
---|
| 44 | $GLOBALS['phpgw']->template->set_var('lang_reenter_password',lang('Re-enter your password')); |
---|
| 45 | $GLOBALS['phpgw']->template->set_var('lang_change',lang('Change')); |
---|
| 46 | $GLOBALS['phpgw']->template->set_var('lang_cancel',lang('Cancel')); |
---|
| 47 | $GLOBALS['phpgw']->template->set_var('form_action',$GLOBALS['phpgw']->link('/preferences/changepassword.php')); |
---|
| 48 | |
---|
[72] | 49 | if ($_GET['cd'] == 1) |
---|
| 50 | { |
---|
| 51 | $lang1 = lang('Your password has expired'); |
---|
| 52 | $lang2 = lang('You must register a new password'); |
---|
| 53 | $GLOBALS['phpgw']->template->set_var('messages',"<font color=red><h1>$lang1.<br>$lang2.</h1></font>"); |
---|
| 54 | } |
---|
| 55 | |
---|
[2] | 56 | if ($GLOBALS['phpgw_info']['server']['auth_type'] != 'ldap') |
---|
| 57 | { |
---|
| 58 | $GLOBALS['phpgw']->template->set_var('sql_message',lang('note: This feature does *not* change your email password. This will ' |
---|
| 59 | . 'need to be done manually.')); |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | if ($_POST['change']) |
---|
| 63 | { |
---|
[35] | 64 | // Default number of letters = 3 |
---|
| 65 | if (!$GLOBALS['phpgw_info']['server']['num_letters_userpass']) |
---|
| 66 | $GLOBALS['phpgw_info']['server']['num_letters_userpass'] = 3; |
---|
| 67 | // Default number of special letters = 0 |
---|
| 68 | if (!$GLOBALS['phpgw_info']['server']['num_special_letters_userpass']) |
---|
| 69 | $GLOBALS['phpgw_info']['server']['num_special_letters_userpass'] = 0; |
---|
[32] | 70 | if (! $GLOBALS['phpgw']->auth->authenticate($GLOBALS['phpgw_info']['user']['account_lid'], $a_passwd)) |
---|
| 71 | { |
---|
| 72 | $errors[] = lang('Your actual password is wrong'); |
---|
| 73 | } |
---|
[35] | 74 | else if ($n_passwd != $n_passwd_2) |
---|
[2] | 75 | { |
---|
| 76 | $errors[] = lang('The two passwords are not the same'); |
---|
| 77 | } |
---|
[72] | 78 | else if ($a_passwd == $n_passwd) |
---|
| 79 | { |
---|
| 80 | $errors[] = lang('Your old password and your new password are the same. Choose a different new password'); |
---|
| 81 | } |
---|
[35] | 82 | else if (! $n_passwd) |
---|
[2] | 83 | { |
---|
| 84 | $errors[] = lang('You must enter a password'); |
---|
| 85 | } |
---|
[35] | 86 | else if ( strlen( $n_passwd ) < $GLOBALS['phpgw_info']['server']['num_letters_userpass'] ) |
---|
[32] | 87 | { |
---|
[35] | 88 | $errors[] = lang('Your password must contain %1 or more letters', $GLOBALS['phpgw_info']['server']['num_letters_userpass']); |
---|
[77] | 89 | } |
---|
| 90 | |
---|
| 91 | // Special Letters |
---|
| 92 | $speccial_letter = 0; |
---|
| 93 | for ($i=0; $i<strlen($n_passwd); $i++) |
---|
[32] | 94 | { |
---|
[77] | 95 | $letter = $n_passwd[$i]; |
---|
| 96 | if (! ereg ("[a-zA-Z]", $letter ) ) |
---|
| 97 | $speccial_letter++; |
---|
| 98 | } |
---|
| 99 | if ($speccial_letter < $GLOBALS['phpgw_info']['server']['num_special_letters_userpass']) |
---|
| 100 | { |
---|
[32] | 101 | $errors[] = lang('Your password must contain at least %1 numbers or characters special', $GLOBALS['phpgw_info']['server']['num_special_letters_userpass']); |
---|
| 102 | } |
---|
| 103 | |
---|
[2] | 104 | if(is_array($errors)) |
---|
| 105 | { |
---|
| 106 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 107 | echo parse_navbar(); |
---|
| 108 | $GLOBALS['phpgw']->template->set_var('messages',$GLOBALS['phpgw']->common->error_list($errors)); |
---|
| 109 | $GLOBALS['phpgw']->template->pfp('out','form'); |
---|
| 110 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | $o_passwd = $GLOBALS['phpgw_info']['user']['passwd']; |
---|
| 114 | $passwd_changed = $GLOBALS['phpgw']->auth->change_password($o_passwd, $n_passwd); |
---|
| 115 | if(!$passwd_changed) |
---|
| 116 | { |
---|
[545] | 117 | $errors[] = lang('Failed to change password') . ". " . lang('Please contact your administrator') . '.'; |
---|
[2] | 118 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 119 | echo parse_navbar(); |
---|
| 120 | $GLOBALS['phpgw']->template->set_var('messages',$GLOBALS['phpgw']->common->error_list($errors)); |
---|
| 121 | $GLOBALS['phpgw']->template->pfp('out','form'); |
---|
| 122 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 123 | } |
---|
| 124 | else |
---|
| 125 | { |
---|
| 126 | $GLOBALS['phpgw_info']['user']['passwd'] = $GLOBALS['phpgw']->auth->change_password($o_passwd, $n_passwd); |
---|
| 127 | $GLOBALS['hook_values']['account_id'] = $GLOBALS['phpgw_info']['user']['account_id']; |
---|
| 128 | $GLOBALS['hook_values']['old_passwd'] = $o_passwd; |
---|
| 129 | $GLOBALS['hook_values']['new_passwd'] = $n_passwd; |
---|
| 130 | $GLOBALS['phpgw']->hooks->process('changepassword'); |
---|
[35] | 131 | |
---|
| 132 | if ($GLOBALS['phpgw_info']['server']['use_https'] == 1) |
---|
| 133 | Header('Location: http://' . $_SERVER['HTTP_HOST'] . $GLOBALS['phpgw_info']['server']['webserver_url'] . '/preferences/index.php'); |
---|
| 134 | else |
---|
| 135 | $GLOBALS['phpgw']->redirect_link('/preferences/index.php','cd=18'); |
---|
[2] | 136 | } |
---|
| 137 | } |
---|
| 138 | else |
---|
| 139 | { |
---|
| 140 | $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Change your password'); |
---|
| 141 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 142 | echo parse_navbar(); |
---|
| 143 | |
---|
| 144 | $GLOBALS['phpgw']->template->pfp('out','form'); |
---|
| 145 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
| 146 | } |
---|
| 147 | ?> |
---|