-
Notifications
You must be signed in to change notification settings - Fork 0
/
updatepassword.php
executable file
·45 lines (44 loc) · 2.06 KB
/
updatepassword.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
<?php
$host = "host = 127.0.0.1";
$port = "port = 5432";
$dbname = "dbname = testdb";
$username = $_POST['username'];
$password = $_POST['password'];
$newpassword = $_POST['newpassword'];
$credentials = "user = $username password=$password";
$conn = pg_connect( " $host $port $dbname $credentials" );
echo "<html>
<head>
<title>Lintel</title>
<meta charset=\"utf-8\">
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">
<link rel=\"stylesheet\" href=\"bootstrap/css/bootstrap.min.css\">
<link rel=\"stylesheet\" href=\"font-awesome/css/font-awesome.min.css\">
</head><body><div class=\"container-fluid\" style=\"text-align:center\">";
if (!$conn) {
echo "Please check your credentials <br>";
}
$query = "alter user $username password '$newpassword'";
$result = pg_query($query);
if($result){
if (!$content = file_get_contents ("../.credentials.txt")){
echo "Unable to open credentials for readfiles even though database passsword is updated, Please contact admin to correct it";
}
else {
$content = str_replace($password,$newpassword,$content);
if (!file_put_contents ("../.credentials.txt",$content)){
echo "Unable to update credentials for readfiles even though database passsword is updated, Please contact admin to correct it";
}
else {
echo "Password updated..! ${output}";
}
echo "  <a href=\"password.html\">Back  <span class=\"glyphicon glyphicon-check\"></span></a>";
}
}
else{
echo "Password update failed...!";
echo "  <a href=\"password.html\">Retry  <span class=\"glyphicon glyphicon-repeat\"></span></a>";
}
echo " </div></body></html>";
pg_close($conn);
?>