/** * Object initialization * * @return void */ protected function _construct() { $this->_init('Magento\\Customer\\Model\\Resource\\Visitor'); $userAgent = $this->httpHeader->getHttpUserAgent(); if ($this->ignoredUserAgents) { if (in_array($userAgent, $this->ignoredUserAgents)) { $this->skipRequestLogging = true; } } }
public function isToolbarAccessAllowed() { $allow = false; $allowedIps = $this->getConfig('dev/restrict/allow_ips'); $toolbarHeader = $this->getConfig('dev/restrict/toolbar_header'); $clientIp = $this->_getRequest()->getClientIp(); if (!empty($allowedIps)) { if (!empty($clientIp)) { $allowedIps = preg_split('#\\s*,\\s*#', $allowedIps, null, PREG_SPLIT_NO_EMPTY); if (array_search($clientIp, $allowedIps) !== false) { $allow = true; } } } elseif ($clientIp && $clientIp == '127.0.0.1') { $allow = true; } if (!empty($toolbarHeader)) { if (!preg_match('/' . $toolbarHeader . '/', $this->_httpHeader->getHttpUserAgent(true))) { $allow = false; } } return $allow; }
/** * @param $uaRegex * @param $currentUserAgent * @param $isCurrentUserAgent * @dataProvider isCurrentUserAgentDataProvider */ public function testIsCurrentUserAgent($uaRegex, $currentUserAgent, $isCurrentUserAgent) { $this->httpHeader->expects($this->any())->method('getHttpUserAgent')->willReturn($currentUserAgent); $this->assertEquals($isCurrentUserAgent, $this->request->isCurrentUserAgent($uaRegex)); }
/** * @param string $uaRegex * @return bool */ public function isCurrentUserAgent($uaRegex) { return $uaRegex && @preg_match($uaRegex, $this->httpHeader->getHttpUserAgent()); }
/** * Header value. Must be disabled for IE 8. * * @return string */ public function getValue() { return strpos($this->headerService->getHttpUserAgent(), self::IE_8_USER_AGENT) === false ? self::HEADER_ENABLED : self::HEADER_DISABLED; }
/** * Initialize visitor information from server data * * @return $this */ public function initServerData() { $clean = true; $this->addData(['server_addr' => $this->serverAddress->getServerAddress(true), 'remote_addr' => $this->remoteAddress->getRemoteAddress(true), 'http_secure' => $this->storeManager->getStore()->isCurrentlySecure(), 'http_host' => $this->httpHeader->getHttpHost($clean), 'http_user_agent' => $this->httpHeader->getHttpUserAgent($clean), 'http_accept_language' => $this->httpHeader->getHttpAcceptLanguage($clean), 'http_accept_charset' => $this->httpHeader->getHttpAcceptCharset($clean), 'request_uri' => $this->httpHeader->getRequestUri($clean), 'http_referer' => $this->httpHeader->getHttpReferer($clean)]); return $this; }
public function testGetRequestUri() { $this->assertNull($this->_header->getRequestUri()); }
public function testGetRequestUri() { $this->assertEquals('/', $this->_header->getRequestUri()); }