-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforgot.php
175 lines (149 loc) · 8.79 KB
/
forgot.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?php
require_once 'vendor/autoload.php';
require('connect.php');
try {
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
extract($_GET);
// $email = '[email protected]';
if (!empty($email)) {
$stmt = $conn->prepare(
"SELECT email FROM users WHERE email =:email"
);
$stmt->execute(['email' => $email,]);
if ($stmt->rowCount() > 0) {
$str = mt_rand(1111, 9999);
$stmt = $conn->prepare(
"INSERT INTO codes (email,code) VALUES (:email,:code)"
);
$stmt->execute(['email' => $email, 'code' => $str]);
$to = $email; // User's email address
$transport = (new Swift_SmtpTransport('server.techowdy.com', 465, 'ssl')) // Use port 587 for TLS
->setUsername('[email protected]')
->setPassword('FU%$$#s,dser');
// Create the Mailer using your created Transport
$mailer = new Swift_Mailer($transport);
// Create a message
$message = (new Swift_Message('Reset Password'))
->setFrom(['[email protected]' => 'Future Advisers'])
->setTo($to)
->setBody('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>OTP Email</title>
<meta name="viewport" content="width=device-width">
<!-- Favicon icon -->
<link rel="icon" href="" type="image/x-icon">
<style type="text/css">
@media only screen and (max-width: 1240px), screen and (max-device-width: 1240px) {
body[yahoo] .buttonwrapper { background-color: transparent !important; }
body[yahoo] .button { padding: 0 !important; }
body[yahoo] .button a { background-color: #9b59b6; padding: 15px 25px !important; }
}
th{
width:82px;
}
</style>
</head>
<body bgcolor="#34495E" style="margin: 0; padding: 0;" yahoo="fix">
<!--[if (gte mso 9)|(IE)]>
<table width="600" align="center" cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<![endif]-->
<table align="left" border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; width: 100%;" class="content">
<tr>
<td align="left" bgcolor="#ffffff" style="padding: 30px 10px 00px 10px; color: #ffffff; font-family: Arial, sans-serif; font-size: 36px; font-weight: bold;">
<img src=https://futureadvisers.co/wp-content/uploads/2016/06/logo_new.png" alt="OTP Email" width="100" style="display:block; margin-bottom: 15px;">
</td>
</tr>
<tr>
<td align="left" bgcolor="#ffffff" style="padding: 10px 10px 20px 10px; color: #555555; font-family: Arial, sans-serif; font-size: 20px; line-height: 30px; ">
<b>Dear user</b>
</td>
</tr>
<tr>
<td align="left" bgcolor="#ffffff" style="padding: 0px 10px 0px 10px; color: #555555; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px; ">
<span>We have received a password reset request for your account. If you did not initiate this request, kindly disregard this email, and no further action is required.</span>
</td>
</tr>
<tr>
<td align="left" bgcolor="#ffffff" style="padding: 20px 10px 20px 10px; color: #555555; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px; border-bottom: 2px solid #d0cece;">
<span >
However, if you did request a password reset, please use the following One-Time Password (OTP) code to proceed with the reset process:
</span>
</td>
</tr>
<tr>
<td align="center" bgcolor="#ffffff" style="padding: 0px 10px 40px 10px; color: #555555; font-family: Arial, sans-serif; font-size: 20px; line-height: 30px; border-bottom: 2px solid #d0cece;">
<!--[if (gte mso 9)|(IE)]>
<table width="387" align="left" cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<![endif]-->
<br>
<table class="col387" align="center" border="0" cellpadding="0" cellspacing="0" style= "width: auto">
<tr>
<th style="padding: 0 0 10px 0; color: #5945b2; text-align: left; font-family: Arial, sans-serif; font-size: 24px;width: 150px; line-height: 24px;">OTP CODE :</th>
<td style="padding: 0 0 10px 0; color: #44ca35; text-align: left; font-family: Arial, sans-serif; font-size: 28px;width: 150px; line-height: 24px;"> <b>' . $str . '</b></td>
</tr>
</table>
</td>
</tr>
</td>
</tr>
<tr>
<td align="left" bgcolor="#ffffff" style="padding: 20px 10px 20px 10px; color: #555555; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px; border-bottom: 2px solid #d0cece;">
<span>
Your security is important to us, and we encourage you to keep your account information confidential.
</span>
</td>
</tr>
<tr>
<td align="left" bgcolor="#ffffff" style="padding: 20px 10px 20px 10px; color: #555555; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px; border-bottom: 2px solid #d0cece;">
<span>
Best regards,
<br>
<b>Future Advisers</b><br>
Customer Support Team
</span>
</td>
</tr>
<tr>
<td align="center" bgcolor="#000" style="padding: 15px 10px 15px 10px; color: #ffffff; font-family: Arial, sans-serif; font-size: 12px; line-height: 18px;text-decoration:none">
<b><a style="text-decoration:none; color:#fff" href="#">© All Rights Reserved</a></b>
</td>
</tr>
</table>
<!--[if (gte mso 9)|(IE)]>
</td>
</tr>
</table>
<![endif]-->
</body>
</html>', 'text/html');
// Send the message
$result = $mailer->send($message);
$response = ['message' => 'User exist'];
http_response_code(200);
} else {
// User login failed
$response = ['message' => 'User doesnot exist'];
http_response_code(401);
}
} else {
// Invalid request parameters
$response = ['message' => 'Invalid request parameters'];
http_response_code(400);
}
} else {
// Invalid request method
$response = ['message' => 'Invalid request method'];
http_response_code(405);
}
// Return the response as JSON
echo json_encode($response);
} catch (PDOException $e) {
echo $e->getMessage();
}
$conn = null;