root/trunk/gui/client/password_change.php

Revision 1390, 3.7 kB (checked in by simple, 1 month ago)

fix according to http://www.isp-control.net/ispcp/ticket/1564
* clear untechnical message
* including the required length
* message according to config-setting (passwd_strong or not)
changed all files with chk_password and error message in it, as well as the language files base and de_DE to add the string

Line 
1 <?php
2 /**
3  * ispCP ω (OMEGA) a Virtual Hosting Control System
4  *
5  * @copyright     2001-2006 by moleSoftware GmbH
6  * @copyright     2006-2008 by ispCP | http://isp-control.net
7  * @version     SVN: $Id$
8  * @link         http://isp-control.net
9  * @author         ispCP Team
10  *
11  * @license
12  *   This program is free software; you can redistribute it and/or modify it under
13  *   the terms of the MPL General Public License as published by the Free Software
14  *   Foundation; either version 1.1 of the License, or (at your option) any later
15  *   version.
16  *   You should have received a copy of the MPL Mozilla Public License along with
17  *   this program; if not, write to the Open Source Initiative (OSI)
18  *   http://opensource.org | osi@opensource.org
19  */
20
21 require '../include/ispcp-lib.php';
22
23 check_login(__FILE__);
24
25 $tpl = new pTemplate();
26
27 $tpl->define_dynamic('page', Config::get('CLIENT_TEMPLATE_PATH') . '/password_change.tpl');
28 $tpl->define_dynamic('page_message', 'page');
29 $tpl->define_dynamic('logged_from', 'page');
30
31 $theme_color = Config::get('USER_INITIAL_THEME');
32
33 $tpl->assign(array('TR_CLIENT_CHANGE_PASSWORD_PAGE_TITLE' => tr('ispCP - Client/Change Password'),
34         'THEME_COLOR_PATH' => "../themes/$theme_color",
35         'THEME_CHARSET' => tr('encoding'),
36         'ISP_LOGO' => get_logo($_SESSION['user_id'])));
37
38 if (isset($_POST['uaction']) && $_POST['uaction'] === 'updt_pass') {
39     if (empty($_POST['pass']) || empty($_POST['pass_rep']) || empty($_POST['curr_pass'])) {
40         set_page_message(tr('Please fill up all data fields!'));
41     } else if ($_POST['pass'] !== $_POST['pass_rep']) {
42         set_page_message(tr('Passwords do not match!'));
43     } else if (!chk_password($_POST['pass'])) {
44         if(Config::get('PASSWD_STRONG')){
45       set_page_message(sprintf(tr('The password must be at least %s long and contain letters and numbers to be valid.'), Config::get('PASSWD_CHARS')));
46     } else {
47       set_page_message(sprintf(tr('Password data is shorter than %s signs or includes not permitted signs!'), Config::get('PASSWD_CHARS')));
48     }
49     } else if (!check_udata($_SESSION['user_id'], $_POST['curr_pass'])) {
50         set_page_message(tr('The current password is wrong!'));
51     } else {
52         $upass = crypt_user_pass($_POST['pass']);
53
54         $_SESSION['user_pass'] = $upass;
55
56         $user_id = $_SESSION['user_id'];
57
58         $query = <<<SQL_QUERY
59             update
60               admin
61             set
62               admin_pass = ?
63             where
64               admin_id = ?
65 SQL_QUERY;
66
67         $rs = exec_query($sql, $query, array($upass, $user_id));
68         write_log($_SESSION['user_logged'] . ": update password!");
69         set_page_message(tr('User password updated successfully!'));
70     }
71 }
72
73 function check_udata($id, $pass) {
74     $sql = Database::getInstance();
75
76     $query = <<<SQL_QUERY
77         select
78                admin_id, admin_pass
79         from
80             admin
81         where
82             admin_id = ?
83         and
84             admin_pass = ?
85 SQL_QUERY;
86
87     $rs = exec_query($sql, $query, array($id, md5($pass)));
88
89     if (($rs->RecordCount()) != 1)
90         return false;
91     else return true;
92 }
93
94 /*
95  *
96  * static page messages.
97  *
98  */
99 gen_client_mainmenu($tpl, Config::get('CLIENT_TEMPLATE_PATH') . '/main_menu_general_information.tpl');
100 gen_client_menu($tpl, Config::get('CLIENT_TEMPLATE_PATH') . '/menu_general_information.tpl');
101
102 gen_logged_from($tpl);
103
104 check_permissions($tpl);
105
106 check_permissions($tpl);
107
108 $tpl->assign(array('TR_CHANGE_PASSWORD' => tr('Change password'),
109         'TR_PASSWORD_DATA' => tr('Password data'),
110         'TR_PASSWORD' => tr('Password'),
111         'TR_PASSWORD_REPEAT' => tr('Repeat password'),
112         'TR_UPDATE_PASSWORD' => tr('Update password'),
113         'TR_CURR_PASSWORD' => tr('Current password')
114         ));
115
116 gen_page_message($tpl);
117
118 $tpl->parse('PAGE', 'page');
119 $tpl->prnt();
120
121 if (Config::get('DUMP_GUI_DEBUG'))
122     dump_gui_debug();
123
124 unset_messages();
125
126 ?>
Note: See TracBrowser for help on using the browser.