![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/mautic.corals.io/app/bundles/CoreBundle/IpLookup/ |
<?php namespace Mautic\CoreBundle\IpLookup; use GuzzleHttp\Exception\GuzzleException; abstract class AbstractRemoteDataLookup extends AbstractLookup { /** * Method to use when communicating with the service. * * @var string */ protected $method = 'get'; /** * Get the URL to fetch data from. * * @return mixed */ abstract protected function getUrl(); /** * @return mixed */ abstract protected function parseResponse($response); /** * @return array */ protected function getHeaders() { return []; } /** * @return array */ protected function getParameters() { return []; } /** * Fetch data from lookup service. */ protected function lookup() { $url = $this->getUrl(); try { $response = ('post' == $this->method) ? $this->client->post($url, [ \GuzzleHttp\RequestOptions::BODY => $this->getParameters(), \GuzzleHttp\RequestOptions::HEADERS => $this->getHeaders(), \GuzzleHttp\RequestOptions::TIMEOUT => 10, ]) : $this->client->get($url, [ \GuzzleHttp\RequestOptions::HEADERS => $this->getHeaders(), \GuzzleHttp\RequestOptions::TIMEOUT => 10, ]); $this->parseResponse($response->getBody()); } catch (GuzzleException $exception) { if ($this->logger) { $this->logger->warning('IP LOOKUP: '.$exception->getMessage()); } } } }