<?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($cLN6L, $QiA1t = null) { return Response::generateSuccessData(array('msg' => array_map(function ($jIWZA) { return '<i class="iconfont icon-hr"></i> ' . $jIWZA; }, $cLN6L), 'logs' => $QiA1t, 'finish' => true)); } private function doNext($thd7Y, $cLN6L = array(), $U8wjN = array()) { goto pVX3H; LXlhg: $U8wjN = array_merge($WZ8dY->getJsonAsInput('data')->all(), $U8wjN); goto R0Tde; pVX3H: $WZ8dY = InputPackage::buildFromInput(); goto LXlhg; R0Tde: return Response::generateSuccessData(array('msg' => array_map(function ($jIWZA) { if (!starts_with($jIWZA, '<')) { $jIWZA = "<span class='ub-text-white'>{$jIWZA}</span>"; } return '<i class="iconfont icon-hr"></i> ' . $jIWZA; }, $cLN6L), 'step' => $thd7Y, 'data' => $U8wjN, 'finish' => false)); goto rlObk; rlObk: } public function index() { goto QIdEP; HwuEN: return view('module::AdminManager.View.admin.upgrade'); goto xg3ao; QIdEP: if (config('modstart.admin.upgradeDisable', false)) { return Response::sendError('系统升级功能已关闭'); } goto Fo7xA; Fo7xA: if (Request::isPost()) { goto en7UC; Inyu9: $oOn5l = $HsJPm->getTrimString('toVersion'); goto cWe0v; k2Ksz: $HsJPm = $WZ8dY->getJsonAsInput('data'); goto Inyu9; WHXKj: $thd7Y = $WZ8dY->getTrimString('step'); goto jc7Tg; cWe0v: BizException::throwsIfEmpty('toVersion为空', $oOn5l); goto ewJ12; en7UC: AdminPermission::demoCheck(); goto LF0Cz; ewJ12: switch ($thd7Y) { case 'upgradePackage': goto GTduB; WsOn6: $EiUju = $HsJPm->getTrimString('diffContentFile'); goto Gj8q8; pjqKT: BizException::throwsIfResponseError($Tbn6c); goto pgbnp; GTduB: $owryS = $HsJPm->getTrimString('package'); goto WsOn6; gigu1: $Tbn6c = UpgradeUtil::upgradePackage($owryS, $EiUju); goto pjqKT; Gj8q8: BizException::throwsIfEmpty('package为空', $owryS); goto ZBHmM; ZBHmM: BizException::throwsIfEmpty('diffContentFile为空', $EiUju); goto gigu1; pgbnp: return $this->doFinish(array('<span class="ub-text-success">升级完成，请 <a href="javascript:;" onclick="window.location.reload()">刷新后台</a> 查看最新系统</span>'), $Tbn6c['data']['logs']); goto d2OnR; d2OnR: case 'downloadPackage': goto wM2ch; wM2ch: $Tbn6c = UpgradeUtil::downloadPackage($Jqi9c, AppConstant::APP, AppConstant::VERSION, $oOn5l); goto pGV9M; pGV9M: BizException::throwsIfResponseError($Tbn6c); goto VReNk; VReNk: return $this->doNext('upgradePackage', array('<span class="ub-text-success">获取安装包完成，大小 ' . FileUtil::formatByte($Tbn6c['data']['packageSize']) . '</span>', '<span class="ub-text-white">开始解压升级装包...</span>'), array('package' => $Tbn6c['data']['package'], 'diffContentFile' => $Tbn6c['data']['diffContentFile'])); goto gXolv; gXolv: case 'checkPackage': goto xakX2; YEiMy: BizException::throwsIf('调用 php artisan 命令失败，不能自动升级', 0 != $NOH_v); goto gkTbU; gkTbU: return $this->doNext('downloadPackage', array('PHP版本: v' . PHP_VERSION, '<span class="ub-text-success">预检通过</span>', '<span class="ub-text-white">开始下载升级包...</span>')); goto m7fLv; xakX2: try { $NOH_v = Artisan::call('migrate'); } catch (\Exception $ZemkG) { $NOH_v = -1; } goto YEiMy; m7fLv: default: return $this->doNext('checkPackage', array('<span class="ub-text-success">开始升级系统，从 V' . AppConstant::VERSION . ' 到 V' . $oOn5l . '</span>', '<span class="ub-text-white">开始预检系统...</span>')); } goto siBqv; jc7Tg: $Jqi9c = $WZ8dY->getTrimString('token'); goto k2Ksz; LF0Cz: $WZ8dY = InputPackage::buildFromInput(); goto WHXKj; siBqv: } goto HwuEN; xg3ao: } public function auth() { return view('module::AdminManager.View.admin.auth', array('modules' => ModuleUtil::modules())); } public function info() { $xqIjl = UpgradeUtil::latest(); return Response::generateSuccessData(array('version' => AppConstant::VERSION, 'latestVersion' => $xqIjl['latestVersion'], 'autoUpgrade' => $xqIjl['autoUpgrade'])); } }