gPass

gPass Git Source Tree

Root/server/_user

1<?php
2/*
3 Copyright (C) 2013-2014 Grégory Soutadé
4
5 This file is part of gPass.
6
7 gPass is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 gPass is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with gPass. If not, see <http://www.gnu.org/licenses/>.
19*/
20
21include("conf.php");
22
23function load_database()
24{
25 try {
26 $db = new SQLite3("./gpass.bdd", SQLITE3_OPEN_READONLY);
27 }
28 catch(Exception $e)
29 {
30 die("<b>Unable to load database for user $user !</b><br/>");
31 return null;
32 }
33 return $db;
34}
35
36$PROTOCOL_VERSION = 3;
37
38$db = load_database();
39
40$res = "";
41
42$statement = $db->prepare("SELECT password FROM gpass WHERE login=:login");
43
44echo "protocol=gpass-$PROTOCOL_VERSION\n";
45if ($PKDBF2_LEVEL != 1000)
46 echo "pkdbf2_level=$PKDBF2_LEVEL\n";
47
48for ($i=0; isset($_POST["k$i"]); $i++)
49{
50 $statement->bindValue(":login", $_POST["k$i"]);
51 $result = $statement->execute();
52 $row = $result->fetchArray(SQLITE3_ASSOC);
53 $result->finalize();
54 if (isset($row["password"]))
55 {
56 echo "pass=" . $row["password"] . "\n";
57 break;
58 }
59}
60
61$statement->close();
62
63echo "<end>";
64
65?>

Archive Download this file