10 * Require the base class file.
12 require_once "Auth/OpenID/SQLStore.php";
15 * An SQL store that uses SQLite as its backend.
19 class Auth_OpenID_SQLiteStore extends Auth_OpenID_SQLStore {
22 $this->sql['nonce_table'] =
23 "CREATE TABLE %s (server_url VARCHAR(2047), timestamp INTEGER, ".
24 "salt CHAR(40), UNIQUE (server_url, timestamp, salt))";
26 $this->sql['assoc_table'] =
27 "CREATE TABLE %s (server_url VARCHAR(2047), handle VARCHAR(255), ".
28 "secret BLOB(128), issued INTEGER, lifetime INTEGER, ".
29 "assoc_type VARCHAR(64), PRIMARY KEY (server_url, handle))";
31 $this->sql['set_assoc'] =
32 "INSERT OR REPLACE INTO %s VALUES (?, ?, ?, ?, ?, ?)";
34 $this->sql['get_assocs'] =
35 "SELECT handle, secret, issued, lifetime, assoc_type FROM %s ".
36 "WHERE server_url = ?";
38 $this->sql['get_assoc'] =
39 "SELECT handle, secret, issued, lifetime, assoc_type FROM %s ".
40 "WHERE server_url = ? AND handle = ?";
42 $this->sql['remove_assoc'] =
43 "DELETE FROM %s WHERE server_url = ? AND handle = ?";
45 $this->sql['add_nonce'] =
46 "INSERT INTO %s (server_url, timestamp, salt) VALUES (?, ?, ?)";
48 $this->sql['clean_nonce'] =
49 "DELETE FROM %s WHERE timestamp < ?";
51 $this->sql['clean_assoc'] =
52 "DELETE FROM %s WHERE issued + lifetime < ?";
58 function _add_nonce($server_url, $timestamp, $salt)
60 // PECL SQLite extensions 1.0.3 and older (1.0.3 is the
61 // current release at the time of this writing) have a broken
62 // sqlite_escape_string function that breaks when passed the
63 // empty string. Prefixing all strings with one character
64 // keeps them unique and avoids this bug. The nonce table is
65 // write-only, so we don't have to worry about updating other
66 // functions with this same bad hack.
67 return parent::_add_nonce('x' . $server_url, $timestamp, $salt);