1: <?php
2:
3: 4: 5: 6: 7:
8:
9: 10: 11:
12: require_once "Auth/OpenID/SQLStore.php";
13:
14: 15: 16: 17: 18:
19: class Auth_OpenID_SQLiteStore extends Auth_OpenID_SQLStore {
20: function setSQL()
21: {
22: $this->sql['nonce_table'] =
23: "CREATE TABLE %s (server_url VARCHAR(2047), timestamp INTEGER, ".
24: "salt CHAR(40), UNIQUE (server_url, timestamp, salt))";
25:
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))";
30:
31: $this->sql['set_assoc'] =
32: "INSERT OR REPLACE INTO %s VALUES (?, ?, ?, ?, ?, ?)";
33:
34: $this->sql['get_assocs'] =
35: "SELECT handle, secret, issued, lifetime, assoc_type FROM %s ".
36: "WHERE server_url = ?";
37:
38: $this->sql['get_assoc'] =
39: "SELECT handle, secret, issued, lifetime, assoc_type FROM %s ".
40: "WHERE server_url = ? AND handle = ?";
41:
42: $this->sql['remove_assoc'] =
43: "DELETE FROM %s WHERE server_url = ? AND handle = ?";
44:
45: $this->sql['add_nonce'] =
46: "INSERT INTO %s (server_url, timestamp, salt) VALUES (?, ?, ?)";
47:
48: $this->sql['clean_nonce'] =
49: "DELETE FROM %s WHERE timestamp < ?";
50:
51: $this->sql['clean_assoc'] =
52: "DELETE FROM %s WHERE issued + lifetime < ?";
53: }
54:
55: 56: 57:
58: function _add_nonce($server_url, $timestamp, $salt)
59: {
60:
61:
62:
63:
64:
65:
66:
67: return parent::_add_nonce('x' . $server_url, $timestamp, $salt);
68: }
69: }
70:
71: