-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactivate.php
More file actions
173 lines (145 loc) · 4.36 KB
/
activate.php
File metadata and controls
173 lines (145 loc) · 4.36 KB
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
<?php
session_start();
ob_start();
require "config.php";
include_once 'account.php';
if(!function_exists('hash_equals')) {
function hash_equals($str1, $str2) {
if(strlen($str1) != strlen($str2)) {
return false;
} else {
$res = $str1 ^ $str2;
$ret = 0;
for($i = strlen($res) - 1; $i >= 0; $i--){
$ret |= ord($res[$i]);
}
return !$ret;
}
}
}
$pass1err=$pass2err=$hid="";
if($_SERVER['REQUEST_METHOD']=="GET"){
$pass=base64_decode($_GET['passver']);
if(hash_equals($pass,base64_decode($_SESSION['password_verification']))){
$forward=true;
$hid=base64_decode($_GET['id']);
echo "page valid";
}
else{
$forward=false;
echo "bad request";
exit();
}
}
elseif($_SERVER['REQUEST_METHOD']=="POST"){
$forward=true;
if((empty($_POST['pass1'])||empty($_POST['pass2']))){
$pass1err=$pass2err="both fields muct be filled in";
//echo "post empty k";
}
elseif(!($_POST['pass1']==$_POST['pass2'])){
$pass1err=$pass2err="passwords dont match";
//echo "mismatch";
}
else{
$pass1=crypt($_POST['pass1'],CRYPT_BLOWFISH);
//echo "Gnow".$GLOBALS['hid'];
$b=crypt($_SESSION['userpassreset'],450);
$a=$_POST['hid'];
$df=hash_equals($a,$b);
if($df){
$servername =DB_HOST;
$username = DB_USER;
$password = DB_PASSWORD;
$dbname = DB_DATABASE;
$res=null;
$out="";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("UPDATE users SET password=:np WHERE userid=:uid");
$stmt->bindParam(":np",$pass1);
$stmt->bindParam(":uid",$_SESSION['userpassreset']);
$stmt->execute();
echo "success";
header("Location:login.php");
}
catch(PDOException $e){}
}
else{
echo "something went wrong";
}
}
}
?>
<html>
<head>
<script src="direct.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<title>change password</title>
<script>
/*
function checkPass()
{
//Store the password field objects into variables ...
var pass1 = document.getElementById('pass1');
var pass2 = document.getElementById('pass2');
//Store the Confimation Message Object ...
var message = document.getElementById('confirmMessage');
//Set the colors we will be using ...
var goodColor = "#66cc66";
var badColor = "#ff6666";
//Compare the values in the password field
//and the confirmation field
if(pass1.value == pass2.value){
//The passwords match.
//Set the color to the good color and inform
//the user that they have entered the correct password
pass2.style.backgroundColor = goodColor;
message.style.color = goodColor;
message.innerHTML = "Passwords Match!"
}else{
//The passwords do not match.
//Set the color to the bad color and
//notify the user.
pass2.style.backgroundColor = badColor;
message.style.color = badColor;
message.innerHTML = "Passwords Do Not Match!"
}
} */
</script>
</head>
<body>
<div class="container-fluid" style="margin-top:150px;">
<div class="row">
<div class="col-sm-4 col-sm-offset-4">
<?php if($forward):?>
<div class="panel panel-success">
<div class="panel-heading">Enter new password</div>
<div class="panel-body">
<form id="passreset" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']);?>" method="post">
<div class="form-group">
<label for="pass1">Password:</label>
<input type="password" class="form-control" name="pass1" id="pass1"><span> <?php echo $pass1err;?></span>
</div>
<div class="form-group">
<label for="pass2">Confirm Password:</label>
<input type="password" class="form-control" name="pass2" id="pass2" ><span> <?php echo $pass2err;?></span>
</div>
<input type="hidden" name="hid" value="<?php echo $hid;?>">
<input type="submit" value="send">
</form>
</div>
</div>
<?endif;?>
</div>
</div>
</div>
</body>
</html>