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 ***********************************************************************/
14 include_once($path_to_root . "/includes/session.inc");
16 page(_("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 $selected_id = $_SESSION["wa_current_user"]->username;
26 function can_process()
29 if (strlen($_POST['password']) < 4)
31 display_error( _("The password entered must be at least 4 characters long."));
32 set_focus('password');
36 if (strstr($_POST['password'], $_POST['user_id']) != false)
38 display_error( _("The password cannot contain the user login."));
39 set_focus('password');
43 if ($_POST['password'] != $_POST['passwordConfirm'])
45 display_error( _("The passwords entered are not the same."));
46 set_focus('password');
53 if (isset($_POST['UPDATE_ITEM']))
58 if ($allow_demo_mode) {
59 display_warning(_("Password cannot be changed in demo mode."));
61 update_user_password($_POST['user_id'], md5($_POST['password']));
62 display_notification(_("Your password has been updated."));
64 $Ajax->activate('_page_body');
70 start_table($table_style);
72 $myrow = get_user($selected_id);
74 $_POST['user_id'] = $myrow["user_id"];
75 hidden('selected_id', $selected_id);
76 hidden('user_id', $_POST['user_id']);
78 label_row(_("User login:"), $_POST['user_id']);
80 $_POST['password'] = "";
81 $_POST['passwordConfirm'] = "";
84 label_cell(_("Password:"));
85 label_cell("<input type='password' name='password' size=22 maxlength=20 value='" . $_POST['password'] . "'>");
89 label_cell(_("Repeat password:"));
90 label_cell("<input type='password' name='passwordConfirm' size=22 maxlength=20 value='" . $_POST['passwordConfirm'] . "'>");
93 table_section_title(_("Enter your new password in the fields."));
97 submit_center( 'UPDATE_ITEM', _('Change password'), true, '', true);