<?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 tlKm4; tlKm4: AdminPermission::demoCheck(); goto c_xSZ; S7k4g: ModStart::clearCache(); goto Si3Ni; W0uHl: $ot60b = Artisan::call('cache:clear'); goto U0Fjl; U0Fjl: if (0 != $ot60b) { return Response::send(-1, L('Clear Cache') . ' ' . L('Error') . " cache:clear ExitCode({$ot60b})"); } goto lbldw; R5Hvh: if (0 != $ot60b) { return Response::send(-1, L('Clear Cache') . ' ' . L('Error') . " view:clear ExitCode({$ot60b})"); } goto S7k4g; lbldw: $ot60b = Artisan::call('view:clear'); goto R5Hvh; Si3Ni: return Response::jsonSuccess(L('Operate Success')); goto yIkGH; BEwZj: Admin::addInfoLog(Admin::id(), L('Clear Cache')); goto W0uHl; c_xSZ: AdminPermission::permitCheck('SystemManage'); goto BEwZj; yIkGH: } public function securityFix(AdminDialogPage $l8Zr8) { goto GNYdQ; baNsO: $sYsuI = InputPackage::buildFromInput(); goto fp1Cr; fp1Cr: $E1HRj = $sYsuI->getTrimString('type'); goto qr2FZ; ta7cZ: return Response::sendError('Unknown Type'); goto lQNr7; GNYdQ: AdminPermission::permitCheck('SystemManage'); goto baNsO; qr2FZ: switch ($E1HRj) { case 'installLock': goto PBChY; ETGk2: if (!file_exists(storage_path('install.lock'))) { return Response::json(-1, L('Operate Failed')); } goto EXxkW; EXxkW: return Response::json(0, L('Operate Success'), null, '[reload]'); goto z3BId; PBChY: AdminPermission::demoCheck(); goto Og9yL; Og9yL: if (!file_exists(storage_path('install.lock'))) { file_put_contents(storage_path('install.lock'), 'ok'); } goto ETGk2; z3BId: case 'installScript': goto UXZ19; UXZ19: AdminPermission::demoCheck(); goto xInd4; xInd4: if (file_exists(public_path('install.php'))) { @unlink(public_path('install.php')); } goto XEzzT; pmHzO: return Response::json(0, L('Operate Success'), null, '[reload]'); goto zdxam; XEzzT: if (file_exists(public_path('install.php'))) { return Response::json(-1, L('Operate Failed')); } goto pmHzO; zdxam: case 'appDebug': goto judnL; qRO7k: file_put_contents(base_path('.env'), $BWI89); goto vS6al; h8ryj: $BWI89 = preg_replace('/APP_DEBUG\\s*=\\s*true/', 'APP_DEBUG=false', $BWI89); goto qRO7k; vS6al: return Response::json(0, L('Operate Success'), null, '[reload]'); goto r9PQE; judnL: AdminPermission::demoCheck(); goto yoPDj; yoPDj: $BWI89 = file_get_contents(base_path('.env')); goto h8ryj; r9PQE: case 'adminPath': goto CBw9v; CBw9v: $yfPYJ = new Form(DynamicModel::class); goto RM3vD; CvyiH: return $l8Zr8->pageTitle(L('Change Admin Url'))->body($yfPYJ); goto SdS0z; iRLBH: $yfPYJ->showSubmit(false)->showReset(false); goto Odmys; uhGHw: $yfPYJ->text('newPath', L('New Path'))->rules('required')->value('/admin_' . RandomUtil::lowerReadableString(6) . '/'); goto iRLBH; Odmys: if (Request::isPost()) { return $yfPYJ->formRequest(function (Form $yfPYJ) { AdminPermission::demoCheck(); $zonFp = $yfPYJ->dataForming(); $wnYot = $zonFp['newPath']; if (!Str::startsWith($wnYot, '/') || !Str::endsWith($wnYot, '/')) { return Response::generateError(L('Url must start with / and end with /')); } if (!preg_match('/^\\/[a-zA-Z0-9_]+\\/$/', $wnYot)) { return Response::generateError(L('Admin url only contains a-zA-Z0-9_')); } $BWI89 = file_get_contents(base_path('.env')); $BWI89 = preg_replace('/ADMIN_PATH\\s*=\\s*.*?\\n/', "ADMIN_PATH={$wnYot}\n", $BWI89); try { file_put_contents(base_path('.env'), $BWI89); return Response::json(0, L('Operate Success'), null, '[js]parent.location.href="' . $wnYot . '"'); } catch (\Exception $SwVsw) { return Response::jsonError(L('No Permission')); } }); } goto CvyiH; RM3vD: $yfPYJ->text('oldPath', L('Current Path'))->rules('required')->value(config('env.ADMIN_PATH', '/admin/'))->readonly(true); goto uhGHw; SdS0z: } goto ta7cZ; lQNr7: } }