-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathverify.php
63 lines (56 loc) · 1.98 KB
/
verify.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
<?php
require_once("includes/db.php");
require_once("includes/phpmailer/autoload.php");
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
if(isset($_GET['t'])) {
if(mb_strlen($_GET['t']) < 40 OR mb_strlen($_GET['t']) > 80) {
exit(header('Location: forgetpass'));
}
$conn = $database->openConnection();
$check = $conn->prepare('SELECT timeresetpass,email FROM Customers WHERE verifyCode = :code');
$check->bindValue(":code", $_GET['t']);
$check->execute();
if($check->rowCount() > 0){
$data = $check->fetch();
$time = $data['timeresetpass'];
$email = $data['email'];
if($time > time()){
$timeTo = time() + 259200;
$password = bin2hex(openssl_random_pseudo_bytes(4));
$passwordhash = password_hash($password, PASSWORD_DEFAULT);
$changeIt = $conn->prepare('UPDATE Customers SET password = "'.$passwordhash.'",timeresetpass = '.$timeTo.',verifyCode = "" WHERE verifyCode = :code');
$changeIt->bindValue(":code", $_GET['t']);
$changeIt->execute();
if($changeIt->rowCount() > 0){
$body="<!DOCTYPE html><html><head><meta charset='UTF-8'><title>WSE6 | كلمة المرور</title></head><body dir='rtl'><p>مرحباً</p><p>كلمة مرورك الجديدة : ".$password."</p></body></html>";
$mail = new PHPMailer();
$mail->CharSet = 'UTF-8';
$mail->isSMTP();
$mail->Host = "mail.pgxpo.com";
$mail->SMTPAuth = true;
$mail->Username = "[email protected]";
$mail->Password = "mjwz9bgckueh";
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$mail->setFrom("[email protected]", 'Wse6');
$mail->addAddress($email, '');
$mail->isHTML(true);
$mail->Subject = 'كلمة مرورك الجديدة';
$mail->MsgHTML($body);
if(!$mail->send()) {
exit(header('Location: login?status=2'));
} else {
exit(header('Location: login?status=1'));
}
}
} else {
exit(header('Location: login?status=3'));
}
} else {
exit(header('Location: login'));
}
} else {
exit(header('Location: login'));
}
?>