<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Admin\Controller; use Illuminate\Routing\Controller; use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Str; use ModStart\Admin\Auth\Admin; use ModStart\Admin\Auth\AdminPermission; use ModStart\Admin\Layout\AdminDialogPage; use ModStart\Core\Dao\DynamicModel; use ModStart\Core\Exception\BizException; use ModStart\Core\Input\InputPackage; use ModStart\Core\Input\Request; use ModStart\Core\Input\Response; use ModStart\Core\Util\RandomUtil; use ModStart\Form\Form; use ModStart\Widget\Box; class SystemController extends Controller { public function clearCache() { goto l208V; FQc4g: $zLnaV = Artisan::call('view:clear'); goto I7V7G; I7V7G: if (0 != $zLnaV) { return Response::send(-1, L('Clear Cache') . ' ' . L('Error') . " view:clear ExitCode({$zLnaV})"); } goto k8HeC; chIxF: Admin::addInfoLog(Admin::id(), L('Clear Cache')); goto jsCoj; jsCoj: $zLnaV = Artisan::call('cache:clear'); goto u0Lfg; k8HeC: return Response::jsonSuccess(L('Operate Success')); goto WeYNT; th5BX: AdminPermission::permitCheck('SystemManage'); goto chIxF; l208V: AdminPermission::demoCheck(); goto th5BX; u0Lfg: if (0 != $zLnaV) { return Response::send(-1, L('Clear Cache') . ' ' . L('Error') . " cache:clear ExitCode({$zLnaV})"); } goto FQc4g; WeYNT: } public function securityFix(AdminDialogPage $gt42Q) { goto rbnV8; d5GQf: $BTuN4 = $R4txz->getTrimString('type'); goto sQS9N; mvsrq: $R4txz = InputPackage::buildFromInput(); goto d5GQf; hucYr: return Response::sendError('Unknown Type'); goto NwIk9; sQS9N: switch ($BTuN4) { case 'installLock': goto qyGIe; Sfrdl: if (!file_exists(storage_path('install.lock'))) { file_put_contents(storage_path('install.lock'), 'ok'); } goto Gi5uP; qyGIe: AdminPermission::demoCheck(); goto Sfrdl; Gi5uP: return Response::json(0, L('Operate Success'), null, '[reload]'); goto rnC0j; rnC0j: case 'appDebug': goto FHDTB; kRIf0: $xMSF0 = file_get_contents(base_path('.env')); goto qhAw6; qhAw6: $xMSF0 = preg_replace('/APP_DEBUG\\s*=\\s*true/', 'APP_DEBUG=false', $xMSF0); goto BttaH; kPP5g: return Response::json(0, L('Operate Success'), null, '[reload]'); goto ELt9A; BttaH: file_put_contents(base_path('.env'), $xMSF0); goto kPP5g; FHDTB: AdminPermission::demoCheck(); goto kRIf0; ELt9A: case 'adminPath': goto ACd0Z; nZ8ds: return $gt42Q->pageTitle(L('Change Admin Url'))->body($Pl0Cf); goto qp2FH; d01pN: $Pl0Cf->showSubmit(false)->showReset(false); goto v6EPf; pSCdG: $Pl0Cf->text('oldPath', L('Current Path'))->rules('required')->value(config('env.ADMIN_PATH', '/admin/'))->readonly(true); goto gYgPF; ACd0Z: $Pl0Cf = new Form(DynamicModel::class); goto pSCdG; v6EPf: if (Request::isPost()) { return $Pl0Cf->formRequest(function (Form $Pl0Cf) { AdminPermission::demoCheck(); $Y0YxF = $Pl0Cf->dataForming(); $L6gAf = $Y0YxF['newPath']; if (!Str::startsWith($L6gAf, '/') || !Str::endsWith($L6gAf, '/')) { return Response::generateError(L('Url must start with / and end with /')); } if (!preg_match('/^\\/[a-zA-Z0-9_]+\\/$/', $L6gAf)) { return Response::generateError(L('Admin url only contains a-zA-Z0-9_')); } $xMSF0 = file_get_contents(base_path('.env')); $xMSF0 = preg_replace('/ADMIN_PATH\\s*=\\s*.*?\\n/', "ADMIN_PATH={$L6gAf}\n", $xMSF0); try { file_put_contents(base_path('.env'), $xMSF0); return Response::json(0, L('Operate Success'), null, '[js]parent.location.href="' . $L6gAf . '"'); } catch (\Exception $vBRkZ) { return Response::jsonError(L('No Permission')); } }); } goto nZ8ds; gYgPF: $Pl0Cf->text('newPath', L('New Path'))->rules('required')->value('/admin_' . RandomUtil::readableString(6) . '/'); goto d01pN; qp2FH: } goto hucYr; rbnV8: AdminPermission::permitCheck('SystemManage'); goto mvsrq; NwIk9: } }