<?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 Us0j4; Rvdm3: if (0 != $JsjsY) { return Response::send(-1, L('Clear Cache') . ' ' . L('Error') . " view:clear ExitCode({$JsjsY})"); } goto qPyMj; RYDqT: AdminPermission::permitCheck('SystemManage'); goto jWT2_; Us0j4: AdminPermission::demoCheck(); goto RYDqT; qPyMj: ModStart::clearCache(); goto uwabV; WSySt: if (0 != $JsjsY) { return Response::send(-1, L('Clear Cache') . ' ' . L('Error') . " cache:clear ExitCode({$JsjsY})"); } goto fZjko; sYoBN: $JsjsY = Artisan::call('cache:clear'); goto WSySt; fZjko: $JsjsY = Artisan::call('view:clear'); goto Rvdm3; jWT2_: Admin::addInfoLog(Admin::id(), L('Clear Cache')); goto sYoBN; uwabV: return Response::jsonSuccess(L('Operate Success')); goto hzEmV; hzEmV: } public function securityFix(AdminDialogPage $DbaB3) { goto DOyjA; bAoYu: $BYzWI = $vfMTB->getTrimString('type'); goto llO_J; tpXxT: return Response::sendError('Unknown Type'); goto nZ19Q; llO_J: switch ($BYzWI) { case 'installLock': goto dhaVI; WvA83: if (!file_exists(storage_path('install.lock'))) { return Response::json(-1, L('Operate Failed')); } goto uKIYX; dhaVI: AdminPermission::demoCheck(); goto e3bsT; e3bsT: if (!file_exists(storage_path('install.lock'))) { file_put_contents(storage_path('install.lock'), 'ok'); } goto WvA83; uKIYX: return Response::json(0, L('Operate Success'), null, '[reload]'); goto pE1Fm; pE1Fm: case 'installScript': goto lIG0P; pm_Ur: if (file_exists(public_path('install.php'))) { @unlink(public_path('install.php')); } goto bezMz; mJ9xd: return Response::json(0, L('Operate Success'), null, '[reload]'); goto x2DTk; bezMz: if (file_exists(public_path('install.php'))) { return Response::json(-1, L('Operate Failed')); } goto mJ9xd; lIG0P: AdminPermission::demoCheck(); goto pm_Ur; x2DTk: case 'appDebug': goto n1oUS; dz3PB: file_put_contents(base_path('.env'), $gP2DQ); goto W1n55; pEMtR: $gP2DQ = file_get_contents(base_path('.env')); goto OsfgV; OsfgV: $gP2DQ = preg_replace('/APP_DEBUG\\s*=\\s*true/', 'APP_DEBUG=false', $gP2DQ); goto dz3PB; n1oUS: AdminPermission::demoCheck(); goto pEMtR; W1n55: return Response::json(0, L('Operate Success'), null, '[reload]'); goto NMDcm; NMDcm: case 'adminPath': goto B8IAB; mTUvo: return $DbaB3->pageTitle(L('Change Admin Url'))->body($dBWZm); goto aKQEM; jcHfJ: $dBWZm->text('newPath', L('New Path'))->rules('required')->value('/admin_' . RandomUtil::lowerReadableString(6) . '/'); goto wSjcz; jaI86: $dBWZm->text('oldPath', L('Current Path'))->rules('required')->value(config('env.ADMIN_PATH', '/admin/'))->readonly(true); goto jcHfJ; wSjcz: $dBWZm->showSubmit(false)->showReset(false); goto UUE7x; UUE7x: if (Request::isPost()) { return $dBWZm->formRequest(function (Form $dBWZm) { AdminPermission::demoCheck(); $dTnlu = $dBWZm->dataForming(); $gGiiZ = $dTnlu['newPath']; if (!Str::startsWith($gGiiZ, '/') || !Str::endsWith($gGiiZ, '/')) { return Response::generateError(L('Url must start with / and end with /')); } if (!preg_match('/^\\/[a-zA-Z0-9_]+\\/$/', $gGiiZ)) { return Response::generateError(L('Admin url only contains a-zA-Z0-9_')); } $gP2DQ = file_get_contents(base_path('.env')); $gP2DQ = preg_replace('/ADMIN_PATH\\s*=\\s*.*?\\n/', "ADMIN_PATH={$gGiiZ}\n", $gP2DQ); try { file_put_contents(base_path('.env'), $gP2DQ); return Response::json(0, L('Operate Success'), null, '[js]parent.location.href="' . $gGiiZ . '"'); } catch (\Exception $Sgh1N) { return Response::jsonError(L('No Permission')); } }); } goto mTUvo; B8IAB: $dBWZm = new Form(DynamicModel::class); goto jaI86; aKQEM: } goto tpXxT; DOyjA: AdminPermission::permitCheck('SystemManage'); goto VtEz1; VtEz1: $vfMTB = InputPackage::buildFromInput(); goto bAoYu; nZ19Q: } }