14 private $skipSecurity;
18 parent::__construct();
21 ->setStatus(
'302 Found')
22 ->setSkipSecurity($skipSecurity)
41 $this->url = (string)$url;
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,
"/"))
98 $url = (string)(
new Uri($this->url));
101 $url = str_replace([
"&",
"\r",
"\n"], [
"&",
"",
""],
$url);
106 private function processInternalUrl($url)
113 $server = Context::getCurrent()->getServer();
114 $protocol = Context::getCurrent()->getRequest()->isHttps() ?
"https" :
"http";
115 $host = $server->getHttpHost();
116 $port = (int)$server->getServerPort();
117 if ($port !== 80 && $port !== 443 && $port > 0 && !str_contains(
$host,
":"))
119 $host .=
":" . $port;
122 return "{$protocol}://{$host}{$url}";
127 if ($this->checkTrial())
133 $isExternal = $this->isExternalUrl($url);
134 $url = $this->modifyBySecurity($url);
144 $url = $this->processInternalUrl($url);
setSkipSecurity(bool $skipSecurity)
__construct($url, bool $skipSecurity=false)
addHeader($name, $value='')