Check.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: dingran
  5. * Date: 2019/3/12
  6. * Time: 下午5:42
  7. */
  8. namespace app\common\middleware;
  9. use app\common\traits\JsonTrait;
  10. use app\common\facades\Setting;
  11. class Check
  12. {
  13. use JsonTrait;
  14. public function handle($request, \Closure $next)
  15. {
  16. $this->checkRegister();
  17. $this->checkStaticFile();
  18. return $next($request);
  19. }
  20. /**
  21. * 检测是否注册
  22. */
  23. private function checkRegister()
  24. {
  25. $setting = Setting::getNotUniacid('platform_shop.key');
  26. if ((!$setting['key'] || !$setting['secret']) && (request()->path() != 'admin/index' && !strpos(request()->path(), 'siteRegister'))) {
  27. $this->errorJson('', [
  28. 'status' => -5
  29. ])->send();
  30. exit;
  31. }
  32. }
  33. private function checkStaticFile()
  34. {
  35. $setting = Setting::getNotUniacid('platform_shop.key');
  36. if (($setting['key'] && $setting['secret']) && !is_dir(base_path('static')) && (request()->path() != 'admin/index' && !strpos(request()->path(), 'verifyCheck'))) {
  37. $this->errorJson('', [
  38. 'status' => 'upgrade'
  39. ])->send();
  40. exit;
  41. }
  42. }
  43. }