-
Notifications
You must be signed in to change notification settings - Fork 0
/
confirm.php
129 lines (113 loc) · 4.62 KB
/
confirm.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
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Confirmation</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="manifest" href="site.webmanifest">
<!-- Place favicon.ico in the root directory -->
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.teal-amber.min.css"/>
<script defer src="https://code.getmdl.io/1.3.0/material.min.js"></script>
<!--<link rel="stylesheet" href="css/materialize.css" >-->
<link rel="stylesheet" type="text/css" href="font-awesome-4.7.0/css/font-awesome.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="css/materialize.min.css" media="screen,projection"/>
<link rel="stylesheet" href="css/main.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="js/materialize.min.js"></script>
<style>
#login form {
display: inline-block;
position: fixed;
left: 0;
right: 0;
margin: auto;
}
.error {
color: red;
}
.header1{
color: #ffffff;
}
.btn{
background-color: black;
}
.btn:visited{
background-color: #000000
}
.btn:hover {
background-color: #eb8e3f
}
.btn:focus{
background-color: gray;
}
</style>
<script>
$(document).ready(function () {
$(".button-collapse").sideNav();
});
</script>
</head>
<body style="background-color: #009688">
<div class="row">
<div class="col m6 s12">
<?php
require 'variables.php';
require 'com/config/DBHelper.php';
function test_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
//m->mode(r->reset, c->confirm)
//u->username
//h->hash
$mode = test_input($_GET['m']);
$username = test_input($_GET['u']);
$hash = test_input($_GET['h']);
$db = new DBHelper();
$conn = $db->getConnection();
$q1 = "SELECT hash FROM `users` WHERE username='$username'";
$result = $conn->query($q1);
//print_r($result);
$r = $result->fetch_assoc();
//print_r($r);
if ($result->num_rows == 1 and $r['hash'] == $hash) {
if ($mode == 'c') {
$q2 = "UPDATE `users` SET activated=1 WHERE username='$username'";
if ($conn->query($q2) == false) {
//die($conn->connect_error);
die("<h3 class=\"header1\">Error occured while confirming link.<br>Try Again.</h3>");
} else {
echo "<h3 class=\"header1\">Account confirmation successful.<br>Login and get cracking!.<br></h3>";
echo '<a href="login.php" class="btn" type="button">Login</a>';
}
} else if ($mode == 'r') {
$q2 = "UPDATE `users` SET password=temp_pwd WHERE username='$username'";
if ($conn->query($q2) == false) {
//die($conn->connect_error);
die("Error occured while resetting password.<br>Try Again.");
} else {
echo "Password reset successful.<br>Login with your new credentials.<br>";
echo '<a href="login.php"><b>Login</b></a>';
}
} else {
echo "<h3 class=\"header1\">Invalid link.<br></h3>";
echo "<h3 class=\"header1\">You are encouraged to test your hacking skills on our questions, not here.<br></h3>";
echo "<h3 class=\"header1\">Thank You!<br></h3>";
}
} else {
echo "<h3 class=\"header1\">Invalid link.<br></h3>";
echo "<h3 class=\"header1\">You are encouraged to test your hacking skills on our questions, not here.<br></h3>";
echo "<h3 class=\"header1\">Thank You!<br></h3>";
}
?>
</div>
</div>
</body>
<footer class="footernobg footer-copyright"><div></div><div><p>© 2018 Made by <a href="https://github.com/OpenWeavers" target="_blank"><img src="img/OpenWeavers-01.png" alt="OpenWeavers" width="30" height="30"></a></p></div></footer>
</html>