Exemplo n.º 1
0
 /**
  * @param $type
  * @param $id
  * @param int $sid
  * @param bool $force
  * @return bool
  */
 public function getObj($type, $id, $sid = 0, $force = false)
 {
     if ($this->enabled(!$force)) {
         $sid = $sid ? $sid : $this->_section;
         $id = (int) $id;
         $sid = (int) $sid;
         $lang = Sobi::Lang(false);
         $apc = false;
         if ($this->_apc) {
             $var = apc_fetch("com_sobipro_{$sid}_{$id}_{$type}_{$lang}", $apc);
             if (isset($var['classes'])) {
                 SPLoader::wakeUp(unserialize($var['classes']));
             }
         }
         if (!$apc) {
             $result = $this->Query("SELECT * FROM objects WHERE( type = '{$type}' AND id = '{$id}' AND lang = '{$lang}' AND sid = '{$sid}' )");
             if (!is_array($result) || !count($result)) {
                 return false;
             }
             if ($result['classes']) {
                 SPLoader::wakeUp(unserialize($result['classes']));
             }
             if ($result['schecksum'] != md5($result['data'])) {
                 Sobi::Error('cache', SPLang::e('Checksum of the encoded data does not match'), SPC::WARNING, 0, __LINE__, __FILE__);
                 return false;
             }
             $var = SPConfig::unserialize($result['data']);
         } else {
             $var = $var['obj'];
         }
         $this->_check[$type][$id] = false;
         return $var;
     } else {
         return false;
     }
 }