![]() 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/old/vendor/magento/module-store/Model/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Store\Model; use Magento\Store\Model\ScopeInterface; /** * Verifies that the requested URL matches to base URL of store. */ class BaseUrlChecker { /** * @var \Magento\Framework\App\Config\ScopeConfigInterface */ private $scopeConfig; /** * BaseUrlChecker constructor. * * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig ) { $this->scopeConfig = $scopeConfig; } /** * Performs verification. * * @param array $uri * @param \Magento\Framework\App\Request\Http $request * @return bool */ public function execute($uri, $request) { $requestUri = $request->getRequestUri() ? $request->getRequestUri() : '/'; $isValidSchema = !isset($uri['scheme']) || $uri['scheme'] === $request->getScheme(); $isValidHost = !isset($uri['host']) || $uri['host'] === $request->getHttpHost(); $isValidPath = !isset($uri['path']) || strpos($requestUri, (string) $uri['path']) !== false; return $isValidSchema && $isValidHost && $isValidPath; } /** * Checks whether base URL verification is enabled or not. * * @return bool */ public function isEnabled() { return $this->scopeConfig->isSetFlag( 'web/url/redirect_to_base', ScopeInterface::SCOPE_STORE ); } /** * Checks whether frontend is completely secure or not. * * @return bool */ public function isFrontendSecure() { $baseUrl = $this->scopeConfig->getValue( 'web/unsecure/base_url', ScopeInterface::SCOPE_STORE ); $baseUrlParts = explode('://', $baseUrl); $baseUrlProtocol = array_shift($baseUrlParts); $isSecure = $this->scopeConfig->isSetFlag( 'web/secure/use_in_frontend', ScopeInterface::SCOPE_STORE ); return $isSecure && $baseUrlProtocol == 'https'; } }