From 0a71101798ff909d214ffbc8973921a28698f7d0 Mon Sep 17 00:00:00 2001 From: Gregory Soutade Date: Sat, 7 Dec 2013 10:38:45 +0100 Subject: [PATCH] Modify ref index.php to include code instead of embed it (for simpler future update) --- server/_user | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 server/_user diff --git a/server/_user b/server/_user new file mode 100644 index 0000000..d750a21 --- /dev/null +++ b/server/_user @@ -0,0 +1,61 @@ +. +*/ + +function load_database() +{ + try { + $db = new SQLite3("./gpass.bdd", SQLITE3_OPEN_READONLY); + } + catch(Exception $e) + { + die("Unable to load database for user $user !
"); + return null; + } + return $db; +} + +$PROTOCOL_VERSION = 2; + +$db = load_database(); + +$res = ""; + +$statement = $db->prepare("SELECT password FROM gpass WHERE login=:login"); + +echo "protocol=gpass-$PROTOCOL_VERSION\n"; + +for ($i=0; isset($_POST["k$i"]); $i++) +{ + $statement->bindValue(":login", $_POST["k$i"]); + $result = $statement->execute(); + $row = $result->fetchArray(SQLITE3_ASSOC); + $result->finalize(); + if (isset($row["password"])) + { + echo "pass=" . $row["password"] . "\n"; + break; + } +} + +$statement->close(); + +echo ""; + +?> \ No newline at end of file