cs-webapplibs-commits Mailing List for CS Web Application Libraries (Page 4)
Status: Beta
Brought to you by:
crazedsanity
You can subscribe to this list here.
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(47) |
Sep
(8) |
Oct
(1) |
Nov
(3) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2010 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(3) |
Jun
(14) |
Jul
(5) |
Aug
|
Sep
(5) |
Oct
(2) |
Nov
|
Dec
|
2011 |
Jan
(15) |
Feb
(7) |
Mar
(1) |
Apr
(1) |
May
(1) |
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(2) |
Nov
(3) |
Dec
(1) |
2012 |
Jan
(1) |
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <cra...@us...> - 2009-09-08 14:24:25
|
Revision: 147 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=147&view=rev Author: crazedsanity Date: 2009-09-08 14:24:15 +0000 (Tue, 08 Sep 2009) Log Message: ----------- Fix some rather silly wording in an error. /db_types/cs_phpDB__pgsql.class.php: * set_db_info(): -- change wording about number of required fields to be more useful. Modified Paths: -------------- trunk/0.3/db_types/cs_phpDB__pgsql.class.php Modified: trunk/0.3/db_types/cs_phpDB__pgsql.class.php =================================================================== --- trunk/0.3/db_types/cs_phpDB__pgsql.class.php 2009-08-31 14:52:28 UTC (rev 146) +++ trunk/0.3/db_types/cs_phpDB__pgsql.class.php 2009-09-08 14:24:15 UTC (rev 147) @@ -127,8 +127,8 @@ $this->paramsAreSet = TRUE; } else { - throw new exception(__METHOD__ .": required count (". $requiredCount - .") does not match required number of fields (". count($required) .")"); + throw new exception(__METHOD__ .": given number of fields (". $requiredCount + .") does not match required number of fields (". count($required) .")::: ". $this->gfObj->debug_print($params,0)); } }//end set_db_info() //========================================================================= This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-08-31 14:52:37
|
Revision: 146 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=146&view=rev Author: crazedsanity Date: 2009-08-31 14:52:28 +0000 (Mon, 31 Aug 2009) Log Message: ----------- Fix visibility of $gfObj to match parent class. Modified Paths: -------------- trunk/0.3/cs_tabs.class.php Modified: trunk/0.3/cs_tabs.class.php =================================================================== --- trunk/0.3/cs_tabs.class.php 2009-08-28 20:30:54 UTC (rev 145) +++ trunk/0.3/cs_tabs.class.php 2009-08-31 14:52:28 UTC (rev 146) @@ -10,7 +10,7 @@ private $selectedTab; private $templateVar; - private $gfObj; + protected $gfObj; /** This is the default suffix to use when none is given during the add_tab() call. */ private $defaultSuffix='tab'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-08-28 20:31:01
|
Revision: 145 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=145&view=rev Author: crazedsanity Date: 2009-08-28 20:30:54 +0000 (Fri, 28 Aug 2009) Log Message: ----------- No more include/requires: include before or use __autoload(). NOTE::: this was tested using the current (trunk/1.0) version of cs-content's __autoload.php script. REMOVED require_once() STATEMENTS::: * /cs_authToken.class.php * /cs_bbCodeParser.class.php * /cs_phpDB.class.php * /cs_sessionDB.class.php * /cs_siteConfig.class.php * /cs_tabs.class.php * /cs_webdblogger.class.php * /cs_webdbupgrade.class.php * /abstract/cs_webapplibs.abstract.class.php * /tests/testOfCSPHPDB.php * /tests/testOfCSWebAppLibs.php Modified Paths: -------------- trunk/0.3/abstract/cs_webapplibs.abstract.class.php trunk/0.3/cs_authToken.class.php trunk/0.3/cs_bbCodeParser.class.php trunk/0.3/cs_phpDB.class.php trunk/0.3/cs_sessionDB.class.php trunk/0.3/cs_siteConfig.class.php trunk/0.3/cs_tabs.class.php trunk/0.3/cs_webdblogger.class.php trunk/0.3/cs_webdbupgrade.class.php trunk/0.3/tests/testOfCSPHPDB.php trunk/0.3/tests/testOfCSWebAppLibs.php Modified: trunk/0.3/abstract/cs_webapplibs.abstract.class.php =================================================================== --- trunk/0.3/abstract/cs_webapplibs.abstract.class.php 2009-08-27 16:44:16 UTC (rev 144) +++ trunk/0.3/abstract/cs_webapplibs.abstract.class.php 2009-08-28 20:30:54 UTC (rev 145) @@ -10,7 +10,6 @@ * Last Updated:::::::: $Date$ */ -require_once(dirname(__FILE__) .'/../../cs-content/abstract/cs_version.abstract.class.php'); abstract class cs_webapplibsAbstract extends cs_versionAbstract { protected $gfObj; @@ -24,7 +23,6 @@ if($makeGfObj === true) { //make a cs_globalFunctions{} object. //TODO::: find a way to avoid h - require_once(dirname(__FILE__) ."/../../cs-content/cs_globalFunctions.class.php"); $this->gfObj = new cs_globalFunctions(); } }//end __construct() Modified: trunk/0.3/cs_authToken.class.php =================================================================== --- trunk/0.3/cs_authToken.class.php 2009-08-27 16:44:16 UTC (rev 144) +++ trunk/0.3/cs_authToken.class.php 2009-08-28 20:30:54 UTC (rev 145) @@ -11,7 +11,6 @@ */ -require_once(dirname(__FILE__) .'/abstract/cs_webapplibs.abstract.class.php'); class cs_authToken extends cs_webapplibsAbstract { Modified: trunk/0.3/cs_bbCodeParser.class.php =================================================================== --- trunk/0.3/cs_bbCodeParser.class.php 2009-08-27 16:44:16 UTC (rev 144) +++ trunk/0.3/cs_bbCodeParser.class.php 2009-08-28 20:30:54 UTC (rev 145) @@ -18,7 +18,6 @@ * been converted. */ -require_once(dirname(__FILE__) ."/abstract/cs_webapplibs.abstract.class.php"); class cs_bbCodeParser extends cs_webapplibsAbstract { Modified: trunk/0.3/cs_phpDB.class.php =================================================================== --- trunk/0.3/cs_phpDB.class.php 2009-08-27 16:44:16 UTC (rev 144) +++ trunk/0.3/cs_phpDB.class.php 2009-08-28 20:30:54 UTC (rev 145) @@ -24,9 +24,6 @@ // /////////////////////// -require_once(dirname(__FILE__) ."/abstract/cs_webapplibs.abstract.class.php"); -require_once(dirname(__FILE__) ."/abstract/cs_phpDB.abstract.class.php"); - class cs_phpDB extends cs_webapplibsAbstract { private $dbLayerObj; Modified: trunk/0.3/cs_sessionDB.class.php =================================================================== --- trunk/0.3/cs_sessionDB.class.php 2009-08-27 16:44:16 UTC (rev 144) +++ trunk/0.3/cs_sessionDB.class.php 2009-08-28 20:30:54 UTC (rev 145) @@ -8,10 +8,6 @@ * $LastChangedRevision$ */ -require_once(constant('LIBDIR') .'/cs-content/cs_session.class.php'); -require_once(dirname(__FILE__) .'/cs_phpDB.class.php'); -require_once(constant('LIBDIR') .'/cs-phpxml/cs_arrayToPath.class.php'); -require_once(constant('LIBDIR') .'/cs-webapplibs/cs_webdblogger.class.php'); class cs_sessionDB extends cs_session { Modified: trunk/0.3/cs_siteConfig.class.php =================================================================== --- trunk/0.3/cs_siteConfig.class.php 2009-08-27 16:44:16 UTC (rev 144) +++ trunk/0.3/cs_siteConfig.class.php 2009-08-28 20:30:54 UTC (rev 145) @@ -15,10 +15,6 @@ * */ -require_once(dirname(__FILE__) .'/abstract/cs_webapplibs.abstract.class.php'); -require_once(dirname(__FILE__) .'/../cs-content/cs_fileSystem.class.php'); -require_once(dirname(__FILE__). '/../cs-phpxml/cs_phpxmlParser.class.php'); -require_once(dirname(__FILE__) .'/../cs-phpxml/cs_phpxmlBuilder.class.php'); class cs_siteConfig extends cs_webapplibsAbstract { Modified: trunk/0.3/cs_tabs.class.php =================================================================== --- trunk/0.3/cs_tabs.class.php 2009-08-27 16:44:16 UTC (rev 144) +++ trunk/0.3/cs_tabs.class.php 2009-08-28 20:30:54 UTC (rev 145) @@ -4,9 +4,7 @@ * */ -require_once(dirname(__FILE__) .'/abstract/cs_webapplibs.abstract.class.php'); - class cs_tabs extends cs_webapplibsAbstract { private $tabsArr=array(); private $selectedTab; Modified: trunk/0.3/cs_webdblogger.class.php =================================================================== --- trunk/0.3/cs_webdblogger.class.php 2009-08-27 16:44:16 UTC (rev 144) +++ trunk/0.3/cs_webdblogger.class.php 2009-08-28 20:30:54 UTC (rev 145) @@ -27,8 +27,6 @@ //NOTE::: this class **REQUIRES** cs-content for its "cs_phpDB" class. -require_once(dirname(__FILE__) .'/abstract/cs_webapplibs.abstract.class.php'); -require_once(dirname(__FILE__) .'/cs_webdbupgrade.class.php'); class cs_webdblogger extends cs_webapplibsAbstract { /** Database handle */ Modified: trunk/0.3/cs_webdbupgrade.class.php =================================================================== --- trunk/0.3/cs_webdbupgrade.class.php 2009-08-27 16:44:16 UTC (rev 144) +++ trunk/0.3/cs_webdbupgrade.class.php 2009-08-28 20:30:54 UTC (rev 145) @@ -12,9 +12,6 @@ * */ -require_once(dirname(__FILE__) .'/abstract/cs_webapplibs.abstract.class.php'); -require_once(dirname(__FILE__) .'/cs_webdblogger.class.php'); -require_once(dirname(__FILE__) .'/cs_phpDB.class.php'); class cs_webdbupgrade extends cs_webapplibsAbstract { @@ -87,11 +84,6 @@ throw new exception(__METHOD__ .": required constant 'SITE_ROOT' not set"); } - require_once(constant('LIBDIR') .'/cs-content/cs_globalFunctions.class.php'); - require_once(constant('LIBDIR') .'/cs-content/cs_fileSystem.class.php'); - require_once(constant('LIBDIR') .'/cs-phpxml/cs_phpxmlParser.class.php'); - require_once(constant('LIBDIR') .'/cs-phpxml/cs_phpxmlCreator.class.php'); - require_once(constant('LIBDIR') .'/cs-phpxml/cs_arrayToPath.class.php'); $this->fsObj = new cs_fileSystem(constant('SITE_ROOT')); parent::__construct(true); Modified: trunk/0.3/tests/testOfCSPHPDB.php =================================================================== --- trunk/0.3/tests/testOfCSPHPDB.php 2009-08-27 16:44:16 UTC (rev 144) +++ trunk/0.3/tests/testOfCSPHPDB.php 2009-08-28 20:30:54 UTC (rev 145) @@ -4,8 +4,6 @@ */ -require_once(dirname(__FILE__) .'/../cs_phpDB.class.php'); - class TestOfCSPHPDB extends UnitTestCase { private $dbParams=array(); Modified: trunk/0.3/tests/testOfCSWebAppLibs.php =================================================================== --- trunk/0.3/tests/testOfCSWebAppLibs.php 2009-08-27 16:44:16 UTC (rev 144) +++ trunk/0.3/tests/testOfCSWebAppLibs.php 2009-08-28 20:30:54 UTC (rev 145) @@ -11,7 +11,6 @@ * $LastChangedRevision$ */ -require_once(dirname(__FILE__) .'/../cs_authToken.class.php'); class testOfCSWebAppLibs extends UnitTestCase { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-08-27 16:44:24
|
Revision: 144 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=144&view=rev Author: crazedsanity Date: 2009-08-27 16:44:16 +0000 (Thu, 27 Aug 2009) Log Message: ----------- Fix missing requirement (overwrote in last batch of commits, due to conflicts). Modified Paths: -------------- trunk/0.3/abstract/cs_webapplibs.abstract.class.php Modified: trunk/0.3/abstract/cs_webapplibs.abstract.class.php =================================================================== --- trunk/0.3/abstract/cs_webapplibs.abstract.class.php 2009-08-27 16:43:00 UTC (rev 143) +++ trunk/0.3/abstract/cs_webapplibs.abstract.class.php 2009-08-27 16:44:16 UTC (rev 144) @@ -10,6 +10,7 @@ * Last Updated:::::::: $Date$ */ +require_once(dirname(__FILE__) .'/../../cs-content/abstract/cs_version.abstract.class.php'); abstract class cs_webapplibsAbstract extends cs_versionAbstract { protected $gfObj; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-08-27 16:43:06
|
Revision: 143 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=143&view=rev Author: crazedsanity Date: 2009-08-27 16:43:00 +0000 (Thu, 27 Aug 2009) Log Message: ----------- Update main abstract class to handle cs_globalFunctions & cs_versionParse stuff. /cs_authToken.class.php: * MAIN::: -- set gfObj as protected (not private) * __construct(): -- call parent::__construct() (creates gfObj). /cs_bbCodeParser.class.php: * MAIN::: -- extends cs_webapplibsAbstract instead of cs_contentAbstract. /cs_phpDB.class.php: * MAIN::: -- extends cs_webapplibsAbstract instead of cs_contentAbstract. * __construct(): -- call parent::__construct() (creates gfObj). /cs_siteConfig.class.php: * MAIN::: -- require cs_webapplibsAbstract class file. -- extend cs_webapplibsAbstract instead of cs_contentAbstract /cs_tabs.class.php: * __construct(): -- call parent::__construct(). /cs_webdblogger.class.php: * __construct(): -- call parent::__construct() -- don't create cs_globalFunctions object (parent does that) /cs_webdbupgrade.class.php: * __construct(): -- call parent::__construct() -- don't create cs_globalFunctions object (parent does that) /abstract/cs_webapplibs.abstract.class.php: * MAIN::: -- don't require cs_contentAbstract -- new var, protected $gfObj * __construct() [NEW]: -- do all the stuff required to use cs_versionAbstract -- create gfObj (according to constructor arg #1) Modified Paths: -------------- trunk/0.3/abstract/cs_webapplibs.abstract.class.php trunk/0.3/cs_authToken.class.php trunk/0.3/cs_bbCodeParser.class.php trunk/0.3/cs_phpDB.class.php trunk/0.3/cs_siteConfig.class.php trunk/0.3/cs_tabs.class.php trunk/0.3/cs_webdblogger.class.php trunk/0.3/cs_webdbupgrade.class.php Modified: trunk/0.3/abstract/cs_webapplibs.abstract.class.php =================================================================== --- trunk/0.3/abstract/cs_webapplibs.abstract.class.php 2009-08-26 17:50:33 UTC (rev 142) +++ trunk/0.3/abstract/cs_webapplibs.abstract.class.php 2009-08-27 16:43:00 UTC (rev 143) @@ -10,11 +10,24 @@ * Last Updated:::::::: $Date$ */ -require_once(dirname(__FILE__) .'/../../cs-content/abstract/cs_content.abstract.class.php'); - - -abstract class cs_webapplibsAbstract extends cs_contentAbstract { +abstract class cs_webapplibsAbstract extends cs_versionAbstract { + protected $gfObj; + + //------------------------------------------------------------------------- + function __construct($makeGfObj=true) { + $this->set_version_file_location(dirname(__FILE__) . '/../VERSION'); + $this->get_version(); + $this->get_project(); + + if($makeGfObj === true) { + //make a cs_globalFunctions{} object. + //TODO::: find a way to avoid h + require_once(dirname(__FILE__) ."/../../cs-content/cs_globalFunctions.class.php"); + $this->gfObj = new cs_globalFunctions(); + } + }//end __construct() + //------------------------------------------------------------------------- } ?> Modified: trunk/0.3/cs_authToken.class.php =================================================================== --- trunk/0.3/cs_authToken.class.php 2009-08-26 17:50:33 UTC (rev 142) +++ trunk/0.3/cs_authToken.class.php 2009-08-27 16:43:00 UTC (rev 143) @@ -19,7 +19,7 @@ private $db; /** Object that helps deal with strings. */ - private $gfObj; + protected $gfObj; /** Name of the table */ private $table = 'cswal_auth_token_table'; @@ -39,7 +39,7 @@ else { throw new exception(__METHOD__ .": database object not connected"); } - $this->gfObj = new cs_globalFunctions(); + parent::__construct(true); $upg = new cs_webdbupgrade(dirname(__FILE__) .'/VERSION', dirname(__FILE__) .'/upgrades/upgrade.xml'); $upg->check_versions(true); Modified: trunk/0.3/cs_bbCodeParser.class.php =================================================================== --- trunk/0.3/cs_bbCodeParser.class.php 2009-08-26 17:50:33 UTC (rev 142) +++ trunk/0.3/cs_bbCodeParser.class.php 2009-08-27 16:43:00 UTC (rev 143) @@ -20,7 +20,7 @@ require_once(dirname(__FILE__) ."/abstract/cs_webapplibs.abstract.class.php"); -class cs_bbCodeParser extends cs_webAppLibsAbstract { +class cs_bbCodeParser extends cs_webapplibsAbstract { /** Array containing all the codes & how to parse them. */ private $bbCodeData = NULL; Modified: trunk/0.3/cs_phpDB.class.php =================================================================== --- trunk/0.3/cs_phpDB.class.php 2009-08-26 17:50:33 UTC (rev 142) +++ trunk/0.3/cs_phpDB.class.php 2009-08-27 16:43:00 UTC (rev 143) @@ -27,11 +27,12 @@ require_once(dirname(__FILE__) ."/abstract/cs_webapplibs.abstract.class.php"); require_once(dirname(__FILE__) ."/abstract/cs_phpDB.abstract.class.php"); -class cs_phpDB extends cs_webAppLibsAbstract { +class cs_phpDB extends cs_webapplibsAbstract { private $dbLayerObj; private $dbType; public $connectParams = array(); + protected $gfObj; //========================================================================= public function __construct($type='pgsql') { @@ -43,7 +44,7 @@ $this->dbLayerObj = new $className; $this->dbType = $type; - parent::__construct(); + parent::__construct(true); $this->isInitialized = TRUE; } Modified: trunk/0.3/cs_siteConfig.class.php =================================================================== --- trunk/0.3/cs_siteConfig.class.php 2009-08-26 17:50:33 UTC (rev 142) +++ trunk/0.3/cs_siteConfig.class.php 2009-08-27 16:43:00 UTC (rev 143) @@ -20,7 +20,7 @@ require_once(dirname(__FILE__). '/../cs-phpxml/cs_phpxmlParser.class.php'); require_once(dirname(__FILE__) .'/../cs-phpxml/cs_phpxmlBuilder.class.php'); -class cs_siteConfig extends cs_webAppLibsAbstract { +class cs_siteConfig extends cs_webapplibsAbstract { /** XMLParser{} object, for reading XML config file. */ private $xmlReader; Modified: trunk/0.3/cs_tabs.class.php =================================================================== --- trunk/0.3/cs_tabs.class.php 2009-08-26 17:50:33 UTC (rev 142) +++ trunk/0.3/cs_tabs.class.php 2009-08-27 16:43:00 UTC (rev 143) @@ -38,6 +38,7 @@ //set the internal var. $this->templateVar = $templateVar; } + parent::__construct(); $this->gfObj = new cs_globalFunctions; }//end __construct() Modified: trunk/0.3/cs_webdblogger.class.php =================================================================== --- trunk/0.3/cs_webdblogger.class.php 2009-08-26 17:50:33 UTC (rev 142) +++ trunk/0.3/cs_webdblogger.class.php 2009-08-27 16:43:00 UTC (rev 143) @@ -99,7 +99,7 @@ throw new exception(__METHOD__ .": requires cs_phpDB of higher than v". $mustBeHigherThan,1); } - $this->gfObj = new cs_globalFunctions; + parent::__construct(true); //see if there's an upgrade to perform... if($checkForUpgrades === true) { Modified: trunk/0.3/cs_webdbupgrade.class.php =================================================================== --- trunk/0.3/cs_webdbupgrade.class.php 2009-08-26 17:50:33 UTC (rev 142) +++ trunk/0.3/cs_webdbupgrade.class.php 2009-08-27 16:43:00 UTC (rev 143) @@ -94,7 +94,7 @@ require_once(constant('LIBDIR') .'/cs-phpxml/cs_arrayToPath.class.php'); $this->fsObj = new cs_fileSystem(constant('SITE_ROOT')); - $this->gfObj = new cs_globalFunctions; + parent::__construct(true); if(defined('DEBUGPRINTOPT')) { $this->gfObj->debugPrintOpt = constant('DEBUGPRINTOPT'); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-08-26 17:50:42
|
Revision: 142 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=142&view=rev Author: crazedsanity Date: 2009-08-26 17:50:33 +0000 (Wed, 26 Aug 2009) Log Message: ----------- Updated schema with relationship comments & a required foreign key. Modified Paths: -------------- trunk/0.3/setup/schema.mysql.sql Modified: trunk/0.3/setup/schema.mysql.sql =================================================================== --- trunk/0.3/setup/schema.mysql.sql 2009-08-26 16:12:12 UTC (rev 141) +++ trunk/0.3/setup/schema.mysql.sql 2009-08-26 17:50:33 UTC (rev 142) @@ -2,7 +2,7 @@ -- version 2.10.3 -- http://www.phpmyadmin.net -- --- Generation Time: Aug 24, 2009 at 11:31 AM +-- Generation Time: Aug 26, 2009 at 12:54 PM -- Server version: 5.0.22 -- PHP Version: 5.1.6 @@ -79,8 +79,16 @@ PRIMARY KEY (`event_id`), KEY `cswal_event_table_class_id_fkey` (`class_id`), KEY `cswal_event_table_category_id_fkey` (`category_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +-- +-- RELATIONS FOR TABLE `cswal_event_table`: +-- `class_id` +-- `cswal_class_table` -> `class_id` +-- `category_id` +-- `cswal_category_table` -> `category_id` +-- + -- -------------------------------------------------------- -- @@ -95,8 +103,16 @@ PRIMARY KEY (`log_attribute_id`), KEY `cswal_log_attribute_table_log_id_fkey` (`log_id`), KEY `cswal_log_attribute_table_attribute_id_fkey` (`attribute_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +-- +-- RELATIONS FOR TABLE `cswal_log_attribute_table`: +-- `attribute_id` +-- `cswal_attribute_table` -> `attribute_id` +-- `log_id` +-- `cswal_log_table` -> `log_id` +-- + -- -------------------------------------------------------- -- @@ -112,8 +128,14 @@ `details` text NOT NULL, PRIMARY KEY (`log_id`), KEY `cswal_log_table_event_id_fkey` (`event_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +-- +-- RELATIONS FOR TABLE `cswal_log_table`: +-- `event_id` +-- `cswal_event_table` -> `event_id` +-- + -- -------------------------------------------------------- -- @@ -159,6 +181,7 @@ -- Constraints for table `cswal_log_attribute_table` -- ALTER TABLE `cswal_log_attribute_table` + ADD CONSTRAINT `cswal_log_attribute_table_attribute_id_fkey` FOREIGN KEY (`attribute_id`) REFERENCES `cswal_attribute_table` (`attribute_id`), ADD CONSTRAINT `cswal_log_attribute_table_log_id_fkey` FOREIGN KEY (`log_id`) REFERENCES `cswal_log_table` (`log_id`); -- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-08-26 16:12:21
|
Revision: 141 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=141&view=rev Author: crazedsanity Date: 2009-08-26 16:12:12 +0000 (Wed, 26 Aug 2009) Log Message: ----------- Minor fixes... /cs_siteConfig.class.php: * MAIN::: require cs-webapplibsAbstract. /abstract/cs_webapplibs.abstract.class.php: * MAIN::: -- require cs_contentAbstract{} -- extend cs_contentAbstract{} Modified Paths: -------------- trunk/0.3/abstract/cs_webapplibs.abstract.class.php trunk/0.3/cs_siteConfig.class.php Modified: trunk/0.3/abstract/cs_webapplibs.abstract.class.php =================================================================== --- trunk/0.3/abstract/cs_webapplibs.abstract.class.php 2009-08-26 16:01:41 UTC (rev 140) +++ trunk/0.3/abstract/cs_webapplibs.abstract.class.php 2009-08-26 16:12:12 UTC (rev 141) @@ -10,10 +10,10 @@ * Last Updated:::::::: $Date$ */ -require_once(constant('LIBDIR') .'/cs-content/abstract/cs_version.abstract.class.php'); +require_once(dirname(__FILE__) .'/../../cs-content/abstract/cs_content.abstract.class.php'); -abstract class cs_webapplibsAbstract extends cs_versionAbstract { +abstract class cs_webapplibsAbstract extends cs_contentAbstract { } Modified: trunk/0.3/cs_siteConfig.class.php =================================================================== --- trunk/0.3/cs_siteConfig.class.php 2009-08-26 16:01:41 UTC (rev 140) +++ trunk/0.3/cs_siteConfig.class.php 2009-08-26 16:12:12 UTC (rev 141) @@ -15,7 +15,7 @@ * */ -require_once(dirname(__FILE__) .'/../cs-content/abstract/cs_content.abstract.class.php'); +require_once(dirname(__FILE__) .'/abstract/cs_webapplibs.abstract.class.php'); require_once(dirname(__FILE__) .'/../cs-content/cs_fileSystem.class.php'); require_once(dirname(__FILE__). '/../cs-phpxml/cs_phpxmlParser.class.php'); require_once(dirname(__FILE__) .'/../cs-phpxml/cs_phpxmlBuilder.class.php'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-08-26 16:01:48
|
Revision: 140 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=140&view=rev Author: crazedsanity Date: 2009-08-26 16:01:41 +0000 (Wed, 26 Aug 2009) Log Message: ----------- Fix class "extends" settings. /cs_bbCodeParser.class.php: * MAIN::: -- extend cs_webAppLibsAbstract{}, not cs_contentAbstract{}. /cs_phpDB.class.php: * MAIN::: -- extend cs_webAppLibsAbstract{}, not cs_contentAbstract{}. /cs_siteconfig.class.php: * MAIN::: -- extend cs_webAppLibsAbstract{}, not cs_contentAbstract{}. Modified Paths: -------------- trunk/0.3/cs_bbCodeParser.class.php trunk/0.3/cs_phpDB.class.php trunk/0.3/cs_siteConfig.class.php Modified: trunk/0.3/cs_bbCodeParser.class.php =================================================================== --- trunk/0.3/cs_bbCodeParser.class.php 2009-08-24 16:56:14 UTC (rev 139) +++ trunk/0.3/cs_bbCodeParser.class.php 2009-08-26 16:01:41 UTC (rev 140) @@ -20,7 +20,7 @@ require_once(dirname(__FILE__) ."/abstract/cs_webapplibs.abstract.class.php"); -class cs_bbCodeParser extends cs_contentAbstract { +class cs_bbCodeParser extends cs_webAppLibsAbstract { /** Array containing all the codes & how to parse them. */ private $bbCodeData = NULL; Modified: trunk/0.3/cs_phpDB.class.php =================================================================== --- trunk/0.3/cs_phpDB.class.php 2009-08-24 16:56:14 UTC (rev 139) +++ trunk/0.3/cs_phpDB.class.php 2009-08-26 16:01:41 UTC (rev 140) @@ -27,7 +27,7 @@ require_once(dirname(__FILE__) ."/abstract/cs_webapplibs.abstract.class.php"); require_once(dirname(__FILE__) ."/abstract/cs_phpDB.abstract.class.php"); -class cs_phpDB extends cs_contentAbstract { +class cs_phpDB extends cs_webAppLibsAbstract { private $dbLayerObj; private $dbType; Modified: trunk/0.3/cs_siteConfig.class.php =================================================================== --- trunk/0.3/cs_siteConfig.class.php 2009-08-24 16:56:14 UTC (rev 139) +++ trunk/0.3/cs_siteConfig.class.php 2009-08-26 16:01:41 UTC (rev 140) @@ -20,7 +20,7 @@ require_once(dirname(__FILE__). '/../cs-phpxml/cs_phpxmlParser.class.php'); require_once(dirname(__FILE__) .'/../cs-phpxml/cs_phpxmlBuilder.class.php'); -class cs_siteConfig extends cs_contentAbstract { +class cs_siteConfig extends cs_webAppLibsAbstract { /** XMLParser{} object, for reading XML config file. */ private $xmlReader; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-08-24 16:56:21
|
Revision: 139 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=139&view=rev Author: crazedsanity Date: 2009-08-24 16:56:14 +0000 (Mon, 24 Aug 2009) Log Message: ----------- Fix cs_tabs so it works in its new location. /cs_tabs.class.php: * MAIN::: -- require the standard cs_webapplibsAbstract class. * __construct(): -- don't call parent classes' __construct() (it is an abstract function and will cause a fatal error). Modified Paths: -------------- trunk/0.3/cs_tabs.class.php Modified: trunk/0.3/cs_tabs.class.php =================================================================== --- trunk/0.3/cs_tabs.class.php 2009-08-24 16:25:59 UTC (rev 138) +++ trunk/0.3/cs_tabs.class.php 2009-08-24 16:56:14 UTC (rev 139) @@ -4,10 +4,10 @@ * */ -require_once(dirname(__FILE__) .'/abstract/cs_content.abstract.class.php'); +require_once(dirname(__FILE__) .'/abstract/cs_webapplibs.abstract.class.php'); -class cs_tabs extends cs_contentAbstract { +class cs_tabs extends cs_webapplibsAbstract { private $tabsArr=array(); private $selectedTab; @@ -25,7 +25,6 @@ * @param $templateVar (str,optional) What template var to find the tab blockrows in. */ public function __construct($templateVar="tabs") { - parent::__construct(false); if(is_object($templateVar)) { //trying to pass cs_genericPage{}... tell 'em we don't like that anymore. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-08-24 16:26:05
|
Revision: 138 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=138&view=rev Author: crazedsanity Date: 2009-08-24 16:25:59 +0000 (Mon, 24 Aug 2009) Log Message: ----------- Added cswal_attribute_table definition. Modified Paths: -------------- trunk/0.3/setup/schema.mysql.sql Modified: trunk/0.3/setup/schema.mysql.sql =================================================================== --- trunk/0.3/setup/schema.mysql.sql 2009-08-24 16:05:54 UTC (rev 137) +++ trunk/0.3/setup/schema.mysql.sql 2009-08-24 16:25:59 UTC (rev 138) @@ -1,18 +1,8 @@ --- --- SVN INFORMATION::: --- --------------- --- SVN Signature::::::: $Id$ --- Last Author::::::::: $Author$ --- Current Revision:::: $Revision$ --- Repository Location: $HeadURL$ --- Last Updated:::::::: $Date$ --- - -- phpMyAdmin SQL Dump -- version 2.10.3 -- http://www.phpmyadmin.net -- --- Generation Time: Aug 24, 2009 at 10:55 AM +-- Generation Time: Aug 24, 2009 at 11:31 AM -- Server version: 5.0.22 -- PHP Version: 5.1.6 @@ -22,6 +12,18 @@ -- -------------------------------------------------------- -- +-- Table structure for table `cswal_attribute_table` +-- + +CREATE TABLE `cswal_attribute_table` ( + `attribute_id` int(11) NOT NULL auto_increment, + `attribute_name` text NOT NULL, + PRIMARY KEY (`attribute_id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; + +-- -------------------------------------------------------- + +-- -- Table structure for table `cswal_auth_token_table` -- @@ -37,7 +39,7 @@ `expiration` timestamp NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`auth_token_id`), UNIQUE KEY `auth_token_id` (`auth_token_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- @@ -49,7 +51,7 @@ `category_id` int(11) NOT NULL auto_increment, `category_name` text NOT NULL, PRIMARY KEY (`category_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- @@ -61,7 +63,7 @@ `class_id` int(11) NOT NULL auto_increment, `class_name` text NOT NULL, PRIMARY KEY (`class_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- @@ -77,7 +79,7 @@ PRIMARY KEY (`event_id`), KEY `cswal_event_table_class_id_fkey` (`class_id`), KEY `cswal_event_table_category_id_fkey` (`category_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- @@ -93,7 +95,7 @@ PRIMARY KEY (`log_attribute_id`), KEY `cswal_log_attribute_table_log_id_fkey` (`log_id`), KEY `cswal_log_attribute_table_attribute_id_fkey` (`attribute_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- @@ -110,7 +112,7 @@ `details` text NOT NULL, PRIMARY KEY (`log_id`), KEY `cswal_log_table_event_id_fkey` (`event_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- @@ -126,7 +128,7 @@ `last_updated` datetime NOT NULL, `session_data` longtext NOT NULL, PRIMARY KEY (`session_store_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- @@ -140,7 +142,7 @@ `version_string` varchar(50) NOT NULL, PRIMARY KEY (`version_id`), UNIQUE KEY `project_name` (`project_name`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -- Constraints for dumped tables This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-08-24 16:06:10
|
Revision: 137 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=137&view=rev Author: crazedsanity Date: 2009-08-24 16:05:54 +0000 (Mon, 24 Aug 2009) Log Message: ----------- Set the cswal_version_table's pkey to auto increment. Modified Paths: -------------- trunk/0.3/setup/schema.mysql.sql Modified: trunk/0.3/setup/schema.mysql.sql =================================================================== --- trunk/0.3/setup/schema.mysql.sql 2009-08-24 15:55:55 UTC (rev 136) +++ trunk/0.3/setup/schema.mysql.sql 2009-08-24 16:05:54 UTC (rev 137) @@ -135,7 +135,7 @@ -- CREATE TABLE `cswal_version_table` ( - `version_id` int(11) NOT NULL, + `version_id` int(11) NOT NULL auto_increment, `project_name` varchar(30) NOT NULL, `version_string` varchar(50) NOT NULL, PRIMARY KEY (`version_id`), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-08-24 15:56:01
|
Revision: 136 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=136&view=rev Author: crazedsanity Date: 2009-08-24 15:55:55 +0000 (Mon, 24 Aug 2009) Log Message: ----------- Updated schema via an SQL dump (via PHPMyAdmin) after successfully loading schema. Modified Paths: -------------- trunk/0.3/setup/schema.mysql.sql Modified: trunk/0.3/setup/schema.mysql.sql =================================================================== --- trunk/0.3/setup/schema.mysql.sql 2009-08-24 15:53:15 UTC (rev 135) +++ trunk/0.3/setup/schema.mysql.sql 2009-08-24 15:55:55 UTC (rev 136) @@ -12,7 +12,7 @@ -- version 2.10.3 -- http://www.phpmyadmin.net -- --- Generation Time: Aug 10, 2009 at 11:01 AM +-- Generation Time: Aug 24, 2009 at 10:55 AM -- Server version: 5.0.22 -- PHP Version: 5.1.6 @@ -22,6 +22,26 @@ -- -------------------------------------------------------- -- +-- Table structure for table `cswal_auth_token_table` +-- + +CREATE TABLE `cswal_auth_token_table` ( + `auth_token_id` bigint(20) unsigned NOT NULL auto_increment, + `uid` int(11) NOT NULL default '0', + `checksum` text NOT NULL, + `token` text NOT NULL, + `max_uses` int(11) default NULL, + `total_uses` int(11) NOT NULL default '0', + `creation` timestamp NOT NULL default CURRENT_TIMESTAMP, + `last_updated` timestamp NOT NULL default '0000-00-00 00:00:00', + `expiration` timestamp NOT NULL default '0000-00-00 00:00:00', + PRIMARY KEY (`auth_token_id`), + UNIQUE KEY `auth_token_id` (`auth_token_id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +-- -------------------------------------------------------- + +-- -- Table structure for table `cswal_category_table` -- @@ -29,7 +49,7 @@ `category_id` int(11) NOT NULL auto_increment, `category_name` text NOT NULL, PRIMARY KEY (`category_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- @@ -41,7 +61,7 @@ `class_id` int(11) NOT NULL auto_increment, `class_name` text NOT NULL, PRIMARY KEY (`class_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- @@ -57,11 +77,27 @@ PRIMARY KEY (`event_id`), KEY `cswal_event_table_class_id_fkey` (`class_id`), KEY `cswal_event_table_category_id_fkey` (`category_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- +-- Table structure for table `cswal_log_attribute_table` +-- + +CREATE TABLE `cswal_log_attribute_table` ( + `log_attribute_id` int(11) NOT NULL auto_increment, + `log_id` int(11) NOT NULL, + `attribute_id` int(11) NOT NULL, + `value_text` text NOT NULL, + PRIMARY KEY (`log_attribute_id`), + KEY `cswal_log_attribute_table_log_id_fkey` (`log_id`), + KEY `cswal_log_attribute_table_attribute_id_fkey` (`attribute_id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +-- -------------------------------------------------------- + +-- -- Table structure for table `cswal_log_table` -- @@ -74,89 +110,57 @@ `details` text NOT NULL, PRIMARY KEY (`log_id`), KEY `cswal_log_table_event_id_fkey` (`event_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +-- -------------------------------------------------------- + -- --- Constraints for dumped tables +-- Table structure for table `cswal_session_store_table` -- +CREATE TABLE `cswal_session_store_table` ( + `session_store_id` int(11) NOT NULL auto_increment, + `session_id` varchar(32) NOT NULL, + `user_id` varchar(16) NOT NULL, + `date_created` datetime NOT NULL, + `last_updated` datetime NOT NULL, + `session_data` longtext NOT NULL, + PRIMARY KEY (`session_store_id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +-- -------------------------------------------------------- + -- --- Constraints for table `cswal_event_table` +-- Table structure for table `cswal_version_table` -- -ALTER TABLE `cswal_event_table` - ADD CONSTRAINT `cswal_event_table_class_id_fkey` FOREIGN KEY (`class_id`) REFERENCES `cswal_class_table` (`class_id`), - ADD CONSTRAINT `cswal_event_table_category_id_fkey` FOREIGN KEY (`category_id`) REFERENCES `cswal_category_table` (`category_id`); +CREATE TABLE `cswal_version_table` ( + `version_id` int(11) NOT NULL, + `project_name` varchar(30) NOT NULL, + `version_string` varchar(50) NOT NULL, + PRIMARY KEY (`version_id`), + UNIQUE KEY `project_name` (`project_name`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + -- --- Constraints for table `cswal_log_table` +-- Constraints for dumped tables -- -ALTER TABLE `cswal_log_table` - ADD CONSTRAINT `cswal_log_table_event_id_fkey` FOREIGN KEY (`event_id`) REFERENCES `cswal_event_table` (`event_id`); - - -- --- Table structure for table `cswal_log_attribute_table` +-- Constraints for table `cswal_event_table` -- +ALTER TABLE `cswal_event_table` + ADD CONSTRAINT `cswal_event_table_class_id_fkey` FOREIGN KEY (`class_id`) REFERENCES `cswal_class_table` (`class_id`), + ADD CONSTRAINT `cswal_event_table_category_id_fkey` FOREIGN KEY (`category_id`) REFERENCES `cswal_category_table` (`category_id`); -CREATE TABLE `cswal_log_attribute_table` ( - `log_attribute_id` int(11) NOT NULL auto_increment, - `log_id` int(11) NOT NULL, - `attribute_id` int(11) NOT NULL, - `value_text` text NOT NULL, - PRIMARY KEY (`log_attribute_id`), - KEY `cswal_log_attribute_table_log_id_fkey` (`log_id`), - KEY `cswal_log_attribute_table_attribute_id_fkey` (`attribute_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; - --- -------------------------------------------------------- - - - -- -- Constraints for table `cswal_log_attribute_table` -- ALTER TABLE `cswal_log_attribute_table` ADD CONSTRAINT `cswal_log_attribute_table_log_id_fkey` FOREIGN KEY (`log_id`) REFERENCES `cswal_log_table` (`log_id`); - - - --- 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 cswal_version_table ( - version_id int NOT NULL PRIMARY KEY, - project_name varchar(30) NOT NULL UNIQUE, - version_string varchar(50) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; - -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(), - last_updated timestamp, - expiration timestamp NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; - - - --- --- Store session data in here. --- Idea originally from: http://www.developertutorials.com/tutorials/php/saving-php-session-data-database-050711 --- - -CREATE TABLE `cswal_session_store_table` ( - `session_store_id` int NOT NULL AUTO_INCREMENT, - `session_id` varchar(32) NOT NULL, - `user_id` varchar(16) NOT NULL, - `date_created` datetime NOT NULL, - `last_updated` datetime NOT NULL, - `session_data` LONGTEXT NOT NULL, - PRIMARY KEY (`session_store_id`) -) ENGINE = InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; \ No newline at end of file +-- Constraints for table `cswal_log_table` +-- +ALTER TABLE `cswal_log_table` + ADD CONSTRAINT `cswal_log_table_event_id_fkey` FOREIGN KEY (`event_id`) REFERENCES `cswal_event_table` (`event_id`); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-08-24 15:53:21
|
Revision: 135 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=135&view=rev Author: crazedsanity Date: 2009-08-24 15:53:15 +0000 (Mon, 24 Aug 2009) Log Message: ----------- Updated to have the proper syntax & to avoid duplication of key & table creation. Modified Paths: -------------- trunk/0.3/setup/schema.mysql.sql Modified: trunk/0.3/setup/schema.mysql.sql =================================================================== --- trunk/0.3/setup/schema.mysql.sql 2009-08-24 15:34:54 UTC (rev 134) +++ trunk/0.3/setup/schema.mysql.sql 2009-08-24 15:53:15 UTC (rev 135) @@ -111,28 +111,12 @@ -- -------------------------------------------------------- --- --- Table structure for table `cswal_log_table` --- -CREATE TABLE `cswal_log_table` ( - `log_id` int(11) NOT NULL auto_increment, - `creation` timestamp NOT NULL default CURRENT_TIMESTAMP, - `event_id` int(11) NOT NULL, - `uid` int(11) NOT NULL, - `affected_uid` int(11) NOT NULL, - `details` text NOT NULL, - PRIMARY KEY (`log_id`), - KEY `cswal_log_table_event_id_fkey` (`event_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; - - -- -- Constraints for table `cswal_log_attribute_table` -- ALTER TABLE `cswal_log_attribute_table` - ADD CONSTRAINT `cswal_log_attribute_table_attribute_id_fkey` FOREIGN KEY (`attribute_id`) REFERENCES `cswal_attribute_table` (`attribute_id`), ADD CONSTRAINT `cswal_log_attribute_table_log_id_fkey` FOREIGN KEY (`log_id`) REFERENCES `cswal_log_table` (`log_id`); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-08-24 15:35:04
|
Revision: 134 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=134&view=rev Author: crazedsanity Date: 2009-08-24 15:34:54 +0000 (Mon, 24 Aug 2009) Log Message: ----------- Stop throwing exceptions if a connection parameter isn't required & isn't set internally (just ignore it). Modified Paths: -------------- trunk/0.3/db_types/cs_phpDB__mysql.class.php trunk/0.3/db_types/cs_phpDB__pgsql.class.php trunk/0.3/db_types/cs_phpDB__sqlite.class.php Modified: trunk/0.3/db_types/cs_phpDB__mysql.class.php =================================================================== --- trunk/0.3/db_types/cs_phpDB__mysql.class.php 2009-08-21 16:45:10 UTC (rev 133) +++ trunk/0.3/db_types/cs_phpDB__mysql.class.php 2009-08-24 15:34:54 UTC (rev 134) @@ -103,10 +103,6 @@ $this->$index = $value; $requiredCount++; } - else { - throw new exception(__METHOD__. ": property (". $index .") does " . - "not exist or isn't allowed"); - } } if($requiredCount == count($required)) { Modified: trunk/0.3/db_types/cs_phpDB__pgsql.class.php =================================================================== --- trunk/0.3/db_types/cs_phpDB__pgsql.class.php 2009-08-21 16:45:10 UTC (rev 133) +++ trunk/0.3/db_types/cs_phpDB__pgsql.class.php 2009-08-24 15:34:54 UTC (rev 134) @@ -121,10 +121,6 @@ $this->$index = $params[$index]; $requiredCount++; } - else { - $this->gfObj->debug_print($params,1); - throw new exception(__METHOD__. ": property (". $index .") missing"); - } } if($requiredCount == count($required)) { Modified: trunk/0.3/db_types/cs_phpDB__sqlite.class.php =================================================================== --- trunk/0.3/db_types/cs_phpDB__sqlite.class.php 2009-08-21 16:45:10 UTC (rev 133) +++ trunk/0.3/db_types/cs_phpDB__sqlite.class.php 2009-08-24 15:34:54 UTC (rev 134) @@ -91,10 +91,6 @@ $this->$index = $value; $requiredCount++; } - else { - throw new exception(__METHOD__. ": property (". $index .") does " . - "not exist or isn't allowed"); - } } if($requiredCount == count($required)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-08-21 16:45:17
|
Revision: 133 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=133&view=rev Author: crazedsanity Date: 2009-08-21 16:45:10 +0000 (Fri, 21 Aug 2009) Log Message: ----------- Modified Paths: -------------- trunk/0.3/cs_authToken.class.php trunk/0.3/tests/testOfCSWebAppLibs.php Modified: trunk/0.3/cs_authToken.class.php =================================================================== --- trunk/0.3/cs_authToken.class.php 2009-08-21 16:34:42 UTC (rev 132) +++ trunk/0.3/cs_authToken.class.php 2009-08-21 16:45:10 UTC (rev 133) @@ -298,19 +298,22 @@ public function remove_expired_tokens() { $sql = "SELECT * FROM ". $this->table ." WHERE NOW() > expiration"; + $destroyedTokens = 0; try { $data = $this->db->run_query($sql, 'auth_token_id'); if(is_array($data)) { foreach($data as $tokenId => $tokenData) { //TODO: add logging here? - $this->destroy_token($tokenId); + $destroyedTokens += $this->destroy_token($tokenId); } } } catch(exception $e) { throw new exception(__METHOD__ .": error encountered while expiring tokens::: ". $e->getMessage()); } + + return($destroyedTokens); }//end remove_expired_tokens() //========================================================================= Modified: trunk/0.3/tests/testOfCSWebAppLibs.php =================================================================== --- trunk/0.3/tests/testOfCSWebAppLibs.php 2009-08-21 16:34:42 UTC (rev 132) +++ trunk/0.3/tests/testOfCSWebAppLibs.php 2009-08-21 16:45:10 UTC (rev 133) @@ -178,6 +178,22 @@ $this->assertNotEqual($tokenData['hash'], $tok->doHash($tokenData['id'], $uid, $checksum, $hashThis), "hash is guessable"); } + + //test expiring tokens... + { + //create a token that is immediately expired. + $tokenData = $tok->create_token(22, 'token expiration test', 'Lorem ipsum dolor sit amet, consectetur.', '-5 days'); + $this->do_tokenTest($tokenData, 22, 'token expiration test'); + + $this->assertFalse(is_array($tok->tokenData($tokenData['id'], true))); + $this->assertTrue(is_array($tok->tokenData($tokenData['id'], false))); + $this->assertTrue(count($tok->tokenData($tokenData['id'],false)) == 9); + + //REMEMBER: we've created other tokens that will now expire... + $removedTokens = $tok->remove_expired_tokens(); + $this->assertEqual(2, $removedTokens); + } + }//end test_token_basics() //-------------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-08-21 16:34:48
|
Revision: 132 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=132&view=rev Author: crazedsanity Date: 2009-08-21 16:34:42 +0000 (Fri, 21 Aug 2009) Log Message: ----------- Change basic_token_tests() to do_tokenTest(), as the previous was too close to "test_token_basics()". Modified Paths: -------------- trunk/0.3/tests/testOfCSWebAppLibs.php Modified: trunk/0.3/tests/testOfCSWebAppLibs.php =================================================================== --- trunk/0.3/tests/testOfCSWebAppLibs.php 2009-08-21 16:30:05 UTC (rev 131) +++ trunk/0.3/tests/testOfCSWebAppLibs.php 2009-08-21 16:34:42 UTC (rev 132) @@ -73,7 +73,7 @@ //Generic test to ensure we get the appropriate data back. { $tokenData = $tok->create_token(1, 'test', 'abc123'); - $this->basic_token_tests($tokenData, 1, 'test'); + $this->do_tokenTest($tokenData, 1, 'test'); $this->assertEqual($tok->authenticate_token($tokenData['id'], 'test', $tokenData['hash']), 1); $this->assertFalse($tok->authenticate_token($tokenData['id'], 'testx', $tokenData['hash'])); @@ -91,7 +91,7 @@ { //Generic test to ensure we get the appropriate data back. $tokenData = $tok->create_token(1, 'test', 'abc123', null, 1); - $this->basic_token_tests($tokenData, 1, 'test'); + $this->do_tokenTest($tokenData, 1, 'test'); $this->assertEqual($tok->authenticate_token($tokenData['id'], 'test', $tokenData['hash']), 1); $this->assertTrue(($tok->authenticate_token($tokenData['id'], 'test', $tokenData['hash']) === null), @@ -105,7 +105,7 @@ { //Generic test to ensure we get the appropriate data back. $tokenData = $tok->create_token(1, 'test', 'abc123', '2 years'); - $this->basic_token_tests($tokenData, 1, 'test'); + $this->do_tokenTest($tokenData, 1, 'test'); $this->assertEqual($tok->authenticate_token($tokenData['id'], 'test', $tokenData['hash']), 1); $checkAttempts = 100; @@ -122,7 +122,7 @@ //try to create a token with max_uses of 0. { $tokenData = $tok->create_token(2, 'test', 'xxxxyyyyyxxxx', null, 0); - $this->basic_token_tests($tokenData, 2, 'test'); + $this->do_tokenTest($tokenData, 2, 'test'); $checkData = $tok->tokenData($tokenData['id']); $this->assertTrue(is_array($checkData)); @@ -134,7 +134,7 @@ { $tokenData = $tok->create_token(88, 'test', 'This is a big old TEST', '-3 days'); if($this->assertTrue(is_array($tokenData))) { - $this->basic_token_tests($tokenData, 88, 'test'); + $this->do_tokenTest($tokenData, 88, 'test'); $this->assertFalse($tok->authenticate_token($tokenData['id'], 'test', $tokenData['hash'])); } } @@ -173,7 +173,7 @@ $hashThis = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque ut."; $tokenData = $tok->create_token($uid, $checksum, $hashThis); - $this->basic_token_tests($tokenData, $uid, $checksum); + $this->do_tokenTest($tokenData, $uid, $checksum); $this->assertNotEqual($tokenData['hash'], $tok->doHash($tokenData['id'], $uid, $checksum, $hashThis), "hash is guessable"); @@ -184,7 +184,7 @@ //-------------------------------------------------------------------------- - private function basic_token_tests(array $tokenData, $uid, $checksum) { + private function do_tokenTest(array $tokenData, $uid, $checksum) { if($this->assertTrue(is_array($tokenData)) && $this->assertTrue(is_numeric($uid)) && $this->assertTrue(strlen($checksum))) { @@ -196,7 +196,7 @@ $this->assertTrue((strlen($tokenData['hash']) == 40)); } - }//end basic_token_tests() + }//end do_tokenTest() //-------------------------------------------------------------------------- } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-08-21 16:30:25
|
Revision: 131 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=131&view=rev Author: crazedsanity Date: 2009-08-21 16:30:05 +0000 (Fri, 21 Aug 2009) Log Message: ----------- Table prefix changes, optionally create new connection when reconnecting db. /cs_phpDB.class.php: * ARG CHANGE: NEW ARG: #1 ($forceNewConnection=TRUE) * optionally create a new connection (default is true) /cs_webdblogger.class.php: * fix table prefix from cswdbl to cswal. /cs_webdbupgrade.class.php: * load_table(): -- remove unnecessary str_replace() calls. /tests/testOfCSWebAppLibs.php: * remove_tables(): -- fix table prefixes -- add cswal_session_store_table as one that is dropped, since that is now in the main schema file. Modified Paths: -------------- trunk/0.3/cs_phpDB.class.php trunk/0.3/cs_webdblogger.class.php trunk/0.3/cs_webdbupgrade.class.php trunk/0.3/tests/testOfCSWebAppLibs.php Modified: trunk/0.3/cs_phpDB.class.php =================================================================== --- trunk/0.3/cs_phpDB.class.php 2009-08-21 16:16:22 UTC (rev 130) +++ trunk/0.3/cs_phpDB.class.php 2009-08-21 16:30:05 UTC (rev 131) @@ -182,9 +182,9 @@ //========================================================================= - public function reconnect() { + public function reconnect($forceNewConnection=TRUE) { if(is_array($this->connectParams) && count($this->connectParams)) { - $this->dbLayerObj->connect($this->connectParams, true); + $this->dbLayerObj->connect($this->connectParams, $forceNewConnection); } else { throw new exception(__METHOD__ .": no connection parameters stored"); Modified: trunk/0.3/cs_webdblogger.class.php =================================================================== --- trunk/0.3/cs_webdblogger.class.php 2009-08-21 16:16:22 UTC (rev 130) +++ trunk/0.3/cs_webdblogger.class.php 2009-08-21 16:30:05 UTC (rev 131) @@ -22,7 +22,7 @@ * * QUERY TO GET LAST COUPLE OF LOGS:::: SELECT l.log_id as id, l.creation, l.event_id as lid, le.description AS event, l.details - FROM cswdbl_log_table AS l INNER JOIN cswdbl_event_table AS le USING (event_id) ORDER BY log_id DESC LIMIT 25; + FROM cswal_log_table AS l INNER JOIN cswal_event_table AS le USING (event_id) ORDER BY log_id DESC LIMIT 25; */ //NOTE::: this class **REQUIRES** cs-content for its "cs_phpDB" class. @@ -64,22 +64,22 @@ /** List of tables keyed off an internal reference name. */ protected $tables = array( - 'category' => 'cswdbl_category_table', - 'class' => 'cswdbl_class_table', - 'event' => 'cswdbl_event_table', - 'log' => 'cswdbl_log_table', - 'attrib' => 'cswdbl_attribute_table', - 'logAttrib' => 'cswdbl_log_attribute_table' + 'category' => 'cswal_category_table', + 'class' => 'cswal_class_table', + 'event' => 'cswal_event_table', + 'log' => 'cswal_log_table', + 'attrib' => 'cswal_attribute_table', + 'logAttrib' => 'cswal_log_attribute_table' ); /** List of sequences keyed off an internal reference name (MUST match references above) */ protected $seqs = array( - 'category' => "cswdbl_category_table_category_id_seq", - 'class' => "cswdbl_class_table_class_id_seq", - 'event' => "cswdbl_event_table_event_id_seq", - 'log' => "cswdbl_log_table_log_id_seq", - 'attrib' => "cswdbl_attribute_table_attribute_id_seq", - 'logAttrib' => "cswdbl_log_attribute_table_log_attribute_id_seq" + 'category' => "cswal_category_table_category_id_seq", + 'class' => "cswal_class_table_class_id_seq", + 'event' => "cswal_event_table_event_id_seq", + 'log' => "cswal_log_table_log_id_seq", + 'attrib' => "cswal_attribute_table_attribute_id_seq", + 'logAttrib' => "cswal_log_attribute_table_log_attribute_id_seq" ); //========================================================================= Modified: trunk/0.3/cs_webdbupgrade.class.php =================================================================== --- trunk/0.3/cs_webdbupgrade.class.php 2009-08-21 16:16:22 UTC (rev 130) +++ trunk/0.3/cs_webdbupgrade.class.php 2009-08-21 16:30:05 UTC (rev 131) @@ -905,8 +905,6 @@ public function load_table() { $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); $this->db->exec($schema); $loadTableResult = $this->db->errorMsg(); Modified: trunk/0.3/tests/testOfCSWebAppLibs.php =================================================================== --- trunk/0.3/tests/testOfCSWebAppLibs.php 2009-08-21 16:16:22 UTC (rev 130) +++ trunk/0.3/tests/testOfCSWebAppLibs.php 2009-08-21 16:30:05 UTC (rev 131) @@ -44,9 +44,9 @@ //-------------------------------------------------------------------------- private function remove_tables() { $tableList = array( - 'cswal_auth_token_table', 'cswal_version_table', 'cswdbl_attribute_table', - 'cswdbl_category_table', 'cswdbl_class_table', 'cswdbl_event_table', - 'cswdbl_log_attribute_table', 'cswdbl_log_table', + 'cswal_auth_token_table', 'cswal_version_table', 'cswal_attribute_table', + 'cswal_category_table', 'cswal_class_table', 'cswal_event_table', + 'cswal_log_attribute_table', 'cswal_log_table', 'cswal_session_store_table' ); $db = $this->create_dbconn(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-08-21 16:16:31
|
Revision: 130 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=130&view=rev Author: crazedsanity Date: 2009-08-21 16:16:22 +0000 (Fri, 21 Aug 2009) Log Message: ----------- Fix/consolidate schema, logging. /setup/db_session_schema.*.sql: * consolidated with main schema files. /schema.mysql.sql: * changed all tables to run on InnoDB. * add cswal_session_store_table (for cs_sessionDB) /schema.pgsql.sql: * add cswal_session_store_table (for cs_sessionDB) /cs_sessionDB.class.php: * __construct(): -- fix table name & sequence to use "cswal" prefix. -- create instance of cs_webdblogger (which will automatically cause any upgrades to cs-webapplibs to run). -- remove note about session_id() -- remove the "audit_logging" setting. * do_log(): -- clone internal db handle & call reconnect() to establish a new connection to the database. Modified Paths: -------------- trunk/0.3/cs_sessionDB.class.php trunk/0.3/setup/schema.mysql.sql trunk/0.3/setup/schema.pgsql.sql Removed Paths: ------------- trunk/0.3/setup/db_session_schema.mysql.sql trunk/0.3/setup/db_session_schema.pgsql.sql Modified: trunk/0.3/cs_sessionDB.class.php =================================================================== --- trunk/0.3/cs_sessionDB.class.php 2009-08-21 14:47:11 UTC (rev 129) +++ trunk/0.3/cs_sessionDB.class.php 2009-08-21 16:16:22 UTC (rev 130) @@ -47,13 +47,12 @@ $this->db = new cs_phpDB(constant('DBTYPE')); $this->db->connect($dbParams); - $this->tableName = 'cs_session_store_table'; + $this->tableName = 'cswal_session_store_table'; $this->tablePKey = 'session_store_id'; - $this->sequenceName = 'cs_session_store_table_session_store_id_seq'; + $this->sequenceName = 'cswal_session_store_table_session_store_id_seq'; - if(!$this->sessdb_table_exists()) { - $this->load_table(); - } + //create a logger (this will automatically cause any upgrades to happen). + $this->logger = new cs_webdblogger($this->db, 'Session DB', true); //now tell PHP to use this class's methods for saving the session. session_set_save_handler( @@ -65,17 +64,9 @@ array(&$this, 'sessdb_gc') ); - //NOTE::: calling session_id() here, prior to parent's construct, can set a specific session_id; if - // something like cs_authToken (part of cs-webapplibs project) were used, just call - // cs_authToken::create_token() here... parent::__construct(true); - //Stop things from going into an audit log... see - //http://www.developertutorials.com/tutorials/php/saving-php-session-data-database-050711/page3.html - // NOTE::: not sure if this is valid or not... - $this->audit_logging = false; - }//end __construct() //------------------------------------------------------------------------- @@ -338,8 +329,8 @@ //check if the logger object has been created. if(!is_object($this->logger)) { - $newDB = new cs_phpDB(constant('DBTYPE')); - $newDB->connect($this->db->connectParams, true); + $newDB = clone $this->db; + $newDB->reconnect(true); $this->logger = new cs_webdblogger($newDB, $this->logCategory); } Deleted: trunk/0.3/setup/db_session_schema.mysql.sql =================================================================== --- trunk/0.3/setup/db_session_schema.mysql.sql 2009-08-21 14:47:11 UTC (rev 129) +++ trunk/0.3/setup/db_session_schema.mysql.sql 2009-08-21 16:16:22 UTC (rev 130) @@ -1,17 +0,0 @@ - - --- --- Store session data in here. --- Idea originally from: http://www.developertutorials.com/tutorials/php/saving-php-session-data-database-050711 --- - -CREATE TABLE `cswal_session_store_table` ( - `session_store_id` int NOT NULL AUTO_INCREMENT, - `session_id` varchar(32) NOT NULL, - `user_id` varchar(16) NOT NULL, - `date_created` datetime NOT NULL, - `last_updated` datetime NOT NULL, - `session_data` LONGTEXT NOT NULL, - PRIMARY KEY (`session_store_id`) -) -ENGINE = InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; \ No newline at end of file Deleted: trunk/0.3/setup/db_session_schema.pgsql.sql =================================================================== --- trunk/0.3/setup/db_session_schema.pgsql.sql 2009-08-21 14:47:11 UTC (rev 129) +++ trunk/0.3/setup/db_session_schema.pgsql.sql 2009-08-21 16:16:22 UTC (rev 130) @@ -1,16 +0,0 @@ - - --- --- Store session data in here. --- Idea originally from: http://www.developertutorials.com/tutorials/php/saving-php-session-data-database-050711 --- - -CREATE TABLE cswal_session_store_table ( - session_store_id serial NOT NULL PRIMARY KEY, - session_id varchar(32) NOT NULL DEFAULT '' UNIQUE, - user_id varchar(16), - date_created timestamp NOT NULL DEFAULT NOW(), - last_updated timestamp NOT NULL DEFAULT NOW(), - session_data text -); - Modified: trunk/0.3/setup/schema.mysql.sql =================================================================== --- trunk/0.3/setup/schema.mysql.sql 2009-08-21 14:47:11 UTC (rev 129) +++ trunk/0.3/setup/schema.mysql.sql 2009-08-21 16:16:22 UTC (rev 130) @@ -146,7 +146,7 @@ version_id int NOT NULL PRIMARY KEY, project_name varchar(30) NOT NULL UNIQUE, version_string varchar(50) NOT NULL -); +) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; CREATE TABLE cswal_auth_token_table ( auth_token_id serial NOT NULL PRIMARY KEY, @@ -158,4 +158,21 @@ creation timestamp NOT NULL DEFAULT NOW(), last_updated timestamp, expiration timestamp NOT NULL -); \ No newline at end of file +) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; + + + +-- +-- Store session data in here. +-- Idea originally from: http://www.developertutorials.com/tutorials/php/saving-php-session-data-database-050711 +-- + +CREATE TABLE `cswal_session_store_table` ( + `session_store_id` int NOT NULL AUTO_INCREMENT, + `session_id` varchar(32) NOT NULL, + `user_id` varchar(16) NOT NULL, + `date_created` datetime NOT NULL, + `last_updated` datetime NOT NULL, + `session_data` LONGTEXT NOT NULL, + PRIMARY KEY (`session_store_id`) +) ENGINE = InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; \ No newline at end of file Modified: trunk/0.3/setup/schema.pgsql.sql =================================================================== --- trunk/0.3/setup/schema.pgsql.sql 2009-08-21 14:47:11 UTC (rev 129) +++ trunk/0.3/setup/schema.pgsql.sql 2009-08-21 16:16:22 UTC (rev 130) @@ -104,3 +104,19 @@ expiration timestamp NOT NULL ); + +-- +-- Store session data in here. +-- Idea originally from: http://www.developertutorials.com/tutorials/php/saving-php-session-data-database-050711 +-- + +CREATE TABLE cswal_session_store_table ( + session_store_id serial NOT NULL PRIMARY KEY, + session_id varchar(32) NOT NULL DEFAULT '' UNIQUE, + user_id varchar(16), + date_created timestamp NOT NULL DEFAULT NOW(), + last_updated timestamp NOT NULL DEFAULT NOW(), + session_data text +); + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-08-21 14:47:18
|
Revision: 129 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=129&view=rev Author: crazedsanity Date: 2009-08-21 14:47:11 +0000 (Fri, 21 Aug 2009) Log Message: ----------- Update schema so all table prefixes are "cswal"... /setup/db_session_schema.mysql.sql: * remove all backticks. * change name from (invalid) "test.sess_tmp" to "cswal_session_store_table" /setup/db_session_schema.pgsql.sql: * update table prefix from "cs" to "cswal". /setup/schema.mysql.sql: * changed table prefixes from "cswdbl" to "cswal" /setup/schema.pgsql.sql: * changed table prefixes from "cswdbl" to "cswal" Modified Paths: -------------- trunk/0.3/setup/db_session_schema.mysql.sql trunk/0.3/setup/db_session_schema.pgsql.sql trunk/0.3/setup/schema.mysql.sql trunk/0.3/setup/schema.pgsql.sql Modified: trunk/0.3/setup/db_session_schema.mysql.sql =================================================================== --- trunk/0.3/setup/db_session_schema.mysql.sql 2009-08-20 21:09:10 UTC (rev 128) +++ trunk/0.3/setup/db_session_schema.mysql.sql 2009-08-21 14:47:11 UTC (rev 129) @@ -5,7 +5,7 @@ -- Idea originally from: http://www.developertutorials.com/tutorials/php/saving-php-session-data-database-050711 -- -CREATE TABLE `test`.`sess_tmp` ( +CREATE TABLE `cswal_session_store_table` ( `session_store_id` int NOT NULL AUTO_INCREMENT, `session_id` varchar(32) NOT NULL, `user_id` varchar(16) NOT NULL, Modified: trunk/0.3/setup/db_session_schema.pgsql.sql =================================================================== --- trunk/0.3/setup/db_session_schema.pgsql.sql 2009-08-20 21:09:10 UTC (rev 128) +++ trunk/0.3/setup/db_session_schema.pgsql.sql 2009-08-21 14:47:11 UTC (rev 129) @@ -5,7 +5,7 @@ -- Idea originally from: http://www.developertutorials.com/tutorials/php/saving-php-session-data-database-050711 -- -CREATE TABLE cs_session_store_table ( +CREATE TABLE cswal_session_store_table ( session_store_id serial NOT NULL PRIMARY KEY, session_id varchar(32) NOT NULL DEFAULT '' UNIQUE, user_id varchar(16), Modified: trunk/0.3/setup/schema.mysql.sql =================================================================== --- trunk/0.3/setup/schema.mysql.sql 2009-08-20 21:09:10 UTC (rev 128) +++ trunk/0.3/setup/schema.mysql.sql 2009-08-21 14:47:11 UTC (rev 129) @@ -22,10 +22,10 @@ -- -------------------------------------------------------- -- --- Table structure for table `cswdbl_category_table` +-- Table structure for table `cswal_category_table` -- -CREATE TABLE `cswdbl_category_table` ( +CREATE TABLE `cswal_category_table` ( `category_id` int(11) NOT NULL auto_increment, `category_name` text NOT NULL, PRIMARY KEY (`category_id`) @@ -34,10 +34,10 @@ -- -------------------------------------------------------- -- --- Table structure for table `cswdbl_class_table` +-- Table structure for table `cswal_class_table` -- -CREATE TABLE `cswdbl_class_table` ( +CREATE TABLE `cswal_class_table` ( `class_id` int(11) NOT NULL auto_increment, `class_name` text NOT NULL, PRIMARY KEY (`class_id`) @@ -46,26 +46,26 @@ -- -------------------------------------------------------- -- --- Table structure for table `cswdbl_event_table` +-- Table structure for table `cswal_event_table` -- -CREATE TABLE `cswdbl_event_table` ( +CREATE TABLE `cswal_event_table` ( `event_id` int(11) NOT NULL auto_increment, `class_id` int(11) NOT NULL, `category_id` int(11) NOT NULL, `description` text NOT NULL, PRIMARY KEY (`event_id`), - KEY `cswdbl_event_table_class_id_fkey` (`class_id`), - KEY `cswdbl_event_table_category_id_fkey` (`category_id`) + KEY `cswal_event_table_class_id_fkey` (`class_id`), + KEY `cswal_event_table_category_id_fkey` (`category_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- --- Table structure for table `cswdbl_log_table` +-- Table structure for table `cswal_log_table` -- -CREATE TABLE `cswdbl_log_table` ( +CREATE TABLE `cswal_log_table` ( `log_id` int(11) NOT NULL auto_increment, `creation` timestamp NOT NULL default CURRENT_TIMESTAMP, `event_id` int(11) NOT NULL, @@ -73,7 +73,7 @@ `affected_uid` int(11) NOT NULL, `details` text NOT NULL, PRIMARY KEY (`log_id`), - KEY `cswdbl_log_table_event_id_fkey` (`event_id`) + KEY `cswal_log_table_event_id_fkey` (`event_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- @@ -81,41 +81,41 @@ -- -- --- Constraints for table `cswdbl_event_table` +-- Constraints for table `cswal_event_table` -- -ALTER TABLE `cswdbl_event_table` - ADD CONSTRAINT `cswdbl_event_table_class_id_fkey` FOREIGN KEY (`class_id`) REFERENCES `cswdbl_class_table` (`class_id`), - ADD CONSTRAINT `cswdbl_event_table_category_id_fkey` FOREIGN KEY (`category_id`) REFERENCES `cswdbl_category_table` (`category_id`); +ALTER TABLE `cswal_event_table` + ADD CONSTRAINT `cswal_event_table_class_id_fkey` FOREIGN KEY (`class_id`) REFERENCES `cswal_class_table` (`class_id`), + ADD CONSTRAINT `cswal_event_table_category_id_fkey` FOREIGN KEY (`category_id`) REFERENCES `cswal_category_table` (`category_id`); -- --- Constraints for table `cswdbl_log_table` +-- Constraints for table `cswal_log_table` -- -ALTER TABLE `cswdbl_log_table` - ADD CONSTRAINT `cswdbl_log_table_event_id_fkey` FOREIGN KEY (`event_id`) REFERENCES `cswdbl_event_table` (`event_id`); +ALTER TABLE `cswal_log_table` + ADD CONSTRAINT `cswal_log_table_event_id_fkey` FOREIGN KEY (`event_id`) REFERENCES `cswal_event_table` (`event_id`); -- --- Table structure for table `cswdbl_log_attribute_table` +-- Table structure for table `cswal_log_attribute_table` -- -CREATE TABLE `cswdbl_log_attribute_table` ( +CREATE TABLE `cswal_log_attribute_table` ( `log_attribute_id` int(11) NOT NULL auto_increment, `log_id` int(11) NOT NULL, `attribute_id` int(11) NOT NULL, `value_text` text NOT NULL, PRIMARY KEY (`log_attribute_id`), - KEY `cswdbl_log_attribute_table_log_id_fkey` (`log_id`), - KEY `cswdbl_log_attribute_table_attribute_id_fkey` (`attribute_id`) + KEY `cswal_log_attribute_table_log_id_fkey` (`log_id`), + KEY `cswal_log_attribute_table_attribute_id_fkey` (`attribute_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- --- Table structure for table `cswdbl_log_table` +-- Table structure for table `cswal_log_table` -- -CREATE TABLE `cswdbl_log_table` ( +CREATE TABLE `cswal_log_table` ( `log_id` int(11) NOT NULL auto_increment, `creation` timestamp NOT NULL default CURRENT_TIMESTAMP, `event_id` int(11) NOT NULL, @@ -123,17 +123,17 @@ `affected_uid` int(11) NOT NULL, `details` text NOT NULL, PRIMARY KEY (`log_id`), - KEY `cswdbl_log_table_event_id_fkey` (`event_id`) + KEY `cswal_log_table_event_id_fkey` (`event_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- --- Constraints for table `cswdbl_log_attribute_table` +-- Constraints for table `cswal_log_attribute_table` -- -ALTER TABLE `cswdbl_log_attribute_table` - ADD CONSTRAINT `cswdbl_log_attribute_table_attribute_id_fkey` FOREIGN KEY (`attribute_id`) REFERENCES `cswdbl_attribute_table` (`attribute_id`), - ADD CONSTRAINT `cswdbl_log_attribute_table_log_id_fkey` FOREIGN KEY (`log_id`) REFERENCES `cswdbl_log_table` (`log_id`); +ALTER TABLE `cswal_log_attribute_table` + ADD CONSTRAINT `cswal_log_attribute_table_attribute_id_fkey` FOREIGN KEY (`attribute_id`) REFERENCES `cswal_attribute_table` (`attribute_id`), + ADD CONSTRAINT `cswal_log_attribute_table_log_id_fkey` FOREIGN KEY (`log_id`) REFERENCES `cswal_log_table` (`log_id`); Modified: trunk/0.3/setup/schema.pgsql.sql =================================================================== --- trunk/0.3/setup/schema.pgsql.sql 2009-08-20 21:09:10 UTC (rev 128) +++ trunk/0.3/setup/schema.pgsql.sql 2009-08-21 14:47:11 UTC (rev 129) @@ -14,7 +14,7 @@ -- a project management system with projects and issues, then there would -- be a category for "project" and for "issue". -- -CREATE TABLE cswdbl_category_table ( +CREATE TABLE cswal_category_table ( category_id serial NOT NULL PRIMARY KEY, category_name text NOT NULL ); @@ -25,7 +25,7 @@ -- that was created, "project" would be the category (see above) and the -- class would then be "create". -- -CREATE TABLE cswdbl_class_table ( +CREATE TABLE cswal_class_table ( class_id serial NOT NULL PRIMARY KEY, class_name text NOT NULL ); @@ -38,10 +38,10 @@ -- and make the description for that event more useful, especially if the -- logs are going to be displayed in any sort of useful manner. -- -CREATE TABLE cswdbl_event_table ( +CREATE TABLE cswal_event_table ( event_id serial NOT NULL PRIMARY KEY, - class_id integer NOT NULL REFERENCES cswdbl_class_table(class_id), - category_id integer NOT NULL REFERENCES cswdbl_category_table(category_id), + class_id integer NOT NULL REFERENCES cswal_class_table(class_id), + category_id integer NOT NULL REFERENCES cswal_category_table(category_id), description text NOT NULL ); @@ -54,10 +54,10 @@ -- (zero) for logging non-authenticated things, and a 1 (one) for activities -- performed by the system itself. -- -CREATE TABLE cswdbl_log_table ( +CREATE TABLE cswal_log_table ( log_id serial NOT NULL PRIMARY KEY, creation timestamp NOT NULL DEFAULT NOW(), - event_id integer NOT NULL REFERENCES cswdbl_event_table(event_id), + event_id integer NOT NULL REFERENCES cswal_event_table(event_id), uid integer NOT NULL, affected_uid integer NOT NULL, details text NOT NULL @@ -67,7 +67,7 @@ -- -- List of distinct attribute names. -- -CREATE TABLE cswdbl_attribute_table ( +CREATE TABLE cswal_attribute_table ( attribute_id serial NOT NULL PRIMARY KEY, attribute_name text NOT NULL UNIQUE ); @@ -75,10 +75,10 @@ -- -- Linkage for attributes to logs. -- -CREATE TABLE cswdbl_log_attribute_table ( +CREATE TABLE cswal_log_attribute_table ( log_attribute_id serial NOT NULL PRIMARY KEY, - log_id int NOT NULL REFERENCES cswdbl_log_table(log_id), - attribute_id int NOT NULL REFERENCES cswdbl_attribute_table(attribute_id), + log_id int NOT NULL REFERENCES cswal_log_table(log_id), + attribute_id int NOT NULL REFERENCES cswal_attribute_table(attribute_id), value_text text ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-08-20 21:09:18
|
Revision: 128 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=128&view=rev Author: crazedsanity Date: 2009-08-20 21:09:10 +0000 (Thu, 20 Aug 2009) Log Message: ----------- Make sure all tables are using InnoDB as the engine (for transaction support). Modified Paths: -------------- trunk/0.3/setup/db_session_schema.mysql.sql Modified: trunk/0.3/setup/db_session_schema.mysql.sql =================================================================== --- trunk/0.3/setup/db_session_schema.mysql.sql 2009-08-20 20:39:35 UTC (rev 127) +++ trunk/0.3/setup/db_session_schema.mysql.sql 2009-08-20 21:09:10 UTC (rev 128) @@ -14,4 +14,4 @@ `session_data` LONGTEXT NOT NULL, PRIMARY KEY (`session_store_id`) ) -ENGINE = MyISAM; \ No newline at end of file +ENGINE = InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-08-20 20:39:44
|
Revision: 127 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=127&view=rev Author: crazedsanity Date: 2009-08-20 20:39:35 +0000 (Thu, 20 Aug 2009) Log Message: ----------- All webapp-related items moved here from cs-content... NOTE::: nearly all files now have the "svn:keywords" property set. NOTE2:: this is done to facilitate much faster changes to cs-content. While it may slow development of cs-webapplibs, there is also a lot of work being done to build unit tests there: this should hopefully avoid unexpected breakage in code during upgrades. This also makes upgrading of the database-reliant stuff (like cs_phpDB) to be more easily upgraded. CODE MOVED FROM cs-content::: * /cs_bbCodeParser.class.php * /cs_phpDB.class.php (including db_types & abstract) * /cs_sessionDB.class.php (including schema files) * /cs_siteConfig.class.php * /cs_tabs.class.php * /abstract/cs_phpDB.abstract.class.php * /tests/testOfCSPHPDB.php CHANGED REQUIRE_ONCE PATHS::: * /contentSystem.class.php (cs_sessionDB) MISC::: * /contentSystem.class.php: -- MAIN::: don't require cs_tabs -- initialize_locals(): drop cs_tabs stuff (unneeded) Modified Paths: -------------- trunk/0.3/cs_webdbupgrade.class.php Added Paths: ----------- trunk/0.3/abstract/cs_phpDB.abstract.class.php trunk/0.3/cs_bbCodeParser.class.php trunk/0.3/cs_phpDB.class.php trunk/0.3/cs_sessionDB.class.php trunk/0.3/cs_siteConfig.class.php trunk/0.3/cs_tabs.class.php trunk/0.3/db_types/ trunk/0.3/db_types/cs_phpDB__mysql.class.php trunk/0.3/db_types/cs_phpDB__pgsql.class.php trunk/0.3/db_types/cs_phpDB__sqlite.class.php trunk/0.3/setup/db_session_schema.mysql.sql trunk/0.3/setup/db_session_schema.pgsql.sql trunk/0.3/tests/testOfCSPHPDB.php Property Changed: ---------------- trunk/0.3/docs/CREDITS trunk/0.3/docs/LICENSE trunk/0.3/docs/README.txt trunk/0.3/docs/SETUP.txt trunk/0.3/tests/example_test.php trunk/0.3/tests/testOfCSWebAppLibs.php Added: trunk/0.3/abstract/cs_phpDB.abstract.class.php =================================================================== --- trunk/0.3/abstract/cs_phpDB.abstract.class.php (rev 0) +++ trunk/0.3/abstract/cs_phpDB.abstract.class.php 2009-08-20 20:39:35 UTC (rev 127) @@ -0,0 +1,166 @@ +<?php +/* + * Created on Jan 29, 2009 + * + * FILE INFORMATION: + * + * $HeadURL$ + * $Id$ + * $LastChangedDate$ + * $LastChangedBy$ + * $LastChangedRevision$ + */ + +abstract class cs_phpDBAbstract { + + /** Internal result set pointer. */ + protected $result = NULL; + + /** Internal error code. */ + protected $errorCode = 0; + + /** Status of the current transaction. */ + protected $transStatus = NULL; + + /** Whether there is a transaction in progress or not. */ + protected $inTrans = FALSE; + + /** Holds the last query performed. */ + protected $lastQuery = NULL; + + /** List of queries that have been run */ + protected $queryList=array(); + + /** How many seconds to wait for a query before cancelling it. */ + protected $timeOutSeconds = NULL; + + /** Internal check to determine if a connection has been established. */ + protected $isConnected=FALSE; + + /** Internal check to determine if the parameters have been set. */ + protected $paramsAreSet=FALSE; + + /** Resource handle. */ + protected $connectionID = -1; + + /** Hostname or IP to connect to */ + protected $host; + + /** Port to connect to (default for Postgres is 5432) */ + protected $port; + + /** Name of the database */ + protected $dbname; + + /** Username to connect to the database */ + protected $user; + + /** password to connect to the database */ + protected $password; + + /** Row counter for looping through records */ + protected $row = -1; + + /** cs_globalFunctions object, for string stuff. */ + protected $gfObj; + + /** Internal check to ensure the object has been properly created. */ + protected $isInitialized=FALSE; + + /** List of prepared statements, indexed off the name, with the sub-array being fieldname=>dataType. */ + protected $preparedStatements = array(); + + /** Set to TRUE to save all queries into an array. */ + protected $useQueryList=FALSE; + + /** array that essentially remembers how many times beginTrans() was called. */ + protected $transactionTree = NULL; + + + + //Define some abstract methods so they MUST be provided in order for things to work. + abstract public function set_db_info(array $params); + abstract public function close(); + abstract public function connect(array $dbParams=NULL, $forceNewConnection=FALSE); + abstract public function exec($query); + abstract public function errorMsg($setMessage=null, $logError=null); + abstract public function fobject(); + abstract public function farray(); + abstract public function farray_fieldnames($index=null, $numbered=null,$unsetIndex=1); + abstract public function farray_nvp($name, $value); + abstract public function farray_numbered(); + abstract public function numAffected(); + abstract public function numRows(); + abstract public function is_connected(); + + + //========================================================================= + public function __construct() { + $this->gfObj = new cs_globalFunctions; + $this->isInitialized = true; + }//end __construct() + //========================================================================= + + + + //========================================================================= + /** + * Make sure the object is sane. + */ + final protected function sanity_check() { + if($this->isInitialized !== TRUE) { + throw new exception(__METHOD__ .": not properly initialized"); + } + }//end sanity_check() + //========================================================================= + + + + //========================================================================= + /** + * Disconnect from the database (calls internal "close()" method). + */ + public function disconnect() { + return($this->close()); + }//end disconnect() + //========================================================================= + + + + //========================================================================= + public function affectedRows() { + return($this->numAffected()); + }//end affectedRows() + //========================================================================= + + + + //========================================================================= + public function currRow() { + return($this->row); + }//end currRow() + //========================================================================= + + + + //========================================================================= + public function querySafe($string) { + return($this->gfObj->cleanString($string,"query")); + }//end querySafe() + //========================================================================= + + + + //========================================================================= + /** + * Make it SQL safe. + */ + public function sqlSafe($string) { + return($this->gfObj->cleanString($string,"sql")); + }//end sqlSafe() + //========================================================================= + + + +} +?> \ No newline at end of file Property changes on: trunk/0.3/abstract/cs_phpDB.abstract.class.php ___________________________________________________________________ Added: svn:keywords + Id Author Revision HeadURL Date Added: trunk/0.3/cs_bbCodeParser.class.php =================================================================== --- trunk/0.3/cs_bbCodeParser.class.php (rev 0) +++ trunk/0.3/cs_bbCodeParser.class.php 2009-08-20 20:39:35 UTC (rev 127) @@ -0,0 +1,165 @@ +<?php +/** + * Created on 2007-09-26 + * + * + * SVN INFORMATION::: + * ------------------ + * SVN Signature::::::: $Id$ + * Last Author::::::::: $Author$ + * Current Revision:::: $Revision$ + * Repository Location: $HeadURL$ + * Last Updated:::::::: $Date$ + * + * + * Originally from a snippet (just the function) on PHPFreaks.com: http://www.phpfreaks.com/quickcode/BBCode/712.php + * The original code had parse errors, so it had to be fixed... While it was posted as just a basic function, + * the code within (such as the reference to "$this->bbCodeData" indicated it was from a class... so it has + * been converted. + */ + +require_once(dirname(__FILE__) ."/abstract/cs_webapplibs.abstract.class.php"); + +class cs_bbCodeParser extends cs_contentAbstract { + + /** Array containing all the codes & how to parse them. */ + private $bbCodeData = NULL; + + //========================================================================= + /** + * Setup internal structures. + */ + function __construct() { + parent::__construct(false); + # Which BBCode is accepted here + $this->bbCodeData = array( + 'bold' => array( + 'start' => array('[b]', '\[b\](.*)', '<b>\\1'), + 'end' => array('[/b]', '\[\/b\]', '</b>'), + ), + + 'underline' => array( + 'start' => array('[u]', '\[u\](.*)', '<u>\\1'), + 'end' => array('[/u]', '\[\/u\]', '</u>'), + ), + + 'italic' => array( + 'start' => array('[i]', '\[i\](.*)', '<i>\\1'), + 'end' => array('[/i]', '\[\/i\]', '</i>'), + ), + + 'image' => array( + 'start' => array('[img]', '\[img\](http:\/\/|https:\/\/|ftp:\/\/|\/)(.*)(.jpg|.jpeg|.bmp|.gif|.png)', '<img src=\'\\1\\2\\3\' />'), + 'end' => array('[/img]', '\[\/img\]', ''), + ), + + # [url]http://x.com[/url] + 'url1' => array( + 'start' => array('[url]', '\[url\](http:\/\/|https:\/\/|ftp:\/\/)(.*)', '<a target="_blank" href=\'\\1\\2\'>\\1\\2'), + 'end' => array('[/url]', '\[\/url\]', '</a>'), + ), + + # [url=http://x.com]stuff[/url] + 'url2' => array( + 'start' => array('[url]', '\[url=(http:\/\/|https:\/\/|ftp:\/\/)(.*)\](.*)', '<a target="_blank" href=\'\\1\\2\'>\\3'), + 'end' => array('[/url]', '\[\/url\]', '</a>'), + ), + + 'code' => array( + 'start' => array('[code]', '\[code\](.*)', '<br /><br /><b>CODE</b>:<div class="code">\\1'), + 'end' => array('[/code]', '\[\/code\]', '</div><br />'), + ), + ); + }//end __construct() + //========================================================================= + + + + //========================================================================= + /** + * Ensure the object is initialized properly, throw exception if not. + */ + private function isInitialized() { + if(!is_array($this->bbCodeData) || !count($this->bbCodeData)) { + throw new exception(__METHOD__ .": BBCode array not initialized"); + } + }//end isInitialized() + //========================================================================= + + + + //========================================================================= + /** + * Parse BBCode from the given string & return it with formatting. + */ + function parseString($data, $newlines2BR=FALSE) { + if(is_string($data) && strlen($data) > 10) { + $this->isInitialized(); + $data = str_replace("\n", '||newline||', $data); + + foreach( $this->bbCodeData as $k => $v ) { + if(isset($this->bbCodeData[$k]['special'])) { + $myMatches = array(); + $regex = '/'. $this->bbCodeData[$k]['start'][1] . $this->bbCodeData[$k]['end'][1] .'/'; + $x = preg_match_all($regex .'U', $data, $myMatches); + + if(count($myMatches[1])) { + $funcName = $v['special']; + $myArgs = $myMatches[1]; + $myArgs = array_unique($myArgs); + + foreach($myArgs as $index=>$value) { + $showThis = $this->$funcName($value); + $replaceThis = str_replace(array('[', ']'), array('\\[', '\\]'), $myMatches[0][$index]); + $data = preg_replace('/'. $replaceThis .'/U', $showThis, $data); + } + } + } + else { + $data = preg_replace("/".$this->bbCodeData[$k]['start'][1].$this->bbCodeData[$k]['end'][1]."/U", $this->bbCodeData[$k]['start'][2].$this->bbCodeData[$k]['end'][2], $data); + } + } + + $replaceNewlineStr = "\n"; + if($newlines2BR) { + $replaceNewlineStr = "<br />\n"; + } + $data = str_replace('||newline||', $replaceNewlineStr, $data); + + } + return $data; + }//end parseString() + //========================================================================= + + + + //========================================================================= + /** + * Enables extending classes to register a bbCode with special parsing. + * + * NOTE: right now, this will only handle syntax like "[{bbCodeString}={arg}]". + */ + protected function register_code_with_callback($bbCodeString, $method) { + + if(method_exists($this, $method)) { + $this->bbCodeData[$bbCodeString] = array( + 'special' => $method, + 'start' => array( + '['. $bbCodeString .']', + '\['. $bbCodeString .'=(.*)' + ), + 'end' => array( + '', + '\]' + ) + ); + } + else { + throw new exception(__METHOD__ .": method (". $method .") doesn't exist"); + } + + }//end register_code_with_callback() + //========================================================================= + +} +?> Property changes on: trunk/0.3/cs_bbCodeParser.class.php ___________________________________________________________________ Added: svn:keywords + Id Author Revision HeadURL Date Added: trunk/0.3/cs_phpDB.class.php =================================================================== --- trunk/0.3/cs_phpDB.class.php (rev 0) +++ trunk/0.3/cs_phpDB.class.php 2009-08-20 20:39:35 UTC (rev 127) @@ -0,0 +1,197 @@ +<?php + +/* + * A class for generic PostgreSQL database access. + * + * SVN INFORMATION::: + * SVN Signature:::::::: $Id$ + * Last Committted Date: $Date$ + * Last Committed Path:: $HeadURL$ + * + */ + +/////////////////////// +// ORIGINATION INFO: +// Author: Trevin Chow (with contributions from Lee Pang, wle...@ho...) +// Email: t1...@ma... +// Date: February 21, 2000 +// Last Updated: August 14, 2001 +// +// Description: +// Abstracts both the php function calls and the server information to POSTGRES +// databases. Utilizes class variables to maintain connection information such +// as number of rows, result id of last operation, etc. +// +/////////////////////// + +require_once(dirname(__FILE__) ."/abstract/cs_webapplibs.abstract.class.php"); +require_once(dirname(__FILE__) ."/abstract/cs_phpDB.abstract.class.php"); + +class cs_phpDB extends cs_contentAbstract { + + private $dbLayerObj; + private $dbType; + public $connectParams = array(); + + //========================================================================= + public function __construct($type='pgsql') { + + if(strlen($type)) { + + require_once(dirname(__FILE__) .'/db_types/'. __CLASS__ .'__'. $type .'.class.php'); + $className = __CLASS__ .'__'. $type; + $this->dbLayerObj = new $className; + $this->dbType = $type; + + parent::__construct(); + + $this->isInitialized = TRUE; + } + else { + throw new exception(__METHOD__ .": failed to give a type (". $type .")"); + } + }//end __construct() + //========================================================================= + + + + //========================================================================= + /** + * Magic method to call methods within the database abstraction layer ($this->dbLayerObj). + */ + public function __call($methodName, $args) { + if(method_exists($this->dbLayerObj, $methodName)) { + if($methodName == 'connect' && is_array($args[0])) { + //capture the connection parameters. + $this->connectParams = $args[0]; + } + $retval = call_user_func_array(array($this->dbLayerObj, $methodName), $args); + } + else { + throw new exception(__METHOD__ .': unsupported method ('. $methodName .') for database of type ('. $this->dbType .')'); + } + return($retval); + }//end __call() + //========================================================================= + + + + //========================================================================= + public function get_dbtype() { + return($this->dbType); + }//end get_dbtype() + //========================================================================= + + + + //========================================================================= + /** + * Performs queries which require results. Passing $indexField returns a + * complex array indexed from that field; passing $valueField will change + * it to a name=>value formatted array. + * + * NOTE:: when using an index field, be sure it is guaranteed to be unique, + * i.e. it is a primary key! If duplicates are found, the database class + * will throw an exception! + */ + public function run_query($sql, $indexField=null, $valueField=null) { + + $retval = array(); + + //length must be 19 as that's about the shortest valid SQL: "select * from table" + if(strlen($sql) >= 19) { + $this->exec($sql); + + $numRows = $this->numRows(); + $dbError = $this->errorMsg(); + if($numRows > 0 && !strlen($dbError)) { + if(strlen($indexField) && (is_null($valueField) || !strlen($valueField))) { + //return a complex array based on a given field. + $retval = $this->farray_fieldnames($indexField, null, 0); + } + elseif(strlen($indexField) && strlen($valueField)) { + //return an array as name=>value pairs. + $retval = $this->farray_nvp($indexField, $valueField); + } + else { + $retval = $this->farray_fieldnames(); + } + } + elseif($numRows == 0 && !strlen($dbError)) { + $retval = false; + } + else { + throw new exception(__METHOD__ .": no rows (". $numRows .") or dbError::: ". $dbError ."<BR>\nSQL::: ". $sql); + } + } + else { + throw new exception(__METHOD__ .": invalid length SQL (". $sql .")"); + } + + return($retval); + }//end run_query() + //========================================================================= + + + + //========================================================================= + /** + * Handles performing the insert statement & returning the last inserted ID. + */ + public function run_insert($sql, $sequence='null') { + + $this->exec($sql); + + if($this->numAffected() == 1 && !strlen($this->errorMsg())) { + //retrieve the ID just created. + $retval = $this->lastID($sequence); + } + else { + //something broke... + throw new exception(__METHOD__ .": failed to insert, rows=(". $this->numRows .")... " + ."ERROR::: ". $this->errorMsg() ."\n -- SQL:::: ". $sql); + } + + return($retval); + }//end run_insert() + //========================================================================= + + + + //========================================================================= + /** + * Performs the update & returns how many rows were affected. + */ + public function run_update($sql, $zeroIsOk=false) { + $this->exec($sql); + + $dberror = $this->errorMsg(); + $numAffected = $this->numAffected(); + + if(strlen($dberror)) { + throw new exception(__METHOD__ .": error while running update::: ". $dberror ." -- SQL::: ". $sql); + } + elseif($numAffected==0 && $zeroIsOk == false) { + throw new exception(__METHOD__ .": no rows updated (". $numAffected ."), SQL::: ". $sql); + } + + return($numAffected); + }//end run_update() + //========================================================================= + + + + //========================================================================= + public function reconnect() { + if(is_array($this->connectParams) && count($this->connectParams)) { + $this->dbLayerObj->connect($this->connectParams, true); + } + else { + throw new exception(__METHOD__ .": no connection parameters stored"); + } + }//end reconnect() + //========================================================================= + +} // end class phpDB + +?> Property changes on: trunk/0.3/cs_phpDB.class.php ___________________________________________________________________ Added: svn:keywords + Id Author Revision HeadURL Date Added: trunk/0.3/cs_sessionDB.class.php =================================================================== --- trunk/0.3/cs_sessionDB.class.php (rev 0) +++ trunk/0.3/cs_sessionDB.class.php 2009-08-20 20:39:35 UTC (rev 127) @@ -0,0 +1,366 @@ +<?php +/* + * FILE INFORMATION: + * $HeadURL$ + * $Id$ + * $LastChangedDate$ + * $LastChangedBy$ + * $LastChangedRevision$ + */ + +require_once(constant('LIBDIR') .'/cs-content/cs_session.class.php'); +require_once(dirname(__FILE__) .'/cs_phpDB.class.php'); +require_once(constant('LIBDIR') .'/cs-phpxml/cs_arrayToPath.class.php'); +require_once(constant('LIBDIR') .'/cs-webapplibs/cs_webdblogger.class.php'); + +class cs_sessionDB extends cs_session { + + protected $db; + + protected $logger = null; + + protected $logCategory = "DB Sessions"; + + //------------------------------------------------------------------------- + /** + * The constructor. + * + * @param $createSession (mixed,optional) determines if a session will be started or not; if + * this parameter is non-null and non-numeric, the value will be + * used as the session name. + */ + function __construct() { + + + //map some constants to connection parameters. + //NOTE::: all constants should be prefixed... + $constantPrefix = 'SESSION_DB_'; + $params = array('host', 'port', 'dbname', 'user', 'password'); + foreach($params as $name) { + $value = null; + $constantName = $constantPrefix . strtoupper($name); + if(defined($constantName)) { + $value = constant($constantName); + } + $dbParams[$name] = $value; + } + $this->db = new cs_phpDB(constant('DBTYPE')); + $this->db->connect($dbParams); + + $this->tableName = 'cs_session_store_table'; + $this->tablePKey = 'session_store_id'; + $this->sequenceName = 'cs_session_store_table_session_store_id_seq'; + + if(!$this->sessdb_table_exists()) { + $this->load_table(); + } + + //now tell PHP to use this class's methods for saving the session. + session_set_save_handler( + array(&$this, 'sessdb_open'), + array(&$this, 'sessdb_close'), + array(&$this, 'sessdb_read'), + array(&$this, 'sessdb_write'), + array(&$this, 'sessdb_destroy'), + array(&$this, 'sessdb_gc') + ); + + //NOTE::: calling session_id() here, prior to parent's construct, can set a specific session_id; if + // something like cs_authToken (part of cs-webapplibs project) were used, just call + // cs_authToken::create_token() here... + + parent::__construct(true); + + //Stop things from going into an audit log... see + //http://www.developertutorials.com/tutorials/php/saving-php-session-data-database-050711/page3.html + // NOTE::: not sure if this is valid or not... + $this->audit_logging = false; + + }//end __construct() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Determines if the appropriate table exists in the database. + */ + public function sessdb_table_exists() { + try { + $test = $this->db->run_query("SELECT * FROM ". $this->tableName . + " ORDER BY ". $this->tablePKey ." LIMIT 1"); + $exists = true; + } + catch(exception $e) { + $this->exception_handler(__METHOD__ .": exception while trying to detect table::: ". $e->getMessage()); + $exists = false; + } + + return($exists); + }//end sessdb_table_exists() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + private function load_table() { + $filename = dirname(__FILE__) .'/schema/db_session_schema.'. $this->db->get_dbtype() .'.sql'; + if(file_exists($filename)) { + try { + $this->db->run_update(file_get_contents($filename),true); + } + catch(exception $e) { + $this->exception_handler(__METHOD__ .": failed to load required table " . + "into your database automatically::: ". $e->getMessage(), true); + } + } + else { + $this->exception_handler(__METHOD__ .": while attempting to load required " . + "table into your database, discovered you have a missing schema " . + "file (". $filename .")", true); + } + }//end load_table() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + protected function is_valid_sid($sid) { + $isValid = false; + if(strlen($sid) == 32) { + try { + $sql = "SELECT * FROM ". $this->tableName ." WHERE session_id='". + $sid ."'"; + $this->db->run_query($sql); + $numrows = $this->db->numRows(); + if($numrows == 1) { + $isValid = true; + } + elseif($numrows > 0 || $numrows < 0) { + $this->exception_handler(__METHOD__ .": invalid numrows returned (". $numrows .")",true); + } + } + catch(exception $e) { + //well... do nothing I guess. + } + } + + return($isValid); + }//end is_valid_sid() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Open the session (doesn't really do anything) + */ + public function sessdb_open($savePath, $sessionName) { + return(true); + }//end sessdb_open() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Close the session (call the "gc" method) + */ + public function sessdb_close() { + return($this->sessdb_gc(0)); + }//end sessdb_close() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Read information about the session. If there is no data, it MUST return + * an empty string instead of NULL. + */ + public function sessdb_read($sid) { + $retval = ''; + try { + $sql = "SELECT * FROM ". $this->tableName ." WHERE session_id='". + $sid ."'"; + $data = $this->db->run_query($sql); + + if($this->db->numRows() == 1) { + $retval = $data['session_data']; + } + } + catch(exception $e) { + //no throwing exceptions... + $this->exception_handler(__METHOD__ .": failed to read::: ". $e->getMessage()); + } + return($retval); + }//end sessdb_read() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function sessdb_write($sid, $data) { + $data = array( + 'session_data' => $data, + 'user_id' => null + ); + $cleanString = array( + 'session_data' => 'sql', + 'user_id' => 'numeric' + ); + + + + //pull the uid out of the session... + if(defined('SESSION_DBSAVE_UIDPATH')) { + $a2p = new cs_arrayToPath($_SESSION); + $uidVal = $a2p->get_data(constant('SESSION_DBSAVE_UIDPATH')); + + if(is_string($uidVal) || is_numeric($uidVal)) { + $data['user_id'] = $uidVal; + } + } + + $afterSql = ""; + if($this->is_valid_sid($sid)) { + $type = 'update'; + $sql = "UPDATE ". $this->tableName ." SET "; + $afterSql = "WHERE session_id='". $sid ."'"; + $data['last_updated'] = 'NOW()'; + $secondArg = false; + } + else { + $type = 'insert'; + $sql = "INSERT INTO ". $this->tableName ." "; + $data['session_id'] = $sid; + $secondArg = $this->sequenceName; + } + + $sql .= $this->gfObj->string_from_array($data, $type, null, $cleanString) .' '. $afterSql; + try { + $funcName = 'run_'. $type; + $res = $this->db->$funcName($sql, $secondArg); + } + catch(exception $e) { + //umm... yeah. + $this->exception_handler(__METHOD__ .": failed to perform action (". $type .")::: ". $e->getMessage()); + } + + return(true); + }//end sessdb_write() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function sessdb_destroy($sid) { + try { + $sql = "DELETE FROM ". $this->tableName ." WHERE session_id='". $sid ."'"; + $numDeleted = $this->db->run_update($sql, true); + + if($numDeleted > 0) { + $this->do_log("Destroyed session_id (". $sid .")", 'deleted'); + } + } + catch(exception $e) { + //do... nothing? + } + return(true); + }//end sessdb_destroy() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Define maximum lifetime (in seconds) to store sessions in the database. + * Anything that is older than that time will be purged (gc='garbage collector'). + */ + public function sessdb_gc($maxLifetime=null) { + + $dateFormat = 'Y-m-d H:i:s'; + $strftimeFormat = '%Y-%m-%d %H:%M:%S'; + $nowTime = date($dateFormat); + $excludeCurrent = true; + if(defined('SESSION_MAX_TIME') || defined('SESSION_MAX_IDLE')) { + $maxFreshness = null; + if(defined('SESSION_MAX_TIME')) { + $date = strtotime('- '. constant('SESSION_MAX_TIME')); + $maxFreshness = "date_created < '". strftime($strftimeFormat, $date) ."'"; + $excludeCurrent=false; + } + if(defined('SESSION_MAX_IDLE')) { + + $date = strtotime('- '. constant('SESSION_MAX_IDLE')); + $addThis = "last_updated < '". strftime($strftimeFormat, $date) ."'"; + $maxFreshness = $this->gfObj->create_list($maxFreshness, $addThis, ' OR '); + } + } + elseif(is_null($maxLifetime) || !is_numeric($maxLifetime) || $maxLifetime <= 0) { + //pull it from PHP's ini settings. + $maxLifetime = ini_get("session.gc_maxlifetime"); + $interval = $maxLifetime .' seconds'; + + $dt1 = strtotime($nowTime .' - '. $interval); + $maxFreshness = "last_updated < '". date($dateFormat, $dt1) ."'"; + } + + + + try { + //destroy old sessions, but don't complain if nothing is deleted. + $sql = "DELETE FROM ". $this->tableName ." WHERE ". $maxFreshness; + if(strlen($this->sid) && $excludeCurrent === false) { + $sql .= " AND session_id != '". $this->sid ."'"; + } + $numCleaned = $this->db->run_update($sql, true); + + if($numCleaned > 0) { + $this->do_log("cleaned (". $numCleaned .") old sessions, " . + "excludeCurrent=(". $this->gfObj->interpret_bool($excludeCurrent) .")" . + ", maxFreshness=(". $maxFreshness .")", "debug"); + } + } + catch(exception $e) { + $this->exception_handler(__METHOD__ .": exception while cleaning: ". $e->getMessage()); + } + + return(true); + + }//end sessdb_gc() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + protected function do_log($message, $type) { + + //check if the logger object has been created. + if(!is_object($this->logger)) { + $newDB = new cs_phpDB(constant('DBTYPE')); + $newDB->connect($this->db->connectParams, true); + $this->logger = new cs_webdblogger($newDB, $this->logCategory); + } + + return($this->logger->log_by_class("SID=(". $this->sid .") -- ". $message,$type)); + + }//end do_log() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + protected function exception_handler($message, $throwException=false) { + $logId = $this->do_log($message, 'exception in code'); + if($throwException === true) { + //in this class, it is mostly useless to throw exceptions, so by default they're not thrown. + throw new exception($message); + } + return($logId); + }//end exception_handler() + //------------------------------------------------------------------------- + + +}//end cs_session{} +?> \ No newline at end of file Property changes on: trunk/0.3/cs_sessionDB.class.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Id Author Revision HeadURL Date Added: trunk/0.3/cs_siteConfig.class.php =================================================================== --- trunk/0.3/cs_siteConfig.class.php (rev 0) +++ trunk/0.3/cs_siteConfig.class.php 2009-08-20 20:39:35 UTC (rev 127) @@ -0,0 +1,404 @@ +<?php + +/* + * A class for handling configuration of database-driven web applications. + * + * NOTICE::: this class requires that cs-phpxml and cs-arraytopath are both available + * at the same directory level as cs-content; all projects are SourceForge.net projects, + * using their unix names ("cs-phpxml" and "cs-arrayToPath"). The cs-phpxml project + * requires cs-arrayToPath for parsing XML paths. + * + * SVN INFORMATION::: + * SVN Signature:::::::: $Id$ + * Last Committted Date: $Date$ + * Last Committed Path:: $HeadURL$ + * + */ + +require_once(dirname(__FILE__) .'/../cs-content/abstract/cs_content.abstract.class.php'); +require_once(dirname(__FILE__) .'/../cs-content/cs_fileSystem.class.php'); +require_once(dirname(__FILE__). '/../cs-phpxml/cs_phpxmlParser.class.php'); +require_once(dirname(__FILE__) .'/../cs-phpxml/cs_phpxmlBuilder.class.php'); + +class cs_siteConfig extends cs_contentAbstract { + + /** XMLParser{} object, for reading XML config file. */ + private $xmlReader; + + /** cs_fileSystem{} object, for writing/updating XML config file + * (only available if file is writable) + */ + private $xmlWriter; + + /** XMLBuilder{} object, for updating XML. */ + private $xmlBuilder; + + /** cs_fileSystem{} object, for handling generic file operations (i.e. reading) */ + private $fs; + + /** boolean flag indicating if the given config file is readOnly (false=read/write) */ + private $readOnly; + + /** Directory for the config file. */ + private $configDirname; + + /** Location of the configuration file itself. */ + private $configFile; + + /** Active section of the full site configuration. */ + private $activeSection; + + /** The FULL configuration file, instead of just the active section. */ + private $fullConfig=array(); + + /** cs_arrayToPath{} object. */ + private $a2p; + + /** Prefix to add to every index in GLOBALS and CONSTANTS. */ + private $setVarPrefix; + + /** Sections available within the config */ + private $configSections=array(); + + /** Boolean flag to determine if the object has been properly initialized or not. */ + private $isInitialized=false; + + /** Store a list of items that need to be pushed into $GLOBALS on a given path. */ + private $setGlobalArrays=array(); + + //------------------------------------------------------------------------- + /** + * Constructor. + * + * @param $configFileLocation (str) URI for config file. + * @param $section (str,optional) set active section (default=MAIN) + * @param $setVarPrefix (str,optional) prefix to add to all global & constant names. + * + * @return NULL (PASS) object successfully created + * @return exception (FAIL) failed to create object (see exception message) + */ + public function __construct($configFileLocation, $section='MAIN', $setVarPrefix=null) { + + $section = strtoupper($section); + $this->setVarPrefix=$setVarPrefix; + + parent::__construct(); + + if(strlen($configFileLocation) && file_exists($configFileLocation)) { + + $this->configDirname = dirname($configFileLocation); + $this->configFile = $configFileLocation; + $this->fs = new cs_fileSystem($this->configDirname); + + $this->xmlReader = new cs_phpxmlParser($this->fs->read($configFileLocation)); + + if($this->fs->is_writable($configFileLocation)) { + $this->readOnly = false; + $this->xmlWriter = new cs_fileSystem($this->configDirname); + + } + else { + $this->readOnly = true; + } + } + else { + throw new exception(__METHOD__ .": invalid configuration file (". $configFileLocation .")"); + } + + if(strlen($section)) { + try { + $this->parse_config(); + $this->set_active_section($section); + $this->config = $this->get_section($section); + } + catch(exception $e) { + throw new exception(__METHOD__ .": invalid section (". $section ."), DETAILS::: ". $e->getMessage()); + } + } + else { + throw new exception(__METHOD__ .": no section given (". $section .")"); + } + + }//end __construct() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Sets the active section. + * + * @param $section (str) section to be set as active. + * + * @return VOID (PASS) section was set successfully. + * @return exception (FAIL) problem encountred setting section. + */ + public function set_active_section($section) { + if($this->isInitialized === true) { + $section = strtoupper($section); + if(in_array($section, $this->configSections)) { + $this->activeSection = $section; + } + else { + throw new exception(__METHOD__ .": invalid section (". $section .")"); + } + } + else { + throw new exception(__METHOD__ .": not initialized"); + } + }//end set_active_section($section) + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Parse the configuration file. Handles replacing {VARIABLES} in values, + * sets items as global or as constants, and creates array indicating the + * available sections from the config file. + * + * @param VOID (void) no arguments accepted. + * + * @return NULL (PASS) successfully parsed configuration + * @return exception (FAIL) exception indicates problem encountered. + */ + private function parse_config() { + if(is_object($this->xmlReader)) { + $data = $this->xmlReader->get_path($this->xmlReader->get_root_element()); + $specialVars = $this->build_special_vars(); + $parseThis = array(); + + + $this->configSections = array(); + + foreach($data as $section=>$secData) { + //only handle UPPERCASE index names; lowercase indexes are special entries (i.e. "type" or "attributes" + if($section == strtoupper($section)) { + $this->configSections[] = $section; + + unset($secData['type']); + + if(isset($secData['attributes']) && is_array($secData['attributes'])) { + $sectionAttribs = $secData['attributes']; + unset($secData['attributes']); + + //put stuff into the globals scope... + if(isset($sectionAttribs['SETGLOBAL'])) { + $path = $section; + + $setPath = $path; + if(strlen($sectionAttribs['GLOBALARRAYLOCATION'])) { + $setPath = $sectionAttribs['GLOBALARRAYLOCATION']; + } + $this->setGlobalArrays[$path] = $setPath; + } + } + + foreach($secData as $itemName=>$itemValue) { + $attribs = array(); + if(isset($itemValue['attributes']) && is_array($itemValue['attributes'])) { + $attribs = $itemValue['attributes']; + } + if(isset($itemValue['value'])) { + $itemValue = $itemValue['value']; + } + else { + $itemValue = null; + } + if(preg_match("/{/", $itemValue)) { + $origVal = $itemValue; + + //remove double-slashes (//) + $itemValue = preg_replace('/[\/]{2,}/', '\/', $itemValue); + + //remove leading slash for string replaces (i.e. "{/MAIN/SITE_ROOT}" becomes "{MAIN/SITE_ROOT}") + $itemValue = preg_replace('/{\//', '{', $itemValue); + + //replace special vars. + $itemValue = $this->gfObj->mini_parser($itemValue, $specialVars, '{', '}'); + + //replace internal vars. + $itemValue = $this->gfObj->mini_parser($itemValue, $parseThis, '{', '}'); + } + + if(isset($attribs['CLEANPATH'])) { + $itemValue = $this->fs->resolve_path_with_dots($itemValue); + } + + $parseThis[$itemName] = $itemValue; + $parseThis[$section ."/". $itemName] = $itemValue; + $data[$section][$itemName]['value'] = $itemValue; + + $setVarIndex = $this->setVarPrefix . $itemName; + if(isset($attribs['SETGLOBAL'])) { + $GLOBALS[$setVarIndex] = $itemValue; + } + if(isset($attribs['SETCONSTANT'])) { + if(isset($attribs['SETCONSTANTPREFIX'])) { + //did they give a specific prefix, or just a number/true? + if(strlen($attribs['SETCONSTANTPREFIX']) == 1) { + $setVarIndex = $section ."-". $setVarIndex; + } + else { + //use the prefix they gave. + $setVarIndex = $attribs['SETCONSTANTPREFIX'] ."-". $setVarIndex; + } + } + if(!defined($setVarIndex)) { + define($setVarIndex, $itemValue); + } + } + } + } + } + + $this->a2p = new cs_arrayToPath($data); + $this->isInitialized=true; + + if(count($this->setGlobalArrays)) { + $globA2p = new cs_arrayToPath(&$GLOBALS); + foreach($this->setGlobalArrays as $configPath=>$globalsPath) { + if($this->a2p->get_data($configPath)) { + $setMe = array(); + foreach($this->a2p->get_data($configPath) as $i=>$v) { + $setMe[$i] = $v['value']; + } + $globA2p->set_data($globalsPath, $setMe); + } + else { + throw new exception(__METHOD__ .": attempted to set global array from non-existent path (". $configPath .")"); + } + } + } + } + else { + throw new exception(__METHOD__ .": xmlReader not created, object probably not initialized"); + } + }//end parse_config() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Retrieve all data about the given section. + * + * @param $section (str) section to retrieve. + * + * @return array (PASS) array contains section data. + * @return exception (FAIL) exception indicates problem. + */ + public function get_section($section) { + if($this->isInitialized === true) { + $section = strtoupper($section); + $data = $this->a2p->get_data($section); + + if(is_array($data) && count($data) && $data['type'] == 'open') { + unset($data['type']); + $retval = $data; + } + else { + throw new exception(__METHOD__ .": invalid section (". $section .") or no data (". $data['type'] .")"); + } + } + else { + throw new exception(__METHOD__ .": not initialized"); + } + + return($retval); + }//end get_section() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Retrieves value from the active section, or from another (other sections + * specified like "SECTION/INDEX"). + * + * @param $index (str) index name of value to retrieve. + * + * @return mixed (PASS) returns value of given index. + * + * NOTE::: this will return NULL if the given index or section/index does + * not exist. + */ + public function get_value($index) { + if($this->isInitialized === true) { + if(preg_match("/\//", $index)) { + //section NOT given, assume they're looking for something in the active section. + $index = $this->activeSection ."/". $index; + } + $retval = $this->a2p->get_data($index .'/value'); + } + else { + throw new exception(__METHOD__ .": not initialized"); + } + return($retval); + }//end get_value() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Retrieves list of valid configuration sections, as defined by + * parse_config(). + * + * @param VOID (void) no parameters accepted. + * + * @return array (PASS) array holds list of valid sections. + * @return exception (FAIL) exception gives error. + */ + public function get_valid_sections() { + if($this->isInitialized === true) { + if(is_array($this->configSections) && count($this->configSections)) { + $retval = $this->configSections; + } + else { + throw new exception(__METHOD__ .": no sections defined, probably invalid configuration"); + } + } + else { + throw new exception(__METHOD__ .": not initialized"); + } + + return($retval); + }//end get_valid_sections() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + private function build_special_vars() { + //determine the current "APPURL" (current URL minus hostname and current filename) + { + $appUrl = $_SERVER['SCRIPT_NAME']; + $bits = explode('/', $appUrl); + if(!strlen($bits[0])) { + array_shift($bits); + } + if(count($bits)) { + array_pop($bits); + } + if(!count($bits)) { + $appUrl = '/'; + } + else { + $appUrl = '/'. $this->gfObj->string_from_array($bits, null, '/'); + } + } + + $specialVars = array( + '_DIRNAMEOFFILE_' => $this->configDirname, + '_CONFIGFILE_' => $this->configFile, + '_THISFILE_' => $this->configFile, + '_APPURL_' => $appUrl + ); + return($specialVars); + }//end build_special_vars() + //------------------------------------------------------------------------- + +}//end cs_siteConfig + +?> Property changes on: trunk/0.3/cs_siteConfig.class.php ___________________________________________________________________ Added: svn:keywords + Id Author Revision HeadURL Date Added: trunk/0.3/cs_tabs.class.php =================================================================== --- trunk/0.3/cs_tabs.class.php (rev 0) +++ trunk/0.3/cs_tabs.class.php 2009-08-20 20:39:35 UTC (rev 127) @@ -0,0 +1,175 @@ +<?php +/* + * Created on Jan 9, 2007 + * + */ + +require_once(dirname(__FILE__) .'/abstract/cs_content.abstract.class.php'); + + +class cs_tabs extends cs_contentAbstract { + private $tabsArr=array(); + private $selectedTab; + + private $templateVar; + private $gfObj; + + /** This is the default suffix to use when none is given during the add_tab() call. */ + private $defaultSuffix='tab'; + + //--------------------------------------------------------------------------------------------- + /** + * Build the object, and parses the given template. Tabs must be added & selected manually. + * + * @param $csPageObj (object) Instance of the class "cs_genericPage". + * @param $templateVar (str,optional) What template var to find the tab blockrows in. + */ + public function __construct($templateVar="tabs") { + parent::__construct(false); + + if(is_object($templateVar)) { + //trying to pass cs_genericPage{}... tell 'em we don't like that anymore. + throw new exception(__METHOD__ .": got an object (". get_class($templateVar) .") instead of template var name"); + } + elseif(is_string($templateVar) && is_null($templateVar) || strlen($templateVar) < 3) { + //no template name? AHH!!! + throw new exception("cs_tabs::__construct(): failed to specify proper template file"); + } + else { + //set the internal var. + $this->templateVar = $templateVar; + } + + $this->gfObj = new cs_globalFunctions; + }//end __construct() + //--------------------------------------------------------------------------------------------- + + + + //--------------------------------------------------------------------------------------------- + public function add_tab_array(array $tabs, $useSuffix=null) { + $retval = 0; + foreach($tabs as $name=>$url) { + //call an internal method to do it. + $retval += $this->add_tab($name, $url, $useSuffix); + } + + return($retval); + }//end add_tab_array() + //--------------------------------------------------------------------------------------------- + + + + //--------------------------------------------------------------------------------------------- + /** + * Sets the given tab as selected, provided it exists. + * + * @param $tabName (str) Sets this tab as selected. + * @return (void) + */ + public function select_tab($tabName) { + $this->selectedTab = $tabName; + }//end select_tab() + //--------------------------------------------------------------------------------------------- + + + + //--------------------------------------------------------------------------------------------- + public function add_tab($tabName, $url, $useSuffix=null) { + + //set the default suffix. + if(is_null($useSuffix)) { + $useSuffix = $this->defaultSuffix; + } + + //add it to an array. + $this->tabsArr[$tabName] = array( + 'url' => $url, + 'suffix' => $useSuffix + ); + }//end add_tab() + //--------------------------------------------------------------------------------------------- + + + + //--------------------------------------------------------------------------------------------- + /** + * Call this to add the parsed tabs into the page. + */ + public function display_tabs(array $blockRows) { + + if(!strlen($this->selectedTab)) { + $keys = array_keys($this->tabsArr); + $this->select_tab($keys[0]); + } + + if(is_array($this->tabsArr) && count($this->tabsArr)) { + $finalString = ""; + //loop through the array. + foreach($this->tabsArr as $tabName=>$tabData) { + + $url = $tabData['url']; + $suffix = $tabData['suffix']; + + $blockRowName = 'unselected_'. $suffix; + if(strtolower($tabName) == strtolower($this->selectedTab)) { + $blockRowName = 'selected_'. $suffix; + } + + if(isset($blockRows[$blockRowName])) { + $useTabContent = $blockRows[$blockRowName]; + } + else { + throw new exception(__METHOD__ ."(): failed to load block row " . + "(". $blockRowName .") for tab (". $tabName .")". + $this->gfObj->debug_print($blockRows,0)); + } + + $parseThis = array( + 'title' => $tabName, + 'url' => $url, + 'cleanTitle' => preg_replace('/[^a-zA-Z0-9]/', '_', $tabName) + ); + $finalString .= $this->gfObj->mini_parser($useTabContent, $parseThis, '%%', '%%'); + } + } + else { + //something bombed. + throw new exception(__METHOD__ ."(): no tabs to add"); + } + + return($finalString); + }//end display_tabs() + //--------------------------------------------------------------------------------------------- + + + //--------------------------------------------------------------------------------------------- + /** + * Determine if the given named tab exists (returns boolean true/false) + */ + public function tab_exists($tabName) { + $retval = false; + if(isset($this->tabsArr[$tabName])) { + $retval = true; + } + return($retval); + }//end tab_exists() + //--------------------------------------------------------------------------------------------- + + + + //--------------------------------------------------------------------------------------------- + public function rename_tab($tabName, $newTabName) { + if($this->tab_exists($tabName) && !$this->tab_exists($newTabName)) { + $tabContents = $this->tabsArr[$tabName]; + unset($this->tabsArr[$tabName]); + $this->tabsArr[$newTabName] = $tabContents; + } + else { + throw new exception(__METHOD__ .": tried to rename non-existent tab (". $tabName .") to (". $newTabName .")"); + } + }//end rename_tab(); + //--------------------------------------------------------------------------------------------- + +} +?> Property changes on: trunk/0.3/cs_tabs.class.php ___________________________________________________________________ Added: svn:keywords + Id Author Revision HeadURL Date Modified: trunk/0.3/cs_webdbupgrade.class.php =================================================================== --- trunk/0.3/cs_webdbupgrade.class.php 2009-08-20 19:04:39 UTC (rev 126) +++ trunk/0.3/cs_webdbupgrade.class.php 2009-08-20 20:39:35 UTC (rev 127) @@ -13,7 +13,8 @@ */ require_once(dirname(__FILE__) .'/abstract/cs_webapplibs.abstract.class.php'); - require_once(dirname(__FILE__) .'/cs_webdblogger.class.php'); +require_once(dirname(__FILE__) .'/cs_webdblogger.class.php'); +require_once(dirname(__FILE__) .'/cs_phpDB.class.php'); class cs_webdbupgrade extends cs_webapplibsAbstract { @@ -88,7 +89,6 @@ require_once(constant('LIBDIR') .'/cs-content/cs_globalFunctions.class.php'); require_once(constant('LIBDIR') .'/cs-content/cs_fileSystem.class.php'); - require_once(constant('LIBDIR') .'/cs-content/cs_phpDB.class.php'); require_once(constant('LIBDIR') .'/cs-phpxml/cs_phpxmlParser.class.php'); require_once(constant('LIBDIR') .'/cs-phpxml/cs_phpxmlCreator.class.php'); require_once(constant('LIBDIR') .'/cs-phpxml/cs_arrayToPath.class.php'); Added: trunk/0.3/db_types/cs_phpDB__mysql.class.php =================================================================== --- trunk/0.3/db_types/cs_phpDB__mysql.class.php (rev 0) +++ trunk/0.3/db_types/cs_phpDB__mysql.class.php 2009-08-20 20:39:35 UTC (rev 127) @@ -0,0 +1,821 @@ +<?php + +/* + * A class for generic MySQL database access. + * + * SVN INFORMATION::: + * SVN Signature:::::::: $Id$ + * Last Committted Date: $Date$ + * Last Committed Path:: $HeadURL$ + * + */ + + +class cs_phpDB__mysql extends cs_phpDBAbstract { + + /** Internal result set pointer. */ + protected $result = NULL; + + /** Internal error code. */ + protected $errorCode = 0; + + /** Status of the current transaction. */ + protected $transStatus = NULL; + + /** Whether there is a transaction in progress or not. */ + protected $inTrans = FALSE; + + /** Holds the last query performed. */ + protected $lastQuery = NULL; + + /** List of queries that have been run */ + protected $queryList=array(); + + /** How many seconds to wait for a query before cancelling it. */ + protected $timeOutSeconds = NULL; + + /** Internal check to determine if a connection has been established. */ + protected $isConnected=FALSE; + + /** Internal check to determine if the parameters have been set. */ + protected $paramsAreSet=FALSE; + + /** Resource handle. */ + protected $connectionID = -1; + + /** Hostname or IP to connect to */ + protected $host; + + /** Port to connect to (default for Postgres is 5432) */ + protected $port; + + /** Name of the database */ + protected $dbname; + + /** Username to connect to the database */ + protected $user; + + /** password to connect to the database */ + protected $password; + + /** Row counter for looping through records */ + protected $row = -1; + + /** cs_globalFunctions object, for string stuff. */ + protected $gfObj; + + /** Internal check to ensure the object has been properly created. */ + protected $isInitialized=FALSE; + + /** List of prepared statements, indexed off the name, with the sub-array being fieldname=>dataType. */ + protected $preparedStatements = array(); + + /** Set to TRUE to save all queries into an array. */ + protected $useQueryList=FALSE; + + /** array that essentially remembers how many times beginTrans() was called. */ + protected $transactionTree = NULL; + + //////////////////////////////////////////// + // Core primary connection/database function + //////////////////////////////////////////// + + + //========================================================================= + public function __construct() { + parent::__construct(); + }//end __construct() + //========================================================================= + + + + //========================================================================= + /** + * Set appropriate parameters for database connection + */ + public function set_db_info(array $params){ + $this->sanity_check(); + $required = array('host', 'dbname', 'user', 'password'); + + $requiredCount = 0; + foreach($params as $index=>$value) { + if(property_exists($this, $index) && in_array($index, $required)) { + $this->$index = $value; + $requiredCount++; + } + else { + throw new exception(__METHOD__. ": property (". $index .") does " . + "not exist or isn't allowed"); + } + } + + if($requiredCount == count($required)) { + $this->paramsAreSet = TRUE; + } + else { + throw new exception(__METHOD__ .": required count (". $requiredCount + .") does not match required number of fields (". count($required) .")"); + } + }//end set_db_info() + //========================================================================= + + + + //========================================================================= + /** + * Standard method to close connection. + */ + function close() { + $this->isConnected = FALSE; + $retval = null; + if($this->connectionID != -1) { + $retval = mysql_close($this->connectionID); + $this->transStatus = null; + $this->inTrans=null; + $this->transactionTree=null; + } + else { + throw new exception(__METHOD__ .": Failed to close connection: connection is invalid"); + } + + return($retval); + }//end close() + //========================================================================= + + + + //========================================================================= + /** + * Connect to the database + */ + function connect(array $dbParams=NULL, $forceNewConnection=FALSE){ + $this->sanity_check(); + $retval = NULL; + if(is_array($dbParams)) { + $this->set_db_info($dbParams); + } + + if($this->paramsAreSet === TRUE) { + + //start output buffer for displaying error. + ob_start(); + $connID = mysql_connect($this->host, $this->user, $this->password, $forceNewConnection); + if(!$connID) { + $connectError = mysql_error(); + } + else { + mysql_select_db($this->dbname); + $connectError = ob_get_contents(); + } + ob_end_clean(); + + if(is_resource($connID)) { + $this->errorCode=0; + $this->connectionID = $connID; + $this->isConnected = TRUE; + $retval = $this->connectionID; + } + else { + if(is_bool($connID) && !strlen($connectError)) { + $connectError = "generic connection failure"; + } + throw new exception(__METHOD__ .": FATAL ERROR: ". $connectError); + } + } + else { + throw new exception(__METHOD__ .": paramsAreSet=(". $this->paramsAreSet ."), isConnected=(". $this->isConnected .")"); + } + + return($retval); + }//end connect() + //========================================================================= + + + + //========================================================================= + function get_hostname() { + $this->sanity_check(); + return($this->host); + }//end get_hostname() + //========================================================================= + + + + //========================================================================= + /** + * Run sql queries + * + * TODO: re-implement query logging (setting debug, logfilename, etc). + */ + function exec($query) { + $this->lastQuery = $query; + if($this->useQueryList) { + $this->queryList[] = $query; + } + $returnVal = false; + + $this->result = mysql_query($query, $this->connectionID); + + if($this->result !== false) { + if (eregi("^[[:space:]]*select", $query)) { + //If we didn't have an error and we are a select statement, move the pointer to first result + $numRows = $this->numRows(); + if($numRows > 0) { + $this->move_first(); + } + $returnVal = $numRows; + + } + else { + //We got something other than an update. Use numAffected + $returnVal = $this->numAffected(); + } + } + return($returnVal); + }//end exec() + //========================================================================= + + + + //========================================================================= + /** + * Returns any error caused by the last executed query. + * + * @return NULL OK: no error + * @return (string) FAIL: contains error returned from the query. + */ + function errorMsg($setMessage=NULL,$logError=NULL) { + $this->sanity_check(); + if ($this->connectionID < 0) { + //TODO: implement MySQL version (error codes may vary)... + switch ($this->errorCode) { + //############################################### + case -1: + $retVal = "FATAL ERROR - CONNECTION ERROR: RESOURCE NOT FOUND"; + break; + //############################################### + + //############################################### + case -2: + $retVal = "FATAL ERROR - CLASS ERROR: FUNCTION CALLED WITHOUT PARAMETERS"; + break; + //############################################### + + //############################################### + case -3: + $retVal = "Query exceeded maximum timeout (". $this->timeoutSeconds ."... [truncated message content] |
From: <cra...@us...> - 2009-08-20 19:04:46
|
Revision: 126 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=126&view=rev Author: crazedsanity Date: 2009-08-20 19:04:39 +0000 (Thu, 20 Aug 2009) Log Message: ----------- Convert to sha-1 hashes for better security. /cs_authToken.class.php: * create_hash_string(): -- use sha1() instead of md5(). * authenticate_token(): -- test that the hash is 40 characters (sha-1) instead of 32 (md5) /tests/testOfCSWebAppLibs.php: * basic_token_tests(): -- test that the hash is 40 characters (sha-1) instead of 32 (md5) Modified Paths: -------------- trunk/0.3/cs_authToken.class.php trunk/0.3/tests/testOfCSWebAppLibs.php Modified: trunk/0.3/cs_authToken.class.php =================================================================== --- trunk/0.3/cs_authToken.class.php 2009-08-20 18:47:04 UTC (rev 125) +++ trunk/0.3/cs_authToken.class.php 2009-08-20 19:04:39 UTC (rev 126) @@ -61,7 +61,7 @@ * something very unique. */ protected function create_hash_string($tokenId, $uid, $checksum, $stringToHash=NULL) { - return(md5($tokenId ."_". $uid ."_". $checksum ."_". $stringToHash)); + return(sha1($tokenId ."_". $uid ."_". $checksum ."_". $stringToHash)); }//end create_hash_string() //========================================================================= @@ -196,7 +196,7 @@ $authTokenRes = null; - if(is_numeric($tokenId) && strlen($checksum) && strlen($hash) == 32) { + if(is_numeric($tokenId) && strlen($checksum) && strlen($hash) == 40) { try { $data = $this->get_token_data($tokenId); Modified: trunk/0.3/tests/testOfCSWebAppLibs.php =================================================================== --- trunk/0.3/tests/testOfCSWebAppLibs.php 2009-08-20 18:47:04 UTC (rev 125) +++ trunk/0.3/tests/testOfCSWebAppLibs.php 2009-08-20 19:04:39 UTC (rev 126) @@ -193,7 +193,7 @@ $this->assertTrue(isset($tokenData['id'])); $this->assertTrue(isset($tokenData['hash'])); $this->assertTrue(($tokenData['id'] > 0)); - $this->assertTrue((strlen($tokenData['hash']) == 32)); + $this->assertTrue((strlen($tokenData['hash']) == 40)); } }//end basic_token_tests() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-08-20 18:47:12
|
Revision: 125 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=125&view=rev Author: crazedsanity Date: 2009-08-20 18:47:04 +0000 (Thu, 20 Aug 2009) Log Message: ----------- Make hash unguessable. NOTE::: the last commit missed cs_authToken.class.php, so this looks a bit like a duplicate. NOTE2:: the hash could be encrypted using SHA-1, using the function sha1(), though this would possibly hinder using it for cs_sessionDB{}...? /cs_authToken.class.php: * create_token(): -- add microtime() and a random number to the hash string for better unguessability. * authenticate_token(): -- check length of the array from get_token_data(), and make sure the checksums match (the checksum match was incomplete, must've been distracted or something). * get_token_data(): -- remove initial index (of $tokenId) for simpler checking. -- add exception if the $tokenId index isn't there. /tests/testOfCSWebAppLibs.php: * test_token_basics(): -- test to ensure the token's hash isn't guessable. * authTokenTester::doHash() [NEW]: -- calls cs_authToken::create_hash_string(). Modified Paths: -------------- trunk/0.3/cs_authToken.class.php trunk/0.3/tests/testOfCSWebAppLibs.php Modified: trunk/0.3/cs_authToken.class.php =================================================================== --- trunk/0.3/cs_authToken.class.php 2009-08-20 18:15:30 UTC (rev 124) +++ trunk/0.3/cs_authToken.class.php 2009-08-20 18:47:04 UTC (rev 125) @@ -103,6 +103,7 @@ $tokenId = $this->db->run_insert($sql, $this->seq); //now that we have the ID, let's create the real has string. + $stringToHash .= microtime(true) ."__". rand(1000, 9999999); $finalHash = $this->create_hash_string($tokenId, $uid, $checksum, $stringToHash); $this->_generic_update($tokenId, "token='". $finalHash ."'"); @@ -199,10 +200,9 @@ try { $data = $this->get_token_data($tokenId); - if(count($data) == 1 && isset($data[$tokenId]) && is_array($data[$tokenId])) { - $data = $data[$tokenId]; + if(count($data) == 9 && is_array($data) && isset($data['auth_token_id'])) { - if($data['token'] == $hash && $data['checksum']) { + if($data['token'] == $hash && $data['checksum'] == $checksum) { $methodCall = 'update_token_uses'; if(is_numeric($data['max_uses'])) { @@ -265,7 +265,12 @@ $data = $this->db->run_query($sql, 'auth_token_id'); if(is_array($data) && count($data) == 1) { - $tokenData = $data; + if(isset($data[$tokenId])) { + $tokenData = $data[$tokenId]; + } + else { + throw new exception("missing sub-array for tokenId (". $tokenId .")"); + } } elseif($data === false) { $tokenData = false; Modified: trunk/0.3/tests/testOfCSWebAppLibs.php =================================================================== --- trunk/0.3/tests/testOfCSWebAppLibs.php 2009-08-20 18:15:30 UTC (rev 124) +++ trunk/0.3/tests/testOfCSWebAppLibs.php 2009-08-20 18:47:04 UTC (rev 125) @@ -165,6 +165,19 @@ $this->assertEqual($uniq, ($numTests -1)); } } + + //make sure the hash string isn't guessable, even if they can access our super-secret encryption algorithm. ;) + { + $uid = rand(1,99999); + $checksum = "my birfday"; + $hashThis = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque ut."; + + $tokenData = $tok->create_token($uid, $checksum, $hashThis); + $this->basic_token_tests($tokenData, $uid, $checksum); + + $this->assertNotEqual($tokenData['hash'], $tok->doHash($tokenData['id'], $uid, $checksum, $hashThis), + "hash is guessable"); + } }//end test_token_basics() //-------------------------------------------------------------------------- @@ -194,5 +207,8 @@ public function tokenData($id, $onlyNonExpired=true) { return($this->get_token_data($id, $onlyNonExpired)); } + public function doHash($tokenId, $uid, $checksum, $hash) { + return($this->create_hash_string($tokenId, $uid, $checksum, $hash)); + } } ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-08-20 18:15:36
|
Revision: 124 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=124&view=rev Author: crazedsanity Date: 2009-08-20 18:15:30 +0000 (Thu, 20 Aug 2009) Log Message: ----------- Lots more tests to ensure tokens work properly. /cs_authToken.class.php: * authenticate_token(): -- update to handle new array value from get_token_data(). * get_token_data(): -- remove initial index (of $tokenId) for simpler checking. -- add exception if the $tokenId index isn't there. /tests/testOfCSWebAppLibs.php: * test_token_basics(): -- put first generic test into set of brackes with indentation, call basic_token_tests(). -- check to ensure the number of attempts is proper. -- make sure tokens beyond their max_uses are actually gone. -- authenticate token with max lifetime set 100 times to make sure it stays good. -- update to handle new output of cs_authToken::get_token_data() -- uniqueness test (adds lots of extra tests, but really helps to ensure the hash is unique). * authTokenTester::tokenData(): -- added $onlyNonExpired=true arg to match called method args. Modified Paths: -------------- trunk/0.3/tests/testOfCSWebAppLibs.php Modified: trunk/0.3/tests/testOfCSWebAppLibs.php =================================================================== --- trunk/0.3/tests/testOfCSWebAppLibs.php 2009-08-20 17:33:51 UTC (rev 123) +++ trunk/0.3/tests/testOfCSWebAppLibs.php 2009-08-20 18:15:30 UTC (rev 124) @@ -71,38 +71,52 @@ $tok = new authTokenTester($db); //Generic test to ensure we get the appropriate data back. - $tokenData = $tok->create_token(1, 'test', 'abc123'); - $this->assertTrue(is_array($tokenData)); - $this->assertTrue((count($tokenData) == 2)); - $this->assertTrue(isset($tokenData['id'])); - $this->assertTrue(isset($tokenData['hash'])); - $this->assertTrue(($tokenData['id'] > 0)); - $this->assertTrue((strlen($tokenData['hash']) == 32)); + { + $tokenData = $tok->create_token(1, 'test', 'abc123'); + $this->basic_token_tests($tokenData, 1, 'test'); + + $this->assertEqual($tok->authenticate_token($tokenData['id'], 'test', $tokenData['hash']), 1); + $this->assertFalse($tok->authenticate_token($tokenData['id'], 'testx', $tokenData['hash'])); + $this->assertFalse($tok->authenticate_token($tokenData['id'], 'test', 'abcdefg')); + $this->assertFalse($tok->authenticate_token($tokenData['id'], 'test', '12345678901234567890123456789012')); + $this->assertFalse($tok->authenticate_token(99999, 'test', '12345678901234567890123456789012')); + + //check to make sure the data within this token shows only ONE attempt. + $checkData = $tok->tokenData($tokenData['id']); + $this->assertEqual($checkData['auth_token_id'], $tokenData['id']); + $this->assertEqual($checkData['total_uses'], 1); + } - $this->assertEqual($tok->authenticate_token($tokenData['id'], 'test', $tokenData['hash']), 1); - //create a token with only 1 available use and try to authenticate it twice. { //Generic test to ensure we get the appropriate data back. $tokenData = $tok->create_token(1, 'test', 'abc123', null, 1); $this->basic_token_tests($tokenData, 1, 'test'); - if(!$this->assertEqual($tok->authenticate_token($tokenData['id'], 'test', $tokenData['hash']), 1)) { - $this->gfObj->debug_print($tok->tokenData($tokenData['id']),1); - } - if(!$this->assertTrue(($tok->authenticate_token($tokenData['id'], 'test', $tokenData['hash']) === null), "Able to authenticate twice on a token with only 1 use")) { - $this->gfObj->debug_print($tok->tokenData($tokenData['id'])); - } + $this->assertEqual($tok->authenticate_token($tokenData['id'], 'test', $tokenData['hash']), 1); + $this->assertTrue(($tok->authenticate_token($tokenData['id'], 'test', $tokenData['hash']) === null), + "Able to authenticate twice on a token with only 1 use"); + $this->assertFalse($tok->tokenData($tokenData['id'], true)); + $this->assertFalse($tok->tokenData($tokenData['id'], false)); } - //now create a token with a maximum lifetime... + //now create a token with a maximum lifetime (make sure we can call it a ton of times) { //Generic test to ensure we get the appropriate data back. $tokenData = $tok->create_token(1, 'test', 'abc123', '2 years'); $this->basic_token_tests($tokenData, 1, 'test'); $this->assertEqual($tok->authenticate_token($tokenData['id'], 'test', $tokenData['hash']), 1); + $checkAttempts = 100; + $successAttempts = 0; + for($i=0; $i < 100; $i++) { + $id = $tok->authenticate_token($tokenData['id'], 'test', $tokenData['hash']); + if($this->assertEqual($tok->authenticate_token($tokenData['id'], 'test', $tokenData['hash']), 1)) { + $successAttempts++; + } + } + $this->assertEqual($checkAttempts, $successAttempts); } //try to create a token with max_uses of 0. @@ -110,7 +124,6 @@ $tokenData = $tok->create_token(2, 'test', 'xxxxyyyyyxxxx', null, 0); $this->basic_token_tests($tokenData, 2, 'test'); $checkData = $tok->tokenData($tokenData['id']); - $checkData = $checkData[$tokenData['id']]; $this->assertTrue(is_array($checkData)); $this->assertEqual($tokenData['id'], $checkData['auth_token_id']); @@ -125,6 +138,33 @@ $this->assertFalse($tok->authenticate_token($tokenData['id'], 'test', $tokenData['hash'])); } } + + //make sure we don't get the same hash when creating multiple tokens with the same data. + //NOTE: this pushes the number of tests up pretty high, but I think it is required to help ensure hash uniqueness. + { + $uid=rand(1,999999); + $checksum = 'multiple ToKEN check'; + $hashThis = "Lorem ipsum dolor sit amet. "; + + $numTests = 30; + $numPass = 0; + $tokenList = array(); + for($i=0;$i<$numTests;$i++) { + $tokenList[$i] = $tok->create_token($uid, $checksum, $hashThis); + } + $lastItem = ($numTests -1); + for($i=0;$i<$numTests;$i++) { + $checkHash = $tokenList[$i]['hash']; + $uniq=0; + foreach($tokenList as $k=>$a) { + //check against everything BUT itself. + if($i != $k && $this->assertNotEqual($checkHash, $a['hash'])) { + $uniq++; + } + } + $this->assertEqual($uniq, ($numTests -1)); + } + } }//end test_token_basics() //-------------------------------------------------------------------------- @@ -151,8 +191,8 @@ class authTokenTester extends cs_authToken { public $isTest=true; - public function tokenData($id) { - return($this->get_token_data($id)); + public function tokenData($id, $onlyNonExpired=true) { + return($this->get_token_data($id, $onlyNonExpired)); } } ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-08-20 17:34:02
|
Revision: 123 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=123&view=rev Author: crazedsanity Date: 2009-08-20 17:33:51 +0000 (Thu, 20 Aug 2009) Log Message: ----------- Fix a test to use the correct checksum value. Modified Paths: -------------- trunk/0.3/tests/testOfCSWebAppLibs.php Modified: trunk/0.3/tests/testOfCSWebAppLibs.php =================================================================== --- trunk/0.3/tests/testOfCSWebAppLibs.php 2009-08-20 16:21:45 UTC (rev 122) +++ trunk/0.3/tests/testOfCSWebAppLibs.php 2009-08-20 17:33:51 UTC (rev 123) @@ -121,7 +121,7 @@ { $tokenData = $tok->create_token(88, 'test', 'This is a big old TEST', '-3 days'); if($this->assertTrue(is_array($tokenData))) { - $this->basic_token_tests($tokenData, 88, 'This is a big old TEST'); + $this->basic_token_tests($tokenData, 88, 'test'); $this->assertFalse($tok->authenticate_token($tokenData['id'], 'test', $tokenData['hash'])); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |