Пример #1
0
 public function fetchAllCache($cacheNames)
 {
     $cacheNames = is_array($cacheNames) ? $cacheNames : array($cacheNames);
     $data = CacheUtil::get($cacheNames);
     if (is_array($data) && in_array(false, $data, true) || !$data) {
         $data = false;
     }
     $newArray = $data !== false ? array_diff($cacheNames, array_keys($data)) : $cacheNames;
     if (empty($newArray)) {
         foreach ($data as &$cache) {
             $isSerialized = $cache == serialize(false) || @unserialize($cache) !== false;
             $cache = $isSerialized ? unserialize($cache) : $cache;
         }
         return $data;
     } else {
         $cacheNames = $newArray;
     }
     $caches = $this->fetchAll(sprintf("FIND_IN_SET(name,'%s')", implode(",", $cacheNames)));
     if ($caches) {
         foreach ($caches as $sysCache) {
             $data[$sysCache["name"]] = $sysCache["type"] ? unserialize($sysCache["value"]) : $sysCache["value"];
             CacheUtil::set($sysCache["name"], $data[$sysCache["name"]]);
         }
         foreach ($cacheNames as $name) {
             if ($data[$name] === null) {
                 $data[$name] = null;
                 CacheUtil::rm($name);
             }
         }
     }
     return $data;
 }
Пример #2
0
 public function parse($isUpdate = false)
 {
     Ibos::import("application.extensions.simple_html_dom", true);
     if ($isUpdate) {
         $model = preg_replace("/\\s+data-id\\s?=\\s?\"?\\d+\"?/i", "", $this->printmodel);
         $max = 0;
     } else {
         $model = $this->printmodel;
         $max = intval($this->itemmax);
     }
     $elements = array();
     $doc = new simple_html_dom();
     $doc->load($model, true, true, CHARSET);
     $items = $doc->find("ic");
     $config = $this->getItemConfig();
     if (!empty($items) && !empty($config)) {
         $this->refactor($items, $config, $max, $elements);
     }
     $html = $doc->save();
     $this->_cache = $elements;
     CacheUtil::set("form_" . $this->ID, $elements);
     $form["printmodelshort"] = $html;
     if ($max != $this->itemmax) {
         $form["itemmax"] = $max;
     }
     $doc->clear();
     FlowFormType::model()->modify($this->ID, $form);
 }
Пример #3
0
 public static function getSourceInfo($table, $rowId, $forApi = false, $moduleName = "weibo")
 {
     static $_forApi = "0";
     $_forApi == "0" && ($_forApi = intval($forApi));
     $key = $_forApi ? $table . $rowId . "_api" : $table . $rowId;
     $info = CacheUtil::get("source_info_" . $key);
     if ($info) {
         return $info;
     }
     switch ($table) {
         case "feed":
             $info = self::getInfoFromFeed($table, $rowId, $_forApi);
             break;
         case "comment":
             $info = self::getInfoFromComment($table, $rowId, $_forApi);
             break;
         default:
             $table = ucfirst($table);
             $model = $table::model();
             if (method_exists($model, "getSourceInfo")) {
                 $info = $model->getSourceInfo($rowId, $_forApi);
             }
             unset($model);
             break;
     }
     $info["source_table"] = $table;
     $info["source_id"] = $rowId;
     CacheUtil::set("source_info_" . $key, $info);
     return $info;
 }
Пример #4
0
 public function getNodeList()
 {
     $list = CacheUtil::get("notifyNode");
     if (!$list) {
         $list = $this->fetchAllSortByPk("node", array("order" => "`module` DESC"));
         CacheUtil::set("notifyNode", $list);
     }
     return $list;
 }
Пример #5
0
 public static function getPurv($posId)
 {
     $access = CacheUtil::get("purv_" . $posId);
     if (!$access) {
         $access = Ibos::app()->getAuthManager()->getItemChildren($posId);
         CacheUtil::set("purv_" . $posId, array_flip(array_map("strtolower", array_keys($access))));
     }
     return $access;
 }
Пример #6
0
 public static function getLogTableId()
 {
     $tableId = CacheUtil::get("logtableid");
     if ($tableId === false) {
         $tableId = Ibos::app()->db->createCommand()->select("svalue")->from("{{setting}}")->where("skey = 'logtableid'")->queryScalar();
         CacheUtil::set("logtableid", intval($tableId));
     }
     return $tableId;
 }
Пример #7
0
 public function fetchAllEnabledModule()
 {
     $module = CacheUtil::get("module");
     if ($module == false) {
         $criteria = array("condition" => "`disabled` = 0", "order" => "`sort` ASC");
         $module = $this->fetchAllSortByPk("module", $criteria);
         CacheUtil::set("module", $module);
     }
     return $module;
 }
Пример #8
0
 private function processCmdCache($cmd, $name, $ttl = 0)
 {
     $ret = "";
     switch ($cmd) {
         case "set":
             $ret = CacheUtil::set("process_lock_" . $name, TIMESTAMP, $ttl);
             break;
         case "get":
             $ret = CacheUtil::get("process_lock_" . $name);
             break;
         case "rm":
             $ret = CacheUtil::rm("process_lock_" . $name);
     }
     return $ret;
 }
Пример #9
0
 public function getUserData($uid = "")
 {
     if (empty($uid)) {
         $uid = Ibos::app()->user->uid;
     }
     if (($data = CacheUtil::get("userData_" . $uid)) === false || count($data) == 1) {
         $data = array();
         $list = $this->fetchAll("`uid` = :uid", array(":uid" => $uid));
         if (!empty($list)) {
             foreach ($list as $v) {
                 $data[$v["key"]] = (int) $v["value"];
             }
         }
         CacheUtil::set("userData_" . $uid, $data, 60);
     }
     return $data;
 }
Пример #10
0
 public function fetchAllEnabledModule()
 {
     $module = CacheUtil::get("module");
     if ($module == false) {
         $criteria = array("condition" => "`disabled` = 0", "order" => "`sort` ASC");
         $module = $this->fetchAllSortByPk("module", $criteria);
         if (defined("LICENCE_DISABLE")) {
             $disabledModules = explode(",", LICENCE_DISABLE);
         } else {
             $disabledModules = false;
         }
         if ($disabledModules) {
             foreach ($module as $index => $mod) {
                 if (in_array($mod["module"], $disabledModules)) {
                     unset($module[$index]);
                 }
             }
         }
         CacheUtil::set("module", $module);
     }
     return $module;
 }
Пример #11
0
 public static function getAllExpression($flush = false)
 {
     $cacheId = "expression";
     if (($res = CacheUtil::get($cacheId)) === false || $flush === true) {
         $filepath = "static/image/expression/";
         $expression = new Dir($filepath);
         $expression_pkg = $expression->toArray();
         $res = array();
         $typeMap = array("df" => "默认", "bm" => "暴漫");
         foreach ($expression_pkg as $index => $value) {
             list($file) = explode(".", $value["filename"]);
             list($type) = explode("_", $file);
             $temp["value"] = $file;
             $temp["phrase"] = "[" . $file . "]";
             $temp["icon"] = $value["filename"];
             $temp["type"] = $type;
             $temp["category"] = $typeMap[$type];
             $res[$temp["phrase"]] = $temp;
         }
         CacheUtil::set($cacheId, $res);
     }
     return $res;
 }
Пример #12
0
 public static function loadProcessCache($flowId)
 {
     $cacheName = "flowprocess_" . intval($flowId);
     $cache = CacheUtil::get($cacheName);
     if ($cache === false) {
         $cache = array();
         $data = Ibos::app()->db->createCommand()->select("ft.name,ft.type,fp.*")->from("{{flow_type}} ft")->leftJoin("{{flow_process}} fp", "ft.flowid = fp.flowid")->where(sprintf("ft.flowid = %d", $flowId))->order("ft.flowid,fp.processid")->queryAll();
         foreach ($data as $process) {
             $cache[$process["processid"]] = $process;
         }
         CacheUtil::set($cacheName, $cache);
     }
     return $cache;
 }
Пример #13
0
 public function handleNode($event)
 {
     CacheUtil::set("notifyNode", NULL);
     Notify::model()->getNodeList();
 }
Пример #14
0
 private static function parseAtByUserName($name)
 {
     $info = CacheUtil::get("userInfoRealName_" . md5($name[1]));
     if (!$info) {
         $info = User::model()->fetchByRealname($name[1]);
         CacheUtil::set("userInfoRealName_" . md5($name[1]), $info);
     }
     if ($info) {
         return "<a class=\"anchor\" data-toggle=\"usercard\" data-param=\"uid=" . $info["uid"] . "\" href=\"" . $info["space_url"] . "\" target=\"_blank\">" . $name[0] . "</a>";
     } else {
         return $name[0];
     }
 }
Пример #15
0
<?php

CacheUtil::set("notifyNode", null);
$diaryComments = Comment::model()->fetchAllByAttributes(array("module" => "diary"));
$cidArr = ConvertUtil::getSubByKey($diaryComments, "cid");
if (!empty($diaryComments)) {
    $cidStr = implode(",", $cidArr);
    Comment::model()->deleteAll("rowid IN({$cidStr})");
    Comment::model()->deleteAllByAttributes(array("module" => "diary"));
}
Пример #16
0
 public function getCommentInfo($id, $source = true)
 {
     $id = intval($id);
     if (empty($id)) {
         $this->addError("get", Ibos::lang("Parameters error", "error"));
         return false;
     }
     $info = CacheUtil::get("comment_info_" . $id);
     if ($info) {
         return $info;
     } else {
         $info = $this->fetchByPk($id);
         $info["user_info"] = User::model()->fetchByUid($info["uid"]);
         $info["content"] = $info["content"];
         $source && ($info["sourceInfo"] = Source::getCommentSource($info));
         $source && CacheUtil::set("comment_info_" . $id, $info);
         return $info;
     }
 }
Пример #17
0
 public function fetchAllByPk($pks)
 {
     $record = $this->fetchCaches($pks);
     if ($record === false || count($pks) != count($record)) {
         if (is_array($record) && !empty($record)) {
             $pks = array_diff($pks, array_keys($record));
         }
         if ($record === false) {
             $record = array();
         }
         if (!empty($pks)) {
             $records = $this->findAllByPk(array_merge($pks));
             if (!empty($records)) {
                 foreach ($records as $rec) {
                     $pk = $rec->getPrimaryKey();
                     $record[$pk] = $rec->attributes;
                     if ($this->getIsAllowCache()) {
                         CacheUtil::set($this->getCacheKey($pk), $rec->attributes, $this->cacheLife);
                     }
                 }
             }
         }
     }
     return $record;
 }
Пример #18
0
 private function setFeedCache($value = array(), $feedId = array())
 {
     if (!empty($feedId)) {
         !is_array($feedId) && ($feedId = explode(",", $feedId));
         $feedId = implode(",", $feedId);
         $list = Ibos::app()->db->createCommand()->select("a.*,b.clientip,b.feeddata")->from("{{feed}} a")->leftJoin("{{feed_data}} b", "a.feedid = b.feedid")->where("a.feedid IN ({$feedId})")->queryAll();
         $r = array();
         foreach ($list as &$v) {
             $parseData = $this->parseTemplate($v);
             $v["info"] = $parseData["info"];
             $v["title"] = $parseData["title"];
             $v["content"] = $parseData["content"];
             if (isset($parseData["attach_id"])) {
                 $v["attach_id"] = $parseData["attach_id"];
             }
             $v["body"] = $parseData["body"];
             $v["api_source"] = $parseData["api_source"];
             $v["actions"] = $parseData["actions"];
             $v["user_info"] = $parseData["userInfo"];
             CacheUtil::set("feed_" . $v["feedid"], $v);
             $r[$v["feedid"]] = $v;
         }
         return $r;
     } else {
         $parseData = $this->parseTemplate($value);
         $value["info"] = $parseData["info"];
         $value["title"] = $parseData["title"];
         $value["content"] = $parseData["content"];
         if (isset($parseData["attach_id"])) {
             $v["attach_id"] = $parseData["attach_id"];
         }
         $value["body"] = $parseData["body"];
         $value["api_source"] = $parseData["api_source"];
         $value["actions"] = $parseData["actions"];
         $value["user_info"] = $parseData["userInfo"];
         CacheUtil::set("feed_" . $value["feedid"], $value);
         return $value;
     }
 }