Exemplo n.º 1
0
 /**
  * 保存模块
  */
 private function saveCacheModules()
 {
     if (!$this->cacheModules) {
         throw new ZOL_Exception('The cacheModules is empty!');
     }
     $content = serialize($this->cacheModules);
     return ZOL_File::write($content, self::$cacheModulesListFile);
 }
Exemplo n.º 2
0
 public function save()
 {
     if (!self::$_entities) {
         throw new ZOL_Exception('the entities is empty!');
     }
     $content = '<?php return ' . var_export(SELF::$_entities, true) . '?>';
     return ZOL_File::write($content, self::$_entitiesListFile);
 }
Exemplo n.º 3
0
 /**
  * 写入文件缓存
  */
 public static function set($cacheKey, $data)
 {
     if (!$data || !$cacheKey) {
         return false;
     }
     #获得缓存文件的地址
     $filePath = self::getCachePath($cacheKey);
     ZOL_File::write($data, $filePath);
     return false;
 }
Exemplo n.º 4
0
 public static function add($key = '', $var = '', $expire = 3600)
 {
     if (empty($var) || empty($key)) {
         return false;
     }
     $expire = intval($expire);
     if ($expire <= 0) {
         return false;
     }
     $expire = $expire > $_SERVER['REQUEST_TIME'] ? $expire : $expire + $_SERVER['REQUEST_TIME'];
     $content = $expire . self::$separator . serialize($var);
     if (ZOL_File::exists(self::$path)) {
         // add if caching was expired
         // no write yet
         if (false == ZOL_File::write($content, self::$path)) {
             return false;
         } else {
             return true;
         }
     } else {
         return false;
     }
 }
Exemplo n.º 5
0
 public static function write($message, $type, $hasMark = true)
 {
     if (empty($message)) {
         trigger_error('$message dose not empty! ');
         return false;
     }
     if (empty($type)) {
         trigger_error('$type dose not empty! ');
         return false;
     }
     if (!isset(self::$type[$type])) {
         trigger_error('Unknow log type: ' . $type);
         return false;
     }
     $var = defined('ZOL_API_LOG') ? ZOL_API_LOG : SYSTEM_VAR;
     $path = $var . '/log/' . self::$type[$type] . '/' . date('Y/m/d') . '.log';
     if ($hasMark) {
         $mark = "\n\n===========================================================================\n";
         $mark .= 'time:' . date('Y/m/d H:i:s') . "\n";
         $message = $mark . $message;
     }
     return ZOL_File::write($message, $path, FILE_APPEND | LOCK_EX);
 }
Exemplo n.º 6
0
 public function buildStaticPage(array $data, $template, $filePath)
 {
     if (empty($data)) {
         trigger_error('$data dose not empty!');
         return false;
     }
     if (empty($template)) {
         trigger_error('$template dose not empty!');
         return false;
     }
     if (empty($filePath)) {
         trigger_error('$filePath dose not empty!');
         return false;
     }
     $output = new ZOL_Response();
     $output->add($data);
     $output->template = $template;
     $view = new ZOL_View_Simple($output);
     ZOL_File::write($view->render(), $filePath);
     return false;
 }
Exemplo n.º 7
0
 public static function setCache($html = null, $url = null)
 {
     $key = self::$_cacheKey;
     $html = is_null($html) ? self::$_html : $html;
     if (!$html) {
         return false;
     }
     $html = gzdeflate($html, 9);
     return ZOL_File::write($html, $key);
 }
Exemplo n.º 8
0
 /**
  * 设置文件缓存
  * @param array $cacheParam
  * @param mixed $content 内容
  * @param boolen $fileSyn 是否同步
  */
 public function set($cacheParam = null, $content = null, $fileSyn = false)
 {
     $this->processParam($cacheParam);
     //		var_dump($cacheParam);
     //		var_dump($this->_cacheParam);
     $this->_content = isset($content) ? $content : $this->_content;
     if (empty($this->_cachePath)) {
         return false;
     }
     //删除当前文件
     //		if (ZOL_File::exists($this->_cachePath) && empty($this->_content)) {
     //			$this->rm();
     //			return false;
     //		} elseif (empty($this->_content)) {
     //			return false;
     //		}
     if (is_object($this->_content)) {
         $this->_content = (array) $this->_content;
     }
     if (is_array($this->_content)) {
         #过滤空值
         $this->_content = self::arrayFilter($this->_content);
     }
     //var_dump($this->_content);
     #转换数据,以便保存
     $this->_convData($this->_content);
     $this->_endTime = microtime(true);
     #var_dump($this->_cachePath);
     if (ZOL_File::exists($this->_cachePath) || !empty($this->_content)) {
         //$sourceMd5 = md5($content);
         //$desMd5    = md5(ZOL_File::get($this->_cachePath));
         //if($sourceMd5 != $desMd5){#判断md5是否相同~~
         if ($fileSyn) {
             $this->fileSyn();
         }
         //}
         //			var_dump($this->_content, $this->_cachePath);
         ZOL_File::write($this->_content, $this->_cachePath);
         unset($content, $this->_content);
         return true;
     }
     return false;
 }