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.

43 lines
962B

  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()
  15. {
  16. return in_array($_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1']);
  17. }
  18. public function getCookieDomain()
  19. {
  20. return ($this->isServerLocalhost()) ? null : $this->parameterBag->get('app.cookie_domain_distant');
  21. }
  22. public function isBot()
  23. {
  24. if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match(
  25. '/bot|crawl|slurp|spider/i',
  26. $_SERVER['HTTP_USER_AGENT']
  27. )) {
  28. return true;
  29. } else {
  30. return false;
  31. }
  32. }
  33. }