Example #1
0
 public function tocpjs($path)
 {
     if (!is_dir($this->devpath . $path)) {
         if (strpos(strtolower($path), '.js') == strlen($path) - 3) {
             if (file_exists($this->propath . $path) && filemtime($this->devpath . $path) < filemtime($this->propath . $path)) {
                 return;
             }
             File::creat_dir_with_filepath($this->propath . $path);
             $buffer = file_get_contents($this->devpath . $path);
             //如果传入的是JS文件则压缩
             if (!$this->needcomp) {
                 file_put_contents($this->propath . $path, $buffer);
             } else {
                 $packer = new JavaScriptPacker($buffer, 'Normal', true, false);
                 file_put_contents($this->propath . $path, $packer->pack());
             }
         } else {
             @copy($this->devpath . $path, $this->propath . $path);
         }
         return;
     }
     //如果传入的参数是目录
     $handle = File::scandir($this->devpath . $path);
     foreach ($handle as $file) {
         if ($file != '.' && $file != '..') {
             $dir = $path . '/' . $file;
             //当前文件$dir为文件目录+文件
             $this->tocpjs($dir);
         }
     }
     return;
 }
Example #2
0
 /**
  * 永久要保存的缓存数据<br/>
  * 这个方法通过文件形式存储缓存
  *
  * @param string $k 键
  * @param mixed $v 值
  */
 public static function forever($k, $v = null)
 {
     $path = YYUC_FRAME_PATH . 'sys/cache/YYUCFOREVER/' . str_replace('%2F', '/', urlencode($k));
     if ($v === null) {
         //读取
         if (file_exists($path)) {
             return unserialize(file_get_contents($path));
         }
         return null;
     } else {
         //设置
         File::creat_dir_with_filepath($path);
         file_put_contents($path, serialize($v), LOCK_EX);
     }
 }
Example #3
0
 /**
  *写入缓存
  *第一行 如果为'time'则是按照时间过期规则处理 第二行则为此缓存过期时间 如果为'null'则永不过期。
  *第一行 如果为数字  则是按照DB过期规则处理,这则数字是文件创建时间  第二行则为关联更新的一些数据库表名 以','分割
  */
 public function write_cache()
 {
     if (Conf::$is_developing || Page::$cache_type === false) {
         return;
     }
     if (Page::$cache_type === CACHE_NORMAL) {
         $cachepath = YYUC_FRAME_PATH . YYUC_PUB . '/' . $_SERVER['REAL_REQUEST_URI'] . '.htm';
         File::creat_dir_with_filepath($cachepath);
         file_put_contents($cachepath, $this->html);
     } else {
         //缓存标识
         $lines = array();
         if (Page::$cache_type === CACHE_TIME) {
             $expiretime = Page::$cache_time == null ? Conf::$cache_time == null ? 2400 : Conf::$cache_time : Page::$cache_time;
             Cache::set($this->cache_path . '_KEY', '@', $expiretime * 3600);
             Cache::set($this->cache_path, $this->html, $expiretime * 3600);
             return;
         } else {
             $lines[0] = time();
             $lines[1] = Page::$cache_dbs;
         }
         if (is_string(Page::$sys_before_action)) {
             $lines[2] = Page::$sys_before_action;
         }
         $lines_str = implode('@YYUC@', $lines);
         Cache::set($this->cache_path . '_KEY', $lines_str);
         Cache::set($this->cache_path, $this->html);
     }
 }
Example #4
0
 /**
  * 根据页面标识 存储上传的文件 通常用在Form提交中的预上传处理
  * @param string $key 上传控件的的name值提交上来的属性
  * @param string $folderpath pub文件夹下的相对文件夹路径
  * @param string $isFile 上一参数是否是文件,如果是则直接覆盖文件
  * @return string 此次存储的文件相对网站根目录的路径没有信息提交则返回false
  */
 private static function _resave_upload_file($key, $folderpath = null, $isFile = false)
 {
     //临时目录清空
     if (trim(Conf::$remote_path) != '') {
         $syspathp = Conf::$local_remote;
         $STA = Conf::$remote_path;
     } else {
         $syspathp = YYUC_FRAME_PATH . YYUC_PUB . '/';
         $STA = '/';
     }
     if (stripos($key, 'http') === 0) {
         //是修改且从未被修改过
         return $key;
     } elseif (trim($key) == '') {
         //提交信息为空
         return false;
     } elseif (strpos($key, '/') === 0) {
         //是修改且从未被修改过
         return $key;
     } elseif (strpos($key, '@-@') === 0) {
         //删除上次的文件地址
         @unlink($syspathp . substr($key, 4));
         return false;
     } elseif (strpos($key, '@-@') !== false) {
         //修改后删除上次的文件地址
         $keys = explode('@-@', $key);
         $key = $keys[0];
         @unlink($syspathp . $keys[1]);
     }
     if ($folderpath === null) {
         $folderpath = 'upload/auto/' . date('Y/m/d', time());
     }
     if (!$isFile) {
         File::creat_dir($syspathp . $folderpath);
         $tsubppath = str_replace('//', '/', $folderpath . '/' . basename($key));
         $newpath = $syspathp . $folderpath . '/' . basename($key);
     } else {
         File::creat_dir_with_filepath($syspathp . $folderpath);
         $tsubppath = str_replace('//', '/', $folderpath);
         $newpath = $syspathp . $folderpath;
     }
     @unlink($newpath);
     rename($syspathp . $key, $newpath);
     return $STA . $tsubppath;
 }