<?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($lqkIk, $bQ5pn = null) { return Response::generateSuccessData(array('msg' => array_map(function ($MNZ1i) { return '<i class="iconfont icon-hr"></i> ' . $MNZ1i; }, $lqkIk), 'logs' => $bQ5pn, 'finish' => true)); } private function doNext($fsoVJ, $lqkIk = array(), $GpXwG = array()) { goto L6RMX; k0iC2: return Response::generateSuccessData(array('msg' => array_map(function ($MNZ1i) { if (!starts_with($MNZ1i, '<')) { $MNZ1i = "<span class='ub-text-white'>{$MNZ1i}</span>"; } return '<i class="iconfont icon-hr"></i> ' . $MNZ1i; }, $lqkIk), 'step' => $fsoVJ, 'data' => $GpXwG, 'finish' => false)); goto nvk6Q; A45hr: $GpXwG = array_merge($i3uTh->getJsonAsInput('data')->all(), $GpXwG); goto k0iC2; L6RMX: $i3uTh = InputPackage::buildFromInput(); goto A45hr; nvk6Q: } public function index() { goto L49E_; dXhnM: return view('module::AdminManager.View.admin.upgrade'); goto ZzRTl; AW1b3: if (Request::isPost()) { goto hsjDl; VG26b: switch ($fsoVJ) { case 'upgradePackage': goto tAZOx; Eb77b: BizException::throwsIfEmpty('package为空', $MZdfD); goto Atq2v; tAZOx: $MZdfD = $zr2vo->getTrimString('package'); goto VzZI3; VzZI3: $pboir = $zr2vo->getTrimString('diffContentFile'); goto Eb77b; UtPdq: return $this->doFinish(array('<span class="ub-text-success">升级完成，请 <a href="javascript:;" onclick="window.location.reload()">刷新后台</a> 查看最新系统</span>'), $gMg9x['data']['logs']); goto eq2UY; DyXkQ: $gMg9x = UpgradeUtil::upgradePackage($MZdfD, $pboir); goto p3yEA; p3yEA: BizException::throwsIfResponseError($gMg9x); goto UtPdq; Atq2v: BizException::throwsIfEmpty('diffContentFile为空', $pboir); goto DyXkQ; eq2UY: case 'downloadPackage': goto d03d1; piCps: return $this->doNext('upgradePackage', array('<span class="ub-text-success">获取安装包完成，大小 ' . FileUtil::formatByte($gMg9x['data']['packageSize']) . '</span>', '<span class="ub-text-white">开始解压升级装包...</span>'), array('package' => $gMg9x['data']['package'], 'diffContentFile' => $gMg9x['data']['diffContentFile'])); goto nO81P; ndEcF: BizException::throwsIfResponseError($gMg9x); goto piCps; d03d1: $gMg9x = UpgradeUtil::downloadPackage($cUrpz, AppConstant::APP, AppConstant::VERSION, $U1vNQ); goto ndEcF; nO81P: case 'checkPackage': goto dB4Hf; OUCSJ: BizException::throwsIf('调用 php artisan 命令失败，不能自动升级', 0 != $yTeE1); goto vayey; dB4Hf: try { $yTeE1 = Artisan::call('migrate'); } catch (\Exception $re7gC) { $yTeE1 = -1; } goto OUCSJ; vayey: return $this->doNext('downloadPackage', array('PHP版本: v' . PHP_VERSION, '<span class="ub-text-success">预检通过</span>', '<span class="ub-text-white">开始下载升级包...</span>')); goto KbsR0; KbsR0: default: return $this->doNext('checkPackage', array('<span class="ub-text-success">开始升级系统，从 V' . AppConstant::VERSION . ' 到 V' . $U1vNQ . '</span>', '<span class="ub-text-white">开始预检系统...</span>')); } goto d9Q4_; hS1E8: $fsoVJ = $i3uTh->getTrimString('step'); goto kSVyx; DO4ex: $i3uTh = InputPackage::buildFromInput(); goto hS1E8; BNlVR: $zr2vo = $i3uTh->getJsonAsInput('data'); goto RqSiE; hsjDl: AdminPermission::demoCheck(); goto DO4ex; kSVyx: $cUrpz = $i3uTh->getTrimString('token'); goto BNlVR; XUhBP: BizException::throwsIfEmpty('toVersion为空', $U1vNQ); goto VG26b; RqSiE: $U1vNQ = $zr2vo->getTrimString('toVersion'); goto XUhBP; d9Q4_: } goto dXhnM; L49E_: if (config('modstart.admin.upgradeDisable', false)) { return Response::sendError('系统升级功能已关闭'); } goto AW1b3; ZzRTl: } public function auth() { return view('module::AdminManager.View.admin.auth', array('modules' => ModuleUtil::modules())); } public function info() { $Ci5Kw = UpgradeUtil::latest(); return Response::generateSuccessData(array('version' => AppConstant::VERSION, 'latestVersion' => $Ci5Kw['latestVersion'], 'autoUpgrade' => $Ci5Kw['autoUpgrade'])); } }