<?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($OmBIh, $zkKO0 = null) { return Response::generateSuccessData(array('msg' => array_map(function ($vPOhn) { return '<i class="iconfont icon-hr"></i> ' . $vPOhn; }, $OmBIh), 'logs' => $zkKO0, 'finish' => true)); } private function doNext($C_smj, $OmBIh = array(), $smBDO = array()) { goto XRubk; XRubk: $Ylazq = InputPackage::buildFromInput(); goto iSWGb; mvZKb: return Response::generateSuccessData(array('msg' => array_map(function ($vPOhn) { if (!starts_with($vPOhn, '<')) { $vPOhn = "<span class='ub-text-white'>{$vPOhn}</span>"; } return '<i class="iconfont icon-hr"></i> ' . $vPOhn; }, $OmBIh), 'step' => $C_smj, 'data' => $smBDO, 'finish' => false)); goto VTQmk; iSWGb: $smBDO = array_merge($Ylazq->getJsonAsInput('data')->all(), $smBDO); goto mvZKb; VTQmk: } public function index() { goto iNcb4; mKajq: return view('module::AdminManager.View.admin.upgrade'); goto Xmf8u; UMPPM: if (Request::isPost()) { goto xYSNv; TqZ2A: $iGHvN = $rvDWr->getTrimString('toVersion'); goto kYYY0; G0uDJ: $Ylazq = InputPackage::buildFromInput(); goto HvCH1; Cj2us: $h7611 = $Ylazq->getTrimString('token'); goto GzIZ_; GzIZ_: $rvDWr = $Ylazq->getJsonAsInput('data'); goto TqZ2A; kYYY0: BizException::throwsIfEmpty('toVersion为空', $iGHvN); goto AyNiF; HvCH1: $C_smj = $Ylazq->getTrimString('step'); goto Cj2us; AyNiF: switch ($C_smj) { case 'upgradePackage': goto EAX1S; BPsd4: $DNs9z = $rvDWr->getTrimString('diffContentFile'); goto asuc6; eHje5: BizException::throwsIfEmpty('diffContentFile为空', $DNs9z); goto uFgNI; yLa4H: return $this->doFinish(array('<span class="ub-text-success">升级完成，请 <a href="javascript:;" onclick="window.location.reload()">刷新后台</a> 查看最新系统</span>'), $Gs3Xd['data']['logs']); goto hsaoD; asuc6: BizException::throwsIfEmpty('package为空', $xAW3P); goto eHje5; EAX1S: $xAW3P = $rvDWr->getTrimString('package'); goto BPsd4; uFgNI: $Gs3Xd = UpgradeUtil::upgradePackage($xAW3P, $DNs9z); goto r39Gc; r39Gc: BizException::throwsIfResponseError($Gs3Xd); goto yLa4H; hsaoD: case 'downloadPackage': goto Ja7st; GCSvI: BizException::throwsIfResponseError($Gs3Xd); goto vpmwZ; vpmwZ: return $this->doNext('upgradePackage', array('<span class="ub-text-success">获取安装包完成，大小 ' . FileUtil::formatByte($Gs3Xd['data']['packageSize']) . '</span>', '<span class="ub-text-white">开始解压升级装包...</span>'), array('package' => $Gs3Xd['data']['package'], 'diffContentFile' => $Gs3Xd['data']['diffContentFile'])); goto w72_A; Ja7st: $Gs3Xd = UpgradeUtil::downloadPackage($h7611, AppConstant::APP, AppConstant::VERSION, $iGHvN); goto GCSvI; w72_A: case 'checkPackage': goto YErJf; EXZNU: BizException::throwsIf('调用 php artisan 命令失败，不能自动升级', 0 != $N3esS); goto mWw1J; YErJf: try { $N3esS = Artisan::call('migrate'); } catch (\Exception $hSVcc) { $N3esS = -1; } goto EXZNU; mWw1J: return $this->doNext('downloadPackage', array('PHP版本: v' . PHP_VERSION, '<span class="ub-text-success">预检通过</span>', '<span class="ub-text-white">开始下载升级包...</span>')); goto Jr02_; Jr02_: default: return $this->doNext('checkPackage', array('<span class="ub-text-success">开始升级系统，从 V' . AppConstant::VERSION . ' 到 V' . $iGHvN . '</span>', '<span class="ub-text-white">开始预检系统...</span>')); } goto b2RJn; xYSNv: AdminPermission::demoCheck(); goto G0uDJ; b2RJn: } goto mKajq; iNcb4: if (config('modstart.admin.upgradeDisable', false)) { return Response::sendError('系统升级功能已关闭'); } goto UMPPM; Xmf8u: } public function auth() { return view('module::AdminManager.View.admin.auth', array('modules' => ModuleUtil::modules())); } public function info() { $TkUd7 = UpgradeUtil::latest(); return Response::generateSuccessData(array('version' => AppConstant::VERSION, 'latestVersion' => $TkUd7['latestVersion'], 'autoUpgrade' => $TkUd7['autoUpgrade'])); } }