[Cs-webapplibs-commits] SF.net SVN: cs-webapplibs:[115] trunk/0.3
Status: Beta
Brought to you by:
crazedsanity
From: <cra...@us...> - 2009-08-20 01:44:23
|
Revision: 115 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=115&view=rev Author: crazedsanity Date: 2009-08-20 01:44:14 +0000 (Thu, 20 Aug 2009) Log Message: ----------- Updated schema, tests, & set cs_authToken to be MySQL-compatible. TODO::: incorporate changes in cs-webdbupgrade that include the attribute tables into the main SQL file(s). /cs_authToken.class.php: * load_table() [DELETED]: -- this table should be included in with all the other tables. * create_token(): -- set a default value for expiration so the database doesn't have to set that. -- NOTE::: any tokens with a NULL expiration and unlimited uses will NEVER be automatically removed. /cs_webdbupgrade.class.php: * __construct(): -- set DB_TABLE and DB_PRIMARYKEY to hardcoded values. * load_table(): -- updated location of schema file -- NOTE::: this should probably be named "load_schema()", as it is actually loading several different tables now. /setup/authtoken_schema.pgsql.sql [DELETED]: * incorporated into the pgsql & mysql schema files. /setup/schema.mysql.sql: * changed "cs_version_table" to cswal_version_table (cswal == CS-WebAppLibs), removed unnecessary columns (previously removed in cs-webdbupgrade v0.2.0). * create cswal_auth_token_table. /setup/schema.pgsql.sql: * (same as the mysql version). /tests/testOfAuthToken.php: * remove code for creating & destroying tables (NOTE: my test site actually destroys & rebuilds the entire database... this should probably be changed to a series of "DROP TABLE" statements). Modified Paths: -------------- trunk/0.3/cs_authToken.class.php trunk/0.3/cs_webdbupgrade.class.php trunk/0.3/setup/schema.mysql.sql trunk/0.3/setup/schema.pgsql.sql trunk/0.3/tests/testOfAuthToken.php Removed Paths: ------------- trunk/0.3/setup/authtoken_schema.pgsql.sql Modified: trunk/0.3/cs_authToken.class.php =================================================================== --- trunk/0.3/cs_authToken.class.php 2009-08-19 20:12:33 UTC (rev 114) +++ trunk/0.3/cs_authToken.class.php 2009-08-20 01:44:14 UTC (rev 115) @@ -48,29 +48,6 @@ //========================================================================= /** - * Load table into the database... - */ - public function load_table() { - $file = dirname(__FILE__) .'/setup/authtoken_schema.'. $this->db->get_dbtype() .'.sql'; - - if(file_exists($file)) { - try { - $this->db->run_update(file_get_contents($file), true); - } - catch(exception $e) { - throw new exception(__METHOD__ .": error while trying to load table::: ". $e->getMessage()); - } - } - else { - throw new exception(__METHOD__ .": unsupported database type (". $this->db->get_dbtype() .")"); - } - }//end load_table() - //========================================================================= - - - - //========================================================================= - /** * Standardized method of creating a hash from a string. * * @param $tokenId (int) matches auth_token_id column.... @@ -110,6 +87,8 @@ 'checksum' => $checksum, 'token' => '____INCOMPLETE____' ); + + $insertData['expiration'] = strftime('%Y-%m-%d %T', strtotime('1 day')); if(!is_null($lifetime) && strlen($lifetime)) { $insertData['expiration'] = strftime('%Y-%m-%d %T', strtotime($lifetime)); } Modified: trunk/0.3/cs_webdbupgrade.class.php =================================================================== --- trunk/0.3/cs_webdbupgrade.class.php 2009-08-19 20:12:33 UTC (rev 114) +++ trunk/0.3/cs_webdbupgrade.class.php 2009-08-20 01:44:14 UTC (rev 115) @@ -99,13 +99,8 @@ $this->gfObj->debugPrintOpt = constant('DEBUGPRINTOPT'); } - if(!defined(__CLASS__ .'-DB_PRIMARYKEY') || !defined(__CLASS__ .'-DB_TABLE')) { - throw new exception(__METHOD__ .": no setting for DB_TABLE or DB_PRIMARYKEY, cannot continue"); - } - else { - $this->config['DB_TABLE'] = constant(__CLASS__ .'-DB_TABLE'); - $this->config['DB_PRIMARYKEY'] = constant(__CLASS__ .'-DB_PRIMARYKEY'); - } + $this->config['DB_TABLE'] = 'cswal_version_table'; + $this->config['DB_PRIMARYKEY'] = 'version_id'; $this->sequenceName = $this->config['DB_TABLE'] .'_'. $this->config['DB_PRIMARYKEY'] .'_seq'; if(!defined('DBTYPE')) { @@ -908,7 +903,7 @@ //========================================================================= public function load_table() { - $schemaFileLocation = dirname(__FILE__) .'/schema/schema.sql'; + $schemaFileLocation = dirname(__FILE__) .'/setup/schema.'. $this->db->get_dbtype() .'.sql'; $schema = file_get_contents($schemaFileLocation); $schema = str_replace('{tableName}', $this->config['DB_TABLE'], $schema); $schema = str_replace('{primaryKey}', $this->config['DB_PRIMARYKEY'], $schema); Deleted: trunk/0.3/setup/authtoken_schema.pgsql.sql =================================================================== --- trunk/0.3/setup/authtoken_schema.pgsql.sql 2009-08-19 20:12:33 UTC (rev 114) +++ trunk/0.3/setup/authtoken_schema.pgsql.sql 2009-08-20 01:44:14 UTC (rev 115) @@ -1,20 +0,0 @@ --- --- SVN INFORMATION::: --- --------------- --- SVN Signature::::::: $Id$ --- Last Author::::::::: $Author$ --- Current Revision:::: $Revision$ --- Repository Location: $HeadURL$ --- Last Updated:::::::: $Date$ --- - -CREATE TABLE cswal_auth_token_table ( - auth_token_id serial NOT NULL PRIMARY KEY, - uid integer NOT NULL DEFAULT 0, - checksum text NOT NULL, - token text NOT NULL, - max_uses integer DEFAULT NULL, - total_uses integer NOT NULL DEFAULT 0, - creation timestamp NOT NULL DEFAULT NOW(), - expiration timestamp NOT NULL DEFAULT NOW() + '1 day'::interval -); \ No newline at end of file Modified: trunk/0.3/setup/schema.mysql.sql =================================================================== --- trunk/0.3/setup/schema.mysql.sql 2009-08-19 20:12:33 UTC (rev 114) +++ trunk/0.3/setup/schema.mysql.sql 2009-08-20 01:44:14 UTC (rev 115) @@ -98,14 +98,19 @@ -- otherwise separate schema files have to be created and the code will have to -- do extra checking... -- --- The "{tableName}" portion will be replaced with the value of the configured --- "DB_TABLE" setting. -CREATE TABLE cs_version_table ( +CREATE TABLE cswal_version_table ( version_id int NOT NULL PRIMARY KEY, project_name varchar(30) NOT NULL UNIQUE, - version_string varchar(50) NOT NULL, - version_major integer NOT NULL, - version_minor integer NOT NULL, - version_maintenance integer NOT NULL, - version_suffix varchar(20) NOT NULL + version_string varchar(50) NOT NULL ); + +CREATE TABLE cswal_auth_token_table ( + auth_token_id serial NOT NULL PRIMARY KEY, + uid integer NOT NULL DEFAULT 0, + checksum text NOT NULL, + token text NOT NULL, + max_uses integer DEFAULT NULL, + total_uses integer NOT NULL DEFAULT 0, + creation timestamp NOT NULL DEFAULT NOW(), + expiration timestamp NOT NULL +); \ No newline at end of file Modified: trunk/0.3/setup/schema.pgsql.sql =================================================================== --- trunk/0.3/setup/schema.pgsql.sql 2009-08-19 20:12:33 UTC (rev 114) +++ trunk/0.3/setup/schema.pgsql.sql 2009-08-20 01:44:14 UTC (rev 115) @@ -66,13 +66,21 @@ -- This table create statement MUST work in PostgreSQL v8.2.x+ AND MySQL v5.0.x+: -- otherwise separate schema files have to be created and the code will have to -- do extra checking... -CREATE TABLE cs_version_table ( +CREATE TABLE cswal_version_table ( version_id serial NOT NULL PRIMARY KEY, project_name varchar(30) NOT NULL UNIQUE, - version_string varchar(50) NOT NULL, - version_major integer NOT NULL, - version_minor integer NOT NULL, - version_maintenance integer NOT NULL, - version_suffix varchar(20) NOT NULL + version_string varchar(50) NOT NULL ); + +CREATE TABLE cswal_auth_token_table ( + auth_token_id serial NOT NULL PRIMARY KEY, + uid integer NOT NULL DEFAULT 0, + checksum text NOT NULL, + token text NOT NULL, + max_uses integer DEFAULT NULL, + total_uses integer NOT NULL DEFAULT 0, + creation timestamp NOT NULL DEFAULT NOW(), + expiration timestamp NOT NULL +); + Modified: trunk/0.3/tests/testOfAuthToken.php =================================================================== --- trunk/0.3/tests/testOfAuthToken.php 2009-08-19 20:12:33 UTC (rev 114) +++ trunk/0.3/tests/testOfAuthToken.php 2009-08-20 01:44:14 UTC (rev 115) @@ -38,35 +38,6 @@ //-------------------------------------------------------------------------- - function tearDown() { - $db = $this->create_db(); - try { - $db->run_update('DROP TABLE cswal_auth_token_table', true); - } - catch(exception $e) { - } - }//end - //-------------------------------------------------------------------------- - - - - //-------------------------------------------------------------------------- - private function create_db() { - $dbParams = array( - 'host' => constant('DB_PG_HOST'), - 'dbname' => constant('DB_PG_DBNAME'), - 'user' => constant('DB_PG_DBUSER'), - 'password' => constant('DB_PG_DBPASS'), - 'port' => constant('DB_PG_PORT') - ); - $db = new cs_phpDB(constant('DBTYPE')); - $db->connect($dbParams); - return($db); - }//end create_db() - //-------------------------------------------------------------------------- - - - //-------------------------------------------------------------------------- function test_basics() { $db = $this->create_db(); $tok = new authTokenTester($db); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |