One Time Password Retrieval Tool
false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION] ); } 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(); $count = $MyLookup->rowCount(); if($count == 1){ $myRow = $MyLookup->fetch(PDO::FETCH_OBJ); $MyIP = $myRow->retrieved_ip; 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{ print '

Error: You need to supply a valid key.

'; } } else{ print '

Error: You need to supply a valid key.

'; } } elseif(isset($_REQUEST['random'])) { //captcah was used, process it $captchas = new CaptchasDotNet ('demo', 'secret', '/tmp/captchasnet-random-strings','3600', 'abcdefghkmnopqrstuvwxyz','6', '240','80','000088'); // Read the form values $password = $_REQUEST['password']; $random_string = $_REQUEST['random']; $newPassword = str_replace("'", '', trim($_POST['newPassword'])); if (!$captchas->validate ($random_string)) { // captcah error echo 'The session key (random) does not exist, please go back and reload form.
'; echo 'In case you are the administrator of this page, '; echo 'please check if random keys are stored correct.
'; echo 'See http://captchas.net/sample/php/ "Problems with save mode"'; } elseif ($captchas->verify ($password)) { //captcah passes, add password to DB $displayForm = false; //$pdo->query($dbConnection, "START TRANSACTION;;"); $myLookup = $pdo->prepare("INSERT INTO pwtool.mypasswd (code, password) VALUES(sha2(CONCAT(rand(),rand(),rand()),256), '$newPassword');"); $myLookup->execute(); $myLookup = $pdo->prepare("SELECT code FROM pwtool.mypasswd WHERE id = LAST_INSERT_ID();"); $myLookup->execute(); $myKey = $myLookup->fetch(PDO::FETCH_OBJ); //pg_fetch_result($myLookup, 0, 0); //$pdo->query($dbConnection, "COMMIT"); print '

Password insert succeeded. Here\'s the URL to fetch it:

'; print '

link

'; } else { //captcah worng //print '

Nope, not here: '.$adminPassword.'

'; echo 'You entered the wrong captcah. Aren\'t you human?'; } } 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: