-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpasswordrecover.php
183 lines (158 loc) · 6.78 KB
/
passwordrecover.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
176
177
178
179
180
181
<?php require_once ("include/initialize.php"); ?>
<link href="<?php echo web_root ?>css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="<?php echo web_root ?>/js/bootstrap.min.js"></script>
<script src="<?php echo web_root ?>jquery/jquery.min.js"></script>
<link rel="stylesheet" href="<?php echo web_root ?>/font/css/font-awesome.min.css">
<style type="text/css">
.form-gap {
padding-top: 70px;
}
</style>
<?php
if (isset($_POST['recover-submit'])) {
# code...
$_SESSION['phonenumber'] = $_POST['phonenumber'];
$customer = New Customer();
@$res = $customer->find_phone($_SESSION['phonenumber']);
if ($res) {
# code...
$code = mt_rand(1000,10000);
$_SESSION['recovery_code'] = $code;
// $sql = "INSERT INTO `messageout` (`Id`, `MessageTo`, `MessageFrom`, `MessageText`) VALUES (Null, '".$_SESSION['phonenumber']."','Janno','".'Your code is ' .$_SESSION['recovery_code']."')";
// $mydb->setQuery($sql);
// $mydb->executeQuery();
redirect('passwordrecover.php?code');
}else{
//redirect('passwordrecover.php?code='.$code);
$phonemessage = '<p>Your phone number is incorrect.</p>';
}
}
if (isset($_POST['validatecode-submit'])) {
# code...
if ($_SESSION['recovery_code']==$_POST['resetcode']) {
# code...
redirect('passwordrecover.php?resetpassword');
}else{
$codemessage = '<p>Your code is incorrect.</p>';
}
}
if (isset($_POST['savepass-submit'])) {
# code...
$customer = New Customer();
$res = $customer->find_phone($_SESSION['phonenumber']);
if ($res) {
# code...
$customer = New Customer();
$customer->CUSPASS = sha1($_POST['newpassword']);
$customer->update($res->CUSTOMERID);
}
unset($_SESSION['phonenumber']);
unset($_SESSION['recovery_code']);
redirect('passwordrecover.php?success');
}
?>
<div class="form-gap"></div>
<?php if (isset($_GET['code'])) { ?>
<div class="container">
<div class="row">
<div class="col-md-4 col-md-offset-4">
<div class="panel panel-default">
<div class="panel-body">
<div class="text-center">
<h3><i class="fa fa-lock fa-4x"></i></h3>
<h2 class="text-center">Forgot Password?</h2>
<p>Put your code here.</p>
<?php echo isset($codemessage) ? $codemessage : "";?>
<div class="panel-body">
<form id="register-form" role="form" autocomplete="off" class="form" method="post">
<div class="form-group">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-code color-blue"></i></span>
<input id="resetcode" name="resetcode" placeholder="Input your Code Number here" class="form-control" type="number" required="true">
</div>
</div>
<div class="form-group">
<input name="validatecode-submit" class="btn btn-lg btn-primary btn-block" value="Submit" type="submit">
<a href="index.php">Back to site</a>
</div>
<input type="hidden" class="hide" name="token" id="token" value="">
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php }elseif(isset($_GET['resetpassword'])){ ?>
<div class="container">
<div class="row">
<div class="col-md-4 col-md-offset-4">
<div class="panel panel-default">
<div class="panel-body">
<div class="text-center">
<h3><i class="fa fa-lock fa-4x"></i></h3>
<h2 class="text-center">Forgot Password?</h2>
<p>Change your password.</p>
<div class="panel-body">
<form id="register-form" role="form" autocomplete="off" class="form" method="post">
<div class="form-group">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-user color-blue"></i></span>
<input id="newpassword" name="newpassword" placeholder="New Password" class="form-control" type="password" required="true">
</div>
</div>
<div class="form-group">
<input name="savepass-submit" class="btn btn-lg btn-primary btn-block" value="Save" type="submit">
<a href="index.php">Back to site</a>
</div>
<input type="hidden" class="hide" name="token" id="token" value="<?php echo $_SESSION['phonenumber']; ?>">
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php }elseif(isset($_GET['success'])){ ?>
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-4">
<h2 style="color: blue">Password has been change</h2>
<a href="index.php">Back to login</a>
</div>
</div>
<?php }else{ ?>
<div class="container">
<div class="row">
<div class="col-md-4 col-md-offset-4">
<div class="panel panel-default">
<div class="panel-body">
<div class="text-center">
<h3><i class="fa fa-lock fa-4x"></i></h3>
<h2 class="text-center">Forgot Password?</h2>
<p>You can reset your password here.</p>
<?php echo isset($phonemessage) ? $phonemessage : "";?>
<div class="panel-body">
<form id="register-form" role="form" autocomplete="off" class="form" method="post">
<div class="form-group">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-phone color-blue"></i> +212</span>
<input id="phonenumber" name="phonenumber" placeholder="Enter your Phone Number" class="form-control" type="number" required="true">
</div>
</div>
<div class="form-group">
<input name="recover-submit" class="btn btn-lg btn-primary btn-block" value="Send" type="submit">
<a href="index.php">Back to site</a>
</div>
<input type="hidden" class="hide" name="token" id="token" value="">
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php } ?>