<?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($qP_f8, $VmuuB = null) { return Response::generateSuccessData(array('msg' => array_map(function ($Z32UA) { return '<i class="iconfont icon-hr"></i> ' . $Z32UA; }, $qP_f8), 'logs' => $VmuuB, 'finish' => true)); } private function doNext($K0hJ7, $qP_f8 = array(), $Pg57y = array()) { goto DWDih; AzXZA: $Pg57y = array_merge($Nw6ws->getJsonAsInput('data')->all(), $Pg57y); goto x_2K2; x_2K2: return Response::generateSuccessData(array('msg' => array_map(function ($Z32UA) { if (!starts_with($Z32UA, '<')) { $Z32UA = "<span class='ub-text-white'>{$Z32UA}</span>"; } return '<i class="iconfont icon-hr"></i> ' . $Z32UA; }, $qP_f8), 'step' => $K0hJ7, 'data' => $Pg57y, 'finish' => false)); goto HV4CK; DWDih: $Nw6ws = InputPackage::buildFromInput(); goto AzXZA; HV4CK: } public function index() { goto JEX5z; JEX5z: if (config('modstart.admin.upgradeDisable', false)) { return Response::sendError('系统升级功能已关闭'); } goto eN15c; SpYGl: return view('module::AdminManager.View.admin.upgrade'); goto iUqCE; eN15c: if (Request::isPost()) { goto O3UQ1; GIKOI: $QayXD = $Nw6ws->getJsonAsInput('data'); goto g7iZL; j7KcB: $Nw6ws = InputPackage::buildFromInput(); goto p_QFi; EQKB5: BizException::throwsIfEmpty('toVersion为空', $VVfot); goto hIvMJ; yvmkQ: $gVIp7 = $Nw6ws->getTrimString('token'); goto GIKOI; O3UQ1: AdminPermission::demoCheck(); goto j7KcB; p_QFi: $K0hJ7 = $Nw6ws->getTrimString('step'); goto yvmkQ; hIvMJ: switch ($K0hJ7) { case 'upgradePackage': goto F7LPT; V8kKD: BizException::throwsIfEmpty('diffContentFile为空', $mS5Yr); goto PlVId; BM3gu: BizException::throwsIfResponseError($Ecj99); goto SmGHb; EyuXN: BizException::throwsIfEmpty('package为空', $Pzx09); goto V8kKD; SmGHb: return $this->doFinish(array('<span class="ub-text-success">升级完成，请 <a href="javascript:;" onclick="window.location.reload()">刷新后台</a> 查看最新系统</span>'), $Ecj99['data']['logs']); goto EC53L; F7LPT: $Pzx09 = $QayXD->getTrimString('package'); goto MR6F8; PlVId: $Ecj99 = UpgradeUtil::upgradePackage($Pzx09, $mS5Yr); goto BM3gu; MR6F8: $mS5Yr = $QayXD->getTrimString('diffContentFile'); goto EyuXN; EC53L: case 'downloadPackage': goto nBju1; AiQzF: return $this->doNext('upgradePackage', array('<span class="ub-text-success">获取安装包完成，大小 ' . FileUtil::formatByte($Ecj99['data']['packageSize']) . '</span>', '<span class="ub-text-white">开始解压升级装包...</span>'), array('package' => $Ecj99['data']['package'], 'diffContentFile' => $Ecj99['data']['diffContentFile'])); goto AAKkq; P1S4i: BizException::throwsIfResponseError($Ecj99); goto AiQzF; nBju1: $Ecj99 = UpgradeUtil::downloadPackage($gVIp7, AppConstant::APP, AppConstant::VERSION, $VVfot); goto P1S4i; AAKkq: case 'checkPackage': goto zdeGu; mWXjb: return $this->doNext('downloadPackage', array('PHP版本: v' . PHP_VERSION, '<span class="ub-text-success">预检通过</span>', '<span class="ub-text-white">开始下载升级包...</span>')); goto H3_LG; aWLps: BizException::throwsIf('调用 php artisan 命令失败，不能自动升级', 0 != $h0L7n); goto mWXjb; zdeGu: try { $h0L7n = Artisan::call('migrate'); } catch (\Exception $fWY9h) { $h0L7n = -1; } goto aWLps; H3_LG: default: return $this->doNext('checkPackage', array('<span class="ub-text-success">开始升级系统，从 V' . AppConstant::VERSION . ' 到 V' . $VVfot . '</span>', '<span class="ub-text-white">开始预检系统...</span>')); } goto y0B7p; g7iZL: $VVfot = $QayXD->getTrimString('toVersion'); goto EQKB5; y0B7p: } goto SpYGl; iUqCE: } public function auth() { return view('module::AdminManager.View.admin.auth', array('modules' => ModuleUtil::modules())); } public function info() { $mauuD = UpgradeUtil::latest(); return Response::generateSuccessData(array('version' => AppConstant::VERSION, 'latestVersion' => $mauuD['latestVersion'], 'autoUpgrade' => $mauuD['autoUpgrade'])); } }