root/trunk/gui/reseller/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 $tpl->define_dynamic('page', Config::get('RESELLER_TEMPLATE_PATH') . '/password_change.tpl');
27 $tpl->define_dynamic('page_message', 'page');
28 $tpl->define_dynamic('logged_from', 'page');
29
30 $theme_color = Config::get('USER_INITIAL_THEME');
31
32 $tpl->assign(
33     array('TR_CLIENT_CHANGE_PASSWORD_PAGE_TITLE' => tr('ispCP - Reseller/Change Password'),
34         'THEME_COLOR_PATH' => "../themes/$theme_color",
35         'THEME_CHARSET' => tr('encoding'),
36         'ISP_LOGO' => get_logo($_SESSION['user_id']),
37         )
38     );
39
40 if (isset($_POST['uaction']) && $_POST['uaction'] === 'updt_pass') {
41     if (empty($_POST['pass']) OR empty($_POST['pass_rep']) OR empty($_POST['curr_pass'])) {
42         set_page_message(tr('Please fill up all data fields!'));
43     } else if ($_POST['pass'] !== $_POST['pass_rep']) {
44         set_page_message(tr('Passwords do not match!'));
45     } else if (!chk_password($_POST['pass'])) {
46         if(Config::get('PASSWD_STRONG')){
47       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')));
48     } else {
49       set_page_message(sprintf(tr('Password data is shorter than %s signs or includes not permitted signs!'), Config::get('PASSWD_CHARS')));
50     }
51     } else if (check_udata($_SESSION['user_id'], $_POST['curr_pass']) === false) {
52         set_page_message(tr('The current password is wrong!'));
53     } else {
54         // Correct input password
55         $upass = crypt_user_pass(htmlentities($_POST['pass']));
56
57         $_SESSION['user_pass'] = $upass;
58
59         $user_id = $_SESSION['user_id'];
60         // Begin update admin-db
61         $query = <<<SQL_QUERY
62             update
63                 admin
64             set
65                 admin_pass = ?
66             where
67                 admin_id = ?
68 SQL_QUERY;
69
70         $rs = exec_query($sql, $query, array($upass, $user_id));
71
72         set_page_message(tr('User password updated successfully!'));
73     }
74 }
75
76 function check_udata($id, $pass) {
77     $sql = Database::getInstance();
78
79     $query = <<<SQL_QUERY
80         select
81                admin_id, admin_pass
82         from
83             admin
84         where
85             admin_id = ?
86         and
87             admin_pass = ?
88 SQL_QUERY;
89
90     $rs = exec_query($sql, $query, array($id, md5($pass)));
91
92     if (($rs->RecordCount()) != 1)
93         return false;
94     else return true;
95 }
96
97 /*
98  *
99  * static page messages.
100  *
101  */
102
103 gen_reseller_mainmenu($tpl, Config::get('RESELLER_TEMPLATE_PATH') . '/main_menu_general_information.tpl');
104 gen_reseller_menu($tpl, Config::get('RESELLER_TEMPLATE_PATH') . '/menu_general_information.tpl');
105
106 gen_logged_from($tpl);
107
108 $tpl->assign(
109     array('TR_CHANGE_PASSWORD' => tr('Change password'),
110         'TR_PASSWORD_DATA' => tr('Password data'),
111         'TR_PASSWORD' => tr('Password'),
112         'TR_PASSWORD_REPEAT' => tr('Repeat password'),
113         'TR_UPDATE_PASSWORD' => tr('Update password'),
114         'TR_CURR_PASSWORD' => tr('Current password')
115         )
116     );
117
118 gen_page_message($tpl);
119
120 $tpl->parse('PAGE', 'page');
121 $tpl->prnt();
122
123 if (Config::get('DUMP_GUI_DEBUG'))
124     dump_gui_debug();
125
126 unset_messages();
127
128 ?>
Note: See TracBrowser for help on using the browser.