Example #1
0
 /**
  * 一键安装接口
  * @return void
  */
 public function downloadAndInstall()
 {
     header("content-Type: text/html; charset=utf-8");
     // 获取下载地址
     $develop_id = intval($_GET['develop_id']);
     $url = $this->RemoteAppURL . '/index.php?app=public&mod=Tool&act=downloadApp&develop_id=' . $develop_id;
     $info = file_get_contents($url);
     $info = json_decode($info, true);
     // 载入下载类
     tsload(ADDON_PATH . '/library/Update.class.php');
     $updateClass = new Update();
     //从服务器端下载应用到本地
     $res = $updateClass->downloadFile($info['packageURL']);
     if ($res != 1) {
         $this->error('下载应用失败,请确认网络是否正常');
         exit;
     }
     // 压缩
     $package = explode('/', $info['file']['filename']);
     $packageName = array_pop($package);
     $targetDir = $updateClass->downloadPath . 'unzip';
     // 创建目录unzip
     if (!is_dir($targetDir)) {
         @mkdir($targetDir, 0777);
     }
     $res = $updateClass->unzipPackage($packageName, $targetDir);
     if ($res != 1) {
         $this->error('下载应用解压失败');
         exit;
     }
     // 覆盖代码
     switch ($info['type']) {
         case 3:
             // 应用
             $res = $updateClass->overWrittenFile(APPS_PATH);
             break;
         case 2:
             // 插件
             $res = $updateClass->overWrittenFile(ADDON_PATH . '/plugin');
             break;
         case 1:
             // 皮肤
             $res = $updateClass->overWrittenFile(ADDON_PATH . '/theme');
             break;
     }
     // 安装
     switch ($info['type']) {
         case 3:
             // 应用
             U('admin/Apps/preinstall', array('app_name' => $info['app_name'], 'install' => 1), true);
             break;
         case 2:
             // 插件
             U('admin/Addons/index', array('install' => 1), true);
             break;
         case 1:
             U('admin/Apps/onLineApp', true);
             break;
     }
 }
Example #2
0
 /**
  * 本地一键安装接口
  *
  * @return void
  */
 public function downloadAndInstall()
 {
     header("content-Type: text/html; charset=utf-8");
     // 获取下载地址
     $id = intval($_GET['id']);
     $url = $this->remoteBaseURL . '/index.php?s=admin/store/downloadApp&id=' . $id;
     // 		dump($url);exit;
     $info = wp_file_get_contents($url);
     $info = json_decode($info, true);
     if (!$info['status']) {
         $this->error($info['error']);
         exit;
     }
     // 载入下载类
     Vendor('Update');
     $updateClass = new \Update();
     // 从服务器端下载应用到本地
     $res = $updateClass->downloadFile($info['data']['packageURL']);
     if ($res != 1) {
         $this->error('下载应用失败,请确认网络是否正常');
         exit;
     }
     // 压缩
     $package = explode('/', $info['data']['packageURL']);
     $packageName = array_pop($package);
     $targetDir = $updateClass->downloadPath . 'unzip';
     // 创建目录unzip
     if (!is_dir($targetDir)) {
         @mkdir($targetDir, 0777);
     }
     $res = $updateClass->unzipPackage($packageName, $targetDir);
     if ($res != 1) {
         $this->error('下载应用解压失败');
         exit;
     }
     // 覆盖代码
     switch ($info['data']['type']) {
         case 3:
             // 万能页面功能块
             $res = $updateClass->overWrittenFile(SITE_PATH . '/Addons/Diy/Widget');
             break;
         case 2:
             // 在线素材
             $res = $updateClass->overWrittenFile(SITE_PATH . '/Addons/Material');
             break;
         case 2:
             // 微官网模板
             $res = $updateClass->overWrittenFile(SITE_PATH . '/Addons/WeiSite/View/default');
             break;
         default:
             // 微信插件
             $res = $updateClass->overWrittenFile(SITE_PATH . '/Addons');
             if (empty($res)) {
                 $this->install($updateClass->addon_name);
                 exit;
             }
     }
     $this->success('安装完成');
 }
Example #3
0
 function step06_overWritten()
 {
     // 提示需要删除的文件
     $filePath = $targetDir = DATA_PATH . '/update/download/unzip/fileForDeleteList.php';
     if (file_exists($filePath)) {
         $deleteList = (require_once $filePath);
         foreach ($deleteList as $d) {
             unlink(SITE_PATH . '/' . $d);
         }
         unlink($filePath);
     }
     // 执行文件替换
     tsload(ADDON_PATH . '/library/Update.class.php');
     $updateClass = new Update();
     $res = $updateClass->overWrittenFile();
     if (!empty($res['error'])) {
         $this->assign('error', $res['error']);
         $this->display();
     } else {
         echo 1;
     }
 }