Example #1
0
 /**
  * 构造函数,初始化配置
  */
 private function __construct()
 {
     if (!empty(self::$FileLoader)) {
         return;
     }
     $this->day = date('Ymd', time());
     $this->dtime = date('Y-m-d H:i:s', time());
     self::$FileLoader = new FileLoader(PathGeneration::getFolder(".\\log\\") . "log_xqx_{$this->day}.log", null);
 }
Example #2
0
 protected function __construct()
 {
     $cachePath = PathGeneration::getFolder("./cache/kvdb/");
     $this->cacheFile = $cachePath . "local.tmp";
     if (is_readable($this->cacheFile)) {
         $this->data = json_decode(file_get_contents($this->cacheFile), true);
     } else {
         $this->data = array();
     }
 }
Example #3
0
 public static function append($path, $filename, &$context, $length = null)
 {
     $path = PathGeneration::getFolder($path);
     if (is_writable($path . $filename)) {
         $fp = fopen($path . $filename, "ab");
         if (fwrite($fp, $context, $length)) {
             return empty($length) ? strlen($context) : $length;
         }
     }
     return -1;
 }
Example #4
0
 /**
  * 缓存获取与设置结束,存入文件或者内存
  * @param null $cacheTime
  * @return bool
  */
 public function cacheSave($cacheTime = null)
 {
     if (isset($cacheTime) && !empty($cacheTime)) {
         $this->setCacheTime($cacheTime);
     }
     if ($this->ifGetByEcho) {
         // 获取输出缓冲数据
         $this->cacheContent = ob_get_contents();
         ob_end_flush();
     }
     // 更新内存中的缓存信息
     $this->cacheInfo[$this->cacheDigest]['expiredTime'] = $this->cacheTime;
     $this->cacheInfo[$this->cacheDigest]['expiredDateTime'] = date("Y-m-d H:i:s", $this->cacheTime);
     $ifSave = false;
     // 缓存文件地址
     $cacheContentFile = new FileLoader(PathGeneration::getFolder("{$this->cachePath}{$this->cacheId}") . "{$this->cacheDigest}.tmp", array("mode" => "write"));
     $cacheInfoFile = new FileLoader("{$this->cachePath}{$this->cacheId}_info.tmp", array("mode" => "write"));
     if ($cacheInfoFile->isWritable()) {
         if ($cacheContentFile->isWritable()) {
             $cacheInfoFile->write(json_encode($this->cacheInfo));
             $cacheContentFile->write($this->cacheContent);
             $cacheContentFile->close();
             $ifSave = true;
         }
         $cacheInfoFile->close();
     }
     return $ifSave;
 }
Example #5
0
 /**
  * 修改上传的配置,包括保存地址,允许的文件类型,允许的最大大小
  * @param string $savePath 保存的路径,存放从[upload][rootPath]目录开始的文件夹
  */
 public function changeConfig($savePath = null)
 {
     if (!empty($savePath)) {
         $this->config['savePath'] = PathGeneration::getFolder($this->config['rootPath'] . $savePath);
     }
 }