<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\AdminManager\Admin\Controller; use App\Constant\AppConstant; use Illuminate\Routing\Controller; use Illuminate\Support\Facades\Artisan; use ModStart\Admin\Auth\AdminPermission; use ModStart\Core\Exception\BizException; use ModStart\Core\Input\InputPackage; use ModStart\Core\Input\Request; use ModStart\Core\Input\Response; use ModStart\Core\Util\FileUtil; use Module\AdminManager\Util\ModuleUtil; use Module\AdminManager\Util\UpgradeUtil; class UpgradeController extends Controller { public static $PermitMethodMap = array('index' => '@SystemUpgrade', 'info' => '@SystemUpgrade', 'auth' => '@SystemUpgrade'); private function doFinish($ScSdy, $Krz8K = null) { return Response::generateSuccessData(array('msg' => array_map(function ($FSL7c) { return '<i class="iconfont icon-hr"></i> ' . $FSL7c; }, $ScSdy), 'logs' => $Krz8K, 'finish' => true)); } private function doNext($q8NFf, $ScSdy = array(), $cwaKT = array()) { goto o4YF6; crMcF: $cwaKT = array_merge($tBuXm->getJsonAsInput('data')->all(), $cwaKT); goto bqtx2; bqtx2: return Response::generateSuccessData(array('msg' => array_map(function ($FSL7c) { if (!starts_with($FSL7c, '<')) { $FSL7c = "<span class='ub-text-white'>{$FSL7c}</span>"; } return '<i class="iconfont icon-hr"></i> ' . $FSL7c; }, $ScSdy), 'step' => $q8NFf, 'data' => $cwaKT, 'finish' => false)); goto fAAsW; o4YF6: $tBuXm = InputPackage::buildFromInput(); goto crMcF; fAAsW: } public function index() { goto e7j_3; tUnWo: if (Request::isPost()) { goto HvToj; keAM2: BizException::throwsIfEmpty('toVersion为空', $GPX1G); goto njM5t; HvToj: AdminPermission::demoCheck(); goto hZ69k; njM5t: switch ($q8NFf) { case 'upgradePackage': goto Edbty; nReZQ: BizException::throwsIfEmpty('package为空', $scQcd); goto KInL2; Edbty: $scQcd = $dkQEh->getTrimString('package'); goto ypz2U; GIMYi: $ZrjxR = UpgradeUtil::upgradePackage($scQcd, $dFEzs); goto L4xoy; L4xoy: BizException::throwsIfResponseError($ZrjxR); goto snAot; KInL2: BizException::throwsIfEmpty('diffContentFile为空', $dFEzs); goto GIMYi; snAot: return $this->doFinish(array('<span class="ub-text-success">升级完成，请 <a href="javascript:;" onclick="window.location.reload()">刷新后台</a> 查看最新系统</span>'), $ZrjxR['data']['logs']); goto QrUk5; ypz2U: $dFEzs = $dkQEh->getTrimString('diffContentFile'); goto nReZQ; QrUk5: case 'downloadPackage': goto YvQlP; V4BSi: return $this->doNext('upgradePackage', array('<span class="ub-text-success">获取安装包完成，大小 ' . FileUtil::formatByte($ZrjxR['data']['packageSize']) . '</span>', '<span class="ub-text-white">开始解压升级装包...</span>'), array('package' => $ZrjxR['data']['package'], 'diffContentFile' => $ZrjxR['data']['diffContentFile'])); goto aZjrb; HjHOw: BizException::throwsIfResponseError($ZrjxR); goto V4BSi; YvQlP: $ZrjxR = UpgradeUtil::downloadPackage($ufeje, AppConstant::APP, AppConstant::VERSION, $GPX1G); goto HjHOw; aZjrb: case 'checkPackage': goto ZKzAF; n5Mr5: BizException::throwsIf('调用 php artisan 命令失败，不能自动升级', 0 != $ppEQn); goto H0dcr; H0dcr: return $this->doNext('downloadPackage', array('PHP版本: v' . PHP_VERSION, '<span class="ub-text-success">预检通过</span>', '<span class="ub-text-white">开始下载升级包...</span>')); goto J0j1Z; ZKzAF: try { $ppEQn = Artisan::call('migrate'); } catch (\Exception $RWZxh) { $ppEQn = -1; } goto n5Mr5; J0j1Z: default: return $this->doNext('checkPackage', array('<span class="ub-text-success">开始升级系统，从 V' . AppConstant::VERSION . ' 到 V' . $GPX1G . '</span>', '<span class="ub-text-white">开始预检系统...</span>')); } goto LrM8E; KdkZV: $dkQEh = $tBuXm->getJsonAsInput('data'); goto x2Lmx; x2Lmx: $GPX1G = $dkQEh->getTrimString('toVersion'); goto keAM2; hZ69k: $tBuXm = InputPackage::buildFromInput(); goto qxtMJ; Gh3qZ: $ufeje = $tBuXm->getTrimString('token'); goto KdkZV; qxtMJ: $q8NFf = $tBuXm->getTrimString('step'); goto Gh3qZ; LrM8E: } goto C5ySa; C5ySa: return view('module::AdminManager.View.admin.upgrade'); goto zzRQk; e7j_3: if (config('modstart.admin.upgradeDisable', false)) { return Response::sendError('系统升级功能已关闭'); } goto tUnWo; zzRQk: } public function auth() { return view('module::AdminManager.View.admin.auth', array('modules' => ModuleUtil::modules())); } public function info() { $GKPP_ = UpgradeUtil::latest(); return Response::generateSuccessData(array('version' => AppConstant::VERSION, 'latestVersion' => $GKPP_['latestVersion'], 'autoUpgrade' => $GKPP_['autoUpgrade'])); } }