Primary.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace ForkBB\Controllers;
  3. use R2\DependencyInjection\ContainerInterface;
  4. class Primary
  5. {
  6. /**
  7. * Контейнер
  8. * @var ContainerInterface
  9. */
  10. protected $c;
  11. /**
  12. * Конструктор
  13. * @param array $config
  14. */
  15. public function __construct(ContainerInterface $container)
  16. {
  17. $this->c = $container;
  18. }
  19. /**
  20. * Проверка на обслуживание
  21. * Проверка на обновление
  22. * Проверка на бан
  23. * @return Page|null
  24. */
  25. public function check()
  26. {
  27. $config = $this->c->get('config');
  28. // Проверяем режим обслуживания форума
  29. if ($config['o_maintenance'] && ! defined('PUN_TURN_OFF_MAINT')) { //????
  30. if (! in_array($this->c->get('UserCookie')->id(), $this->c->get('admins'))
  31. || ! in_array($this->c->get('user')['id'], $this->c->get('admins'))
  32. ) {
  33. return $this->c->get('Maintenance');
  34. }
  35. }
  36. // Обновляем форум, если нужно
  37. if (empty($config['i_fork_revision']) || $config['i_fork_revision'] < FORK_REVISION) {
  38. header('Location: db_update.php'); //????
  39. exit;
  40. }
  41. if (($banned = $this->c->get('CheckBans')->check()) !== null) {
  42. return $this->c->get('Ban')->ban($banned);
  43. }
  44. }
  45. }