Example #1
0
 /**
  * 更新缓存
  * 
  * @return boolean
  */
 public function updateCache()
 {
     $data = $this->_getWindidAreaDs()->fetchAll();
     $file = Wind::getRealPath('DATA:area.area.php', true);
     WindFolder::mk(dirname($file));
     WindFile::savePhpData($file, $data, true);
     return $data;
 }
 /**
  * 根据用户key计算获取真是缓存文件
  * 
  * 缓存key在安全处理之后,判断该key是否已经被访问过
  * <ul>
  * <li>如果被访问过,则直接返回该真实缓存文件</li>
  * <li>没有访问过,则将会进入计算流程.
  * <ol>
  * <li>如果用该组件配置了缓存子目录的长度n:
  * <ul>
  * <li>获得缓存key的md5值的0~n的子字串作为子缓存目录;</li>
  * <li>将缓存文件存放在该缓存子目录下.同时将该缓存文件的新路径保存到已访问的缓存路径列表中,供下次直接调用.</li>
  * </ul>
  * </li>
  * <li>如果没有配置缓存子目录长度,则直接将该文件缓存在缓存根目录下,同时也将该缓存文件路径保存在已访问的缓存路径列表中.</li>
  * </ol>
  * </li>
  * </ul>
  * 
  * @param string $key 用户的缓存文件key
  * @return string 真实的缓存文件
  */
 protected function buildSecurityKey($key)
 {
     $key = parent::buildSecurityKey($key);
     if (false !== ($dir = $this->checkCacheDir($key))) {
         return $dir;
     }
     $_dir = $this->getCacheDir();
     if (0 < ($level = $this->getCacheDirectoryLevel())) {
         $_subdir = substr(md5($key), 0, $level);
         $_dir .= '/' . $_subdir;
         WindFolder::mk($_dir);
     }
     $filename = $key . '.' . $this->getCacheFileSuffix();
     $this->cacheFileList[$key] = $_dir ? $_dir . '/' . $filename : $filename;
     return $this->cacheFileList[$key];
 }
 /**
  * 复制目录
  *
  * @param string $fromFolder
  * @param string $toFolder
  * @return boolean
  */
 protected function copyRecur($fromFolder, $toFolder)
 {
     $dir = @opendir($fromFolder);
     if (!$dir) {
         return false;
     }
     WindFolder::mk($toFolder);
     while (false !== ($file = readdir($dir))) {
         if ($file != '.' && $file != '..') {
             if (is_dir($fromFolder . '/' . $file)) {
                 $this->copyRecur($fromFolder . '/' . $file, $toFolder . '/' . $file);
             } else {
                 @copy($fromFolder . '/' . $file, $toFolder . '/' . $file);
                 @chmod($toFolder . '/' . $file, 0777);
             }
         }
     }
     @closedir($dir);
     return true;
 }
Example #4
0
 protected function writeFile($fileData)
 {
     $failArray = array();
     $dir = $this->tplPath;
     WindFolder::rm($dir, true);
     WindFolder::mk($dir);
     foreach ($fileData as $file) {
         WindFolder::mkRecur($dir . '/' . dirname($file['filename']));
         if (!WindFile::write($dir . '/' . $file['filename'], $file['data'])) {
             $failArray[] = $file['filename'];
         }
     }
     return $failArray;
 }