| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- /**
- * Created by PhpStorm.
- * User: dingran
- * Date: 2019/3/12
- * Time: 下午5:42
- */
- namespace app\common\middleware;
- use app\common\traits\JsonTrait;
- use app\common\facades\Setting;
- class Check
- {
- use JsonTrait;
- public function handle($request, \Closure $next)
- {
- $this->checkRegister();
- $this->checkStaticFile();
- return $next($request);
- }
- /**
- * 检测是否注册
- */
- private function checkRegister()
- {
- $setting = Setting::getNotUniacid('platform_shop.key');
- if ((!$setting['key'] || !$setting['secret']) && (request()->path() != 'admin/index' && !strpos(request()->path(), 'siteRegister'))) {
- $this->errorJson('', [
- 'status' => -5
- ])->send();
- exit;
- }
- }
- private function checkStaticFile()
- {
- $setting = Setting::getNotUniacid('platform_shop.key');
- if (($setting['key'] && $setting['secret']) && !is_dir(base_path('static')) && (request()->path() != 'admin/index' && !strpos(request()->path(), 'verifyCheck'))) {
- $this->errorJson('', [
- 'status' => 'upgrade'
- ])->send();
- exit;
- }
- }
- }
|