<?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($lSQqf, $sjJrw = null) { return Response::generateSuccessData(array('msg' => array_map(function ($kHxHl) { return '<i class="iconfont icon-hr"></i> ' . $kHxHl; }, $lSQqf), 'logs' => $sjJrw, 'finish' => true)); } private function doNext($pFCkJ, $lSQqf = array(), $MGhSY = array()) { goto LFNJP; kJ6Uc: return Response::generateSuccessData(array('msg' => array_map(function ($kHxHl) { if (!starts_with($kHxHl, '<')) { $kHxHl = "<span class='ub-text-white'>{$kHxHl}</span>"; } return '<i class="iconfont icon-hr"></i> ' . $kHxHl; }, $lSQqf), 'step' => $pFCkJ, 'data' => $MGhSY, 'finish' => false)); goto TtxU_; btu0p: $MGhSY = array_merge($Q9nmo->getJsonAsInput('data')->all(), $MGhSY); goto kJ6Uc; LFNJP: $Q9nmo = InputPackage::buildFromInput(); goto btu0p; TtxU_: } public function index() { goto DUPxZ; BXvXu: return view('module::AdminManager.View.admin.upgrade'); goto UZXLb; DUPxZ: if (config('modstart.admin.upgradeDisable', false)) { return Response::sendError('系统升级功能已关闭'); } goto nnThA; nnThA: if (Request::isPost()) { goto nEopz; qRuUk: $Q9nmo = InputPackage::buildFromInput(); goto aVq91; nEopz: AdminPermission::demoCheck(); goto qRuUk; Mfysj: BizException::throwsIfEmpty('toVersion为空', $GRVfW); goto fTnuU; qGy7k: $ieh3D = $Q9nmo->getJsonAsInput('data'); goto TcdRh; aVq91: $pFCkJ = $Q9nmo->getTrimString('step'); goto oV06B; oV06B: $p23ja = $Q9nmo->getTrimString('token'); goto qGy7k; fTnuU: switch ($pFCkJ) { case 'upgradePackage': goto ZIu6n; ZIu6n: $qWHC7 = $ieh3D->getTrimString('package'); goto fu8L2; y133x: BizException::throwsIfEmpty('package为空', $qWHC7); goto s1GIq; FkKsn: $om_hh = UpgradeUtil::upgradePackage($qWHC7, $JhjhO); goto gpnMR; gpnMR: BizException::throwsIfResponseError($om_hh); goto cDtlJ; fu8L2: $JhjhO = $ieh3D->getTrimString('diffContentFile'); goto y133x; cDtlJ: return $this->doFinish(array('<span class="ub-text-success">升级完成，请 <a href="javascript:;" onclick="window.location.reload()">刷新后台</a> 查看最新系统</span>'), $om_hh['data']['logs']); goto Y3IER; s1GIq: BizException::throwsIfEmpty('diffContentFile为空', $JhjhO); goto FkKsn; Y3IER: case 'downloadPackage': goto gH0ej; CDSag: BizException::throwsIfResponseError($om_hh); goto cFy5P; cFy5P: return $this->doNext('upgradePackage', array('<span class="ub-text-success">获取安装包完成，大小 ' . FileUtil::formatByte($om_hh['data']['packageSize']) . '</span>', '<span class="ub-text-white">开始解压升级装包...</span>'), array('package' => $om_hh['data']['package'], 'diffContentFile' => $om_hh['data']['diffContentFile'])); goto IFDiZ; gH0ej: $om_hh = UpgradeUtil::downloadPackage($p23ja, AppConstant::APP, AppConstant::VERSION, $GRVfW); goto CDSag; IFDiZ: case 'checkPackage': goto zt1Rc; TfSIr: BizException::throwsIf('调用 php artisan 命令失败，不能自动升级', 0 != $rx99h); goto onCUg; zt1Rc: try { $rx99h = Artisan::call('migrate'); } catch (\Exception $se7TW) { $rx99h = -1; } goto TfSIr; onCUg: return $this->doNext('downloadPackage', array('PHP版本: v' . PHP_VERSION, '<span class="ub-text-success">预检通过</span>', '<span class="ub-text-white">开始下载升级包...</span>')); goto DQtWf; DQtWf: default: return $this->doNext('checkPackage', array('<span class="ub-text-success">开始升级系统，从 V' . AppConstant::VERSION . ' 到 V' . $GRVfW . '</span>', '<span class="ub-text-white">开始预检系统...</span>')); } goto rvUOW; TcdRh: $GRVfW = $ieh3D->getTrimString('toVersion'); goto Mfysj; rvUOW: } goto BXvXu; UZXLb: } public function auth() { return view('module::AdminManager.View.admin.auth', array('modules' => ModuleUtil::modules())); } public function info() { $H_YAC = UpgradeUtil::latest(); return Response::generateSuccessData(array('version' => AppConstant::VERSION, 'latestVersion' => $H_YAC['latestVersion'], 'autoUpgrade' => $H_YAC['autoUpgrade'])); } }