00001 <?php
00002
00012 require_once "Auth/OpenID/SQLStore.php";
00013
00019 class Auth_OpenID_MySQLStore extends Auth_OpenID_SQLStore {
00023 function setSQL()
00024 {
00025 $this->sql['nonce_table'] =
00026 "CREATE TABLE %s (\n".
00027 " server_url VARCHAR(2047) NOT NULL,\n".
00028 " timestamp INTEGER NOT NULL,\n".
00029 " salt CHAR(40) NOT NULL,\n".
00030 " UNIQUE (server_url(255), timestamp, salt)\n".
00031 ") ENGINE=InnoDB";
00032
00033 $this->sql['assoc_table'] =
00034 "CREATE TABLE %s (\n".
00035 " server_url BLOB NOT NULL,\n".
00036 " handle VARCHAR(255) NOT NULL,\n".
00037 " secret BLOB NOT NULL,\n".
00038 " issued INTEGER NOT NULL,\n".
00039 " lifetime INTEGER NOT NULL,\n".
00040 " assoc_type VARCHAR(64) NOT NULL,\n".
00041 " PRIMARY KEY (server_url(255), handle)\n".
00042 ") ENGINE=InnoDB";
00043
00044 $this->sql['set_assoc'] =
00045 "REPLACE INTO %s (server_url, handle, secret, issued,\n".
00046 " lifetime, assoc_type) VALUES (?, ?, !, ?, ?, ?)";
00047
00048 $this->sql['get_assocs'] =
00049 "SELECT handle, secret, issued, lifetime, assoc_type FROM %s ".
00050 "WHERE server_url = ?";
00051
00052 $this->sql['get_assoc'] =
00053 "SELECT handle, secret, issued, lifetime, assoc_type FROM %s ".
00054 "WHERE server_url = ? AND handle = ?";
00055
00056 $this->sql['remove_assoc'] =
00057 "DELETE FROM %s WHERE server_url = ? AND handle = ?";
00058
00059 $this->sql['add_nonce'] =
00060 "INSERT INTO %s (server_url, timestamp, salt) VALUES (?, ?, ?)";
00061
00062 $this->sql['clean_nonce'] =
00063 "DELETE FROM %s WHERE timestamp < ?";
00064
00065 $this->sql['clean_assoc'] =
00066 "DELETE FROM %s WHERE issued + lifetime < ?";
00067 }
00068
00072 function blobEncode($blob)
00073 {
00074 return "0x" . bin2hex($blob);
00075 }
00076 }
00077
00078 ?>