From 8455a98ec5fc120863307038f6e85dc57d579757 Mon Sep 17 00:00:00 2001 From: Yasen Pramatarov Date: Thu, 1 Aug 2024 11:20:31 +0300 Subject: [PATCH] Searches for default config file --- public_html/index.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/public_html/index.php b/public_html/index.php index 54758f5..49d1be4 100644 --- a/public_html/index.php +++ b/public_html/index.php @@ -31,8 +31,22 @@ $allowed_urls = [ ]; // cnfig file -$config_file = '/home/yasen/work/code/git/lindeas-code/jilo-web/jilo-web.conf.php'; -if (file_exists($config_file)) { +// possible locations, in order of preference +$config_file_locations = [ + __DIR__ . '/../jilo-web.conf.php', + '/srv/jilo-web/jilo-web.conf.php', + '/opt/jilo-web/jilo-web.conf.php' +]; +$config_file = null; +// try to find the config file +foreach ($config_file_locations as $location) { + if (file_exists($location)) { + $config_file = $location; + break; + } +} +// if found, use it +if ($config_file) { require_once $config_file; } else { die('Config file not found');