From 3197544cccb6620ee20edd0e5cc873cbb4fb8599 Mon Sep 17 00:00:00 2001 From: Joerg Date: Sun, 14 Apr 2024 17:43:49 +0200 Subject: [PATCH] Docker-readiness --- index.php | 6 ++++-- install/includes/core_class.php | 30 +++++++++++++++++------------- install/index.php | 3 +++ 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/index.php b/index.php index 689cce4d7..d1b1f81b4 100644 --- a/index.php +++ b/index.php @@ -54,7 +54,9 @@ * NOTE: If you change these, also change the error_reporting() code below */ #define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development'); - if (file_exists('.debug')) { + if (isset($_SERVER['CI_ENV'])) { + define('ENVIRONMENT', $_SERVER['CI_ENV']) { + elseif (file_exists('.debug')) { define('ENVIRONMENT', 'development'); } else if (file_exists('.maintenance')) { define('ENVIRONMENT', 'maintenance'); @@ -81,7 +83,7 @@ switch (ENVIRONMENT) error_reporting(-1); ini_set('display_errors', 1); break; - + case 'production': ini_set('display_errors', 0); if (version_compare(PHP_VERSION, '5.3', '>=')) diff --git a/install/includes/core_class.php b/install/includes/core_class.php index fabe5dcbd..0c74f12f2 100644 --- a/install/includes/core_class.php +++ b/install/includes/core_class.php @@ -41,27 +41,27 @@ class Core // Validate First Name if (isset($_POST['firstname']) && !empty($_POST['firstname'])) { $counter++; - } + } // Validate Last Name if (isset($_POST['lastname']) && !empty($_POST['lastname'])) { $counter++; - } + } // Validate Username if (isset($_POST['username']) && !empty($_POST['username'])) { $counter++; - } + } // Validate Callsign if (isset($_POST['callsign']) && !empty($_POST['callsign'])) { $counter++; - } + } // Validate Password if (isset($_POST['password']) && !empty($_POST['password'])) { $counter++; - } + } // Validate Locator if (isset($_POST['userlocator']) && !empty($_POST['userlocator'])) { @@ -78,7 +78,7 @@ class Core // Validate Confirm Password if (isset($_POST['cnfm_password']) && !empty($_POST['cnfm_password'])) { $counter++; - } + } // Validate Email Address if (isset($_POST['user_email']) && filter_var($_POST['user_email'], FILTER_VALIDATE_EMAIL)) { @@ -90,7 +90,7 @@ class Core // Validate Timezone if (isset($_POST['timezone']) && is_numeric($_POST['timezone'])) { $counter++; - } + } // Check if all the required fields have been entered if ($counter == '13') { @@ -107,12 +107,14 @@ class Core } // Function to write the config file - function write_config($data) - { + function write_config($data) { - // Config path $template_path = 'config/database.php'; $output_path = $_SERVER['DOCUMENT_ROOT'] . '/' . $data['directory'] . '/application/config/database.php'; + if (isset($_SERVER['CI_ENV'])) { + $template_path = $_SERVER['CI_ENV'].'/database.php'; + $output_path = $_SERVER['DOCUMENT_ROOT'] . '/' . $data['directory'] . '/application/'.$_SERVER['CI_ENV'].'/database.php'; + } // Open the file $database_file = file_get_contents($template_path); @@ -147,12 +149,14 @@ class Core } // Function to write the config file - function write_configfile($data) - { + function write_configfile($data) { - // Config path $template_path = 'config/config.php'; $output_path = $_SERVER['DOCUMENT_ROOT'] . '/' . $data['directory'] . '/application/config/config.php'; + if (isset($_SERVER['CI_ENV'])) { + $template_path = $_SERVER['CI_ENV'].'/config.php'; + $output_path = $_SERVER['DOCUMENT_ROOT'] . '/' . $data['directory'] . '/application/'.$_SERVER['CI_ENV'].'/config.php'; + } // Open the file $database_file = file_get_contents($template_path); diff --git a/install/index.php b/install/index.php index 8c072371e..a0b74d9a1 100644 --- a/install/index.php +++ b/install/index.php @@ -24,6 +24,9 @@ if (file_exists('config_unattended.php')) { // Config Paths $db_config_path = '../application/config/'; +if (isset($_SERVER['CI_ENV'])) { + $db_config_path ='../application/'.$_SERVER['CI_ENV'].'/'; +} $db_file_path = $db_config_path . "database.php"; // if you need to disabled all button locks you can create a root_mode file in the /install directory