<?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 y59PD; gMSCD: $xeLB9 = Artisan::call('cache:clear'); goto xbon2; r0OvF: $xeLB9 = Artisan::call('view:clear'); goto EvQ2e; xbon2: if (0 != $xeLB9) { return Response::send(-1, L('Clear Cache') . ' ' . L('Error') . " cache:clear ExitCode({$xeLB9})"); } goto r0OvF; EvQ2e: if (0 != $xeLB9) { return Response::send(-1, L('Clear Cache') . ' ' . L('Error') . " view:clear ExitCode({$xeLB9})"); } goto wQEY0; hZ0wz: AdminPermission::permitCheck('SystemManage'); goto noRtn; kSYP7: return Response::jsonSuccess(L('Operate Success')); goto wpmh4; noRtn: Admin::addInfoLog(Admin::id(), L('Clear Cache')); goto gMSCD; wQEY0: ModStart::clearCache(); goto kSYP7; y59PD: AdminPermission::demoCheck(); goto hZ0wz; wpmh4: } public function securityFix(AdminDialogPage $WibEV) { goto Ee67V; Ee67V: AdminPermission::permitCheck('SystemManage'); goto t6aep; t6aep: $do_OL = InputPackage::buildFromInput(); goto dFuPq; vBbcS: return Response::sendError('Unknown Type'); goto qBsj2; dFuPq: $gJGJ7 = $do_OL->getTrimString('type'); goto jmgte; jmgte: switch ($gJGJ7) { case 'installLock': goto uZxt5; wZUd1: if (!file_exists(storage_path('install.lock'))) { return Response::json(-1, L('Operate Failed')); } goto pYd3A; N5iOs: if (!file_exists(storage_path('install.lock'))) { file_put_contents(storage_path('install.lock'), 'ok'); } goto wZUd1; uZxt5: AdminPermission::demoCheck(); goto N5iOs; pYd3A: return Response::json(0, L('Operate Success'), null, '[reload]'); goto hTBx4; hTBx4: case 'installScript': goto C9Ko2; hHCXw: return Response::json(0, L('Operate Success'), null, '[reload]'); goto sMxFB; HNtmG: if (file_exists(public_path('install.php'))) { @unlink(public_path('install.php')); } goto GrF16; C9Ko2: AdminPermission::demoCheck(); goto HNtmG; GrF16: if (file_exists(public_path('install.php'))) { return Response::json(-1, L('Operate Failed')); } goto hHCXw; sMxFB: case 'appDebug': goto SyBz_; mIS68: $ohNZt = file_get_contents(base_path('.env')); goto lFISp; QHHp6: return Response::json(0, L('Operate Success'), null, '[reload]'); goto VUAfo; FsgC_: file_put_contents(base_path('.env'), $ohNZt); goto QHHp6; lFISp: $ohNZt = preg_replace('/APP_DEBUG\\s*=\\s*true/', 'APP_DEBUG=false', $ohNZt); goto FsgC_; SyBz_: AdminPermission::demoCheck(); goto mIS68; VUAfo: case 'adminPath': goto mVziY; D0KVD: $mjvnb->text('oldPath', L('Current Path'))->rules('required')->value(config('env.ADMIN_PATH', '/admin/'))->readonly(true); goto eV2jd; QRBYB: return $WibEV->pageTitle(L('Change Admin Url'))->body($mjvnb); goto eBxnf; cA1vy: $mjvnb->showSubmit(false)->showReset(false); goto gfu2O; gfu2O: if (Request::isPost()) { return $mjvnb->formRequest(function (Form $mjvnb) { AdminPermission::demoCheck(); $IaeCl = $mjvnb->dataForming(); $yfxhH = $IaeCl['newPath']; if (!Str::startsWith($yfxhH, '/') || !Str::endsWith($yfxhH, '/')) { return Response::generateError(L('Url must start with / and end with /')); } if (!preg_match('/^\\/[a-zA-Z0-9_]+\\/$/', $yfxhH)) { return Response::generateError(L('Admin url only contains a-zA-Z0-9_')); } $ohNZt = file_get_contents(base_path('.env')); $ohNZt = preg_replace('/ADMIN_PATH\\s*=\\s*.*?\\n/', "ADMIN_PATH={$yfxhH}\n", $ohNZt); try { file_put_contents(base_path('.env'), $ohNZt); return Response::json(0, L('Operate Success'), null, '[js]parent.location.href="' . $yfxhH . '"'); } catch (\Exception $GrUf4) { return Response::jsonError(L('No Permission')); } }); } goto QRBYB; mVziY: $mjvnb = new Form(DynamicModel::class); goto D0KVD; eV2jd: $mjvnb->text('newPath', L('New Path'))->rules('required')->value('/admin_' . RandomUtil::lowerReadableString(6) . '/'); goto cA1vy; eBxnf: } goto vBbcS; qBsj2: } }