AdminLoginListener.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * +----------------------------------------------------------------------
  4. * | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  5. * +----------------------------------------------------------------------
  6. * | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  7. * +----------------------------------------------------------------------
  8. * | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  9. * +----------------------------------------------------------------------
  10. * | Author: CRMEB Team <admin@crmeb.com>
  11. * +----------------------------------------------------------------------
  12. */
  13. namespace app\listener\admin;
  14. /**
  15. * Class AdminLogin
  16. * @package app\listener\admin
  17. */
  18. class AdminLoginListener
  19. {
  20. public function handle($event)
  21. {
  22. $res = false;
  23. $res1 = false;
  24. try {
  25. [$key] = $event;
  26. //检测消息队列是否执行
  27. $path = root_path('runtime') . '.queue';
  28. $content = file_get_contents($path);
  29. $res = $key === $content;
  30. if (sys_config('queue_open', 0) == 0) $res = true;
  31. unlink($path);
  32. } catch (\Throwable $e) {
  33. }
  34. try {
  35. $timerPath = root_path('runtime') . '.timer';
  36. $timer = file_get_contents($timerPath);
  37. if ($timer && $timer <= time() && $timer > (time() - 70)) {
  38. $res1 = true;
  39. }
  40. } catch (\Throwable $e) {
  41. }
  42. return [$res, $res1];
  43. }
  44. }