processing HTTP_HOST to update SERVER_NAME and SERVER_PORT in .server_info
This commit is contained in:
@@ -308,6 +308,22 @@ try {
|
|||||||
$_CSERVER = $_SERVER;
|
$_CSERVER = $_SERVER;
|
||||||
unset($_CSERVER['REQUEST_TIME']);
|
unset($_CSERVER['REQUEST_TIME']);
|
||||||
unset($_CSERVER['REMOTE_PORT']);
|
unset($_CSERVER['REMOTE_PORT']);
|
||||||
|
if (!empty($_SERVER['HTTP_HOST'])) {
|
||||||
|
$hostParts = explode(':', $_SERVER['HTTP_HOST']);
|
||||||
|
|
||||||
|
$host = $hostParts[0];
|
||||||
|
|
||||||
|
if (isset($hostParts[1]) && is_numeric($hostParts[1])) {
|
||||||
|
$port = (int)$hostParts[1];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$host = $_SERVER['SERVER_NAME'] ?? 'localhost';
|
||||||
|
$port = $_SERVER['SERVER_PORT'] ?? 80;
|
||||||
|
}
|
||||||
|
|
||||||
|
$_CSERVER['SERVER_PORT'] = (string)$port;
|
||||||
|
$_CSERVER['SERVER_NAME'] = (string)$host;
|
||||||
|
|
||||||
$cput = serialize($_CSERVER);
|
$cput = serialize($_CSERVER);
|
||||||
if (!is_file(PATH_DATA_SITE . '.server_info')) {
|
if (!is_file(PATH_DATA_SITE . '.server_info')) {
|
||||||
file_put_contents(PATH_DATA_SITE . '.server_info', $cput);
|
file_put_contents(PATH_DATA_SITE . '.server_info', $cput);
|
||||||
|
|||||||
Reference in New Issue
Block a user