diff --git a/README.md b/README.md index dd70de5..e580fea 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,8 @@ services: - type: bind source: ~/docker_files/gpodder/data target: /var/www/server/data + environment: + - gpodder_url=https://gpodder.example.org hostname: gpodder.example.org ports: - 80:80 diff --git a/server/inc/API.php b/server/inc/API.php index f2cace2..6487d12 100644 --- a/server/inc/API.php +++ b/server/inc/API.php @@ -28,6 +28,12 @@ public function __construct(DB $db) $url .= ':' . $_SERVER['SERVER_PORT']; } + // Check if environment variable with service url is set + // When running inside Docker, we cannot determine the correct URL by ourselves. + if (getenv('gpodder_url') !== false) { + $url = getenv('gpodder_url'); + } + $url .= '/'; $this->base_url = $url; } diff --git a/server/index.php b/server/index.php index 8952a0a..cea9ac3 100644 --- a/server/index.php +++ b/server/index.php @@ -70,12 +70,12 @@ function html_head() { - ' . htmlspecialchars($title) . ' + ' . htmlspecialchars($title ?? '') . ' -

' . htmlspecialchars($title) . '

+

' . htmlspecialchars($title ?? '') . '

'; } @@ -101,11 +101,11 @@ function html_foot() { foreach ($gpodder->listActions((int)$_GET['id']) as $row) { printf('%s%s%s%s', - htmlspecialchars($row->action), - htmlspecialchars($row->device), + htmlspecialchars($row->action ?? ''), + htmlspecialchars($row->device ?? ''), date('d/m/Y H:i', $row->changed), - htmlspecialchars($row->url), - htmlspecialchars(basename($row->url)), + htmlspecialchars($row->url ?? ''), + htmlspecialchars(basename($row->url) ?? ''), ); } } @@ -115,7 +115,7 @@ function html_foot() { foreach ($gpodder->listActiveSubscriptions() as $row) { printf('%s%s%d', $row->id, - htmlspecialchars($row->url), + htmlspecialchars($row->url ?? ''), date('d/m/Y H:i', $row->changed), $row->count ); @@ -153,7 +153,7 @@ function html_foot() { html_head(); if ($error) { - printf('

%s

', htmlspecialchars($error)); + printf('

%s

', htmlspecialchars($error ?? '')); } if (isset($_GET['token'])) { @@ -188,7 +188,7 @@ function html_foot() { echo '

Invalid captcha.

'; } elseif ($error = $gpodder->subscribe($_POST['username'] ?? '', $_POST['password'] ?? '')) { - printf('

%s

', htmlspecialchars($error)); + printf('

%s

', htmlspecialchars($error ?? '')); } else { echo '

Your account is registered.

';