Example #1
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 #2
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;
     }
 }
 /**
  * 对比后台菜单配置文件
  */
 public function updateAdminTab()
 {
     /* 下载文件-begin */
     tsload(ADDON_PATH . '/library/Update.class.php');
     $updateClass = new Update();
     $packageURL = C('TS_UPDATE_SITE') . '/data/lang/system_config.zip';
     $updateClass->downloadFile($packageURL);
     $updateClass->unzipPackage('system_config.zip', LANG_PATH, false);
     /* 下载文件-end */
     $tabFileArr = (include LANG_PATH . '/system_config.php');
     $this->pageTitle[ACTION_NAME] = '对比后台菜单配置';
     $this->pageKeyList = array('key', 'DOACTION');
     $this->pageButton[] = array('title' => '同步', 'onclick' => "admin.updateAdminTab(this)");
     $this->_listpk = 'tab_id';
     foreach ($tabFileArr as $key => $val) {
         $keys = explode('-', $key);
         $map['list'] = $keys[1];
         $map['key'] = $keys[0];
         if ($res = D('system_config')->where($map)->find()) {
             $localTab = unserialize($res['value']);
             if (count($val['key']) != count($localTab['key'])) {
                 $arr[$key]['tab_id'] = $key;
                 $arr[$key]['key'] = $keys[0];
                 $arr[$key]['DOACTION'] = '<a href="javascript:void(0);" onclick="admin.updateAdminTab(\'' . $key . '\')">修改</a>';
             } else {
                 foreach ($localTab as $k => $v) {
                     foreach ($v as $k1 => $v1) {
                         if (htmlspecialchars_decode($val[$k][$k1], ENT_QUOTES) != $v1) {
                             $arr[$key]['tab_id'] = $key;
                             $arr[$key]['key'] = $keys[0];
                             $arr[$key]['DOACTION'] = '<a href="javascript:void(0);" onclick="admin.updateAdminTab(\'' . $key . '\')">修改</a>';
                         }
                     }
                 }
             }
         } else {
             $arr[$key]['tab_id'] = $key;
             $arr[$key]['key'] = $keys[0];
             $arr[$key]['DOACTION'] = '<a href="javascript:void(0);" onclick="admin.updateAdminTab(\'' . $key . '\')">添加</a>';
         }
         unset($map);
     }
     // dump(111);exit;
     $listData['data'] = $arr;
     $this->displayList($listData);
 }
Example #4
0
 function step03_download()
 {
     header("content-Type: text/html; charset=utf-8");
     $packageName = t($_GET['packageName']);
     // $packageName = jiemi ( $packageName );
     tsload(ADDON_PATH . '/library/Update.class.php');
     $updateClass = new Update();
     $packageURL = $this->updateURL . '/' . $packageName;
     echo $updateClass->downloadFile($packageURL);
 }