/**
  * 清除缓存
  * @author jry <*****@*****.**>
  */
 public function rmdirr($dirname = RUNTIME_PATH)
 {
     $file = new File();
     $result = $file->del_dir($dirname);
     if ($result) {
         $this->success("缓存清理成功");
     } else {
         $this->error("缓存清理失败");
     }
 }
 /**
  * 在线更新
  * @author	hebidu <*****@*****.**>
  */
 private function update($version, $updatedUrl)
 {
     //PclZip类库不支持命名空间
     import('Org/PclZip');
     //
     $date = date('YmdHis');
     //		$backupFile = I('post.backupfile');
     //		$backupDatabase = I('post.backupdatabase');
     sleep(1);
     //
     $this->showMsg('系统原始版本:' . C('UPGRADE_APP_VERSION'));
     $this->showMsg('系统在线更新日志:');
     $this->showMsg('更新开始时间:' . date('Y-m-d H:i:s'));
     sleep(1);
     //		/* 建立更新文件夹 */
     $folder = $this->getUpdateFolder();
     $result = File::mk_dir($folder . '/');
     if ($result === false) {
         $this->showMsg('更新文件夹创建失败,请检测' . dirname($folder) . '目录是否有写权限!');
         exit;
     }
     $folder = $folder . '/' . $date;
     $result = File::mk_dir($folder . '/');
     if ($result === false) {
         $this->showMsg('更新文件夹创建失败,请检测' . dirname($folder) . '目录是否有写权限!');
         exit;
     }
     //
     //		//备份重要文件
     //		if($backupFile){
     $this->showMsg('开始备份重要程序文件...');
     G('start1');
     $backupallPath = $folder . '/backupall.zip';
     $zip = new \PclZip($backupallPath);
     $zip->create('Application,Core,index.php');
     $this->showMsg('成功完成重要程序备份,备份文件路径:<a href=\'' . __ROOT__ . $backupallPath . '\'>' . $backupallPath . '</a>, 耗时:' . G('start1', 'stop1') . 's', 'success');
     //		}
     //
     //		/* 获取更新包 */
     //
     //		//下载并保存
     $this->showMsg('远程更新包地址: ' . $updatedUrl);
     $this->showMsg('开始获取远程更新包...');
     sleep(1);
     $zipPath = $folder . '/update.zip';
     $downZip = $this->getRemoteUrl($updatedUrl);
     //		dump($downZip);
     if (empty($downZip)) {
         $this->showMsg('下载更新包出错,请重试!', 'error');
         exit;
     }
     File::write_file($zipPath, $downZip);
     $this->showMsg('获取远程更新包成功,更新包路径:<a href=\'' . __ROOT__ . ltrim($zipPath, '.') . '\'>' . $zipPath . '</a>', 'success');
     sleep(1);
     //
     /* 解压缩更新包 */
     //TODO: 检查权限
     $this->showMsg('更新包解压缩...');
     sleep(1);
     $zip = new \PclZip($zipPath);
     $res = $zip->extract(PCLZIP_OPT_PATH, "./");
     //		$this->showMsg('更新包解压缩成功'.$res, 'success');
     if ($res === 0) {
         $this->showMsg('解压缩失败:' . $zip->errorInfo(true) . '------更新终止', 'error');
         exit;
     }
     $this->showMsg('更新包解压缩成功', 'success');
     sleep(1);
     /* 更新数据库 */
     $updatesql = './update.sql';
     if (is_file($updatesql)) {
         $this->showMsg('更新数据库开始...');
         if (file_exists($updatesql)) {
             $Model = M();
             $sql = File::read_file($updatesql);
             $sql = str_replace("\r\n", "\n", $sql);
             foreach (explode(";\n", trim($sql)) as $query) {
                 $Model->query(trim($query));
             }
         }
         unlink($updatesql);
         $this->showMsg('更新数据库完毕', 'success');
     }
     /* 系统版本号更新 */
     $Model = M('Config', "common_");
     $res = $Model->where(array("name" => 'UPGRADE_APP_VERSION'))->data(array("value" => $version))->save();
     if ($res === false) {
         $this->showMsg('更新系统版本号失败', 'error');
     } else {
         $this->showMsg('更新系统版本号成功', 'success');
     }
     sleep(1);
     //
     $this->showMsg('##################################################################');
     $this->showMsg('在线更新全部完成,如有备份,请及时将备份文件移动至非web目录下!', 'success');
     S("config_" . session_id() . '_' . session("uid"), null);
 }