Thread: [Cs-webapplibs-commits] SF.net SVN: cs-webapplibs:[163] trunk/0.3/cs_sessionDB.class.php
Status: Beta
Brought to you by:
crazedsanity
From: <cra...@us...> - 2010-06-09 01:25:16
|
Revision: 163 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=163&view=rev Author: crazedsanity Date: 2010-06-09 01:25:09 +0000 (Wed, 09 Jun 2010) Log Message: ----------- Remove logging when it cleans sessions. Modified Paths: -------------- trunk/0.3/cs_sessionDB.class.php Modified: trunk/0.3/cs_sessionDB.class.php =================================================================== --- trunk/0.3/cs_sessionDB.class.php 2010-05-27 14:49:12 UTC (rev 162) +++ trunk/0.3/cs_sessionDB.class.php 2010-06-09 01:25:09 UTC (rev 163) @@ -303,11 +303,11 @@ } $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"); - } + #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()); @@ -350,4 +350,4 @@ }//end cs_session{} -?> \ 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...> - 2010-07-31 17:50:19
|
Revision: 181 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=181&view=rev Author: crazedsanity Date: 2010-07-31 17:50:13 +0000 (Sat, 31 Jul 2010) Log Message: ----------- Fix issue where session ID's aren't necessarily 32 characters long. /cs_sessionDB.class.php: * is_valid_sid(): -- length must be at least 20 (not 32) characters. * sessdb_write(): -- more info in the exception details. Modified Paths: -------------- trunk/0.3/cs_sessionDB.class.php Modified: trunk/0.3/cs_sessionDB.class.php =================================================================== --- trunk/0.3/cs_sessionDB.class.php 2010-07-23 14:17:25 UTC (rev 180) +++ trunk/0.3/cs_sessionDB.class.php 2010-07-31 17:50:13 UTC (rev 181) @@ -114,7 +114,7 @@ //------------------------------------------------------------------------- protected function is_valid_sid($sid) { $isValid = false; - if(strlen($sid) == 32) { + if(strlen($sid) >= 20) { try { $sql = "SELECT * FROM ". $this->tableName ." WHERE session_id='". $sid ."'"; @@ -231,7 +231,7 @@ } catch(exception $e) { //umm... yeah. - $this->exception_handler(__METHOD__ .": failed to perform action (". $type .")::: ". $e->getMessage()); + $this->exception_handler(__METHOD__ .": failed to perform action (". $type ."), sid=(". $sid ."), sid length=(". strlen($sid) ."), validSid=(". $this->is_valid_sid($sid) .")::: ". $e->getMessage()); } return(true); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2010-09-01 14:09:59
|
Revision: 183 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=183&view=rev Author: crazedsanity Date: 2010-09-01 14:09:53 +0000 (Wed, 01 Sep 2010) Log Message: ----------- More error handling for invalid SID's. /cs_sessionDB.class.php: * is_valid_sid(): -- call exception_handler() if something goes wrong. * sessdb_write(): -- check if the SID is the proper length, call exception handler if it is not. Modified Paths: -------------- trunk/0.3/cs_sessionDB.class.php Modified: trunk/0.3/cs_sessionDB.class.php =================================================================== --- trunk/0.3/cs_sessionDB.class.php 2010-09-01 14:07:52 UTC (rev 182) +++ trunk/0.3/cs_sessionDB.class.php 2010-09-01 14:09:53 UTC (rev 183) @@ -128,7 +128,7 @@ } } catch(exception $e) { - //well... do nothing I guess. + $this->exception_handler(__METHOD__ .": invalid sid (". $sid .")"); } } @@ -188,52 +188,57 @@ //------------------------------------------------------------------------- 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($sid) && strlen($sid) >= 20) { + $data = array( + 'session_data' => $data, + 'user_id' => null + ); + $cleanString = array( + 'session_data' => 'sql', + 'user_id' => 'numeric' + ); - if(is_string($uidVal) || is_numeric($uidVal)) { - $data['user_id'] = $uidVal; + + + //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 ."), sid=(". $sid ."), sid length=(". strlen($sid) ."), validSid=(". $this->is_valid_sid($sid) .")::: ". $e->getMessage()); + } } - - $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; + $this->exception_handler(__METHOD__ .": invalid sid (". $sid ."), DATA::: ". $this->gfObj->debug_print($data,0)); } - $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 ."), sid=(". $sid ."), sid length=(". strlen($sid) ."), validSid=(". $this->is_valid_sid($sid) .")::: ". $e->getMessage()); - } - return(true); }//end sessdb_write() //------------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |