/
reset.php
145 lines (128 loc) · 4.62 KB
/
reset.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
<!DOCTYPE HTML>
<html>
<?php
if(isSet($_POST["login_submitted"]))
{
include_once("includes/auth.php");
}
?>
<?php include("head.inc"); ?>
<body>
<?php include("bg.inc"); ?>
<div id="main">
<header>
<div id="logo">
<div id="logo_text">
<!-- class="logo_colour", allows you to change the colour of the text -->
<h1><a href="/index.php">HackWeek<span class="logo_colour">#hackTheFlag</span></a></h1>
<h2>Hack like ninja, play for proud, fun and profit!</h2>
</div>
</div>
<nav>
</nav>
</header>
<div id="site_content">
<?php include("common_sidebar.php"); ?>
<?php
$msg = "";
$success = false;
if(isSet($_POST['reset_submitted']))
{
include_once("/var/www/includes/validation.php");
$email = trim($_POST['email']);
if($email != "") { //is_email_valid($email)) {
include_once("/var/www/includes/user.php");
include_once("/var/www/includes/crypt.php");
$u = new user();
$uid = $u->get_user_id($email);
if($uid != 0) {
$cr = new crypto();
$token = base64_encode($cr->encrypt($uid));
$link = 'http://punbt090pc/reset.php?token=' . urlencode($token) ;
include_once("/var/www/includes/email.php");
send_reset_email($email, $link);
$msg = "Reset instruction are sent to email - " . $email . " Please check inbox/junkbox.";
$success = true;
}else {
$msg = "Email is not registered";
}
} else {
$msg = "Invalid Email " . $email;
}
}
elseif(isSet($_POST['resetpwd_submitted'])) {
$token = $_POST['token'];
$new_pwd = trim($_POST['new_password']);
$con_pwd = trim($_POST['con_password']);
if($new_pwd == "" || $con_pwd == "") {
$msg = "No blank fields allowed";
}elseif($new_pwd != $con_pwd) {
$msg = "Password Mismatch";
}else {
include_once("/var/www/includes/user.php");
include_once("/var/www/includes/crypt.php");
$cr = new crypto();
$u = new user();
$uid = urldecode($cr->decrypt(base64_decode($token)));
$uid = intval($uid);
if($uid != 0) {
if($u->update_password($uid, NULL , $cr->one_way_crypt($new_pwd))) {
$msg = "Password changed successfully";
$success = true;
}else {
$msg = "Error while changing password";
}
}else {
$msg = "Something goes wrong while resetting password. Contact Team";
}
}
}
?>
<div class="content">
<h1>Reset Password</h1>
<?php
if (!isSet($_GET['token'])) {
?>
<form id="login" action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
<div class="form_settings">
<p><span>Email</span><input class="contact" id="u_name" type="text" onclick="u_on_click" name="email" value="" /></p>
<p style="padding-top: 15px"><span> </span><input class="submit" onsubmit="return check_form();" type="submit" name="reset_submitted" value="send" /></p>
<h3>
<?php if($success) { ?>
<font color="green"><?php echo $msg; ?>
<?php }else { ?>
<font color="red"><?php echo $msg; ?>
<?php } ?>
</font></h3>
</div>
</form>
<?php }
else {
$token = trim($_GET['token']);
if($token != "") {
?>
<form id="reset_pwd" action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
<div class="form_settings">
<p><span>New Password</span><input class="contact" id="new_password" type="password" name="new_password" value="" /></p>
<p><span>Confirm Password</span><input class="contact" id="con_password" type="password" name="con_password" value="" /></p>
<input class="contact" id="token" type="hidden" name="token" value="<?php echo $token ?>" /></p>
<p style="padding-top: 15px"><span> </span><input class="submit" type="submit" name="resetpwd_submitted" value="send" /></p>
<h3><font color="green"><?php echo $msg; ?></font></h3>
</div>
<?php } }?>
</div>
</div>
</div>
</div>
<!-- javascript at the bottom for fast page loading -->
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.easing-sooper.js"></script>
<script type="text/javascript" src="js/jquery.sooperfish.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('ul.sf-menu').sooperfish();
$('.top').click(function() {$('html, body').animate({scrollTop:0}, 'fast'); return false;});
});
</script>
</body>
</html>