-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathresetpass.php
143 lines (116 loc) · 3.63 KB
/
resetpass.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
<?php
ob_start();
session_start();
include "includes/config.php";
date_default_timezone_set('UTC');
if(isset($_SESSION['sname']) and isset($_SESSION['spass'])){
header("location: buyer/");
exit();
}
?>
<?php
$pincode = $_GET['code'];
$user = $_GET['user'];
$finder = mysqli_query($dbcon, "
SELECT * FROM users WHERE username='$user' ") or die("mysql error");
if(mysqli_num_rows($finder) != 0){
$row = mysqli_fetch_assoc($finder);
if(($pincode == $row['resetpin'])){
?>
<!doctype html>
<html>
<link rel="stylesheet" type="text/css" href="buyer/assets/bootstrap.css" />
<script type="text/javascript" src="buyer/assets/jquery.js"></script>
<script type="text/javascript" src="buyer/assets/bootstrap.js"></script>
<link rel="shortcut icon" href="img/favicon.ico" />
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<title>JERUX SHOP - Password Reset</title>
<style>
@import url(http://fonts.googleapis.com/css?family=Roboto:400);
html, body {
background: url(img/bg.png);
}
.container {
padding: 25px;
position: fixed;
}
.form-login {
background-color: #EDEDED;
padding-top: 10px;
padding-bottom: 20px;
padding-left: 20px;
padding-right: 20px;
border-radius: 15px;
border-color:#d2d2d2;
border-width: 5px;
box-shadow:0 1px 0 #cfcfcf;
}
h4 {
border:0 solid #fff;
border-bottom-width:1px;
padding-bottom:10px;
text-align: center;
}
h6 {
border:0 solid #fff;
border-bottom-width:1px;
padding-bottom:5px;
text-align: center;
}
.form-control {
border-radius: 10px;
}
.wrapper {
text-align: center;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-offset-5 col-md-3">
<div class="form-login" id="logindiv">
<h4> <b><span class='glyphicon glyphicon-fire'></span> JERUX SHOP - Forget</b> </h4>
<div id='errorbox'>
</div>
<form method='post'>
<input type='password' id='new_p' name='new_p' class='form-control input-sm chat-input' placeholder='New Password' required/>
<br>
<div class='wrapper'>
<button type='submit' name="do" id='divButton' class='btn btn-primary btn-md'>Reset <span class='glyphicon glyphicon-log-in'></span></button>
</div>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
<?php
if(isset($_POST['do'])){
$newpass = mysqli_real_escape_string($dbcon, strip_tags($_POST['new_p']));
$passstrlen = strlen($newpass);
if($passstrlen <5 or $passstrlen > 16){
echo '<script>swal("Failed", "Password must be more than 6 and less than 16" , "error");</script>';
echo '<meta http-equiv="refresh" content="1">';
} else {
$salt = 'fs978'; // SALT for encrypting
$newpassword = md5($newpass . $salt);
$lvisi = $newpassword;
$qqz = mysqli_query($dbcon, "UPDATE users SET resetpin='token-removed-expired' WHERE username='$user'")or die("mysql error");
$qq = mysqli_query($dbcon, "UPDATE users SET password='$lvisi' WHERE username='$user'")or die("mysql error");
if($qq){
$ko = mysqli_query($dbcon, "UPDATE umanager SET online='0',tpwchanges=(tpwchanges + 1) WHERE username='$user'")or die("error up");
echo '<script>swal("Done", "Password changed" , "success");</script>';
echo ' <meta http-equiv="refresh" content="1;URL=index.html" />';
} } }
?>
<?php
} else {
echo "Invalid token";
} } else {
echo "Invalid token";
}
?>