Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions server/_inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion server/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down