Skip to content

Commit ae63bc1

Browse files
committed
Update $MYSITE to use HTTP_HOST
1 parent b2ed7a9 commit ae63bc1

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

include/site.inc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,14 @@ if (!isset($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] != "on") {
244244
$proto = "https";
245245
}
246246

247-
if ($_SERVER["SERVER_PORT"] != '80' && $_SERVER["SERVER_PORT"] != 443) {
247+
$hostHeader = $hostHeader = $_SERVER["HTTP_HOST"] ?? null;
248+
if ($hostHeader
249+
/* incoming hostname validation logic */
250+
&& preg_match('/^([a-z0-9]([a-z0-9-]*[a-z0-9])?\.)*[a-z0-9]([a-z0-9-]*[a-z0-9])?(?::\d{1,5})?$/i', $hostHeader)
251+
) {
252+
$MYSITE = $proto . '://' . $hostHeader . '/';
253+
$msite = 'https://' . $hostHeader . '/';
254+
} elseif ($_SERVER["SERVER_PORT"] != '80' && $_SERVER["SERVER_PORT"] != 443) {
248255
$MYSITE = $proto . '://' . $_SERVER["SERVER_NAME"] . ':' . (int)$_SERVER["SERVER_PORT"] . '/';
249256
$msite = 'http://' . $_SERVER["SERVER_NAME"] . ':' . (int)$_SERVER["SERVER_PORT"] . '/';
250257
} else {

0 commit comments

Comments
 (0)