56 lines
1.4 KiB
PHP
56 lines
1.4 KiB
PHP
|
<?php
|
||
|
/*
|
||
|
Copyright (C) 2013 Grégory Soutadé
|
||
|
|
||
|
This file is part of gPass.
|
||
|
|
||
|
gPass is free software: you can redistribute it and/or modify
|
||
|
it under the terms of the GNU General Public License as published by
|
||
|
the Free Software Foundation, either version 3 of the License, or
|
||
|
(at your option) any later version.
|
||
|
|
||
|
gPass is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
GNU General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU General Public License
|
||
|
along with gPass. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*/
|
||
|
|
||
|
function load_database()
|
||
|
{
|
||
|
try {
|
||
|
$db = new SQLite3("./gpass.bdd", SQLITE3_OPEN_READONLY);
|
||
|
}
|
||
|
catch(Exception $e)
|
||
|
{
|
||
|
die("<b>Unable to load database for user $user !</b><br/>");
|
||
|
return null;
|
||
|
}
|
||
|
return $db;
|
||
|
}
|
||
|
|
||
|
$db = load_database();
|
||
|
|
||
|
$res = "";
|
||
|
|
||
|
$statement = $db->prepare("SELECT password FROM gpass WHERE login=:login");
|
||
|
|
||
|
for ($i=0; isset($_POST["k$i"]); $i++)
|
||
|
{
|
||
|
$statement->bindValue(":login", $_POST["k$i"]);
|
||
|
$result = $statement->execute();
|
||
|
$row = $result->fetchArray();
|
||
|
if (isset($row["password"]))
|
||
|
{
|
||
|
echo "pass=" . $row["password"] . "\n";
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$statement->close();
|
||
|
|
||
|
echo "<end>";
|
||
|
|
||
|
?>
|