Beispiel #1
0
 /**
  * 工厂模式实例化常用缓存类
  *
  * @access public
  *
  * @param string $adapter 缓存类型
  * @param array $options 参数
  *
  * @return object
  */
 public static function factory($adapter, $options = null)
 {
     //参数分析
     if (!$adapter) {
         return false;
     }
     $adapter = trim($adapter);
     $object = false;
     //分析缓存引擎
     switch ($adapter) {
         case 'Memcache':
             $object = Cache_Memcache::getInstance($options);
             break;
         case 'Redis':
             $object = Cache_Redis::getInstance($options);
             break;
         case 'File':
         case 'Apc':
         case 'Xcache':
         case 'Wincache':
         case 'Eaccelerator':
             $object = Doit::singleton('Cache_' . $adapter);
             break;
     }
     return $object;
 }
 function __construct()
 {
     $this->mem = Cache_Memcache::getInstance();
     $this->mem->init();
     if (($this->bwl = $this->mem->get("BlackWordList")) == false) {
         $this->getBlackWordListFromDB();
     }
 }
 public function __construct()
 {
     if (Sp_Admin_User::isLogin() === FALSE) {
         header("Location: " . SP_URL_CDGN . "login/index.html");
         exit;
     }
     $userArr = Sp_Admin_User::getUser();
     $user_id = $userArr['id'];
     //单点登录验证
     $session_id = $_COOKIE['session_id'];
     $cache = Cache_Memcache::getInstance();
     $SSO_memcache_key = 'SSO_admin_user_' . $user_id;
     $SSO_memcache_data = $cache->get($SSO_memcache_key);
     if ($session_id != $SSO_memcache_data && !empty($SSO_memcache_data) && $user_id != 1) {
         echo "<script type='text/javascript'>";
         echo "alert('您的账号在其他地方登录,已被踢下线!');";
         echo "location.href = '" . SP_URL_DESK . "login/signout.html'";
         echo "</script>";
         exit;
     }
     $spAdminUser = new Sp_Admin_User();
     $userInfo = $spAdminUser->adminuser_getUserAndRole($user_id, DATA_TYPE);
     if ($userInfo['groupid'] > 0 && $userInfo['cdgn_del'] >= 0 || $userInfo['groupid'] == 1) {
         define('CDGN_GROUP', '1');
     }
     if ($userInfo['custom_groupid'] > 0 && $userInfo['custom_del'] >= 0 || $userInfo['groupid'] == 1) {
         define('CUSTOM_GROUP', '1');
     }
     if ($userInfo['ad_groupid'] > 0 && $userInfo['ad_del'] >= 0 || $userInfo['groupid'] == 1) {
         define('AD_GROUP', '1');
     }
     if ($userInfo['cs_groupid'] > 0 && $userInfo['cs_del'] >= 0 || $userInfo['groupid'] == 1) {
         define('CS_GROUP', '1');
     }
     if ($userInfo['groupid'] == 1) {
         define('CS_SYSTEM', '1');
     }
     if ($userInfo[STATUS_DEL] != 0) {
         echo "<script type='text/javascript'>";
         echo "alert('您在该管理系统没有权限,或者是被移除!')";
         echo "</script>";
         exit;
     }
     if ($userInfo['groupid'] == 1) {
         $this->_isAdmin = TRUE;
     }
     if ($userInfo['groupid'] != 1) {
         $spAdminRole = new Sp_Admin_Role();
         $spGroupInfo = $spAdminRole->adminuser_getGroupRole($userInfo[GROUP_NAME]);
         $spAdminGroupRole = is_array($spGroupInfo['rolelist']) && count($spGroupInfo['rolelist']) > 0 ? $spGroupInfo['rolelist'] : array();
         $spUserRole = is_array($userInfo['rolelist']) && count($userInfo['rolelist']) > 0 ? $userInfo['rolelist'] : array();
         $spRoleList = array_merge($spAdminGroupRole, $spUserRole);
         $this->_roleList = $spRoleList;
         $spFormatRoleList = array();
         foreach ($spRoleList as $val) {
             $spFormatRoleList[] = $val['m'] . DIRECTORY_SEPARATOR . $val['c'];
         }
         $requestUriArr = str_replace("/custom", "", $_SERVER['REQUEST_URI']);
         $requestUriArr = explode('.', $requestUriArr);
         $userPath = str_replace('/', DIRECTORY_SEPARATOR, ltrim(ltrim($requestUriArr[0], '/'), '\\'));
         $userPath = str_replace('\\', DIRECTORY_SEPARATOR, $userPath);
         $checkList = explode(DIRECTORY_SEPARATOR, $userPath);
         if ($userPath != '' && !in_array($userPath, $spFormatRoleList) && !Sp_Admin_Menu::checkWhiteList($checkList[0], $checkList[1])) {
             echo "<script type='text/javascript'>";
             echo "alert('您没有获得该权限!');";
             echo "location.href = '" . SP_URL_DESK . "';";
             echo "</script>";
             exit;
         }
     }
 }
 /**
  * 返回 Cache 对象
  *
  * @return object
  */
 protected function getCacheInstance()
 {
     if ($this->_cacheobj === null) {
         $this->_cacheobj = Cache_Memcache::getInstance();
     }
     return $this->_cacheobj;
 }
 function __construct()
 {
     $this->_isChanged = false;
     $this->_gCacheStorage = array();
     $this->context = Model_Context::getInstance();
     $this->__usePageCache = $this->context->getProperty('service.pagecache');
     $this->_gBlogId = getBlogId();
     if ($this->context->getProperty('service.memcached') == true) {
         $this->pool = Cache_Memcache::getInstance();
     } else {
         $this->pool = DBModel::getInstance();
     }
 }
$ctl_class = !empty($crl) ? ucfirst($res) . '_' . ucfirst($priv) . '_' . ucfirst($crl) : ucfirst($res) . '_' . ucfirst($priv);
Loader::loadClass($ctl_class);
if (($_SERVER['REQUEST_URI'] == '/' && (empty($testRes) && empty($testPriv)) || strpos($_SERVER['REQUEST_URI'], ".")) && class_exists($ctl_class, false)) {
    $ctl_obj = new $ctl_class();
    isset($g_timer) && $g_timer->setMarker('dust.main class instanced');
    // TODO: cache process
    $cached = checkCached($res, $priv, $crl, $request->format);
    if (is_array($cached) && isset($cached['life']) && isset($cached['cache_key'])) {
        $cache_life = $cached['life'];
        $cache_key = $cached['cache_key'];
    } else {
        $cache_life = intval($cached);
        $cache_key = sprintf("huitong_www_ac_%u_%s", crc32($_SERVER['REQUEST_URI']), $request->format);
    }
    if (!$request->isPost() && $cache_life > 0) {
        $cache = Cache_Memcache::getInstance();
        $result = $cache->get($cache_key);
        if (FALSE === $result) {
            $result = $ctl_obj->execute($request);
            $cache->set($cache_key, $result, $cache_life);
        }
    } else {
        $result = $ctl_obj->execute($request);
    }
    isset($g_timer) && $g_timer->setMarker('dust.main class executed');
    if ($result === TRUE) {
        $result = array('success' => true);
    } elseif (is_array($result) && count($result) == 3 && isset($result[0]) && isset($result[1]) && is_bool($result[0]) && is_string($result[1])) {
        $tmp = $result;
        if ($tmp[0] === TRUE) {
            $result = array('success' => true);