Example #1
0
 public static function write($id, $session_data)
 {
     $dbPath = SJB_PATH_BASE . '/system/core/DB.php';
     if (strstr(getcwd(), 'system\\lib')) {
         $dbPath = '../core/DB.php';
     }
     require_once $dbPath;
     SJB_DB::init(SJB_System::getSystemSettings('DBHOST'), SJB_System::getSystemSettings('DBUSER'), SJB_System::getSystemSettings('DBPASSWORD'), SJB_System::getSystemSettings('DBNAME'));
     $user_sid = 0;
     if (isset($_SESSION['current_user'])) {
         $user_sid = $_SESSION['current_user']['sid'];
     }
     if (count(SJB_DB::query("select * from session where `session_id` = ?s", $id)) > 0) {
         SJB_DB::query("update session set `data` = ?s, `time` = ?s, `user_sid` = ?n where `session_id` = ?s", $session_data, time(), $user_sid, $id);
     } else {
         SJB_DB::query("insert into session (`session_id`, `data`, `time`, `user_sid`) values (?s, ?s, ?s, ?n)", $id, $session_data, time(), $user_sid);
     }
     return true;
 }
Example #2
0
 public static function init()
 {
     SJB_DB::init(SJB_System::getSystemSettings('DBHOST'), SJB_System::getSystemSettings('DBUSER'), SJB_System::getSystemSettings('DBPASSWORD'), SJB_System::getSystemSettings('DBNAME'));
     ini_set('zlib.output_compression', SJB_System::getSettingByName('gzip_compression'));
     $GLOBALS['fatal_error_reserve_buffer'] = str_repeat('x', 1024 * 200);
     ob_start(array('SJB_Error', 'fatalErrorHandler'));
     SJB_Session::init(SJB_System::getSystemSettings('SITE_URL'));
     $sessionId = SJB_DB::queryValue("SELECT `session_id` FROM `user_session_data_storage` WHERE `session_id` = ?s", SJB_Session::getSessionId());
     // if not updated (row not exists) - insert that value
     if (empty($sessionId)) {
         SJB_DB::query("INSERT INTO `user_session_data_storage` SET `last_activity` = NOW(), `session_id` = ?s", SJB_Session::getSessionId());
     } else {
         SJB_DB::query("UPDATE `user_session_data_storage` SET `last_activity` = NOW() WHERE `session_id` = ?s", $sessionId);
     }
     //set timezone
     if (SJB_Settings::getSettingByName('timezone')) {
         ini_set('date.timezone', SJB_Settings::getSettingByName('timezone'));
     }
     // Set Error Handler and Shutdown function
     set_error_handler(array('SJB_Error', 'errorHandler'));
     register_shutdown_function(array('SJB_System', 'shutdownFunction'));
     SJB_System::prepareGlobalArrays();
     SJB_System::setGlobalTemplateVariable('is_ajax', SJB_Request::isAjax());
     SJB_System::setGlobalTemplateVariable('site_url', SJB_System::getSystemSettings('SITE_URL'));
     SJB_System::setGlobalTemplateVariable('user_site_url', SJB_System::getSystemSettings('USER_SITE_URL'));
     SJB_System::setGlobalTemplateVariable('admin_site_url', SJB_System::getSystemSettings('ADMIN_SITE_URL'));
     SJB_System::setGlobalTemplateVariable('radius_search_unit', SJB_System::getSettingByName('radius_search_unit'));
     SJB_System::setGlobalTemplateVariable('settings', SJB_Settings::getSettings());
     ThemeManager::getCurrentTheme();
     SJB_PluginManager::loadPlugins(SJB_System::getSystemSettings('PLUGINS_DIR'));
     SJB_System::setGlobalTemplateVariable('plugins', SJB_PluginManager::getAllPluginsList());
     $GLOBALS['System']['MODULE_MANAGER'] = new SJB_ModuleManager();
     SJB_Event::dispatch('moduleManagerCreated');
     $GLOBALS['System']['MODULE_MANAGER']->executeModulesStartupFunctions();
     // define if subadmin loged in and set subamdinmode for templates
     if (SJB_System::getSystemSettings('SYSTEM_ACCESS_TYPE') == SJB_System::getSystemSettings('ADMIN_ACCESS_TYPE') && SJB_SubAdmin::getSubAdminSID()) {
         SJB_System::setGlobalTemplateVariable('subAdminSID', SJB_SubAdmin::getSubAdminSID());
     }
     $GLOBALS['uri'] = SJB_Navigator::getURI();
 }