Merge pull request #277 from int2001/docker_readiness

Docker readiness
This commit is contained in:
Joerg (DJ7NT)
2024-04-14 20:24:51 +02:00
committed by GitHub
3 changed files with 36 additions and 23 deletions

View File

@@ -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($_ENV['CI_ENV'])) {
define('ENVIRONMENT', $_ENV['CI_ENV']);
} else if (file_exists('.debug')) {
define('ENVIRONMENT', 'development');
} else if (file_exists('.maintenance')) {
define('ENVIRONMENT', 'maintenance');
@@ -81,15 +83,20 @@ switch (ENVIRONMENT)
error_reporting(-1);
ini_set('display_errors', 1);
break;
case 'docker':
ini_set('display_errors', 0);
if (version_compare(PHP_VERSION, '5.3', '>=')) {
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
} else {
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
}
case 'production':
ini_set('display_errors', 0);
if (version_compare(PHP_VERSION, '5.3', '>='))
{
if (version_compare(PHP_VERSION, '5.3', '>=')) {
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
}
else
{
} else {
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
}
break;

View File

@@ -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,13 @@ 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($_ENV['CI_ENV'])) {
$output_path = $_SERVER['DOCUMENT_ROOT'] . '/' . $data['directory'] . '/application/config/'.$_ENV['CI_ENV'].'/database.php';
}
// Open the file
$database_file = file_get_contents($template_path);
@@ -147,12 +148,13 @@ 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($_ENV['CI_ENV'])) {
$output_path = $_SERVER['DOCUMENT_ROOT'] . '/' . $data['directory'] . '/application/config/'.$_ENV['CI_ENV'].'/config.php';
}
// Open the file
$database_file = file_get_contents($template_path);

View File

@@ -6,6 +6,7 @@ This installer guides a user through the install process and all
necessary parameters for the new Wavelog Installation.
HB9HIL - January 2024
DJ7NT - Docker Readiness - April 2024
*/
// #########################################################
@@ -24,6 +25,9 @@ if (file_exists('config_unattended.php')) {
// Config Paths
$db_config_path = '../application/config/';
if (isset($_ENV['CI_ENV'])) {
$db_config_path ='../application/config/'.$_ENV['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
@@ -112,11 +116,11 @@ if ($_POST) {
} elseif ($database->create_tables($_POST) == false) {
$message = $core->show_message('error', "The database tables could not be created, please verify your settings.");
} elseif ($core->write_config($_POST) == false) {
$message = $core->show_message('error', "The database configuration file could not be written, please chmod /application/config/database.php file to 777");
$message = $core->show_message('error', "The database configuration file could not be written, please chmod ".$db_config_path."/database.php file to 777");
}
if ($core->write_configfile($_POST) == false) {
$message = $core->show_message('error', "The config configuration file could not be written, please chmod /application/config/config.php file to 777");
$message = $core->show_message('error', "The config configuration file could not be written, please chmod ".$db_config_path."/config.php file to 777");
}
// If no errors, redirect to registration page
@@ -1455,7 +1459,7 @@ global $wavelog_url;
<body>
<div class="container mt-4 p-2" style="max-width: 600px; ">
<div class="card p-2 justify-content-center" style="min-height: 200px; margin-top: 200px;">
<p class="error text-center">Please make the /application/config/ folder writable. <strong>Example</strong>:<br /><br /><code>chmod -R 777 application/config/</code><br /><br /><i>Don't forget to restore the permissions afterwards.</i></p>
<p class="error text-center">Please make the <?php echo $db_config_path; ?> folder writable. <strong>Example</strong>:<br /><br /><code>chmod -R 777 <?php echo $db_config_path; ?></code><br /><br /><i>Don't forget to restore the permissions afterwards.</i></p>
</div>
</div>
</body>