-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathforgotpassword.php
executable file
·153 lines (137 loc) · 6.57 KB
/
forgotpassword.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php
require_once 'database.php';
require_once 'mail.php';
class forgot_password{
public function _construct(){}
public function show_form(){
echo '
<div id="content">
<div id="simple-page-container">
<div id="head-section">
<img src="images/terms-of-use-icon.jpg" alt="Contact us" />
<h2>Password</h2>
<p>recover your password</p>
</div>
<div class="clear"></div>
<div id="main-section">
<h3>Enter your data</h3>
<form action="index.php" method="post" enctype="multipart/form-data" name="forgotpassword" id="forgotpassword" class="studentform">
<label>Username:</label><input type="text" name="username" id="username">
<label>Email:</label><input type="text" name="mail" id="mail">
<input type="submit" name="forgot" class="btn" value="" />
</form>
</div>
</div>
</div>
';
}
public function generate_password(){
$username=$_POST['username'];
$true=0;
$mail=$_POST['mail'];
$db=new database();
$sql="SELECT ID,Login_email, Username FROM universitys";
list($result,$a)=$db->query($sql);
while(@$row= mysql_fetch_array($result)){
if($username==$row['Username'] && $mail==$row['Login_email']){
$true++;
$id=$row['ID'];
$new_password="lykeion".time();
$pass_base=md5($new_password);
$s="UPDATE universitys SET Password='$pass_base' WHERE ID='$id'";
$db->query($s);
$m=new mail();
$subject="[Lykeion] New password";
$message="
<html>
<body bgcolor='#DCEEFC'>
<center>
<br>
<a href='http://lykeion.eestec.net/lykeion.jpg'><img src='http://lykeion.eestec.net/lykeion.jpg'></a>
</center>
<br><br>
Dear user<br><br>Your new password is generated. It is recommended that you change password after you log in.<br><br><strong> New password:".$new_password."</strong><br><br>
<p>Best regards,</p>
<p>Lykeion website team</p>
<p><a href='http://lykeion.eestec.net'>lykeion.eestec.net</a></p>
</body></html>";
$m->SendMail($id, "universitys", $subject, $message);
}
}
$sql="SELECT ID,Login_email, Username FROM companys";
list($result,$a)=$db->query($sql);
while(@$row= mysql_fetch_array($result)){
if($username==$row['Username'] && $mail==$row['Login_email']){
$true++;
$id=$row['ID'];
$new_password="lykeion".time();
$pass_base=md5($new_password);
$s="UPDATE companys SET Password='$pass_base' WHERE ID='$id'";
$db->query($s);
$m=new mail();
$subject="[Lykeion] New password";
$message="<html>
<body bgcolor='#DCEEFC'>
<center>
<br>
<a href='http://lykeion.eestec.net/lykeion.jpg'><img src='http://lykeion.eestec.net/lykeion.jpg'></a>
</center>
<br><br>
Dear user<br><br>Your new password is generated. It is recommended that you change password after you log in.<br><br><strong> New password:".$new_password."</strong><br><br>
<p>Best regards,</p>
<p>Lykeion website team</p>
<p><a href='http://lykeion.eestec.net'>lykeion.eestec.net</a></p>
</body></html>";
$m->SendMail($id, "companys", $subject, $message);
}
}
$sql="SELECT ID,Email, Username FROM users";
list($result,$a)=$db->query($sql);
while(@$row= mysql_fetch_array($result)){
if($username==$row['Username'] && $mail==$row['Email']){
$true++;
$id=$row['ID'];
$new_password="lykeion".time();
$pass_base=md5($new_password);
$s="UPDATE users SET Password='$pass_base' WHERE ID='$id'";
$db->query($s);
$m=new mail();
$subject="[Lykeion] New password";
$message="<html>
<body bgcolor='#DCEEFC'>
<center>
<br>
<a href='http://lykeion.eestec.net/lykeion.jpg'><img src='http://lykeion.eestec.net/lykeion.jpg'></a>
</center>
<br><br>
Dear user<br><br>Your new password is generated. It is recommended that you change password after you log in.<br><br><strong> New password:".$new_password."</strong><br><br>
<p>Best regards,</p>
<p>Lykeion website team</p>
<p><a href='http://lykeion.eestec.net'>lykeion.eestec.net</a></p>
</body></html>";
$m->SendMail($id, "users", $subject, $message);
}
}
if($true>0)
echo '
<script type="text/javascript">
function errorhide(){
$("#error_message").hide();
}
</script>
<div id="error_message"><br/><br/>Your new generated password has been sent to your mail address.<br/><br/><a href="?do=" onclick="errorhide()">Close</a><br/></div>';
else
echo '
<script type="text/javascript">
function errorhide(){
$("#error_message").hide();
}
</script>
<div id="error_message"><br/><br/>Wrong username or email address.<br/><br/><a href="?do=" onclick="errorhide()">Close</a><br/></div>';
}
}
if(isset($_POST['forgot'])){
$g=new forgot_password();
$g->generate_password();
}
?>