-
Notifications
You must be signed in to change notification settings - Fork 0
/
reset.php
executable file
·58 lines (54 loc) · 2.21 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
<?php
$host = "host = 127.0.0.1";
$port = "port = 5432";
$dbname = "dbname = testdb";
$pid = $_POST['pid'];
$upassword = $_POST['newpassword'];
$loginData = file('../.credentials.txt');
foreach ($loginData as $line) {
list($username, $password) = explode(',',$line);
}
$credentials = "user = $username password=$password";
$conn = pg_connect( " $host $port $dbname $credentials" );
if (!$conn) {
echo "<script type=\"text/javascript\">
alert('Server Busy, Please tryagian later');
setTimeout(\"location.href = 'index.html'\",0);
</script>";
}
$myranpassword = "reset-" . $pid;
$query = "select * from userdetails where password='$myranpassword'";
$result = pg_query($query);
if($result){
$rowcount = pg_num_rows($result);
if ($rowcount > 0 ) {
$query = "update userdetails set password = '$upassword' where password='$myranpassword'";
$result = pg_query($query);
if($result){
echo "<script type=\"text/javascript\">
alert('Updated the password, Please try login in');
setTimeout(\"location.href = 'index.html'\",0);
</script>";
}
else {
echo "<script type=\"text/javascript\">
alert('Failed to update password, Please try again1');
setTimeout(\"location.href = 'index.html'\",0);
</script>";
}
}
else {
echo "<script type=\"text/javascript\">
alert('Failed to update password/Link you are trying is wrong, Please try again2');
setTimeout(\"location.href = 'index.html'\",0);
</script>";
}
}
else{
echo "<script type=\"text/javascript\">
alert('Failed to update password, Please try again3');
setTimeout(\"location.href = 'index.html'\",0);
</script>";
}
pg_close($conn);
?>