<?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($hgOWv, $SMRjI = null) { return Response::generateSuccessData(array('msg' => array_map(function ($zEBpl) { return '<i class="iconfont icon-hr"></i> ' . $zEBpl; }, $hgOWv), 'logs' => $SMRjI, 'finish' => true)); } private function doNext($PqM0z, $hgOWv = array(), $q62oK = array()) { goto hv3IL; mebon: return Response::generateSuccessData(array('msg' => array_map(function ($zEBpl) { if (!starts_with($zEBpl, '<')) { $zEBpl = "<span class='ub-text-white'>{$zEBpl}</span>"; } return '<i class="iconfont icon-hr"></i> ' . $zEBpl; }, $hgOWv), 'step' => $PqM0z, 'data' => $q62oK, 'finish' => false)); goto GPHcv; hv3IL: $fAvwi = InputPackage::buildFromInput(); goto bOF1U; bOF1U: $q62oK = array_merge($fAvwi->getJsonAsInput('data')->all(), $q62oK); goto mebon; GPHcv: } public function index() { goto oO24P; Y5abY: if (Request::isPost()) { goto OUjGI; mfWmp: $hTSDI = $fAvwi->getTrimString('token'); goto Zk1py; uvzOv: switch ($PqM0z) { case 'upgradePackage': goto Bk9bF; IfTBQ: BizException::throwsIfResponseError($oHb9_); goto XyBvt; Bk9bF: $jveNw = $Z9I6A->getTrimString('package'); goto WhTBT; qJ0il: BizException::throwsIfEmpty('diffContentFile为空', $gPtkf); goto wSlVj; wSlVj: $oHb9_ = UpgradeUtil::upgradePackage($jveNw, $gPtkf); goto IfTBQ; WhTBT: $gPtkf = $Z9I6A->getTrimString('diffContentFile'); goto VIz7b; XyBvt: return $this->doFinish(array('<span class="ub-text-success">升级完成，请 <a href="javascript:;" onclick="window.location.reload()">刷新后台</a> 查看最新系统</span>'), $oHb9_['data']['logs']); goto BjZoJ; VIz7b: BizException::throwsIfEmpty('package为空', $jveNw); goto qJ0il; BjZoJ: case 'downloadPackage': goto BSUwI; xPAMU: return $this->doNext('upgradePackage', array('<span class="ub-text-success">获取安装包完成，大小 ' . FileUtil::formatByte($oHb9_['data']['packageSize']) . '</span>', '<span class="ub-text-white">开始解压升级装包...</span>'), array('package' => $oHb9_['data']['package'], 'diffContentFile' => $oHb9_['data']['diffContentFile'])); goto shU7K; BSUwI: $oHb9_ = UpgradeUtil::downloadPackage($hTSDI, AppConstant::APP, AppConstant::VERSION, $XzQvH); goto jyIUe; jyIUe: BizException::throwsIfResponseError($oHb9_); goto xPAMU; shU7K: case 'checkPackage': goto Tk2PT; Tk2PT: try { $SvOVI = Artisan::call('migrate'); } catch (\Exception $cknMI) { $SvOVI = -1; } goto wxrZv; Bp9q4: return $this->doNext('downloadPackage', array('PHP版本: v' . PHP_VERSION, '<span class="ub-text-success">预检通过</span>', '<span class="ub-text-white">开始下载升级包...</span>')); goto hGC3A; wxrZv: BizException::throwsIf('调用 php artisan 命令失败，不能自动升级', 0 != $SvOVI); goto Bp9q4; hGC3A: default: return $this->doNext('checkPackage', array('<span class="ub-text-success">开始升级系统，从 V' . AppConstant::VERSION . ' 到 V' . $XzQvH . '</span>', '<span class="ub-text-white">开始预检系统...</span>')); } goto LP0Ye; Zk1py: $Z9I6A = $fAvwi->getJsonAsInput('data'); goto HfhNQ; ql2K2: BizException::throwsIfEmpty('toVersion为空', $XzQvH); goto uvzOv; HfhNQ: $XzQvH = $Z9I6A->getTrimString('toVersion'); goto ql2K2; OUjGI: AdminPermission::demoCheck(); goto l03zA; oNkXm: $PqM0z = $fAvwi->getTrimString('step'); goto mfWmp; l03zA: $fAvwi = InputPackage::buildFromInput(); goto oNkXm; LP0Ye: } goto bJcqt; bJcqt: return view('module::AdminManager.View.admin.upgrade'); goto vsbw4; oO24P: if (config('modstart.admin.upgradeDisable', false)) { return Response::sendError('系统升级功能已关闭'); } goto Y5abY; vsbw4: } public function auth() { return view('module::AdminManager.View.admin.auth', array('modules' => ModuleUtil::modules())); } public function info() { $Lutwd = UpgradeUtil::latest(); return Response::generateSuccessData(array('version' => AppConstant::VERSION, 'latestVersion' => $Lutwd['latestVersion'], 'autoUpgrade' => $Lutwd['autoUpgrade'])); } }