From 18f60648ebff2c350e2c32c21b2c2ab5f685f951 Mon Sep 17 00:00:00 2001
From: Stein Magne Bjorklund <steinmb@smbjorklund.com>
Date: Thu, 16 Sep 2021 10:11:39 +0200
Subject: [PATCH] Make index.php validate

Addressing a old legacy bug. Making sure the file validate also make it
easier to spot newly introduced errors and bugs.
---
 index.php | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/index.php b/index.php
index d4eb0337..d4ccd194 100644
--- a/index.php
+++ b/index.php
@@ -17,7 +17,7 @@ if (isset($_GET['q']) && $_GET['q'] === 'import') {
 
 // Check that application is installed.
 if (!file_exists('settings.inc.php')) {
-    echo 'Need to configure lodspeakr first. Please run "install.sh". Alternatively, you can <a href="import">import an existing application</a>';
+    echo 'Need to configure lodspeakr first. Please run "install.sh". Alternatively, you can <a href="' . $_SERVER['HTTP_HOST'] . '/import">import an existing application</a>';
     exit(0);
 }
 
@@ -48,7 +48,7 @@ $endpoints['local'] = new Endpoint($conf['endpoint']['local'], $conf['endpointPa
 
 $acceptContentType = Utils::getBestContentType($_SERVER['HTTP_ACCEPT'], $conf['http_accept']);
 $extension = Utils::getExtension($acceptContentType, $conf['http_accept']);
-
+$uri = $conf['basedir'] . $_GET['q'];
 
 // Check that content type is supported by LODSPeaKr.
 if ($acceptContentType === null) {
@@ -65,7 +65,6 @@ if ($conf['export'] && $_GET['q'] === 'export') {
 }
 
 // Redirect to root URL if necessary.
-$uri = $conf['basedir'] . $_GET['q'];
 $localUri = $uri;
 if ($uri === $conf['basedir']) {
     header('Location: ' . $conf['root']);
-- 
GitLab