Skip to content

Commit 997018e

Browse files
authored
Merge pull request wavelog#277 from int2001/docker_readiness
Docker readiness
2 parents 0a67573 + 2fa3def commit 997018e

File tree

3 files changed

+36
-23
lines changed

3 files changed

+36
-23
lines changed

index.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@
5454
* NOTE: If you change these, also change the error_reporting() code below
5555
*/
5656
#define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');
57-
if (file_exists('.debug')) {
57+
if (isset($_ENV['CI_ENV'])) {
58+
define('ENVIRONMENT', $_ENV['CI_ENV']);
59+
} else if (file_exists('.debug')) {
5860
define('ENVIRONMENT', 'development');
5961
} else if (file_exists('.maintenance')) {
6062
define('ENVIRONMENT', 'maintenance');
@@ -81,15 +83,20 @@
8183
error_reporting(-1);
8284
ini_set('display_errors', 1);
8385
break;
84-
85-
case 'production':
86+
87+
case 'docker':
8688
ini_set('display_errors', 0);
87-
if (version_compare(PHP_VERSION, '5.3', '>='))
88-
{
89+
if (version_compare(PHP_VERSION, '5.3', '>=')) {
8990
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
91+
} else {
92+
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
9093
}
91-
else
92-
{
94+
95+
case 'production':
96+
ini_set('display_errors', 0);
97+
if (version_compare(PHP_VERSION, '5.3', '>=')) {
98+
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
99+
} else {
93100
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
94101
}
95102
break;

install/includes/core_class.php

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,27 @@ function validate_post($data)
4141
// Validate First Name
4242
if (isset($_POST['firstname']) && !empty($_POST['firstname'])) {
4343
$counter++;
44-
}
44+
}
4545

4646
// Validate Last Name
4747
if (isset($_POST['lastname']) && !empty($_POST['lastname'])) {
4848
$counter++;
49-
}
49+
}
5050

5151
// Validate Username
5252
if (isset($_POST['username']) && !empty($_POST['username'])) {
5353
$counter++;
54-
}
54+
}
5555

5656
// Validate Callsign
5757
if (isset($_POST['callsign']) && !empty($_POST['callsign'])) {
5858
$counter++;
59-
}
59+
}
6060

6161
// Validate Password
6262
if (isset($_POST['password']) && !empty($_POST['password'])) {
6363
$counter++;
64-
}
64+
}
6565

6666
// Validate Locator
6767
if (isset($_POST['userlocator']) && !empty($_POST['userlocator'])) {
@@ -78,7 +78,7 @@ function validate_post($data)
7878
// Validate Confirm Password
7979
if (isset($_POST['cnfm_password']) && !empty($_POST['cnfm_password'])) {
8080
$counter++;
81-
}
81+
}
8282

8383
// Validate Email Address
8484
if (isset($_POST['user_email']) && filter_var($_POST['user_email'], FILTER_VALIDATE_EMAIL)) {
@@ -90,7 +90,7 @@ function validate_post($data)
9090
// Validate Timezone
9191
if (isset($_POST['timezone']) && is_numeric($_POST['timezone'])) {
9292
$counter++;
93-
}
93+
}
9494

9595
// Check if all the required fields have been entered
9696
if ($counter == '13') {
@@ -107,12 +107,13 @@ function show_message($type, $message)
107107
}
108108

109109
// Function to write the config file
110-
function write_config($data)
111-
{
110+
function write_config($data) {
112111

113-
// Config path
114112
$template_path = 'config/database.php';
115113
$output_path = $_SERVER['DOCUMENT_ROOT'] . '/' . $data['directory'] . '/application/config/database.php';
114+
if (isset($_ENV['CI_ENV'])) {
115+
$output_path = $_SERVER['DOCUMENT_ROOT'] . '/' . $data['directory'] . '/application/config/'.$_ENV['CI_ENV'].'/database.php';
116+
}
116117

117118
// Open the file
118119
$database_file = file_get_contents($template_path);
@@ -147,12 +148,13 @@ function write_config($data)
147148
}
148149

149150
// Function to write the config file
150-
function write_configfile($data)
151-
{
151+
function write_configfile($data) {
152152

153-
// Config path
154153
$template_path = 'config/config.php';
155154
$output_path = $_SERVER['DOCUMENT_ROOT'] . '/' . $data['directory'] . '/application/config/config.php';
155+
if (isset($_ENV['CI_ENV'])) {
156+
$output_path = $_SERVER['DOCUMENT_ROOT'] . '/' . $data['directory'] . '/application/config/'.$_ENV['CI_ENV'].'/config.php';
157+
}
156158

157159
// Open the file
158160
$database_file = file_get_contents($template_path);

install/index.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
necessary parameters for the new Wavelog Installation.
77
88
HB9HIL - January 2024
9+
DJ7NT - Docker Readiness - April 2024
910
*/
1011

1112
// #########################################################
@@ -24,6 +25,9 @@
2425

2526
// Config Paths
2627
$db_config_path = '../application/config/';
28+
if (isset($_ENV['CI_ENV'])) {
29+
$db_config_path ='../application/config/'.$_ENV['CI_ENV'].'/';
30+
}
2731
$db_file_path = $db_config_path . "database.php";
2832

2933
// if you need to disabled all button locks you can create a root_mode file in the /install directory
@@ -112,11 +116,11 @@ function delDir($dir)
112116
} elseif ($database->create_tables($_POST) == false) {
113117
$message = $core->show_message('error', "The database tables could not be created, please verify your settings.");
114118
} elseif ($core->write_config($_POST) == false) {
115-
$message = $core->show_message('error', "The database configuration file could not be written, please chmod /application/config/database.php file to 777");
119+
$message = $core->show_message('error', "The database configuration file could not be written, please chmod ".$db_config_path."/database.php file to 777");
116120
}
117121

118122
if ($core->write_configfile($_POST) == false) {
119-
$message = $core->show_message('error', "The config configuration file could not be written, please chmod /application/config/config.php file to 777");
123+
$message = $core->show_message('error', "The config configuration file could not be written, please chmod ".$db_config_path."/config.php file to 777");
120124
}
121125

122126
// If no errors, redirect to registration page
@@ -1455,7 +1459,7 @@ function prevTab() {
14551459
<body>
14561460
<div class="container mt-4 p-2" style="max-width: 600px; ">
14571461
<div class="card p-2 justify-content-center" style="min-height: 200px; margin-top: 200px;">
1458-
<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>
1462+
<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>
14591463
</div>
14601464
</div>
14611465
</body>

0 commit comments

Comments
 (0)