2 /**********************************************************************
3 Copyright (C) FrontAccounting, LLC.
4 Released under the terms of the GNU General Public License, GPL,
5 as published by the Free Software Foundation, either version 3
6 of the License, or (at your option) any later version.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
12 $page_security = 'SA_CHGPASSWD';
14 include_once($path_to_root . "/includes/session.inc");
16 page(_($help_context = "Change password"));
18 include_once($path_to_root . "/includes/date_functions.inc");
19 include_once($path_to_root . "/includes/ui.inc");
21 include_once($path_to_root . "/admin/db/users_db.inc");
23 function can_process()
26 if (strlen($_POST['password']) < 4)
28 display_error( _("The password entered must be at least 4 characters long."));
29 set_focus('password');
33 if (strstr($_POST['password'], $_SESSION["wa_current_user"]->username) != false)
35 display_error( _("The password cannot contain the user login."));
36 set_focus('password');
40 if ($_POST['password'] != $_POST['passwordConfirm'])
42 display_error( _("The passwords entered are not the same."));
43 set_focus('password');
50 if (isset($_POST['UPDATE_ITEM']) && check_csrf_token())
55 if ($allow_demo_mode) {
56 display_warning(_("Password cannot be changed in demo mode."));
58 update_user_password($_SESSION["wa_current_user"]->user,
59 $_SESSION["wa_current_user"]->username,
60 md5($_POST['password']));
61 display_notification(_("Your password has been updated."));
63 $Ajax->activate('_page_body');
69 start_table(TABLESTYLE);
71 $myrow = get_user($_SESSION["wa_current_user"]->user);
73 label_row(_("User login:"), $myrow['user_id']);
75 $_POST['password'] = "";
76 $_POST['passwordConfirm'] = "";
78 password_row(_("Password:"), 'password', $_POST['password']);
79 password_row(_("Repeat password:"), 'passwordConfirm', $_POST['passwordConfirm']);
81 table_section_title(_("Enter your new password in the fields."));
85 submit_center( 'UPDATE_ITEM', _('Change password'), true, '', 'default');