<?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\Input\InputPackage; use ModStart\Core\Input\Request; use ModStart\Core\Input\Response; use ModStart\Core\Util\RandomUtil; use ModStart\Form\Form; use ModStart\ModStart; class SystemController extends Controller { public function clearCache() { goto yrytH; mESTY: ModStart::clearCache(); goto XZay9; bpv3_: Admin::addInfoLog(Admin::id(), L('Clear Cache')); goto N4tbX; gBr0J: if (0 != $nhQHe) { return Response::send(-1, L('Clear Cache') . ' ' . L('Error') . " cache:clear ExitCode({$nhQHe})"); } goto qfDoh; yrytH: AdminPermission::demoCheck(); goto hwdCc; hwdCc: AdminPermission::permitCheck('SystemManage'); goto bpv3_; iI_Oz: if (0 != $nhQHe) { return Response::send(-1, L('Clear Cache') . ' ' . L('Error') . " view:clear ExitCode({$nhQHe})"); } goto mESTY; qfDoh: $nhQHe = Artisan::call('view:clear'); goto iI_Oz; N4tbX: $nhQHe = Artisan::call('cache:clear'); goto gBr0J; XZay9: return Response::jsonSuccess(L('Operate Success')); goto GWtmN; GWtmN: } public function securityFix(AdminDialogPage $FzbRC) { goto C3Koa; C3Koa: AdminPermission::permitCheck('SystemManage'); goto oLe2M; oLe2M: $TG2we = InputPackage::buildFromInput(); goto W2e1U; W2e1U: $F28aA = $TG2we->getTrimString('type'); goto CC1ad; vt44K: return Response::sendError('Unknown Type'); goto KJJHV; CC1ad: switch ($F28aA) { case 'installLock': goto wtwrz; wtwrz: AdminPermission::demoCheck(); goto bj3MW; bj3MW: if (!file_exists(storage_path('install.lock'))) { file_put_contents(storage_path('install.lock'), 'ok'); } goto ZHUo4; ZHUo4: if (!file_exists(storage_path('install.lock'))) { return Response::json(-1, L('Operate Failed')); } goto hcWwe; hcWwe: return Response::json(0, L('Operate Success'), null, '[reload]'); goto osfl_; osfl_: case 'installScript': goto POE3G; eBxep: if (file_exists(public_path('install.php'))) { return Response::json(-1, L('Operate Failed')); } goto njPQV; njPQV: return Response::json(0, L('Operate Success'), null, '[reload]'); goto RrZhA; POE3G: AdminPermission::demoCheck(); goto OfeGZ; OfeGZ: if (file_exists(public_path('install.php'))) { @unlink(public_path('install.php')); } goto eBxep; RrZhA: case 'appDebug': goto u15bj; u15bj: AdminPermission::demoCheck(); goto cSV00; A76rM: return Response::json(0, L('Operate Success'), null, '[reload]'); goto IJC44; uYcgg: file_put_contents(base_path('.env'), $LTC5O); goto A76rM; cSV00: $LTC5O = file_get_contents(base_path('.env')); goto oZpwj; oZpwj: $LTC5O = preg_replace('/APP_DEBUG\\s*=\\s*true/', 'APP_DEBUG=false', $LTC5O); goto uYcgg; IJC44: case 'adminPath': goto P3bb3; usKb9: $wDk8k->showSubmit(false)->showReset(false); goto L6LeP; nlzM0: return $FzbRC->pageTitle(L('Change Admin Url'))->body($wDk8k); goto rwQlS; c72mW: $wDk8k->text('oldPath', L('Current Path'))->rules('required')->value(config('env.ADMIN_PATH', '/admin/'))->readonly(true); goto JxgTc; JxgTc: $wDk8k->text('newPath', L('New Path'))->rules('required')->value('/admin_' . RandomUtil::lowerReadableString(6) . '/'); goto usKb9; L6LeP: if (Request::isPost()) { return $wDk8k->formRequest(function (Form $wDk8k) { AdminPermission::demoCheck(); $Sj05q = $wDk8k->dataForming(); $kvTbV = $Sj05q['newPath']; if (!Str::startsWith($kvTbV, '/') || !Str::endsWith($kvTbV, '/')) { return Response::generateError(L('Url must start with / and end with /')); } if (!preg_match('/^\\/[a-zA-Z0-9_]+\\/$/', $kvTbV)) { return Response::generateError(L('Admin url only contains a-zA-Z0-9_')); } $LTC5O = file_get_contents(base_path('.env')); $LTC5O = preg_replace('/ADMIN_PATH\\s*=\\s*.*?\\n/', "ADMIN_PATH={$kvTbV}\n", $LTC5O); try { file_put_contents(base_path('.env'), $LTC5O); return Response::json(0, L('Operate Success'), null, '[js]parent.location.href="' . $kvTbV . '"'); } catch (\Exception $tZVhb) { return Response::jsonError(L('No Permission')); } }); } goto nlzM0; P3bb3: $wDk8k = new Form(DynamicModel::class); goto c72mW; rwQlS: } goto vt44K; KJJHV: } }