Display Password entry from index if key not supplied
This commit is contained in:
parent
ed9eed7a36
commit
d9522084f9
79
index.php
79
index.php
|
|
@ -13,14 +13,10 @@
|
|||
<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>
|
||||
<strong>One Time Password Retrieval Tool</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");
|
||||
try {
|
||||
$pdo = new PDO(
|
||||
'mysql:host=localhost;dbname=pwtool;charset=utf8',
|
||||
|
|
@ -32,15 +28,21 @@
|
|||
} catch (PDOException $failure) {
|
||||
echo "Connection failed: " . $failure->getMessage();
|
||||
};
|
||||
require 'CaptchasDotNet.php';
|
||||
|
||||
$captchas = new CaptchasDotNet ('demo', 'secret',
|
||||
'/tmp/captchasnet-random-strings','3600',
|
||||
'abcdefghkmnopqrstuvwxyz','6',
|
||||
'240','80','000088');
|
||||
|
||||
if(isset($_GET['key']))
|
||||
{ //Key set in URL
|
||||
$MyKey = preg_replace('/[^a-f0-9]/', '', trim($_GET['key']));
|
||||
|
||||
if(($MyKey != '') and (strlen($MyKey) == 32) || (strlen($MyKey) == 64)) {
|
||||
|
||||
$MyLookup = $pdo->prepare("SELECT password, retrieved_ip, retireved_time FROM pwtool.mypasswd WHERE code = '$MyKey'");
|
||||
$MyLookup->execute();
|
||||
/* $MyLookup = pg_query($DBConnection, "SELECT password, retrieved_ip, extract('epoch' from retrieved_time)::integer
|
||||
FROM mypasswd.password_delivery
|
||||
WHERE code = '".pg_escape_string($MyKey)."'");
|
||||
*/
|
||||
$count = $MyLookup->rowCount();
|
||||
|
||||
if($count == 1){
|
||||
|
|
@ -50,7 +52,6 @@
|
|||
|
||||
if($MyIP != ''){
|
||||
|
||||
//$MyTime = date('l, F j Y G:i:s', $myRow->retireved_time);
|
||||
$MyTime = $myRow->retireved_time;
|
||||
|
||||
print '<p><strong>Error:</strong> This key was valid for one-time '
|
||||
|
|
@ -58,27 +59,18 @@
|
|||
.'<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{
|
||||
} else {
|
||||
|
||||
//$MyPassword = pg_fetch_result($MyLookup,0,0);
|
||||
$MyPassword = $myRow->password;
|
||||
$MyIP = $_SERVER['REMOTE_ADDR'];
|
||||
$myUpdate = $pdo->prepare("UPDATE pwtool.mypasswd SET retrieved_ip = '$MyIP',retireved_time = now(),password = ''
|
||||
WHERE code = '$MyKey'");
|
||||
$myUpdate->execute();
|
||||
/*$MyLookup = pg_query($DBConnection, "UPDATE mypasswd.password_delivery
|
||||
SET retrieved_ip = '".pg_escape_string($MyIP)."',
|
||||
retrieved_time = 'now()',
|
||||
password = ''
|
||||
WHERE code = '".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>';
|
||||
}
|
||||
|
|
@ -92,6 +84,53 @@
|
|||
else{
|
||||
print '<p><strong>Error:</strong> You need to supply a valid key.</p>';
|
||||
}
|
||||
} else
|
||||
{ //Display New password entry form
|
||||
?>
|
||||
<form method="post" action="add.php">
|
||||
<table border="0" cellspacing="2" cellpadding="2">
|
||||
<?php /*<tr>
|
||||
<td>Admin Password:</td><td><input type="password" name="adminPassword" value="" /></td>
|
||||
</tr> */ ?>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="hidden" name="random" value="<?= $captchas->random () ?>" />
|
||||
<?php //Your message:</td><td><input name="message" value="Hello World" size="60" /> ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
<?= $captchas->image () ?> </br><a href="javascript:captchas_image_reload('captchas.net')">Reload Image</a>
|
||||
<?php /*<br> <a href="<?= $captchas->audio_url () ?>">Phonetic spelling (mp3)</a>
|
||||
<br> <a href="<?= $captchas->audio_url () ?>&language=de">Buchstabieren (mp3)</a>
|
||||
<br> <a href="<?= $captchas->audio_url () ?>&language=it">Compitare (mp3)</a>
|
||||
<br> <a href="<?= $captchas->audio_url () ?>&language=nl">Spellen (mp3)</a>
|
||||
<br> <a href="<?= $captchas->audio_url () ?>&language=fr">Epeler (mp3)</a> */ ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
The CAPTCHA:
|
||||
</td>
|
||||
<td>
|
||||
<input name="password" size="6" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>New Password:</td><td><input type="text" name="newPassword" value="" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input type="submit" name="submit" value="Submit" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue