Skip to content

Commit 326a8db

Browse files
committed
Users can reset their login password. The password is sent by email to the email address listed in the client account settings.
1 parent 944afea commit 326a8db

File tree

4 files changed

+125
-16
lines changed

4 files changed

+125
-16
lines changed
Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
<?php
2-
3-
$wb[1001] = "Username or Password empty.";
4-
$wb[1002] = "Username or Password wrong.";
5-
$wb[1003] = "User is blocked.";
6-
$wb[1004] = "To many wrong login's, Please retry it after 15 minutes";
7-
8-
9-
10-
11-
12-
13-
14-
15-
16-
1+
<?php
2+
3+
$wb[1001] = "Username or Password empty.";
4+
$wb[1002] = "Username or Password wrong.";
5+
$wb[1003] = "User is blocked.";
6+
$wb[1004] = "To many wrong login's, Please retry it after 15 minutes";
7+
$wb['pass_reset_txt'] = 'A new password will be generated and send to your email address if the email address entered above matches the email address in your client settings.';
8+
$wb['pw_reset'] = 'The password has been reset and send to your email address.';
9+
$wb['pw_error'] = 'Username or email address does not match.';
10+
$wb['pw_error_noinput'] = 'Please enter email address and username.';
11+
12+
$wb['pw_reset_mail_msg'] = 'The password to your ISPConfig 3 control panel account has been reset. The new password is: ';
13+
$wb['pw_reset_mail_title'] = 'ISPConfig 3 Control panel password has been reset.';
14+
1715
?>
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
3+
/*
4+
Copyright (c) 2008, Till Brehm, projektfarm Gmbh
5+
All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without modification,
8+
are permitted provided that the following conditions are met:
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.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22+
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
31+
require_once('../../lib/config.inc.php');
32+
require_once('../../lib/app.inc.php');
33+
34+
// Loading the template
35+
$app->uses('tpl');
36+
$app->tpl->newTemplate("form.tpl.htm");
37+
$app->tpl->setInclude('content_tpl','templates/password_reset.htm');
38+
39+
$app->tpl_defaults();
40+
41+
include(ISPC_ROOT_PATH.'/web/login/lib/lang/'.$_SESSION['s']['language'].'.lng');
42+
$app->tpl->setVar($wb);
43+
44+
if(isset($_POST['username']) && $_POST['username'] != '' && $_POST['email'] != '' && $_POST['username'] != 'admin') {
45+
46+
$username = $app->db->quote($_POST['username']);
47+
$email = $app->db->quote($_POST['email']);
48+
49+
$client = $app->db->queryOneRecord("SELECT * FROM client WHERE username = '$username' && email = '$email'");
50+
51+
if($client['client_id'] > 0) {
52+
$new_password = md5 (uniqid (rand()));
53+
$new_password = $app->db->quote($new_password);
54+
$username = $app->db->quote($client['username']);
55+
$app->db->query("UPDATE sys_user SET passwort = md5('$new_password') WHERE username = '$username'");
56+
$app->db->query("UPDATE client SET ´password´ = md5('$new_password') WHERE username = '$username'");
57+
$app->tpl->setVar("message",$wb['pw_reset']);
58+
59+
mail($client['email'],$wb['pw_reset_mail_title'],$wb['pw_reset_mail_msg'].$new_password);
60+
61+
} else {
62+
$app->tpl->setVar("message",$wb['pw_error']);
63+
}
64+
65+
} else {
66+
$app->tpl->setVar("message",$wb['pw_error_noinput']);
67+
}
68+
69+
70+
71+
$app->tpl_defaults();
72+
$app->tpl->pparse();
73+
74+
75+
76+
77+
78+
?>

interface/web/login/templates/index.htm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
<tr>
88
<td colspan="2"><tmpl_var name="error"></td>
99
</tr>
10+
<tr>
11+
<td colspan="2" height="30" align="left"><a href="#" onclick="loadContent('login/password_reset.php');">Password lost?</a></td>
12+
</tr>
1013
</tmpl_if>
1114
<tr>
1215
<td>Username</td>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<div style="margin-top: 100px">
2+
<table style="width: 400px; margin: 0px auto;" class="table">
3+
<tr>
4+
<th colspan="2">Password Reset</th>
5+
</tr>
6+
<tmpl_if name="message">
7+
<tr>
8+
<td colspan="2"><b><i><tmpl_var name="message"></i></b></td>
9+
</tr>
10+
</tmpl_if>
11+
<tr>
12+
<td>Email address</td>
13+
<td><input name="email" type="text" id="email" class="text"></td>
14+
</tr>
15+
<tr>
16+
<td>Username</td>
17+
<td><input name="username" type="text" id="username" class="text"></td>
18+
</tr>
19+
<tr>
20+
<td colspan="2"><tmpl_var name="pass_reset_txt"></td>
21+
</tr>
22+
<tr>
23+
<td>&nbsp;</td>
24+
<td><input type="button" name="submit" id="submit" value="Resend password" class="button" onclick="submitForm('pageForm','login/password_reset.php');" ><div class="buttonEnding"></div>
25+
</td>
26+
</tr>
27+
</table>
28+
<input type="hidden" name="s_mod" value="login" />
29+
<input type="hidden" name="s_pg" value="index" />
30+
</div>

0 commit comments

Comments
 (0)