80 lines
2.5 KiB
PHP
80 lines
2.5 KiB
PHP
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<title>Password Fetch tool</title>
|
|
<style type="text/css">
|
|
body{
|
|
padding: 32px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body style="width: 500px; margin: auto; font-family: Verdana, Geneva, sans-serif; font-size: 14px;">
|
|
<br /><br />
|
|
<div align="center" style="width: 500px">
|
|
<div style="border: 1px solid #000000; text-align: center; background: #486b92; font-size: 20px; color: #ffffff;">
|
|
<strong>AJServer password retrieval</strong>
|
|
</div>
|
|
<div style="border: 1px solid #000000; text-align: left; padding: 8px;">
|
|
<?php
|
|
|
|
$MyKey = preg_replace('/[^a-f0-9]/', '', trim($_GET['key']));
|
|
|
|
$DBConnection = pg_connect("host=localhost port=5432 dbname=mypasswd user=mypasswd password=passwdT00l");
|
|
|
|
if(($MyKey != '') and (strlen($MyKey) == 32)){
|
|
|
|
$MyLookup = pg_query($DBConnection, "SELECT password, retrieved_ip, extract('epoch' from retrieved_time)::integer
|
|
FROM password_delivery
|
|
WHERE key = '".pg_escape_string($MyKey)."'");
|
|
if(pg_num_rows($MyLookup)){
|
|
|
|
$MyIP = pg_fetch_result($MyLookup,0,1);
|
|
|
|
if($MyIP != ''){
|
|
|
|
$MyTime = date('l, F j Y G:i:s', pg_fetch_result($MyLookup, 0, 2));
|
|
|
|
print '<p><strong>Error:</strong> This key was valid for one-time '
|
|
.'use and is no longer valid.</p><p>It was already delivered to IP address '
|
|
.'<strong>'.$MyIP.'</strong> on <strong>'.$MyTime.'</strong>. Please contact '
|
|
.'support immediately to have your password reset if you feel your key '
|
|
.'might have been intercepted.</p>';
|
|
}
|
|
else{
|
|
|
|
$MyPassword = pg_fetch_result($MyLookup,0,0);
|
|
$MyIP = $_SERVER['REMOTE_ADDR'];
|
|
$MyLookup = pg_query($DBConnection, "UPDATE password_delivery
|
|
SET retrieved_ip = '".pg_escape_string($MyIP)."',
|
|
retrieved_time = 'now()',
|
|
password = ''
|
|
WHERE key = '".pg_escape_string($MyKey)."'");
|
|
|
|
print '<p>Your password is:</p><p style="font-size: 18px; text-align: center;">';
|
|
|
|
if(strlen($MyPassword) > 20){
|
|
|
|
print '<pre>'.$MyPassword.'</pre></p>';
|
|
|
|
} else {
|
|
print '<strong>'.$MyPassword.'</strong></p>';
|
|
}
|
|
print '<p>Do not hit reload on your browser. This URL is one-time use and will not show your passsword again.<p>';
|
|
}
|
|
}
|
|
else{
|
|
print '<p><strong>Error:</strong> You need to supply a valid key.</p>';
|
|
}
|
|
}
|
|
else{
|
|
print '<p><strong>Error:</strong> You need to supply a valid key.</p>';
|
|
}
|
|
|
|
?>
|
|
</div>
|
|
</div>
|
|
<br /><br />
|
|
</body>
|
|
</html>
|