forked from llcit/FVP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpasswordSetup.php
110 lines (105 loc) · 4.44 KB
/
passwordSetup.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
<!DOCTYPE html>
<html lang="en">
<head>
<?php
$SETTINGS = parse_ini_file(__DIR__."/inc/settings.ini");
require 'vendor/autoload.php';
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
include "./inc/dump.php";
include "./inc/SESMailer.php";
include "./inc/db_pdo.php";
include "./inc/sqlFunctions.php";
$userMsg = '';
if (isset($_POST['password-reset']) && $_POST['email']) {
$emailId = $_POST['email'];
$userExists = getExistingUser($emailId,null);
if($userExists){
$token = md5($emailId).rand(10,9999);
$expFormat = mktime(
date("H"), date("i"), date("s"), date("m") ,date("d")+1, date("Y")
);
$expDate = date("Y-m-d H:i:s",$expFormat);
$success = updatePassword($password,$emailId,$token,$expDate);
if($success) {
$emailVars = [
'email' => $emailId,
'token' => $token
];
$userMsg = sendMail("Password_Reset", $emailVars);
}
else {
$userMsg = "Unable to generate a reset token!";
$msgClass = " error";
}
}
else {
$userMsg = "We are unable to locate that email address in the system. Please use the address to which your invitation was sent.";
$msgClass = " error";
}
}
if ($userMsg != '') {
$userMsgPanel = "
<div class='msg $msgClass'>
$userMsg
</div>
";
}
$disabled = ($_GET['email']) ? "" : "disabled";
?>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<!-- Able Player CSS -->
<link rel="stylesheet" href="./css/main.css" type="text/css"/>
<script src='./js/main.js'></script>
<script>
function enableSend() {
var email = document.getElementById('email').value;
if (isEmail(email)) {
document.getElementById("password-reset").disabled = false;
}
}
</script>
</head>
<body>
<div class="panel panel-default">
<div class="panel-heading fv_heading">
<img src='./img/logo_lf.png'>
Flagship Video Password Setup
</div>
<div class="panel-body">
<form method="post" action="">
<div class="container">
<div class="container" style="max-width: 1200px;">
<div class="row fv_main">
<div class="col-md-12 mb-5">
<div class="card soloCard">
<div class="card-body">
<h2 class="card-title">Password Setup</h2>
<p class="card-text">Enter your email address below to receive a message with a password setup link.</p>
</div>
<?php echo($userMsgPanel); ?>
<div class="card-footer">
<div class="form-group">
<div>
<label for="username">Email:</label>
<input type="text" class="textbox fv_text_box" id="email" name="email" value='<?php echo($_GET['email']); ?>' placeholder="Email" / onkeyup="enableSend();">
</div>
<div>
<input type="submit" value="Send Link" name="password-reset" id="password-reset" class='btn btn-primary fv_button' <?php echo($disabled); ?>/>
</div>
</div>
</div>
</div>
</div>
<a class ="pull-right loginLink" href='login.php'>Return to Login</a>
</div>
</div>
</div>
</form>
</div>
<div class="footer">
<p> </p>
</div>
</div>
</body>
</html>