You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
815B

  1. <?php
  2. /**
  3. * @author La clic ! <contact@laclic.fr>
  4. */
  5. namespace Lc\SovBundle\Resolver;
  6. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  7. class UrlResolver
  8. {
  9. protected ParameterBagInterface $parameterBag;
  10. public function __construct(ParameterBagInterface $parameterBag)
  11. {
  12. $this->parameterBag = $parameterBag;
  13. }
  14. public function isServerLocalhost(): bool
  15. {
  16. return in_array($_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1']);
  17. }
  18. public function isBot(): bool
  19. {
  20. if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match(
  21. '/bot|crawl|slurp|spider/i',
  22. $_SERVER['HTTP_USER_AGENT']
  23. )) {
  24. return true;
  25. } else {
  26. return false;
  27. }
  28. }
  29. }