Index: trunk/core/kernel/session/session.php =================================================================== diff -u -r932 -r937 --- trunk/core/kernel/session/session.php (.../session.php) (revision 932) +++ trunk/core/kernel/session/session.php (.../session.php) (revision 937) @@ -32,7 +32,7 @@ use this SID only if both cookie and query string matches. However if cookies are disabled on the client side, the script will work the same way as in GET_ONLY mode. -4. After the script has the SID it tries to laod it from the Storage (default is database) +4. After the script has the SID it tries to load it from the Storage (default is database) 5. If such SID is found in the database, the script checks its expiration time. If session is not expired, it updates its expiration, and resend the cookie (if applicable to session mode) 6. Then the script loads all the data (session variables) pertaining to the SID. @@ -62,13 +62,7 @@ var $Expiration; - var $OriginalData; - - function SessionStorage() - { - parent::kDBBase(); - $this->OriginalData = Array(); - } + var $OriginalData=Array(); function StoreSession(&$session) { @@ -108,15 +102,14 @@ function LocateSession($sid) { - $query = sprintf( "SELECT * FROM %sSessions WHERE %s = %s", + $query = sprintf( "SELECT expire FROM %sSessions WHERE %s = %s", TABLE_PREFIX, 'sid', $sid); - $result = $this->Conn->GetRow($query); - if ($result === false || $result == NULL) { - return false; - } - $this->Expiration = $result['expire']; + $result = $this->Conn->GetOne($query); + if($result===false) return false; + + $this->Expiration = $result; return true; } @@ -140,10 +133,14 @@ $ses_data = $session->Data->GetParams(); $replace = ''; - foreach ($ses_data as $key => $value) { - if (array_key_exists($key, $this->OriginalData) && $this->OriginalData[$key] == $value) + foreach ($ses_data as $key => $value) + { + if ( isset($this->OriginalData[$key]) && $this->OriginalData[$key] == $value) + { continue; //skip unchanged session data - else { + } + else + { $replace .= sprintf("(%s, %s, %s),", $session->SID, $this->Conn->qstr($key), @@ -201,7 +198,7 @@ var $Data; - function Session($mode = smAUTO) + function Session($mode=smAUTO) { parent::kBase(); $this->SetMode($mode); @@ -269,7 +266,7 @@ return; } $http_query =& $this->Application->recallObject('HTTPQuery'); - $cookies_on = $http_query->Cookie['cookies_on']; + $cookies_on = $http_query->Cookie['cookies_on']; // not good here if (!$cookies_on) { //If referer is our server, but we don't have our cookies_on, it's definetly off @@ -382,10 +379,16 @@ $sid_part_1 = ereg_replace("^0","",$sid_part_1); $sid_part_1=$digit_one.$sid_part_1; } - $this->SID = $sid_part_1.$sid_part_2.$sid_part_3; + $this->setSID($sid_part_1.$sid_part_2.$sid_part_3); return $this->SID; } + function setSID($new_sid) + { + $this->SID=$new_sid; + $this->Application->SetVar($this->GETName,$new_sid); + } + function SetSession() { $this->GenerateSID(); @@ -471,9 +474,10 @@ $this->Data->Set($name, $value); } - function RecallVar($name) + function RecallVar($name,$default=false) { - return $this->Data->Get($name); + $ret=$this->Data->Get($name); + return ($ret===false)?$default:$ret; } function RemoveVar($name) Index: trunk/core/kernel/application.php =================================================================== diff -u -r935 -r937 --- trunk/core/kernel/application.php (.../application.php) (revision 935) +++ trunk/core/kernel/application.php (.../application.php) (revision 937) @@ -162,9 +162,15 @@ $this->registerDefaultClasses(); - // to read configs before doing any recallObject + // 1. to read configs before doing any recallObject $config_reader =& $this->recallObject('kUnitConfigReader'); + + // 2. to virtually create SID and T application vars just + // in case if they are needed before ProcessRequest method call + $event_manager =& $this->recallObject('EventManager'); + $event_manager->processQueryString(); + $this->Phrases =& new PhrasesCache($this->RecallVar('LanguageId', DEFAULT_LANGUAGE_ID)); $this->ValidateLogin(); // TODO: write that method Index: trunk/core/kernel/event_manager.php =================================================================== diff -u -r932 -r937 --- trunk/core/kernel/event_manager.php (.../event_manager.php) (revision 932) +++ trunk/core/kernel/event_manager.php (.../event_manager.php) (revision 937) @@ -5,7 +5,17 @@ class kEventManager extends kDBBase { + /** + * Cache of QueryString parameters + * from config, that are represented + * in enviroment variable + * + * @var unknown_type + */ + var $queryMaps=Array(); + + /** * Build events registred for * pseudo classes. key - pseudo class * value - event name @@ -77,14 +87,19 @@ return $t; } - function ProcessRequest() + /** + * Process QueryString only, create + * events, ids, based on config + * set template name and sid in + * desired application variables. + * + * @access public + */ + function processQueryString() { // env=SID:TEMPLATE:m-1-1-1-1:l0-0-0:n-0-0-0:bb-0-0-1-1-1-0 - // 1. process QueryString $env_var =& $this->Application->GetVar(ENV_VAR_NAME); - $query_maps=Array(); - if($env_var) { $parts=explode(':',$env_var); @@ -106,8 +121,8 @@ $prefix_special=array_shift($mixed_part); // l.pick, l list($prefix)=explode('.',$prefix_special); - $query_maps[$prefix_special]=$this->Application->getUnitOption($prefix,'QueryString'); - foreach($query_maps[$prefix_special] as $index => $var_name) + $this->queryMaps[$prefix_special]=$this->Application->getUnitOption($prefix,'QueryString'); + foreach($this->queryMaps[$prefix_special] as $index => $var_name) { // l_id, l_page, l_bla-bla-bla $this->Application->SetVar($prefix_special.'_'.$var_name,$mixed_part[$index-1]); @@ -120,15 +135,19 @@ $t=$this->getTemplateName('index'); $this->Application->SetVar('t',$t); } - + } + + + function ProcessRequest() + { // 1. get events from $_POST $events=$this->Application->GetVar('events'); if($events===false) $events=Array(); // 2. if nothing there, then try to find them in $_GET - if($query_maps && !$events) + if($this->queryMaps && !$events) { // if we got $_GET type submit (links, not javascript) - foreach($query_maps as $prefix_special => $query_map) + foreach($this->queryMaps as $prefix_special => $query_map) { $query_map=array_flip($query_map); if(isset($query_map['event'])) @@ -139,7 +158,7 @@ } //print_pre($events); - $t=$this->Application->GetVar('t'); + //$t=$this->Application->GetVar('t'); foreach($events as $prefix_special => $event_name) { if(!$event_name) continue;