<?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($PVH3V, $gS7dY = null) { return Response::generateSuccessData(array('msg' => array_map(function ($lDvaK) { return '<i class="iconfont icon-hr"></i> ' . $lDvaK; }, $PVH3V), 'logs' => $gS7dY, 'finish' => true)); } private function doNext($izqtU, $PVH3V = array(), $xJzrK = array()) { goto P2FAf; P2FAf: $OPo_x = InputPackage::buildFromInput(); goto t9iA0; t9iA0: $xJzrK = array_merge($OPo_x->getJsonAsInput('data')->all(), $xJzrK); goto YRBBg; YRBBg: return Response::generateSuccessData(array('msg' => array_map(function ($lDvaK) { if (!starts_with($lDvaK, '<')) { $lDvaK = "<span class='ub-text-white'>{$lDvaK}</span>"; } return '<i class="iconfont icon-hr"></i> ' . $lDvaK; }, $PVH3V), 'step' => $izqtU, 'data' => $xJzrK, 'finish' => false)); goto P5d7r; P5d7r: } public function index() { goto MefU3; MefU3: if (config('modstart.admin.upgradeDisable', false)) { return Response::sendError('系统升级功能已关闭'); } goto xv6_a; xv6_a: if (Request::isPost()) { goto ApD25; r9Oxw: $OPo_x = InputPackage::buildFromInput(); goto kusz0; GZHoy: $Wgcnm = $OFyFS->getTrimString('toVersion'); goto Bi1Ng; R1paW: $GA_R3 = $OPo_x->getTrimString('token'); goto CLfws; CLfws: $OFyFS = $OPo_x->getJsonAsInput('data'); goto GZHoy; ApD25: AdminPermission::demoCheck(); goto r9Oxw; kusz0: $izqtU = $OPo_x->getTrimString('step'); goto R1paW; aeLQt: switch ($izqtU) { case 'upgradePackage': goto enrgL; YmhQo: BizException::throwsIfEmpty('package为空', $HDfwB); goto wUsAu; enrgL: $HDfwB = $OFyFS->getTrimString('package'); goto bJzDg; E4t1H: BizException::throwsIfResponseError($yCUD1); goto zjKOH; bJzDg: $TiNKC = $OFyFS->getTrimString('diffContentFile'); goto YmhQo; zjKOH: return $this->doFinish(array('<span class="ub-text-success">升级完成，请 <a href="javascript:;" onclick="window.location.reload()">刷新后台</a> 查看最新系统</span>'), $yCUD1['data']['logs']); goto gV91A; wUsAu: BizException::throwsIfEmpty('diffContentFile为空', $TiNKC); goto cHhtf; cHhtf: $yCUD1 = UpgradeUtil::upgradePackage($HDfwB, $TiNKC); goto E4t1H; gV91A: case 'downloadPackage': goto uiQev; AdlDL: return $this->doNext('upgradePackage', array('<span class="ub-text-success">获取安装包完成，大小 ' . FileUtil::formatByte($yCUD1['data']['packageSize']) . '</span>', '<span class="ub-text-white">开始解压升级装包...</span>'), array('package' => $yCUD1['data']['package'], 'diffContentFile' => $yCUD1['data']['diffContentFile'])); goto fF4vQ; uiQev: $yCUD1 = UpgradeUtil::downloadPackage($GA_R3, AppConstant::APP, AppConstant::VERSION, $Wgcnm); goto JNJz5; JNJz5: BizException::throwsIfResponseError($yCUD1); goto AdlDL; fF4vQ: case 'checkPackage': goto YAXJ8; YAXJ8: try { $LAwgR = Artisan::call('migrate'); } catch (\Exception $Q19lV) { $LAwgR = -1; } goto iH51e; iH51e: BizException::throwsIf('调用 php artisan 命令失败，不能自动升级', 0 != $LAwgR); goto ppPIb; ppPIb: return $this->doNext('downloadPackage', array('PHP版本: v' . PHP_VERSION, '<span class="ub-text-success">预检通过</span>', '<span class="ub-text-white">开始下载升级包...</span>')); goto c8Bq8; c8Bq8: default: return $this->doNext('checkPackage', array('<span class="ub-text-success">开始升级系统，从 V' . AppConstant::VERSION . ' 到 V' . $Wgcnm . '</span>', '<span class="ub-text-white">开始预检系统...</span>')); } goto K5eBB; Bi1Ng: BizException::throwsIfEmpty('toVersion为空', $Wgcnm); goto aeLQt; K5eBB: } goto zY32u; zY32u: return view('module::AdminManager.View.admin.upgrade'); goto ZXF8E; ZXF8E: } public function auth() { return view('module::AdminManager.View.admin.auth', array('modules' => ModuleUtil::modules())); } public function info() { $ShMf2 = UpgradeUtil::latest(); return Response::generateSuccessData(array('version' => AppConstant::VERSION, 'latestVersion' => $ShMf2['latestVersion'], 'autoUpgrade' => $ShMf2['autoUpgrade'])); } }