diff --git a/index.php b/index.php index e98f2d5..2488a92 100755 --- a/index.php +++ b/index.php @@ -13,85 +13,124 @@

-AJServer password retrieval +One Time Password Retrieval Tool
false, - PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION] - ); - } catch (PDOException $failure) { - echo "Connection failed: " . $failure->getMessage(); - }; + $pdo = new PDO( + 'mysql:host=localhost;dbname=pwtool;charset=utf8', + 'pwtool', + 'BaVYtU9YqMyrp4qi', + [PDO::ATTR_EMULATE_PREPARES => false, + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION] + ); + } catch (PDOException $failure) { + echo "Connection failed: " . $failure->getMessage(); + }; + require 'CaptchasDotNet.php'; - if(($MyKey != '') and (strlen($MyKey) == 32) || (strlen($MyKey) == 64)) { + $captchas = new CaptchasDotNet ('demo', 'secret', + '/tmp/captchasnet-random-strings','3600', + 'abcdefghkmnopqrstuvwxyz','6', + '240','80','000088'); - $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(isset($_GET['key'])) + { //Key set in URL + $MyKey = preg_replace('/[^a-f0-9]/', '', trim($_GET['key'])); - if($count == 1){ + if(($MyKey != '') and (strlen($MyKey) == 32) || (strlen($MyKey) == 64)) { - $myRow = $MyLookup->fetch(PDO::FETCH_OBJ); - $MyIP = $myRow->retrieved_ip; + $MyLookup = $pdo->prepare("SELECT password, retrieved_ip, retireved_time FROM pwtool.mypasswd WHERE code = '$MyKey'"); + $MyLookup->execute(); + $count = $MyLookup->rowCount(); - if($MyIP != ''){ + if($count == 1){ - //$MyTime = date('l, F j Y G:i:s', $myRow->retireved_time); - $MyTime = $myRow->retireved_time; + $myRow = $MyLookup->fetch(PDO::FETCH_OBJ); + $MyIP = $myRow->retrieved_ip; - print '

Error: This key was valid for one-time ' - .'use and is no longer valid.

It was already delivered to IP address ' - .''.$MyIP.' on '.$MyTime.'. Please contact ' - .'support immediately to have your password reset if you feel your key ' - .'might have been intercepted.

'; + if($MyIP != ''){ + + $MyTime = $myRow->retireved_time; + + print '

Error: This key was valid for one-time ' + .'use and is no longer valid.

It was already delivered to IP address ' + .''.$MyIP.' on '.$MyTime.'. Please contact ' + .'support immediately to have your password reset if you feel your key ' + .'might have been intercepted.

'; + } else { + + $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(); + + print '

Your password is:

'; + + if(strlen($MyPassword) > 20){ + print '

'.$MyPassword.'

'; + } else { + print ''.$MyPassword.'

'; + } + print '

Do not hit reload on your browser. This URL is one-time use and will not show your passsword again.

'; + } } 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 '

Your password is:

'; - - if(strlen($MyPassword) > 20){ - - print '

'.$MyPassword.'

'; - - } else { - print ''.$MyPassword.'

'; - } - print '

Do not hit reload on your browser. This URL is one-time use and will not show your passsword again.

'; + print '

Error: You need to supply a valid key.

'; } } else{ print '

Error: You need to supply a valid key.

'; } + } else + { //Display New password entry form + ?> +
+ + + + */ ?> + + + + + + + + + + + + + + + + + + + +
Admin Password:
+ + ?> +
+ + image () ?>
Reload Image + Phonetic spelling (mp3) +
Buchstabieren (mp3) +
Compitare (mp3) +
Spellen (mp3) +
Epeler (mp3) */ ?> +
+ The CAPTCHA: + + +
New Password:
+
+ Error: You need to supply a valid key.

'; - } + ?>