public function controller_category($args) { $vars["category"] = $args["category"]; if (is_string($vars["category"])) { $categories = DataManager::fetch("db.demos.{$vars['category']}", "demo_categories", array("category" => $vars["category"])); $vars["category"] = $categories[0]; } return $this->GetComponentResponse("./category.tpl", $vars); }
public static function init() { $cookieinfo = explode(",", $_COOKIE['fl-uid']); $fluid = $cookieinfo[0]; $device = DataManager::fetch("db.session.{$deviceid}:nocache", "usersession.usersession", array("fl_uid" => $fluid)); if (count($device) == 1) { self::set(preg_match("/^a:\\d+:{/", $device[0]["data"]) ? unserialize($device[0]["data"]) : json_decode($device[0]["data"])); } }
/** * mysql session write handler. * Persist the entire portion of $_SESSION["persist"] to DB. * Refresh memcache with $_SESSION. * * @param string session id * @param string data to write */ public function write($id, $data) { Profiler::StartTimer("SessionManager::write", 1); // Save user, and all associated lists, settings, etc. Profiler::StartTimer("SessionManager::write - save user"); $user = User::singleton(); $user->save(); Profiler::StopTimer("SessionManager::write - save user"); $pdata = $_SESSION["persist"]; strip_nulls($pdata); // compare the persist data before and after for changes $pdata_serialize = serialize($pdata); //Logger::Warn($pdata_serialize); //$data = $this->cache_obj->get($id); $data = DataManager::fetch("memcache.session#{$id}", $id); $pdata_before = $data["persist"]; $pdata_before_serialize = serialize($pdata_before); // update the memcache with the entire $_SESSION //$session_serialize = serialize($_SESSION); //$this->cache_obj->set($id, $_SESSION, 0); $data = DataManager::update("memcache.session#{$id}", $id, $_SESSION); if (empty($pdata) || is_null($pdata)) { $new_crc = 0; } else { $new_crc = strlen($pdata_serialize) . crc32($pdata_serialize); } if ($this->crc != $new_crc) { // if the user does not have a record already, create one first // NOTE from James - removed '&& (! $pdata["user"]["userid"]' from below, didn't seem to make sense... if ($this->has_db_record == false) { $this->create_new_persist_record(); // need to set the session cache again with we set the has_db_record param //$session_serialize = serialize($_SESSION); //$this->cache_obj->set($id, $_SESSION, 0, $this->session_cache_expire); DataManager::update("memcache.session#{$id}", $id, $_SESSION); } else { $result = $this->data->QueryUpdate($this->sessionsource . "#{$this->fluid}", $this->sessiontable, array($this->fluid => array("data" => $pdata_serialize)), array("fl_uid" => $this->fluid)); Logger::Info("Updating userdata.usersession record for {$this->fluid}"); } } Profiler::StopTimer("SessionManager::write"); }