예제 #1
0
 /**
  * 函数findrank,用户等级整合数组.
  *
  * @param $condition 用户信息
  * @param $cache_key 缓存识别
  * @param $lists_formated 用户列表
  * @param $lists 用户列表
  *
  * @return $lists_formated 用户等级整合列表
  */
 public function findrank()
 {
     $condition = '';
     $cache_key = md5($this->name . '_findrank');
     $lists_formated = cache::read($cache_key);
     if ($lists_formated) {
         return $lists_formated;
     } else {
         $lists = $this->find('all', array('conditions' => $condition));
         $lists_formated = array();
         if (is_array($lists)) {
             foreach ($lists as $k => $v) {
                 $lists_formated[$v['UserRank']['id']]['UserRank'] = $v['UserRank'];
                 if (is_array($v['UserRankI18n'])) {
                     $lists_formated[$v['UserRank']['id']]['UserRankI18n'][] = $v['UserRankI18n'];
                 }
                 $lists_formated[$v['UserRank']['id']]['UserRank']['name'] = '';
                 foreach ($lists_formated[$v['UserRank']['id']]['UserRankI18n'] as $key => $val) {
                     $lists_formated[$v['UserRank']['id']]['UserRank']['name'] .= $val['name'] . ' | ';
                 }
             }
         }
         cache::write($cache_key, $lists_formated);
         return $lists_formated;
     }
 }
예제 #2
0
 /**
  * 重构find方法,增加缓存的调用.
  *
  * @author 笨笨天才@20101127
  *
  * $params['cache']=array('use'=>true,'config'=>'short');
  * short是core.php定义的Cache:Config,默认为null
  *
  * @param string $type                      输入类型
  * @param mixed  $params                    输入参数
  * @param bool   $params['cache']['use']    是否使用缓存标志
  * @param string $params['cache']['config'] 缓存类型
  *
  * @return mixed $data 返回值
  */
 public function find($type, $params = array())
 {
     //!isset($params['cache'])
     if (isset($params['cache']) && $params['cache']['use'] !== false) {
         //判断是否不读取缓存数据
         $cache_config = isset($params['cache']['config']) ? $params['cache']['config'] : null;
         $model = isset($this->name) ? '_' . $this->name : 'appmodel';
         $paramsHash = md5(serialize($params));
         $cache_key = $model . '_' . $type . '_' . $this->locale . '_' . $paramsHash;
         //根据模型名称,type参数,多语言,params组成缓存唯一序号
         //	echo $params['cache']['config']."----".$cache_key."<br />";
         //pr($cache_config);
         $data = cache::read($cache_key, $cache_config);
         //print_r($params);
         if ($data) {
             //	echo "cached:".$cache_key."<br /><pre>";
             return $data;
         } else {
             //echo "not find cached:".$cache_key."<br /><pre>";
             //print_r($params);
             $data = parent::find($type, $params);
             cache::write($cache_key, $data, $cache_config);
             //将数据库的值写入缓存
             return $data;
         }
     } else {
         //echo "no cache:".$cache_key."<br /><pre>";
         return parent::find($type, $params);
     }
 }
예제 #3
0
 /**
  * Konstruktor
  * @param string $langCode
  * @return boolean
  */
 public function __construct($langCode)
 {
     if (!$langCode) {
         $langCode = FPCM_DEFAULT_LANGUAGE_CODE;
     }
     if (!is_dir(baseconfig::$langDir . $langCode)) {
         trigger_error('Try to load undefined language: ' . $langCode);
         return false;
     }
     $this->langCode = $langCode;
     $confFile = baseconfig::$langDir . $langCode . '/lang.cfg';
     if (!file_exists($confFile)) {
         trigger_error('Unable to find language config file in: ' . $langCode);
         return false;
     }
     $this->langList[$langCode] = file_get_contents($confFile);
     $this->helpFile = baseconfig::$langDir . $langCode . '/help.php';
     $this->cache = new cache('langcache_' . $langCode, 'system');
     if (!$this->cache->isExpired()) {
         $this->langData = $this->cache->read();
         return;
     }
     $moduleLangFiles = $langCode != FPCM_DEFAULT_LANGUAGE_CODE ? glob(baseconfig::$moduleDir . '*/*/lang/' . FPCM_DEFAULT_LANGUAGE_CODE . '/*.php') : array();
     $moduleLangFiles_langcode = glob(baseconfig::$moduleDir . '*/*/lang/' . $langCode . '/*.php');
     if (is_array($moduleLangFiles_langcode)) {
         $moduleLangFiles += $moduleLangFiles_langcode;
     }
     $langfiles = array_merge(glob(baseconfig::$langDir . $langCode . '/*.php'), is_array($moduleLangFiles) ? $moduleLangFiles : array());
     foreach ($langfiles as $file) {
         if (strpos($file, 'help.php') !== false) {
             continue;
         }
         include $file;
         if (!isset($lang)) {
             trigger_error('No language data defined in:' . $file);
             continue;
         }
         $this->langData = array_merge($this->langData, $lang);
     }
     $this->cache->write($this->langData, FPCM_LANGCACHE_TIMEOUT);
 }
예제 #4
0
 /**
  * 函数find_template 用于选择模板
  *
  * @param $sql sql语句
  * @param $cache_key 缓存的识别码
  * @param $template 缓存中读取模板
  *
  * @return $template 模板信息
  */
 public function find_template($sql)
 {
     $cache_key = md5($this->name . '_' . $sql);
     $template = cache::read($cache_key);
     if ($template) {
         return $template;
     } else {
         $template = $this->findAll($sql);
         cache::write($cache_key, $template);
         return $template;
     }
 }
 public function prepare()
 {
     global $schema, $settings;
     $this->template = "economy";
     $this->tab = 'item';
     $this->title = "State of the economy";
     $b = new backpack(false);
     $json = cache::read('item_stats.json');
     $item_stats = json_decode($json, true);
     $total_items = $item_stats['total_items'];
     $metal_index = $item_stats['total_metal'] / $item_stats['total_players'];
     $this->params['metal_index'] = $metal_index;
     krsort($this->params['effects']);
     $this->params['profiles'] = $item_stats['total_players'];
     $this->params['time'] = cache::date('item_stats.json');
 }
예제 #6
0
 /**
  * 函数findall_ranks,获取商品等级.
  *
  * @param $cache_key 缓存调取商品等级
  * @param $rank_price 商品等级价
  * @param $p_r 所有商品等级
  *
  * @return $rank_price 商品等级对应价格
  */
 public function findall_ranks()
 {
     $cache_key = md5('ProductRank_findall');
     $rank_price = cache::read($cache_key);
     if (!$rank_price) {
         $p_r = $this->findall();
         $rank_price = array();
         if (is_array($p_r) && sizeof($p_r) > 0) {
             foreach ($p_r as $k => $v) {
                 $rank_price[$v['ProductRank']['product_id']][$v['ProductRank']['rank_id']] = $v;
             }
         }
         cache::write($cache_key, $rank_price);
         return $rank_price;
     } else {
         return $rank_price;
     }
 }
예제 #7
0
 /**
  * findassoc方法,取得id=>name的数组.
  *
  * @param $locale 输入语言
  *
  * @return $lists_formated 返回取得的数组
  */
 public function findassoc($locale = '')
 {
     $condition = " Brand.status ='1' ";
     $orderby = ' orderby asc ';
     $cache_key = md5($this->name . '_' . $locale);
     $lists_formated = cache::read($cache_key);
     if ($lists_formated) {
         return $lists_formated;
     } else {
         //		$lists=$this->findall($condition,'',$orderby);
         $lists = $this->find('all', array('order' => array($orderby, 'BrandI18n.name asc'), 'fields' => array('Brand.id', 'Brand.flash_config', 'Brand.url', 'Brand.img01', 'Brand.modified', 'BrandI18n.img01', 'BrandI18n.name'), 'conditions' => array($condition)));
         $lists_formated = array();
         if (is_array($lists)) {
             foreach ($lists as $k => $v) {
                 $lists_formated[$v['Brand']['id']] = $v;
             }
         }
         cache::write($cache_key, $lists_formated);
         return $lists_formated;
     }
 }
 public function prepare()
 {
     global $schema, $settings;
     $this->template = "qualities";
     $this->tab = 'item';
     $this->title = "Quality statistics";
     $b = new backpack(false);
     $json = cache::read('item_stats.json');
     $item_stats = json_decode($json, true);
     $total_qualities = $item_stats['qualities_total'];
     $total_items = $item_stats['total_items'];
     $qualities = array();
     foreach ($item_stats['qualities'] as $c => $p) {
         $qualities[$p] = array('total' => $p / $total_items, 'quality' => $c, 'name' => quality_to_label(int_to_quality($c)), 'color' => quality_to_color(int_to_quality($c)), 'tooltip' => sprintf('<h1 class="%s">%s</h1>', int_to_quality($c), quality_to_label(int_to_quality($c))));
     }
     $this->params['qualities'] = $qualities;
     krsort($this->params['qualities']);
     //var_dump($this->params['qualities']);
     $this->params['profiles'] = $item_stats['total_players'];
     $this->params['time'] = cache::date('item_stats.json');
 }
 public function prepare()
 {
     global $schema;
     $this->template = "crates";
     $this->tab = 'item';
     $b = new backpack(false);
     $json = cache::read('item_stats_luigi.json');
     $crate_stats = json_decode($json, true);
     foreach ($crate_stats['crate_items'] as $series => $items) {
         foreach ($items as $defindex => $drops) {
             $si = $schema['items'][$defindex];
             $i = $b->get_item($si);
             //var_dump($i);
             $i['drop_rate'] = $drops / $crate_stats['crate_totals'][$series];
             $crates[$series]['items'][] = $i;
             $crates[$series]['series'] = $series;
             $crates[$series]['sample'] = $crate_stats['crate_totals'][$series];
         }
     }
     $this->title = "Crate statistics";
     $this->params['crates'] = $crates;
     $this->params['stats'] = $s;
 }
예제 #10
0
 public function find($type, $params = array())
 {
     //echo $this->locale;
     if (isset($this->cache_config) && $this->cache_config !== false) {
         //判断是否不读取缓存数据
         $model = isset($this->name) ? '_' . $this->name : 'appmodel';
         $paramsHash = serialize($params);
         $cache_key = md5($model . '_' . $type . '_' . $this->locale . '_' . $paramsHash);
         //根据模型名称,type参数,多语言,params组成缓存唯一序号
         $data = cache::read($cache_key, $this->cache_config);
         //print_r($data);
         if ($data) {
             return $data;
         } else {
             $data = parent::find($type, $params);
             cache::write($cache_key, $data, $this->cache_config);
             //将数据库的值写入缓存
             return $data;
         }
     } else {
         return parent::find($type, $params);
     }
 }
예제 #11
0
파일: rp.php 프로젝트: DINKIN/rokket
    public static function getBlog()
    {
        $cacheFile = cache::getFileName(0, 'rpBlog');
        // every 12 hours
        if (cache::exist($cacheFile, 43200)) {
            $content = json_decode(cache::read($cacheFile), true);
        } else {
            $content = apiserver::getBlogFile();
            cache::write($content, $cacheFile);
        }
        $return = [];
        foreach ($content as $blog) {
            $return[] = '
					<div class="item">
						<div class="circle"></div>
						<div class="text">
							<p><a target="_blank" href="' . $blog['link'] . '">' . $blog['name'] . '</a></p>
							<small>' . date(lang::get('dateformat'), strtotime($blog['date'])) . '</small>
						</div>
					</div>
					';
        }
        return implode(PHP_EOL, $return);
    }
예제 #12
0
 public function get_value($value, $mode = true)
 {
     $cache_config = 'short';
     if ($mode) {
         $paramsHash = md5(serialize($value));
         $cache_key = 'pic' . '_' . $paramsHash . '_file';
         $foo = cache::read($cache_key, $cache_config);
         //var_dump($foo);echo ";";$d=file_get_contents($value); imagecreatefromstring($d);die();
         //$foo = false;
         if ($foo) {
             $foo = imagecreatefromstring($foo);
             return $foo;
         } else {
             $foo = file_get_contents($value);
             cache::write($cache_key, $foo, $cache_config);
             //写入缓存
             return imagecreatefromgif($value);
         }
     }
     return imagecreatefromgif($value);
 }
예제 #13
0
 /**
  * Controller abrufen
  * @return array
  */
 public static function getControllers()
 {
     $controllerCache = new cache('controllerCache', 'system');
     if (!$controllerCache->isExpired()) {
         $controllerList = $controllerCache->read();
         if (is_array($controllerList)) {
             return $controllerList;
         }
     }
     include_once loader::libGetFilePath('spyc', 'Spyc.php');
     if (!file_exists(self::$controllerFiles['actions']) || !file_exists(self::$controllerFiles['ajax'])) {
         die('ERROR: Controller config files not found.');
     }
     $actions = \Spyc::YAMLLoad(self::$controllerFiles['actions']);
     $ajaxs = \Spyc::YAMLLoad(self::$controllerFiles['ajax']);
     $modules = self::initModuleControllers();
     $controllerList = array_unique(array_merge($actions, $ajaxs, $modules));
     $controllerCache->write($controllerList, FPCM_LANGCACHE_TIMEOUT);
     return $controllerList;
 }
예제 #14
0
파일: dyn.php 프로젝트: pasternt/dynaoCMS
 public static function getAddons()
 {
     $cacheFile = cache::getFileName(0, 'dynaoAddons');
     // jeden halben Tag
     if (cache::exist($cacheFile, 43200)) {
         $content = json_decode(cache::read($cacheFile), true);
     } else {
         $server = 'http://api.dynao.de/addons.json';
         $ch = curl_init($server);
         curl_setopt($ch, CURLOPT_PORT, 80);
         curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla (Statuscheck-Script)');
         curl_setopt($ch, CURLOPT_TIMEOUT, 0);
         curl_setopt($ch, CURLOPT_DNS_CACHE_TIMEOUT, 300);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         $curl = curl_exec($ch);
         curl_close($ch);
         $content = json_decode($curl, true);
         cache::write($content, $cacheFile);
     }
     $table = table::factory(['class' => ['table', 'table-spriped', 'table-hover']]);
     $table->addCollsLayout('60, 140, *, 110');
     $table->addRow()->addCell(lang::get('vote'))->addCell(lang::get('name'))->addCell(lang::get('description'))->addCell();
     $table->addSection('tbody');
     if (is_null($content)) {
         $table->addRow()->addCell(lang::get('no_entries'), ['colspan' => 4]);
     } else {
         foreach ($content as $addon) {
             $perc = round($addon['rate_sum'] / $addon['rate_ppl'] * 10);
             if ($perc < 33) {
                 $class = 'danger';
             } elseif ($perc < 66) {
                 $class = 'warning';
             } else {
                 $class = 'success';
             }
             $table->addRow()->addCell('<span class="label label-' . $class . '">' . $perc . '%</span>')->addCell($addon['title'])->addCell($addon['description'])->addCell('<a href="' . $addon['link'] . '" target="_blank" class="btn btn-sm btn-default">' . lang::get('download') . '</a>');
         }
     }
     return $table->show();
 }
예제 #15
0
 /**
  * Den Cache laden
  */
 protected static function loadCache()
 {
     $cacheFile = cache::getFileName(0, 'autoloadcache');
     if (!cache::exist($cacheFile, 3600)) {
         return;
     }
     list(self::$classes, self::$dirs) = json_decode(cache::read($cacheFile), true);
 }
예제 #16
0
 public static function read($id, $type = 'article')
 {
     $file = self::getFileName($id, $type);
     return parent::read(self::FOLDER . DIRECTORY_SEPARATOR . $file);
 }
예제 #17
0
파일: dyn.php 프로젝트: pasterntt/dynaoCMS
 public static function getModules()
 {
     $cacheFile = cache::getFileName(0, 'dynaoModules');
     // jeden halben Tag
     if (cache::exist($cacheFile, 43200)) {
         $content = json_decode(cache::read($cacheFile), true);
     } else {
         $content = apiserver::getModulesFile();
         cache::write($content, $cacheFile);
     }
     $table = table::factory(['class' => ['table', 'table-spriped', 'table-hover']]);
     $table->addCollsLayout('60, 140, *, 110');
     $table->addRow()->addCell(lang::get('vote'))->addCell(lang::get('name'))->addCell(lang::get('description'))->addCell();
     $table->addSection('tbody');
     if (is_null($content) || !$content) {
         $table->addRow()->addCell(lang::get('no_entries'), ['colspan' => 4]);
     } else {
         foreach ($content as $addon) {
             $perc = round($addon['rate_sum'] / $addon['rate_ppl'] * 10);
             if ($perc < 33) {
                 $class = 'danger';
             } elseif ($perc < 66) {
                 $class = 'warning';
             } else {
                 $class = 'success';
             }
             $table->addRow()->addCell('<span class="label label-' . $class . '">' . $perc . '%</span>')->addCell($addon['title'])->addCell($addon['description'])->addCell('<a href="' . $addon['link'] . '" target="_blank" class="btn btn-sm btn-default">' . lang::get('import') . '</a>');
         }
     }
     return $table->show();
 }
예제 #18
0
 /**
  * findassoc方法,取得id=>name的数组.
  *
  * @param $locale 输入语言
  *
  * @return $lists_formated 返回格式化的列表
  */
 public function findassoc($locale = '')
 {
     $condition = " CategoryProduct.status ='1' ";
     $orderby = ' orderby asc ';
     $cache_key = md5($this->name . '_' . $locale);
     $lists_formated = cache::read($cache_key);
     if ($lists_formated) {
         return $lists_formated;
     } else {
         $lists = $this->findall($condition, '', $orderby);
         $lists_formated = array();
         if (is_array($lists)) {
             foreach ($lists as $k => $v) {
                 $lists_formated[$v['CategoryProduct']['id']] = $v;
             }
         }
         cache::write($cache_key, $lists_formated);
         return $lists_formated;
     }
 }
예제 #19
0
 protected static function loadIncludes($data)
 {
     $packages = array();
     // legacy repo handling
     if (!isset($data['packages']) && !isset($data['includes'])) {
         foreach ($data as $pkg) {
             foreach ($pkg['versions'] as $metadata) {
                 $packages[] = $metadata;
             }
         }
         return $packages;
     }
     if (isset($data['packages'])) {
         foreach ($data['packages'] as $package => $versions) {
             foreach ($versions as $version => $metadata) {
                 $packages[] = $metadata;
             }
         }
     }
     if (isset($data['includes'])) {
         foreach ($data['includes'] as $include => $metadata) {
             if (cache::sha1($include) === $metadata['sha1']) {
                 $includedData = json_decode(cache::read($include), true);
             } else {
                 $includedData = self::fetchFile($include);
             }
             $packages = array_merge($packages, self::loadIncludes($includedData));
         }
     }
     return $packages;
 }
예제 #20
0
 /**
  * find_home_article方法,查询主要文章.
  *
  * @param $locale 输入语言
  *
  * @return $home_article 返回主要文章
  */
 public function find_home_article($locale)
 {
     $cache_key = md5($this->name . '_' . $locale . '_' . 'find_home_article');
     $home_article = cache::read($cache_key);
     if ($home_article) {
         return $home_article;
     } else {
         $home_article = $this->find_home_article('all', array('order' => array('Article.modified DESC'), 'conditions' => array('Article.status' => '1', 'Article.front' => '1'), 'limit' => 10));
         cache::write($cache_key, $home_article);
         return $home_article;
     }
 }