diff --git a/server/_inc.php b/server/_inc.php index 7b7d542..b8505ff 100644 --- a/server/_inc.php +++ b/server/_inc.php @@ -43,7 +43,7 @@ class UserException extends \Exception {} 'ERRORS_REPORT_URL' => null, 'TITLE' => 'My oPodSync server', 'DEBUG_LOG' => null, - 'HTTP_SCHEME' => !empty($_SERVER['HTTPS']) || $_SERVER['SERVER_PORT'] == 443 ? 'https' : 'http', + 'HTTP_SCHEME' => !empty($_SERVER['HTTPS']) || ($_SERVER['SERVER_PORT'] ?? null) == 443 ? 'https' : 'http', ]; foreach ($defaults as $const => $value) { @@ -73,8 +73,9 @@ class UserException extends \Exception {} } if (!defined(__NAMESPACE__ . '\BASE_URL')) { - $name = $_SERVER['SERVER_NAME']; - $port = !in_array($_SERVER['SERVER_PORT'], [80, 443]) ? ':' . $_SERVER['SERVER_PORT'] : ''; + $name = $_SERVER['SERVER_NAME'] ?? 'localhost'; + $server_port = $_SERVER['SERVER_PORT'] ?? null; + $port = $server_port && !in_array($server_port, [80, 443]) ? ':' . $server_port : ''; $root = '/'; define(__NAMESPACE__ . '\BASE_URL', sprintf('%s://%s%s%s', HTTP_SCHEME, $name, $port, $root)); diff --git a/server/index.php b/server/index.php index c965695..91dab71 100644 --- a/server/index.php +++ b/server/index.php @@ -2,7 +2,7 @@ namespace OPodSync; -$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); +$uri = parse_url($_SERVER['REQUEST_URI'] ?? '', PHP_URL_PATH); // Stop here if we are using CLI server and the requested resource exists, // it will be served by PHP HTTP server