Working index.php
This commit is contained in:
parent
5a4cefb3c2
commit
7ee2c5b8cc
38
index.php
38
index.php
|
|
@ -20,20 +20,38 @@
|
||||||
|
|
||||||
$MyKey = preg_replace('/[^a-f0-9]/', '', trim($_GET['key']));
|
$MyKey = preg_replace('/[^a-f0-9]/', '', trim($_GET['key']));
|
||||||
|
|
||||||
$DBConnection = pg_connect("host=localhost port=5432 dbname=mypasswd user=mypasswd password=passwdT00l");
|
//$DBConnection = pg_connect("host=localhost port=5432 dbname=mypasswd user=mypasswd password=passwdT00l");
|
||||||
|
try {
|
||||||
|
$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();
|
||||||
|
};
|
||||||
|
|
||||||
if(($MyKey != '') and (strlen($MyKey) == 32)){
|
if(($MyKey != '') and (strlen($MyKey) == 32)){
|
||||||
|
|
||||||
$MyLookup = pg_query($DBConnection, "SELECT password, retrieved_ip, extract('epoch' from retrieved_time)::integer
|
$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
|
FROM mypasswd.password_delivery
|
||||||
WHERE code = '".pg_escape_string($MyKey)."'");
|
WHERE code = '".pg_escape_string($MyKey)."'");
|
||||||
if(pg_num_rows($MyLookup)){
|
*/
|
||||||
|
$count = $MyLookup->rowCount();
|
||||||
|
|
||||||
$MyIP = pg_fetch_result($MyLookup,0,1);
|
if($count == 1){
|
||||||
|
|
||||||
|
$myRow = $MyLookup->fetch(PDO::FETCH_OBJ);
|
||||||
|
$MyIP = $myRow->retrieved_ip;
|
||||||
|
|
||||||
if($MyIP != ''){
|
if($MyIP != ''){
|
||||||
|
|
||||||
$MyTime = date('l, F j Y G:i:s', pg_fetch_result($MyLookup, 0, 2));
|
//$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 '
|
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 '
|
.'use and is no longer valid.</p><p>It was already delivered to IP address '
|
||||||
|
|
@ -43,13 +61,17 @@
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
||||||
$MyPassword = pg_fetch_result($MyLookup,0,0);
|
//$MyPassword = pg_fetch_result($MyLookup,0,0);
|
||||||
|
$MyPassword = $myRow->password;
|
||||||
$MyIP = $_SERVER['REMOTE_ADDR'];
|
$MyIP = $_SERVER['REMOTE_ADDR'];
|
||||||
$MyLookup = pg_query($DBConnection, "UPDATE mypasswd.password_delivery
|
$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)."',
|
SET retrieved_ip = '".pg_escape_string($MyIP)."',
|
||||||
retrieved_time = 'now()',
|
retrieved_time = 'now()',
|
||||||
password = ''
|
password = ''
|
||||||
WHERE code = '".pg_escape_string($MyKey)."'");
|
WHERE code = '".pg_escape_string($MyKey)."'");*/
|
||||||
|
|
||||||
print '<p>Your password is:</p><p style="font-size: 18px; text-align: center;">';
|
print '<p>Your password is:</p><p style="font-size: 18px; text-align: center;">';
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue