]> git.mxchange.org Git - friendica-addons.git/blob - dav/SabreDAV/lib/Sabre/DAV/Auth/Backend/PDO.php
removed community home addon
[friendica-addons.git] / dav / SabreDAV / lib / Sabre / DAV / Auth / Backend / PDO.php
1 <?php
2
3 /**
4  * This is an authentication backend that uses a file to manage passwords.
5  *
6  * The backend file must conform to Apache's htdigest format
7  *
8  * @package Sabre
9  * @subpackage DAV
10  * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
11  * @author Evert Pot (http://www.rooftopsolutions.nl/) 
12  * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
13  */
14 class Sabre_DAV_Auth_Backend_PDO extends Sabre_DAV_Auth_Backend_AbstractDigest {
15
16     /**
17      * Reference to PDO connection
18      *
19      * @var PDO
20      */
21     protected $pdo;
22
23     /**
24      * PDO table name we'll be using
25      *
26      * @var string
27      */
28     protected $tableName;
29
30
31     /**
32      * Creates the backend object.
33      *
34      * If the filename argument is passed in, it will parse out the specified file fist.
35      *
36      * @param PDO $pdo
37      * @param string $tableName The PDO table name to use
38      */
39     public function __construct(PDO $pdo, $tableName = 'users') {
40
41         $this->pdo = $pdo;
42         $this->tableName = $tableName;
43
44     }
45
46     /**
47      * Returns the digest hash for a user.
48      *
49      * @param string $realm
50      * @param string $username
51      * @return string|null
52      */
53     public function getDigestHash($realm,$username) {
54
55         $stmt = $this->pdo->prepare('SELECT username, digesta1 FROM '.$this->tableName.' WHERE username = ?');
56         $stmt->execute(array($username));
57         $result = $stmt->fetchAll();
58
59         if (!count($result)) return;
60
61         return $result[0]['digesta1'];
62
63     }
64
65 }