From 0de30f9058602f0fe8789b3ec0dc1dd23766d31a Mon Sep 17 00:00:00 2001 From: linchyim <linchyim@mail.al0c.net> Date: Thu, 20 Nov 2014 11:00:31 -0500 Subject: [PATCH] add lost_password_function --- interface/web/login/lib/lang/en.lng | 3 + interface/web/admin/lib/lang/en_users.lng | 1 interface/web/login/password_reset.php | 75 +++++++++++++++++++------------------ interface/web/login/lib/lang/de.lng | 1 interface/web/admin/lib/lang/de_users.lng | 1 interface/web/admin/form/users.tform.php | 13 ++++++ interface/web/admin/templates/users_user_edit.htm | 8 +++ 7 files changed, 64 insertions(+), 38 deletions(-) diff --git a/interface/web/admin/form/users.tform.php b/interface/web/admin/form/users.tform.php index 9ee2970..6a23559 100644 --- a/interface/web/admin/form/users.tform.php +++ b/interface/web/admin/form/users.tform.php @@ -260,6 +260,19 @@ 'maxlength' => '2', 'rows' => '', 'cols' => '' + ), + 'lost_password_function' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'CHECKBOX', + 'regex' => '', + 'errmsg' => '', + 'default' => 1, + 'value' => array(0 => 0, 1 => 1), + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' ) //################################# // ENDE Datenbankfelder diff --git a/interface/web/admin/lib/lang/de_users.lng b/interface/web/admin/lib/lang/de_users.lng index da26db3..db37a60 100644 --- a/interface/web/admin/lib/lang/de_users.lng +++ b/interface/web/admin/lib/lang/de_users.lng @@ -31,4 +31,5 @@ $wb['password_match_txt'] = 'Die Passwörter stimmen überein.'; $wb['username_error_collision'] = 'Der Benutzername darf nicht <b>web<b> oder <b>web<b> gefolgt von einer Zahl sein.'; $wb['client_not_admin_err'] = 'A user that belongs to a client can not be set to type: admin'; +$wb['lost_password_function_txt'] = 'Passwort vergessen Funktion steht zur Verfügung'; ?> diff --git a/interface/web/admin/lib/lang/en_users.lng b/interface/web/admin/lib/lang/en_users.lng index 09b8ac3..9c57f1d 100644 --- a/interface/web/admin/lib/lang/en_users.lng +++ b/interface/web/admin/lib/lang/en_users.lng @@ -31,4 +31,5 @@ $wb['password_match_txt'] = 'The passwords do match.'; $wb['username_error_collision'] = 'The username may not be web or web plus a number."'; $wb['client_not_admin_err'] = 'A user that belongs to a client can not be set to type: admin'; +$wb['lost_password_function_txt'] = 'Forgot password function is available'; ?> diff --git a/interface/web/admin/templates/users_user_edit.htm b/interface/web/admin/templates/users_user_edit.htm index b973a34..91c35bb 100644 --- a/interface/web/admin/templates/users_user_edit.htm +++ b/interface/web/admin/templates/users_user_edit.htm @@ -60,6 +60,12 @@ {tmpl_var name='language'} </select> </div> + <div class="ctrlHolder"> + <p class="label">{tmpl_var name='lost_password_function_txt'}</p> + <div class="multiField"> + {tmpl_var name='lost_password_function'} + </div> + </div> </fieldset> <input type="hidden" name="id" value="{tmpl_var name='id'}"> @@ -70,4 +76,4 @@ </div> </div> -</div> \ No newline at end of file +</div> diff --git a/interface/web/login/lib/lang/de.lng b/interface/web/login/lib/lang/de.lng index 4ece1b0..44f677b 100644 --- a/interface/web/login/lib/lang/de.lng +++ b/interface/web/login/lib/lang/de.lng @@ -24,4 +24,5 @@ $wb['back_txt'] = 'Zurück'; $wb['stay_logged_in_txt'] = 'Dauerhaft eingeloggt bleiben'; $wb['email_error'] = 'Email contains unallowed characters or has a invalid format.'; +$wb['lost_password_function_disabled_txt'] = 'Die Passwort vergessen Funktion steht für diesen Benutzer nicht zur Verfügung.'; ?> diff --git a/interface/web/login/lib/lang/en.lng b/interface/web/login/lib/lang/en.lng index e540ef2..e7487da 100644 --- a/interface/web/login/lib/lang/en.lng +++ b/interface/web/login/lib/lang/en.lng @@ -24,4 +24,5 @@ $wb['error_maintenance_mode'] = 'This ISPConfig installation is currently under maintenance. We should be back shortly. Thank you for your patience.'; $wb['theme_not_compatible'] = 'The chosen theme is not compatible with the current ISPConfig version. Please check for a new version of the theme.<br />The default theme as been activated automatically.'; $wb['stay_logged_in_txt'] = 'Keep me logged in'; -?> \ No newline at end of file +$wb['lost_password_function_disabled_txt'] = 'The lost password function is not available for this user.'; +?> diff --git a/interface/web/login/password_reset.php b/interface/web/login/password_reset.php index c466ac8..f2e4e95 100644 --- a/interface/web/login/password_reset.php +++ b/interface/web/login/password_reset.php @@ -7,14 +7,14 @@ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of ISPConfig nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of ISPConfig nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED @@ -26,7 +26,7 @@ OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ + */ require_once '../../lib/config.inc.php'; require_once '../../lib/app.inc.php'; @@ -54,36 +54,39 @@ $username = $app->db->quote($_POST['username']); $email = $app->db->quote($_POST['email']); - $client = $app->db->queryOneRecord("SELECT * FROM client WHERE username = '$username' AND email = '$email'"); + $client = $app->db->queryOneRecord("SELECT client.*, sys_user.lost_password_function FROM client,sys_user WHERE client.username = '$username' AND client.email = '$email' AND client.client_id = sys_user.client_id"); - if($client['client_id'] > 0) { - $new_password = $app->auth->get_random_password(); - $new_password_encrypted = $app->auth->crypt_password($new_password); - $new_password_encrypted = $app->db->quote($new_password_encrypted); - - $username = $app->db->quote($client['username']); - $app->db->query("UPDATE sys_user SET passwort = '$new_password_encrypted' WHERE username = '$username'"); - $app->db->query("UPDATE client SET password = '$new_password_encrypted' WHERE username = '$username'"); - $app->tpl->setVar("message", $wb['pw_reset']); - - $app->uses('getconf,ispcmail'); - $mail_config = $app->getconf->get_global_config('mail'); - if($mail_config['smtp_enabled'] == 'y') { - $mail_config['use_smtp'] = true; - $app->ispcmail->setOptions($mail_config); - } - $app->ispcmail->setSender($mail_config['admin_mail'], $mail_config['admin_name']); - $app->ispcmail->setSubject($wb['pw_reset_mail_title']); - $app->ispcmail->setMailText($wb['pw_reset_mail_msg'].$new_password); - $app->ispcmail->send(array($client['contact_name'] => $client['email'])); - $app->ispcmail->finish(); - - $app->plugin->raiseEvent('password_reset', true); - $app->tpl->setVar("msg", $wb['pw_reset']); + if($client['lost_password_function'] == 0) { + $app->tpl->setVar("error", $wb['lost_password_function_disabled_txt']); } else { - $app->tpl->setVar("error", $wb['pw_error']); - } + if($client['client_id'] > 0) { + $new_password = $app->auth->get_random_password(); + $new_password_encrypted = $app->auth->crypt_password($new_password); + $new_password_encrypted = $app->db->quote($new_password_encrypted); + $username = $app->db->quote($client['username']); + $app->db->query("UPDATE sys_user SET passwort = '$new_password_encrypted' WHERE username = '$username'"); + $app->db->query("UPDATE client SET password = '$new_password_encrypted' WHERE username = '$username'"); + $app->tpl->setVar("message", $wb['pw_reset']); + + $app->uses('getconf,ispcmail'); + $mail_config = $app->getconf->get_global_config('mail'); + if($mail_config['smtp_enabled'] == 'y') { + $mail_config['use_smtp'] = true; + $app->ispcmail->setOptions($mail_config); + } + $app->ispcmail->setSender($mail_config['admin_mail'], $mail_config['admin_name']); + $app->ispcmail->setSubject($wb['pw_reset_mail_title']); + $app->ispcmail->setMailText($wb['pw_reset_mail_msg'].$new_password); + $app->ispcmail->send(array($client['contact_name'] => $client['email'])); + $app->ispcmail->finish(); + + $app->plugin->raiseEvent('password_reset', true); + $app->tpl->setVar("msg", $wb['pw_reset']); + } else { + $app->tpl->setVar("error", $wb['pw_error']); + } + } } else { $app->tpl->setVar("msg", $wb['pw_error_noinput']); } -- Gitblit v1.9.1