function set($code = null) { $this->_code = $code; if (empty($this->_code)) { if (isset($_COOKIE[OSCOM::getSite()]['language'])) { $this->_code = $_COOKIE[OSCOM::getSite()]['language']; } else { $this->_code = $this->getBrowserSetting(); } } if (empty($this->_code) || !$this->exists($this->_code)) { $this->_code = 'en_US'; } if (!isset($_COOKIE[OSCOM::getSite()]['language']) || $_COOKIE[OSCOM::getSite()]['language'] != $this->_code) { osc_setcookie(OSCOM::getSite() . '[language]', $this->_code, time() + 60 * 60 * 24 * 90); } }
function set($code = '') { $this->_code = $code; if (empty($this->_code)) { if (isset($_SESSION['language'])) { $this->_code = $_SESSION['language']; } elseif (isset($_COOKIE['language'])) { $this->_code = $_COOKIE['language']; } else { $this->_code = $this->getBrowserSetting(); } } if (empty($this->_code) || $this->exists($this->_code) === false) { $this->_code = DEFAULT_LANGUAGE; } if (!isset($_COOKIE['language']) || isset($_COOKIE['language']) && $_COOKIE['language'] != $this->_code) { osc_setcookie('language', $this->_code, time() + 60 * 60 * 24 * 90); } if (isset($_SESSION['language']) === false || isset($_SESSION['language']) && $_SESSION['language'] != $this->_code) { $_SESSION['language'] = $this->_code; } }
function start() { global $request_type, $osC_Session, $messageStack; if (ini_get('session.use_cookies') == '0') { ini_set('session.use_cookies', '1'); } if (ini_get('session.use_trans_sid') == '1') { ini_set('session.use_trans_sid', '0'); } include 'includes/classes/session.php'; $osC_Session = new osC_Session(); if (SERVICE_SESSION_FORCE_COOKIE_USAGE == '1') { osc_setcookie('cookie_test', 'please_accept_for_session', time() + 60 * 60 * 24 * 90); if (isset($_COOKIE['cookie_test'])) { $osC_Session->start(); } } elseif (SERVICE_SESSION_BLOCK_SPIDERS == '1') { $user_agent = strtolower($_SERVER['HTTP_USER_AGENT']); $spider_flag = false; if (empty($user_agent) === false) { $spiders = file('includes/spiders.txt'); foreach ($spiders as $spider) { if (empty($spider) === false) { if (strpos($user_agent, trim($spider)) !== false) { $spider_flag = true; break; } } } } if ($spider_flag === false) { $osC_Session->start(); } } else { $osC_Session->start(); } // verify the ssl_session_id if ($request_type == 'SSL' && SERVICE_SESSION_CHECK_SSL_SESSION_ID == '1' && ENABLE_SSL == true) { if (isset($_SERVER['SSL_SESSION_ID']) && ctype_xdigit($_SERVER['SSL_SESSION_ID'])) { if (isset($_SESSION['SESSION_SSL_ID']) === false) { $_SESSION['SESSION_SSL_ID'] = $_SERVER['SSL_SESSION_ID']; } if ($_SESSION['SESSION_SSL_ID'] != $_SERVER['SSL_SESSION_ID']) { $osC_Session->destroy(); osc_redirect(osc_href_link(FILENAME_INFO, 'ssl_check', 'AUTO')); } } } // verify the browser user agent if (SERVICE_SESSION_CHECK_USER_AGENT == '1') { $http_user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; if (isset($_SESSION['SESSION_USER_AGENT']) === false) { $_SESSION['SESSION_USER_AGENT'] = $http_user_agent; } if ($_SESSION['SESSION_USER_AGENT'] != $http_user_agent) { $osC_Session->destroy(); osc_redirect(osc_href_link(FILENAME_ACCOUNT, 'login', 'SSL')); } } // verify the IP address if (SERVICE_SESSION_CHECK_IP_ADDRESS == '1') { if (isset($_SESSION['SESSION_IP_ADDRESS']) === false) { $_SESSION['SESSION_IP_ADDRESS'] = osc_get_ip_address(); } if ($_SESSION['SESSION_IP_ADDRESS'] != osc_get_ip_address()) { $osC_Session->destroy(); osc_redirect(osc_href_link(FILENAME_ACCOUNT, 'login', 'SSL')); } } // add messages in the session to the message stack $messageStack->loadFromSession(); return true; }
public static function start() { Registry::set('Session', SessionClass::load()); $OSCOM_Session = Registry::get('Session'); $OSCOM_Session->setLifeTime(SERVICE_SESSION_EXPIRATION_TIME * 60); if (SERVICE_SESSION_FORCE_COOKIE_USAGE == '1' || (bool) ini_get('session.use_only_cookies') === true) { osc_setcookie('cookie_test', 'please_accept_for_session', time() + 60 * 60 * 24 * 90); if (isset($_COOKIE['cookie_test'])) { $OSCOM_Session->start(); } } elseif (SERVICE_SESSION_BLOCK_SPIDERS == '1') { $user_agent = strtolower($_SERVER['HTTP_USER_AGENT']); $spider_flag = false; if (!empty($user_agent)) { $spiders = file('includes/spiders.txt'); foreach ($spiders as $spider) { if (!empty($spider)) { if (strpos($user_agent, trim($spider)) !== false) { $spider_flag = true; break; } } } } if ($spider_flag === false) { $OSCOM_Session->start(); } } else { $OSCOM_Session->start(); } // verify the ssl_session_id if (OSCOM::getRequestType() == 'SSL' && SERVICE_SESSION_CHECK_SSL_SESSION_ID == '1' && ENABLE_SSL == true) { if (isset($_SERVER['SSL_SESSION_ID']) && ctype_xdigit($_SERVER['SSL_SESSION_ID'])) { if (!isset($_SESSION['SESSION_SSL_ID'])) { $_SESSION['SESSION_SSL_ID'] = $_SERVER['SSL_SESSION_ID']; } if ($_SESSION['SESSION_SSL_ID'] != $_SERVER['SSL_SESSION_ID']) { $OSCOM_Session->destroy(); osc_redirect(OSCOM::getLink(null, 'Info', 'SSLcheck', 'AUTO')); } } } // verify the browser user agent if (SERVICE_SESSION_CHECK_USER_AGENT == '1') { $http_user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; if (!isset($_SESSION['SESSION_USER_AGENT'])) { $_SESSION['SESSION_USER_AGENT'] = $http_user_agent; } if ($_SESSION['SESSION_USER_AGENT'] != $http_user_agent) { $OSCOM_Session->destroy(); osc_redirect(osc_href_link(FILENAME_ACCOUNT, 'login', 'SSL')); } } // verify the IP address if (SERVICE_SESSION_CHECK_IP_ADDRESS == '1') { if (!isset($_SESSION['SESSION_IP_ADDRESS'])) { $_SESSION['SESSION_IP_ADDRESS'] = osc_get_ip_address(); } if ($_SESSION['SESSION_IP_ADDRESS'] != osc_get_ip_address()) { $OSCOM_Session->destroy(); osc_redirect(osc_href_link(FILENAME_ACCOUNT, 'login', 'SSL')); } } Registry::get('MessageStack')->loadFromSession(); return true; }