SQLiteStore.php

Go to the documentation of this file.
00001 <?php
00002 
00012 require_once "Auth/OpenID/SQLStore.php";
00013 
00019 class Auth_OpenID_SQLiteStore extends Auth_OpenID_SQLStore {
00020     function setSQL()
00021     {
00022         $this->sql['nonce_table'] =
00023             "CREATE TABLE %s (server_url VARCHAR(2047), timestamp INTEGER, ".
00024             "salt CHAR(40), UNIQUE (server_url, timestamp, salt))";
00025 
00026         $this->sql['assoc_table'] =
00027             "CREATE TABLE %s (server_url VARCHAR(2047), handle VARCHAR(255), ".
00028             "secret BLOB(128), issued INTEGER, lifetime INTEGER, ".
00029             "assoc_type VARCHAR(64), PRIMARY KEY (server_url, handle))";
00030 
00031         $this->sql['set_assoc'] =
00032             "INSERT OR REPLACE INTO %s VALUES (?, ?, ?, ?, ?, ?)";
00033 
00034         $this->sql['get_assocs'] =
00035             "SELECT handle, secret, issued, lifetime, assoc_type FROM %s ".
00036             "WHERE server_url = ?";
00037 
00038         $this->sql['get_assoc'] =
00039             "SELECT handle, secret, issued, lifetime, assoc_type FROM %s ".
00040             "WHERE server_url = ? AND handle = ?";
00041 
00042         $this->sql['remove_assoc'] =
00043             "DELETE FROM %s WHERE server_url = ? AND handle = ?";
00044 
00045         $this->sql['add_nonce'] =
00046             "INSERT INTO %s (server_url, timestamp, salt) VALUES (?, ?, ?)";
00047 
00048         $this->sql['clean_nonce'] =
00049             "DELETE FROM %s WHERE timestamp < ?";
00050 
00051         $this->sql['clean_assoc'] =
00052             "DELETE FROM %s WHERE issued + lifetime < ?";
00053     }
00054 
00058     function _add_nonce($server_url, $timestamp, $salt)
00059     {
00060         // PECL SQLite extensions 1.0.3 and older (1.0.3 is the
00061         // current release at the time of this writing) have a broken
00062         // sqlite_escape_string function that breaks when passed the
00063         // empty string. Prefixing all strings with one character
00064         // keeps them unique and avoids this bug. The nonce table is
00065         // write-only, so we don't have to worry about updating other
00066         // functions with this same bad hack.
00067         return parent::_add_nonce('x' . $server_url, $timestamp, $salt);
00068     }
00069 }
00070 
00071 ?>

Generated on Thu Feb 19 15:02:21 2009 for OXID eShop CE by  doxygen 1.5.5