14 private $skipSecurity;
18 parent::__construct();
21 ->setStatus(
'302 Found')
22 ->setSkipSecurity($skipSecurity)
51 return $this->skipSecurity;
60 $this->skipSecurity = $skipSecurity;
65 private function checkTrial(): bool
68 defined(
"DEMO") && DEMO ===
"Y" &&
70 !defined(
"SITEEXPIREDATE") ||
71 !defined(
"OLDSITEEXPIREDATE") ||
72 SITEEXPIREDATE ==
'' ||
73 SITEEXPIREDATE != OLDSITEEXPIREDATE
80 private function isExternalUrl($url): bool
82 return preg_match(
"'^(http://|https://|ftp://)'i", $url);
85 private function modifyBySecurity($url)
90 $isExternal = $this->isExternalUrl($url);
91 if (!$isExternal && !str_starts_with($url,
"/"))
93 $url = $APPLICATION->GetCurDir() . $url;
96 $url = str_replace([
"&",
"\r",
"\n"], [
"&",
"",
""], $url);
98 if (!defined(
"BX_UTF") && defined(
"LANG_CHARSET"))
100 $url = Encoding::convertEncoding($url, LANG_CHARSET,
"UTF-8");
106 private function processInternalUrl($url)
111 $APPLICATION->StoreCookies();
115 $host = $server->getHttpHost();
116 $port = (int)$server->getServerPort();
117 if ($port !== 80 && $port !== 443 && $port > 0 && strpos($host,
":") ===
false)
119 $host .=
":" . $port;
122 return "{$protocol}://{$host}{$url}";
127 if ($this->checkTrial())
129 die(Main\Localization\
Loc::getMessage(
'MAIN_ENGINE_REDIRECT_TRIAL_EXPIRED'));
133 $isExternal = $this->isExternalUrl($url);
134 $url = $this->modifyBySecurity($url);
137 foreach (GetModuleEvents(
"main",
"OnBeforeLocalRedirect",
true) as $event)
139 ExecuteModuleEventEx($event, [&$url, $this->
isSkippedSecurity(), &$isExternal, $this]);
144 $url = $this->processInternalUrl($url);
148 foreach (GetModuleEvents(
"main",
"OnLocalRedirect",
true) as $event)
150 ExecuteModuleEventEx($event);
153 Main\Application::getInstance()->getKernelSession()[
"BX_REDIRECT_TIME"] = time();
setSkipSecurity(bool $skipSecurity)
__construct($url, bool $skipSecurity=false)
addHeader($name, $value='')
static getMessage($code, $replace=null, $language=null)