From 3c1dd3fe4d7ae49435d7fefd6e367a95bf6a0b16 Mon Sep 17 00:00:00 2001 From: Stein Magne Bjorklund <steinmb@smbjorklund.com> Date: Fri, 17 Sep 2021 12:01:05 +0200 Subject: [PATCH] Make boostrapping Loadspeakr a little less brittle - Require the application default settings. Loadspkr needs it and have to stop if not present and not simply throw a notification. - Introduce a constant that points to where Loadspkr have been installed. Allows us to later move the common.inc.php without it breaks the bootstrap. --- common.inc.php | 8 +++++--- index.php | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/common.inc.php b/common.inc.php index e96a79e2..7a4003dc 100644 --- a/common.inc.php +++ b/common.inc.php @@ -81,8 +81,10 @@ $conf['modules']['available'] = array('static','service', 'type'); $conf['admin']['pass'] = 'admin'; global $lodspk; - $lodspk['maxResults'] = 1000; -include_once('settings.inc.php'); + +if (file_exists(LOADSPEAKR_ROOT . '/settings.inc.php')) { + require_once LOADSPEAKR_ROOT . '/settings.inc.php'; +} + $conf['view']['standard']['baseUrl'] = $conf['basedir']; -?> diff --git a/index.php b/index.php index 3838be68..40ba2c83 100644 --- a/index.php +++ b/index.php @@ -7,7 +7,10 @@ use uib\ub\loadspeakr\Importer; use uib\ub\loadspeakr\Logging; use uib\ub\loadspeakr\Utils; +const LOADSPEAKR_ROOT = __DIR__; + require_once __DIR__ . '/vendor/autoload.php'; +require_once __DIR__ . '/common.inc.php'; if (isset($_GET['q']) && $_GET['q'] === 'import') { $imp = new Importer(); @@ -21,8 +24,6 @@ if (!file_exists('settings.inc.php')) { exit(0); } -include_once('common.inc.php'); - $conf['logfile'] = null; if ($conf['debug']) { if (isset($_GET['q']) && $_GET['q'] === 'logs') { @@ -64,7 +65,6 @@ if ($uri === $conf['basedir']) { // Configure external URIs if necessary. $localUri = $conf['basedir'] . $_GET['q']; -$foo = $_SERVER['HTTP_HOST']; $uri = Utils::getMirroredUri($localUri); // Load Loadspeakr modules. -- GitLab