|
7 | 7 | Redistribution and use in source and binary forms, with or without modification, |
8 | 8 | are permitted provided that the following conditions are met: |
9 | 9 |
|
10 | | - * Redistributions of source code must retain the above copyright notice, |
11 | | - this list of conditions and the following disclaimer. |
12 | | - * Redistributions in binary form must reproduce the above copyright notice, |
13 | | - this list of conditions and the following disclaimer in the documentation |
14 | | - and/or other materials provided with the distribution. |
15 | | - * Neither the name of ISPConfig nor the names of its contributors |
16 | | - may be used to endorse or promote products derived from this software without |
17 | | - specific prior written permission. |
| 10 | + * Redistributions of source code must retain the above copyright notice, |
| 11 | + this list of conditions and the following disclaimer. |
| 12 | + * Redistributions in binary form must reproduce the above copyright notice, |
| 13 | + this list of conditions and the following disclaimer in the documentation |
| 14 | + and/or other materials provided with the distribution. |
| 15 | + * Neither the name of ISPConfig nor the names of its contributors |
| 16 | + may be used to endorse or promote products derived from this software without |
| 17 | + specific prior written permission. |
18 | 18 |
|
19 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
20 | 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
26 | 26 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
27 | 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
28 | 28 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | | -*/ |
| 29 | + */ |
30 | 30 |
|
31 | 31 | require_once '../../lib/config.inc.php'; |
32 | 32 | require_once '../../lib/app.inc.php'; |
|
54 | 54 | $username = $app->db->quote($_POST['username']); |
55 | 55 | $email = $app->db->quote($_POST['email']); |
56 | 56 |
|
57 | | - $client = $app->db->queryOneRecord("SELECT * FROM client WHERE username = '$username' AND email = '$email'"); |
| 57 | + $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"); |
58 | 58 |
|
59 | | - if($client['client_id'] > 0) { |
60 | | - $new_password = $app->auth->get_random_password(); |
61 | | - $new_password_encrypted = $app->auth->crypt_password($new_password); |
62 | | - $new_password_encrypted = $app->db->quote($new_password_encrypted); |
63 | | - |
64 | | - $username = $app->db->quote($client['username']); |
65 | | - $app->db->query("UPDATE sys_user SET passwort = '$new_password_encrypted' WHERE username = '$username'"); |
66 | | - $app->db->query("UPDATE client SET password = '$new_password_encrypted' WHERE username = '$username'"); |
67 | | - $app->tpl->setVar("message", $wb['pw_reset']); |
68 | | - |
69 | | - $app->uses('getconf,ispcmail'); |
70 | | - $mail_config = $app->getconf->get_global_config('mail'); |
71 | | - if($mail_config['smtp_enabled'] == 'y') { |
72 | | - $mail_config['use_smtp'] = true; |
73 | | - $app->ispcmail->setOptions($mail_config); |
74 | | - } |
75 | | - $app->ispcmail->setSender($mail_config['admin_mail'], $mail_config['admin_name']); |
76 | | - $app->ispcmail->setSubject($wb['pw_reset_mail_title']); |
77 | | - $app->ispcmail->setMailText($wb['pw_reset_mail_msg'].$new_password); |
78 | | - $app->ispcmail->send(array($client['contact_name'] => $client['email'])); |
79 | | - $app->ispcmail->finish(); |
80 | | - |
81 | | - $app->plugin->raiseEvent('password_reset', true); |
82 | | - $app->tpl->setVar("msg", $wb['pw_reset']); |
| 59 | + if($client['lost_password_function'] == 0) { |
| 60 | + $app->tpl->setVar("error", $wb['lost_password_function_disabled_txt']); |
83 | 61 | } else { |
84 | | - $app->tpl->setVar("error", $wb['pw_error']); |
| 62 | + if($client['client_id'] > 0) { |
| 63 | + $new_password = $app->auth->get_random_password(); |
| 64 | + $new_password_encrypted = $app->auth->crypt_password($new_password); |
| 65 | + $new_password_encrypted = $app->db->quote($new_password_encrypted); |
| 66 | + |
| 67 | + $username = $app->db->quote($client['username']); |
| 68 | + $app->db->query("UPDATE sys_user SET passwort = '$new_password_encrypted' WHERE username = '$username'"); |
| 69 | + $app->db->query("UPDATE client SET password = '$new_password_encrypted' WHERE username = '$username'"); |
| 70 | + $app->tpl->setVar("message", $wb['pw_reset']); |
| 71 | + |
| 72 | + $app->uses('getconf,ispcmail'); |
| 73 | + $mail_config = $app->getconf->get_global_config('mail'); |
| 74 | + if($mail_config['smtp_enabled'] == 'y') { |
| 75 | + $mail_config['use_smtp'] = true; |
| 76 | + $app->ispcmail->setOptions($mail_config); |
| 77 | + } |
| 78 | + $app->ispcmail->setSender($mail_config['admin_mail'], $mail_config['admin_name']); |
| 79 | + $app->ispcmail->setSubject($wb['pw_reset_mail_title']); |
| 80 | + $app->ispcmail->setMailText($wb['pw_reset_mail_msg'].$new_password); |
| 81 | + $app->ispcmail->send(array($client['contact_name'] => $client['email'])); |
| 82 | + $app->ispcmail->finish(); |
| 83 | + |
| 84 | + $app->plugin->raiseEvent('password_reset', true); |
| 85 | + $app->tpl->setVar("msg", $wb['pw_reset']); |
| 86 | + } else { |
| 87 | + $app->tpl->setVar("error", $wb['pw_error']); |
| 88 | + } |
85 | 89 | } |
86 | | - |
87 | 90 | } else { |
88 | 91 | $app->tpl->setVar("msg", $wb['pw_error_noinput']); |
89 | 92 | } |
|
0 commit comments