Index: branches/5.0.x/core/kernel/session/session.php
===================================================================
diff -u -r12323 -r12368
--- branches/5.0.x/core/kernel/session/session.php (.../session.php) (revision 12323)
+++ branches/5.0.x/core/kernel/session/session.php (.../session.php) (revision 12368)
@@ -1,6 +1,6 @@
TimestampField => $session->Expiration
);
+ // default values + additional values + values set during this script run
+ $additional_fields = array_merge($additional_fields, $this->DirectVars); // used 2 times later
$fields_hash = array_merge($fields_hash, $additional_fields);
$this->Conn->doInsert($fields_hash, $this->TableName);
@@ -245,9 +247,9 @@
unset($this->OriginalData[$var]);
}
- function GetFromData(&$session, $var)
+ function GetFromData(&$session, $var, $default = false)
{
- return getArrayValue($this->OriginalData, $var);
+ return array_key_exists($var, $this->OriginalData) ? $this->OriginalData[$var] : $default;
}
function GetExpiredSIDs()
@@ -428,6 +430,13 @@
var $SessionSet = false;
/**
+ * Session ID is used from GET
+ *
+ * @var bool
+ */
+ var $_fromGet = false;
+
+ /**
* Enter description here...
*
* @var SessionStorage
@@ -444,16 +453,17 @@
var $Data;
/**
- * Names of optional session keys (which does not need to be always stored
+ * Names of optional session keys with their optional values (which does not need to be always stored)
*
- * @var array
+ * @var Array
*/
- var $OptionalData = array();
+ var $OptionalData = Array ();
- function Session($mode=smAUTO)
+ function Session($mode = smAUTO)
{
parent::kBase();
+
$this->SetMode($mode);
}
@@ -544,7 +554,7 @@
$expired_sids = $this->DeleteExpired();
$my_sid_expired = in_array($this->CachedSID, $expired_sids);
- if ( ($expired_sids && $my_sid_expired) || ($this->CachedSID && !$this->SessionSet) ) {
+ if ( ($expired_sids && $my_sid_expired) || ($this->CachedSID && !$this->_fromGet && !$this->SessionSet) ) {
$this->RemoveSessionCookie();
// true was here to force new session creation, but I (kostja) used
// RemoveCookie a line above, to avoid redirect loop with expired sid
@@ -581,51 +591,20 @@
return preg_match($reg, getArrayValue($_SERVER, 'HTTP_REFERER') ) || (defined('IS_POPUP') && IS_POPUP);
}
- /*function CheckDuplicateCookies()
- {
- if (isset($_SERVER['HTTP_COOKIE'])) {
- $cookie_str = $_SERVER['HTTP_COOKIE'];
- $cookies = explode('; ', $cookie_str);
- $all_cookies = array();
- foreach ($cookies as $cookie) {
- list($name, $value) = explode('=', $cookie);
- if (isset($all_cookies[$name])) {
- //double cookie name!!!
- $this->RemoveCookie($name);
- }
- else $all_cookies[$name] = $value;
- }
- }
- }
-
- function RemoveCookie($name)
- {
- $path = $_SERVER['PHP_SELF'];
- $path_parts = explode('/', $path);
- $cur_path = '';
- setcookie($name, false, null, $cur_path);
- foreach ($path_parts as $part) {
- $cur_path .= $part;
- setcookie($name, false, null, $cur_path);
- $cur_path .= '/';
- setcookie($name, false, null, $cur_path);
- }
- }*/
-
function CheckIfCookiesAreOn()
{
-// $this->CheckDuplicateCookies();
- if ($this->Mode == smGET_ONLY)
- {
+ if ($this->Mode == smGET_ONLY) {
//we don't need to bother checking if we would not use it
$this->CookiesEnabled = false;
return;
}
+
$http_query =& $this->Application->recallObject('HTTPQuery');
- $cookies_on = isset($http_query->Cookie['cookies_on']); // not good here
+ $cookies_on = array_key_exists('cookies_on', $http_query->Cookie); // not good here
$get_sid = getArrayValue($http_query->Get, $this->GETName);
- if ($this->IsHTTPSRedirect() && $get_sid) { //Redirect from http to https on different domain
+
+ if ($this->IsHTTPSRedirect() && $get_sid) { // Redirect from http to https on different domain
$this->OriginalMode = $this->Mode;
$this->SetMode(smGET_ONLY);
}
@@ -642,8 +621,10 @@
$this->SetCookie('cookies_on', 1, adodb_mktime() + 31104000); //one year should be enough
}
}
- else
+ else {
$this->CookiesEnabled = true;
+ }
+
return $this->CookiesEnabled;
}
@@ -677,7 +658,7 @@
//try to load session by sid, if everything is fine
$result = $this->LoadSession($sid);
- $this->SessionSet = $result;
+ $this->SessionSet = $result; // fake front-end session will given "false" here
return $result;
}
@@ -705,9 +686,13 @@
function GetPassedSIDValue($use_cache = 1)
{
- if (!empty($this->CachedSID) && $use_cache) return $this->CachedSID;
+ if (!empty($this->CachedSID) && $use_cache) {
+ return $this->CachedSID;
+ }
+
$http_query =& $this->Application->recallObject('HTTPQuery');
$get_sid = getArrayValue($http_query->Get, $this->GETName);
+ $sid_from_get = $get_sid ? true : false;
if ($this->Application->GetVar('admin') == 1 && $get_sid) {
$sid = $get_sid;
@@ -717,30 +702,37 @@
case smAUTO:
//Cookies has the priority - we ignore everything else
$sid = $this->CookiesEnabled ? $this->GetSessionCookie() : $get_sid;
+
+ if ($this->CookiesEnabled) {
+ $sid_from_get = false;
+ }
break;
+
case smCOOKIES_ONLY:
$sid = $this->GetSessionCookie();
break;
+
case smGET_ONLY:
$sid = $get_sid;
break;
+
case smCOOKIES_AND_GET:
$cookie_sid = $this->GetSessionCookie();
//both sids should match if cookies are enabled
- if (!$this->CookiesEnabled || ($cookie_sid == $get_sid))
- {
+ if (!$this->CookiesEnabled || ($cookie_sid == $get_sid)) {
$sid = $get_sid; //we use get here just in case cookies are disabled
}
- else
- {
+ else {
$sid = '';
+ $sid_from_get = false;
}
break;
}
}
-
$this->CachedSID = $sid;
+ $this->_fromGet = $sid_from_get;
+
return $this->CachedSID;
}
@@ -786,43 +778,61 @@
*/
function setSID($new_sid)
{
- $this->SID = $this->CachedSID = $new_sid;
+ $this->SID /*= $this->CachedSID*/ = $new_sid; // don't set cached sid here
$this->Application->SetVar($this->GETName,$new_sid);
}
function NeedSession()
{
$data = $this->Data->GetParams();
+
$data_keys = array_keys($data);
- $optional_keys = array_unique($this->OptionalData);
+ $optional_keys = array_keys($this->OptionalData);
$real_keys = array_diff($data_keys, $optional_keys);
+
return $real_keys ? true : false;
}
function SetSession($force = false)
{
- if ($this->SessionSet && !$force) return true;
+ if ($this->SessionSet && !$force) {
+ return true;
+ }
+
if (!$force && !($this->Application->IsAdmin() || $this->Application->GetVar('admin')) && !$this->NeedSession()) {
// don't create session (in db) on Front-End, when sid is present (GPC), but data in db isn't
- $this->GenerateSID();
+ if ($this->_fromGet) {
+ // set sid, that was given in GET
+ $this->setSID( $this->GetPassedSIDValue() );
+ } else {
+ // re-generate sid only, when cookies are used
+ $this->GenerateSID();
+ }
return false;
}
- if (!$this->SID || $force) $this->GenerateSID();
+ if (!$this->SID || $force) {
+ $this->GenerateSID();
+ }
+
$this->Expiration = adodb_mktime() + $this->SessionTimeout;
+
switch ($this->Mode) {
case smAUTO:
if ($this->CookiesEnabled) {
$this->SetSessionCookie();
}
break;
+
case smGET_ONLY:
break;
+
case smCOOKIES_ONLY:
case smCOOKIES_AND_GET:
$this->SetSessionCookie();
break;
}
+
$this->Storage->StoreSession($this);
if ($this->Application->IsAdmin() || $this->Special == 'admin') {
@@ -909,29 +919,39 @@
$this->SID = $this->CachedSID = '';
$this->SessionSet = false;
- if ($this->CookiesEnabled) $this->SetSessionCookie(); //will remove the cookie due to value (sid) is empty
+// if ($this->CookiesEnabled) {
+ // remove cookie, because we will have fake session and it should be getting sid left in cookies
+ $this->SetSessionCookie(); //will remove the cookie due to value (sid) is empty
+// }
$this->SetSession(true); //will create a new session, true to force
}
function NeedQueryString($use_cache = 1)
{
- if ($this->CachedNeedQueryString != null && $use_cache) return $this->CachedNeedQueryString;
+ if ($this->CachedNeedQueryString != null && $use_cache) {
+ return $this->CachedNeedQueryString;
+ }
$result = false;
- switch ($this->Mode)
- {
+ switch ($this->Mode) {
case smAUTO:
- if (!$this->CookiesEnabled) $result = true;
+ if (!$this->CookiesEnabled) {
+ $result = true;
+ }
break;
+
/*case smCOOKIES_ONLY:
break;*/
+
case smGET_ONLY:
case smCOOKIES_AND_GET:
$result = true;
break;
}
+
$this->CachedNeedQueryString = $result;
+
return $result;
}
@@ -940,7 +960,7 @@
$this->Data->AddParams($this->Storage->LoadData($this));
}
- function PrintSession($comment='')
+ function PrintSession($comment = '')
{
if (defined('DEBUG_MODE') && $this->Application->isDebugMode() && constOn('DBG_SHOW_SESSIONDATA')) {
// dump session data
@@ -953,7 +973,22 @@
}
}
$this->Application->Debugger->dumpVars($session_data);
+
+ // dump real keys
+ $data_keys = array_keys($session_data);
+ $optional_keys = array_keys($this->OptionalData);
+ $real_keys = array_diff($data_keys, $optional_keys);
+
+ if ($real_keys) {
+ $ret = '';
+ foreach ($real_keys as $real_key) {
+ $ret .= '[' . $real_key . '] = [' . $session_data[$real_key] . ']
';
+ }
+
+ $this->Application->Debugger->appendHTML('Real Keys:
' . $ret);
+ }
}
+
if (defined('DEBUG_MODE') && $this->Application->isDebugMode() && constOn('DBG_SHOW_PERSISTENTDATA')) {
// dump persistent session data
if ($this->Storage->PersistentVars) {
@@ -1027,6 +1062,10 @@
elseif ($this->Application->GetVar('admin')) {
// admin checking by session data to prevent recursive session save
if (!$this->RecallVar('admin')) {
+ // bug: we get recursion in this place, when cookies are disabled in browser and we are browsing
+ // front-end in admin's frame (front-end session is initialized using admin's sid and they are
+ // mixed together)
+
$admin_session =& $this->Application->recallObject('Session.admin');
/* @var $admin_session Session */
@@ -1063,6 +1102,11 @@
$params['__URLENCODE__'] = 1; // uses "&" instead of "&" for url part concatenation + replaces "\" to "%5C" (works in HTML)
+
+ if ($this->Application->GetVar('admin') && !array_key_exists('admin', $params) && !defined('EDITING_MODE')) {
+ $params['editing_mode'] = ''; // used in kApplication::Run
+ }
+
$params = array_merge($this->Application->getPassThroughVariables($params), $params);
$ret = $this->Application->BuildEnv($t, $params, 'all');
@@ -1076,9 +1120,20 @@
function StoreVar($name, $value, $optional = false)
{
$this->Data->Set($name, $value);
+
if ($optional) {
- $this->OptionalData[] = $name;
+ // make variable optional, also remember optional value
+ $this->OptionalData[$name] = $value;
}
+ elseif (!$optional && array_key_exists($name, $this->OptionalData)) {
+ if ($this->OptionalData[$name] == $value) {
+ // same value as optional -> don't remove optional mark
+ return ;
+ }
+
+ // make variable non-optional
+ unset($this->OptionalData[$name]);
+ }
}
function StorePersistentVar($name, $value)
@@ -1130,7 +1185,14 @@
*/
function RestoreVar($name)
{
- return $this->StoreVar($name, $this->Storage->GetFromData($this, $name));
+ $value = $this->Storage->GetFromData($this, $name, '__missing__');
+
+ if ($value === '__missing__') {
+ // there is nothing to restore (maybe session was not saved), look in optional variable values
+ $value = array_key_exists($name, $this->OptionalData) ? $this->OptionalData[$name] : false;
+ }
+
+ return $this->StoreVar($name, $value);
}
function GetField($var_name, $default = false)
Index: branches/5.0.x/core/kernel/utility/http_query.php
===================================================================
diff -u -r12323 -r12368
--- branches/5.0.x/core/kernel/utility/http_query.php (.../http_query.php) (revision 12323)
+++ branches/5.0.x/core/kernel/utility/http_query.php (.../http_query.php) (revision 12368)
@@ -1,6 +1,6 @@
Get = $this->AddVars($_GET);
+ if (array_key_exists('sid', $_GET)) {
+ $this->_sidInQueryString = true;
+ }
+
$vars = $this->processQueryString( $this->Get(ENV_VAR_NAME) );
+
+ if (array_key_exists('sid', $vars)) {
+ // used by Session::GetPassedSIDValue
+ $this->Get['sid'] = $vars['sid'];
+ }
+
$this->AddParams($vars);
break;
@@ -566,6 +583,10 @@
{
$unset_vars = Array (ENV_VAR_NAME, 'rewrite', '_mod_rw_url_', 'Action');
+ if (!$this->_sidInQueryString) {
+ $unset_vars[] = 'sid';
+ }
+
$ret = $this->Get;
foreach ($unset_vars as $var_name) {
if( isset($ret[$var_name]) ) {
Index: branches/5.0.x/core/units/captcha/captcha_eh.php
===================================================================
diff -u -r12299 -r12368
--- branches/5.0.x/core/units/captcha/captcha_eh.php (.../captcha_eh.php) (revision 12299)
+++ branches/5.0.x/core/units/captcha/captcha_eh.php (.../captcha_eh.php) (revision 12368)
@@ -1,6 +1,6 @@
Application->recallObject('CaptchaHelper');
/* @var $captcha_helper kCaptchaHelper */
- // generate captcha code
- $captcha_helper->prepareCode($event->MasterEvent);
-
// create field for captcha code storage
$virtual_fields = $this->Application->getUnitOption($event->MasterEvent->Prefix, 'VirtualFields');
$virtual_fields['Captcha'] = Array ('type' => 'string', 'default' => '');
Index: branches/5.0.x/core/units/helpers/captcha_helper.php
===================================================================
diff -u -r12306 -r12368
--- branches/5.0.x/core/units/helpers/captcha_helper.php (.../captcha_helper.php) (revision 12306)
+++ branches/5.0.x/core/units/helpers/captcha_helper.php (.../captcha_helper.php) (revision 12368)
@@ -1,6 +1,6 @@
Application->IsAdmin() || $this->Application->RecallVar($event->getPrefixSpecial() . '_captcha_code')) {
+ if ($this->Application->IsAdmin() || $this->Application->RecallVar($variable_name)) {
// when code found don't generate it 2nd time
- return ;
+ return $this->Application->RecallVar($variable_name);
}
- $this->Application->StoreVar($event->getPrefixSpecial() . '_captcha_code', $this->GenerateCaptchaCode());
+ $code = $this->GenerateCaptchaCode();
+ $this->Application->StoreVar($variable_name, $code);
+
+ return $code;
}
/**
@@ -164,7 +167,10 @@
$object =& $event->getObject();
/* @var $object kDBItem */
- if ($object->GetDBField('Captcha') != $this->Application->RecallVar($event->getPrefixSpecial() . '_captcha_code')) {
+ $valid_code = $this->Application->RecallVar($event->getPrefixSpecial() . '_captcha_code');
+
+ if (!$object->GetDBField('Captcha') || ($object->GetDBField('Captcha') != $valid_code)) {
+ // empty code OR codes doesn't match
$object->SetError('Captcha', 'captcha_error', 'lu_captcha_error');
$this->Application->StoreVar($event->getPrefixSpecial() . '_captcha_code', $this->GenerateCaptchaCode());
Index: branches/5.0.x/core/kernel/application.php
===================================================================
diff -u -r12366 -r12368
--- branches/5.0.x/core/kernel/application.php (.../application.php) (revision 12366)
+++ branches/5.0.x/core/kernel/application.php (.../application.php) (revision 12368)
@@ -1,6 +1,6 @@
Session->SetField('GroupList', $user_groups);
- $this->StoreVar('UserGroups', $user_groups);
+ $this->StoreVar('UserGroups', $user_groups, true); // true for optional
}
$this->HttpQuery->AfterInit();
@@ -382,7 +382,9 @@
}*/
if ($this->GetVar('m_cat_id') === false) $this->SetVar('m_cat_id', 0);
- if( !$this->RecallVar('curr_iso') ) $this->StoreVar('curr_iso', $this->GetPrimaryCurrency() );
+ if (!$this->RecallVar('curr_iso')) {
+ $this->StoreVar('curr_iso', $this->GetPrimaryCurrency(), true); // true for optional
+ }
$this->SetVar('visits_id', $this->RecallVar('visit_id') );
@@ -1235,7 +1237,7 @@
/**
* Allows to parse given block name or include template
*
- * @param Array $params Parameters to pass to block/template. Reserved parameter "name" used to specify block/template name.
+ * @param Array $params Parameters to pass to block. Reserved parameter "name" used to specify block name.
* @param Array $pass_params Forces to pass current parser params to this block/template. Use with cauntion, because you can accidently pass "block_no_data" parameter.
* @param bool $as_template
* @return string
@@ -1250,6 +1252,17 @@
}
/**
+ * Allows to include template with a given name and given parameters
+ *
+ * @param Array $params Parameters to pass to template. Reserved parameter "name" used to specify template name.
+ * @return string
+ */
+ function IncludeTemplate($params)
+ {
+ return $this->Parser->IncludeTemplate($params, isset($block_params['is_silent']) ? 1 : 0);
+ }
+
+ /**
* Returns index file, that could be passed as parameter to method, as parameter to tag and as constant or not passed at all
*
* @param string $prefix
@@ -1936,7 +1949,7 @@
$this->SetVar('u_id', $user_id);
}
- $this->StoreVar('user_id', $user_id);
+ $this->StoreVar('user_id', $user_id, $user_id == -2); // storing Guest user_id (-2) is optional
if ($this->GetVar('expired') == 1) {
// this parameter is set only from admin
Index: branches/5.0.x/core/kernel/db/dbitem.php
===================================================================
diff -u -r12323 -r12368
--- branches/5.0.x/core/kernel/db/dbitem.php (.../dbitem.php) (revision 12323)
+++ branches/5.0.x/core/kernel/db/dbitem.php (.../dbitem.php) (revision 12368)
@@ -1,6 +1,6 @@
Application->GetTopmostPrefix($this->Prefix);
- $this->Application->StoreVar($main_prefix.'_modified', '1');
+ $this->Application->StoreVar($main_prefix.'_modified', '1', !$this->Application->IsAdmin());
if ($this->ShouldLogChanges()) {
$this->LogChanges($main_prefix, $mode);
Index: branches/5.0.x/core/kernel/db/db_event_handler.php
===================================================================
diff -u -r12299 -r12368
--- branches/5.0.x/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 12299)
+++ branches/5.0.x/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 12368)
@@ -1,6 +1,6 @@
Application->SetVar($event->getPrefixSpecial().'_selected_ids', implode(',',$ret));
- $this->Application->LinkVar($event->getPrefixSpecial().'_selected_ids', $session_name);
+ $this->Application->LinkVar($event->getPrefixSpecial().'_selected_ids', $session_name, '', !$ret); // optional when IDs are missing
// This is critical - otherwise getPassedID will return last ID stored in session! (not exactly true)
// this smells... needs to be refactored
@@ -709,7 +709,7 @@
$object =& $event->getObject();
$object->SetPerPage($per_page);
- $this->Application->StoreVarDefault($event->getPrefixSpecial().'_Page', 1);
+ $this->Application->StoreVarDefault($event->getPrefixSpecial().'_Page', 1, true); // true for optional
$page = $this->Application->GetVar($event->getPrefixSpecial().'_Page');
if (!$page) {
Index: branches/5.0.x/core/kernel/db/cat_event_handler.php
===================================================================
diff -u -r12365 -r12368
--- branches/5.0.x/core/kernel/db/cat_event_handler.php (.../cat_event_handler.php) (revision 12365)
+++ branches/5.0.x/core/kernel/db/cat_event_handler.php (.../cat_event_handler.php) (revision 12368)
@@ -1,6 +1,6 @@
getObject();
$object->SetPerPage($per_page);
- $this->Application->StoreVarDefault($event->getPrefixSpecial().'_Page', 1);
+ $this->Application->StoreVarDefault($event->getPrefixSpecial().'_Page', 1, true); // true for optional
$page = $this->Application->GetVar($event->getPrefixSpecial().'_Page');
if (!$page)
@@ -1775,15 +1775,15 @@
{
$page = $this->Application->RecallVar($event->Prefix.'_Page');
}
- if($page) $this->Application->StoreVar($event->getPrefixSpecial().'_Page', $page);
+ if($page) $this->Application->StoreVar($event->getPrefixSpecial().'_Page', $page, true); //true for optional
}
else
{
$page = $this->Application->RecallVar($event->getPrefixSpecial().'_Page');
}
}
else {
- $this->Application->StoreVar($event->getPrefixSpecial().'_Page', $page);
+ $this->Application->StoreVar($event->getPrefixSpecial().'_Page', $page, true); //true for optional
}
if( !$event->getEventParam('skip_counting') )
Index: branches/5.0.x/themes/default2009/platform/inc/captcha_image.elm.tpl
===================================================================
diff -u -r12117 -r12368
--- branches/5.0.x/themes/default2009/platform/inc/captcha_image.elm.tpl (.../captcha_image.elm.tpl) (revision 12117)
+++ branches/5.0.x/themes/default2009/platform/inc/captcha_image.elm.tpl (.../captcha_image.elm.tpl) (revision 12368)
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
Index: branches/5.0.x/core/kernel/event_manager.php
===================================================================
diff -u -r12299 -r12368
--- branches/5.0.x/core/kernel/event_manager.php (.../event_manager.php) (revision 12299)
+++ branches/5.0.x/core/kernel/event_manager.php (.../event_manager.php) (revision 12368)
@@ -1,6 +1,6 @@
Application->SetVar('m_opener', 's');
- $this->Application->StoreVar(rtrim('opener_stack_'.$wid, '_'), serialize($opener_stack));
+ $this->Application->StoreVar(rtrim('opener_stack_'.$wid, '_'), serialize($opener_stack), !$opener_stack); // empty stack is optional
}
/**
Index: branches/5.0.x/core/kernel/session/inp_session.php
===================================================================
diff -u -r12343 -r12368
--- branches/5.0.x/core/kernel/session/inp_session.php (.../inp_session.php) (revision 12343)
+++ branches/5.0.x/core/kernel/session/inp_session.php (.../inp_session.php) (revision 12368)
@@ -1,6 +1,6 @@
SessionTimeout = $this->Application->ConfigValue('SessionTimeout');
$path = (BASE_PATH == '') ? '/' : BASE_PATH;
-// if ( $this->Application->IsAdmin() ) $path = rtrim($path, '/').'/admin';
$this->SetCookiePath($path);
$cookie_name = $this->Application->ConfigValue('SessionCookieName');
- if (!$cookie_name) $cookie_name = 'sid';
- if (($this->Application->IsAdmin() && $special !== 'front') || $special == 'admin' ) { // || $this->Application->GetVar('admin') == 1
- $cookie_name = 'adm_'.$cookie_name;
+ if (!$cookie_name) {
+ $cookie_name = 'sid';
}
+
+ $admin_session = ($this->Application->IsAdmin() && $special !== 'front') || ($special == 'admin');
+
+ if ($admin_session) {
+ $cookie_name = 'adm_' . $cookie_name;
+ }
+
$this->SetCookieName($cookie_name);
$this->SetCookieDomain(SERVER_NAME);
- if( $this->Application->IsAdmin()) { // && $this->Application->GetVar('admin') != 1
+ if ($admin_session) {
$mode = smAUTO;
}
- elseif (constOn('IS_INSTALL')) {
+ elseif (defined('IS_INSTALL') && IS_INSTALL) {
$mode = smCOOKIES_ONLY;
}
else {
$ses_mode = $this->Application->ConfigValue('CookieSessions');
+
if ($ses_mode == 2) $mode = smAUTO;
if ($ses_mode == 1) $mode = smCOOKIES_ONLY;
if ($ses_mode == 0) $mode = smGET_ONLY;
}
+
$this->SetMode($mode);
- parent::Init($prefix,$special);
+ parent::Init($prefix, $special);
- if( !$this->Application->IsAdmin() && $this->GetField('PortalUserId') <= 0 )
- {
+ if (!$this->Application->IsAdmin() && $this->GetField('PortalUserId') <= 0) {
$group_list = $this->Application->ConfigValue('User_GuestGroup').','.$this->Application->ConfigValue('User_LoggedInGroup');
$this->SetField('GroupId', $this->Application->ConfigValue('User_GuestGroup'));
$this->SetField('GroupList', $group_list);
@@ -63,8 +69,12 @@
$this->Storage->DeleteEditTables();
$this->Data = new Params();
$this->SID = $this->CachedSID = '';
- if ($this->CookiesEnabled) $this->SetSessionCookie(); //will remove the cookie due to value (sid) is empty
+// if ($this->CookiesEnabled) {
+ // remove cookie, because we will have fake session and it should be getting sid left in cookies
+ $this->SetSessionCookie(); //will remove the cookie due to value (sid) is empty
+// }
+
$this->SetSession(); //will create a new session
}
Index: branches/5.0.x/core/kernel/processors/main_processor.php
===================================================================
diff -u -r12343 -r12368
--- branches/5.0.x/core/kernel/processors/main_processor.php (.../main_processor.php) (revision 12343)
+++ branches/5.0.x/core/kernel/processors/main_processor.php (.../main_processor.php) (revision 12368)
@@ -1,6 +1,6 @@
NoDebug($params);
$this->Application->SetVar('skip_last_template', 1);
$captcha_helper =& $this->Application->recallObject('CaptchaHelper');
/* @var $captcha_helper kCaptchaHelper */
- $captcha_helper->GenerateCaptchaImage(
- $this->Application->RecallVar($this->Application->GetVar('var')),
- $this->Application->GetVar('w'),
- $this->Application->GetVar('h'),
- true
- );
+ // generate captcha code
+ $code = $captcha_helper->prepareCode( $this->Application->GetVar('var') );
+
+ $captcha_helper->GenerateCaptchaImage($code, $this->Application->GetVar('w'), $this->Application->GetVar('h'), true);
}
function SID($params)