From ec87c015049da2c5cad534eef2e91ae5a3a2dd3a Mon Sep 17 00:00:00 2001
From: HB9HIL
Date: Wed, 24 Jul 2024 13:14:34 +0200
Subject: [PATCH 27/86] drop doubled locator input
---
install/includes/core/core_class.php | 2 +-
install/index.php | 17 +----------------
2 files changed, 2 insertions(+), 17 deletions(-)
diff --git a/install/includes/core/core_class.php b/install/includes/core/core_class.php
index dbf4403fb..25d7cc566 100644
--- a/install/includes/core/core_class.php
+++ b/install/includes/core/core_class.php
@@ -161,7 +161,7 @@ class Core
// creating a unique encryption key
$encryptionkey = uniqid(bin2hex(random_bytes(8)), false);
- $new = str_replace("%baselocator%", $data['locator'], $database_file);
+ $new = str_replace("%baselocator%", $data['userlocator'], $database_file);
$new = str_replace("%websiteurl%", $data['websiteurl'], $new);
$new = str_replace("%directory%", $data['directory'], $new);
$new = str_replace("%callbook%", $data['global_call_lookup'], $new);
diff --git a/install/index.php b/install/index.php
index 2e24f7c5d..5f689129f 100644
--- a/install/index.php
+++ b/install/index.php
@@ -328,13 +328,6 @@ if (!file_exists('.lock')) {
= __("This field can't be empty and have to end with a slash 'example/'!"); ?>
-
- ">
-
-
- = __("Type in a valid locator"); ?>
-
-
+ $prechecks_color = "#ffc107"; ?>
= __("You have some warnings!"); ?>
= __("Some of the settings are not optimal. You can proceed with the installer but be aware that you could run into problems while using Wavelog."); ?>
@@ -448,7 +448,7 @@ if (!file_exists('.lock')) {
= __("All fields are required!"); ?>
-
+
@@ -1255,27 +1255,34 @@ if (!file_exists('.lock')) {
var cnfmPasswordField = $('#cnfm_password');
var minPasswordLenght = 8;
- cnfmPasswordField.on('change', function() {
+ $('#password, #cnfm_password').on('change', function() {
if (cnfmPasswordField.val() == passwordField.val() && cnfmPasswordField.val() != '') {
if (cnfmPasswordField.val().length >= minPasswordLenght) {
passwordField.removeClass('is-invalid');
cnfmPasswordField.removeClass('is-invalid');
+ passwordField.removeClass('has-warning');
+ cnfmPasswordField.removeClass('has-warning');
passwordField.addClass('is-valid');
cnfmPasswordField.addClass('is-valid');
$('#userform_warnings').css('display', 'none');
+ $('#userform_warnings').removeClass('alert-warning alert-danger');
} else {
- passwordField.addClass('is-invalid');
- cnfmPasswordField.addClass('is-invalid');
+ passwordField.addClass('has-warning');
+ cnfmPasswordField.addClass('has-warning');
passwordField.removeClass('is-valid');
cnfmPasswordField.removeClass('is-valid');
+ passwordField.removeClass('is-invalid');
+ cnfmPasswordField.removeClass('is-invalid');
$('#userform_warnings').css('display', 'block');
+ $('#userform_warnings').removeClass('alert-warning alert-danger');
+ $('#userform_warnings').addClass('alert-warning');
$('#userform_warnings').html('= __("Password should be at least 8 characters long"); ?>')
}
@@ -1283,11 +1290,15 @@ if (!file_exists('.lock')) {
passwordField.addClass('is-invalid');
cnfmPasswordField.addClass('is-invalid');
+ passwordField.removeClass('has-warning');
+ cnfmPasswordField.removeClass('has-warning');
passwordField.removeClass('is-valid');
cnfmPasswordField.removeClass('is-valid');
$('#userform_warnings').css('display', 'block');
+ $('#userform_warnings').removeClass('alert-warning alert-danger');
+ $('#userform_warnings').addClass('alert-danger');
$('#userform_warnings').html('= __("Passwords do not match"); ?>');
}
@@ -1302,12 +1313,15 @@ if (!file_exists('.lock')) {
emailField.addClass('is-invalid');
emailField.removeClass('is-valid');
$('#userform_warnings').css('display', 'block');
+ $('#userform_warnings').removeClass('alert-warning alert-danger');
+ $('#userform_warnings').addClass('alert-danger');
$('#userform_warnings').html('= __("The E-Mail Address is not valid"); ?>');
} else {
emailField.removeClass('is-invalid');
emailField.addClass('is-valid');
+ $('#userform_warnings').removeClass('alert-danger alert-warning');
$('#userform_warnings').css('display', 'none');
}
@@ -1325,12 +1339,15 @@ if (!file_exists('.lock')) {
$(field).removeClass('is-valid');
if (field == '#userlocator') {
$('#userform_warnings').css('display', 'block');
+ $('#userform_warnings').removeClass('alert-warning alert-danger');
+ $('#userform_warnings').addClass('alert-danger');
$('#userform_warnings').html("= sprintf(__("The grid locator is not valid. Use a 6-character locator, e.g. HA44AA. If you don't know your grid square then click here!"), "https://zone-check.eu/?m=loc"); ?>");
}
} else {
$(field).removeClass('is-invalid');
$(field).addClass('is-valid');
if (field == '#userlocator') {
+ $('#userform_warnings').removeClass('alert-danger alert-warning');
$('#userform_warnings').css('display', 'none');
}
}
@@ -1471,7 +1488,7 @@ if (!file_exists('.lock')) {
if (($('#checklist_prechecks').hasClass('fa-check-circle') || $('#checklist_prechecks').hasClass('fa-exclamation-triangle')) &&
$('#checklist_configuration').hasClass('fa-check-circle') &&
$('#checklist_database').hasClass('fa-check-circle') &&
- $('#checklist_firstuser').hasClass('fa-check-circle')) {
+ ($('#checklist_firstuser').hasClass('fa-check-circle') || $('#checklist_firstuser').hasClass('fa-exclamation-triangle'))) {
install_possible = true;
}
@@ -1531,7 +1548,7 @@ if (!file_exists('.lock')) {
if (checklist_database) {
if ($('#db_connection_testresult').hasClass('alert-warning')) {
- checklist_icon.addClass('fa-exclamation-triangle').css('color', 'yellow');
+ checklist_icon.addClass('fa-exclamation-triangle').css('color', '#ffc107');
} else if ($('#db_connection_testresult').hasClass('alert-success')) {
checklist_icon.addClass('fa-check-circle').css('color', '#04a004');
} else {
@@ -1574,10 +1591,18 @@ if (!file_exists('.lock')) {
}
if (checklist_firstuser) {
- $('#checklist_firstuser').removeClass('fa-times-circle');
- $('#checklist_firstuser').addClass('fa-check-circle').css('color', '#04a004');
+ if($('#password').hasClass('has-warning')) {
+ $('#checklist_firstuser').removeClass('fa-times-circle');
+ $('#checklist_firstuser').removeClass('fa-check-circle');
+ $('#checklist_firstuser').addClass('fa-exclamation-triangle').css('color', '#ffc107');
+ } else {
+ $('#checklist_firstuser').removeClass('fa-times-circle');
+ $('#checklist_firstuser').removeClass('fa-exclamation-triangle');
+ $('#checklist_firstuser').addClass('fa-check-circle').css('color', '#04a004');
+ }
} else {
$('#checklist_firstuser').removeClass('fa-check-circle');
+ $('#checklist_firstuser').removeClass('fa-exclamation-triangle');
$('#checklist_firstuser').addClass('fa-times-circle').css('color', 'red');
}
From eaea26f8160ad9dc72527d42bcc539965527001c Mon Sep 17 00:00:00 2001
From: HB9HIL
Date: Wed, 24 Jul 2024 13:51:39 +0200
Subject: [PATCH 29/86] db_password can be empty
---
install/index.php | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/install/index.php b/install/index.php
index f3198e67a..f6cfc62ad 100644
--- a/install/index.php
+++ b/install/index.php
@@ -429,7 +429,7 @@ if (!file_exists('.lock')) {
- ">
+ ">
@@ -1161,7 +1161,7 @@ if (!file_exists('.lock')) {
var db_password = $('#db_password').val();
var db_name = $('#db_name').val();
- if (db_hostname === '' || db_username === '' || db_password === '' || db_name === '') {
+ if (db_hostname === '' || db_username === '' || db_name === '') {
$('#db_connection_testresult').addClass('alert-danger');
$('#db_connection_testresult').html('= __("Error: All fields are required."); ?>');
return;
@@ -1539,9 +1539,6 @@ if (!file_exists('.lock')) {
if ($('#db_username').val() === '') {
checklist_database = false;
}
- if ($('#db_password').val() === '') {
- checklist_database = false;
- }
var checklist_icon = $('#checklist_database');
checklist_icon.removeClass('fa-check-circle fa-times-circle fa-exclamation-triangle');
From dd0984f9e268a7b7e49659bfec5144b2c9ad7b74 Mon Sep 17 00:00:00 2001
From: HB9HIL
Date: Wed, 24 Jul 2024 14:20:52 +0200
Subject: [PATCH 30/86] add check if database is empty
---
install/includes/core/database_class.php | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/install/includes/core/database_class.php b/install/includes/core/database_class.php
index 7334de9d1..22d94430d 100644
--- a/install/includes/core/database_class.php
+++ b/install/includes/core/database_class.php
@@ -50,22 +50,28 @@ class Database {
try {
$timeout = 5; /* five seconds for timeout */
$link = mysqli_init();
-
+
$link->options(MYSQLI_OPT_CONNECT_TIMEOUT, $timeout);
-
+
$link->real_connect($data['db_hostname'], $data['db_username'], $data['db_password'], $data['db_name']);
-
+
if ($link->connect_error) {
- throw new Exception('Connection Error: ' . $link->connect_error);
+ throw new Exception(__("Connection Error: ") . $link->connect_error);
}
-
+
+ $result = $link->query("SHOW TABLES");
+
+ if ($result->num_rows > 0) {
+ throw new Exception(__("Database is not empty."));
+ }
+
$mysql_version = $link->server_info;
-
+
$link->close();
-
+
return $mysql_version;
} catch (Exception $e) {
- return 'Error: ' . $e->getMessage();
+ return __("Error: ") . $e->getMessage();
}
}
}
From b8ec37d0af363719596ea62475bd53e40bf390d5 Mon Sep 17 00:00:00 2001
From: HB9HIL
Date: Wed, 24 Jul 2024 15:14:41 +0200
Subject: [PATCH 31/86] adjust check runs on page load
---
install/index.php | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/install/index.php b/install/index.php
index f6cfc62ad..11dcd3162 100644
--- a/install/index.php
+++ b/install/index.php
@@ -1163,7 +1163,7 @@ if (!file_exists('.lock')) {
if (db_hostname === '' || db_username === '' || db_name === '') {
$('#db_connection_testresult').addClass('alert-danger');
- $('#db_connection_testresult').html('= __("Error: All fields are required."); ?>');
+ $('#db_connection_testresult').html('= __("Error: At least Hostname/IP, Database Name and Username are required."); ?>');
return;
}
@@ -1251,11 +1251,11 @@ if (!file_exists('.lock')) {
// Check various user input in tab 4
// user password
- var passwordField = $('#password');
- var cnfmPasswordField = $('#cnfm_password');
- var minPasswordLenght = 8;
+ let passwordField = $('#password');
+ let cnfmPasswordField = $('#cnfm_password');
+ let minPasswordLenght = 8;
- $('#password, #cnfm_password').on('change', function() {
+ function user_pwd_check() {
if (cnfmPasswordField.val() == passwordField.val() && cnfmPasswordField.val() != '') {
if (cnfmPasswordField.val().length >= minPasswordLenght) {
@@ -1302,7 +1302,7 @@ if (!file_exists('.lock')) {
$('#userform_warnings').html('= __("Passwords do not match"); ?>');
}
- });
+ }
// email verification
const emailField = $('#user_email');
@@ -1423,14 +1423,22 @@ if (!file_exists('.lock')) {
$('#resetButton').click(function() {
$('#resetModal').modal('show');
});
-
- db_connection_test()
+ if ($('#db_hostname').val() != '') {
+ db_connection_test()
+ }
// Clear DB Test results on change
$('#db_hostname, #db_name, #db_username, #db_password').on('keyup', function() {
clear_db_testresult();
});
+ $('#cnfm_password').on('change focusout', function() {
+ user_pwd_check();
+ });
+ if ($('#cnfm_password').val() != '') {
+ user_pwd_check();
+ }
+
// Checklist Stuff
checklist_configuration();
$('#directory, #websiteurl').on('change', function() {
@@ -1508,6 +1516,7 @@ if (!file_exists('.lock')) {
// comment: Checklist for Pre-Checks is handled in PHP. See '$prechecks_passed'
function checklist_configuration() {
+ console.log('run checklist_configuration');
var checklist_configuration = true;
if ($('#directory').hasClass('is-invalid')) {
From daca83f030c9539538a0cb83fac84a53dcc3e349 Mon Sep 17 00:00:00 2001
From: HB9HIL
Date: Wed, 24 Jul 2024 15:16:43 +0200
Subject: [PATCH 32/86] uppercase for locator and callsign
---
install/assets/css/installer.css | 4 ++++
install/index.php | 4 ++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/install/assets/css/installer.css b/install/assets/css/installer.css
index e6bb95adf..8ff7b4eee 100644
--- a/install/assets/css/installer.css
+++ b/install/assets/css/installer.css
@@ -236,4 +236,8 @@ div.alert-danger {
.has-warning {
border-color: #ffc107;
+}
+
+.uppercase {
+ text-transform: uppercase;
}
\ No newline at end of file
diff --git a/install/index.php b/install/index.php
index 11dcd3162..c3cce9cba 100644
--- a/install/index.php
+++ b/install/index.php
@@ -475,7 +475,7 @@ if (!file_exists('.lock')) {
-
+
@@ -495,7 +495,7 @@ if (!file_exists('.lock')) {
-
+
From 64aab3a80244cc491ff35aed50647888bd5d3463 Mon Sep 17 00:00:00 2001
From: HB9HIL
Date: Wed, 24 Jul 2024 15:29:35 +0200
Subject: [PATCH 33/86] Error must be english here
---
install/includes/core/database_class.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/install/includes/core/database_class.php b/install/includes/core/database_class.php
index 22d94430d..9081edb52 100644
--- a/install/includes/core/database_class.php
+++ b/install/includes/core/database_class.php
@@ -71,7 +71,7 @@ class Database {
return $mysql_version;
} catch (Exception $e) {
- return __("Error: ") . $e->getMessage();
+ return 'Error: ' . $e->getMessage();
}
}
}
From 24711b1995e936e683e18971968193d266e941d5 Mon Sep 17 00:00:00 2001
From: HB9HIL
Date: Wed, 24 Jul 2024 16:48:26 +0200
Subject: [PATCH 34/86] create db if not exists
---
install/includes/core/database_class.php | 25 ++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/install/includes/core/database_class.php b/install/includes/core/database_class.php
index 9081edb52..215689abd 100644
--- a/install/includes/core/database_class.php
+++ b/install/includes/core/database_class.php
@@ -50,25 +50,34 @@ class Database {
try {
$timeout = 5; /* five seconds for timeout */
$link = mysqli_init();
-
+
$link->options(MYSQLI_OPT_CONNECT_TIMEOUT, $timeout);
-
- $link->real_connect($data['db_hostname'], $data['db_username'], $data['db_password'], $data['db_name']);
-
+
+ $link->real_connect($data['db_hostname'], $data['db_username'], $data['db_password']);
+
if ($link->connect_error) {
throw new Exception(__("Connection Error: ") . $link->connect_error);
}
-
+
+ if (!$link->query("CREATE DATABASE IF NOT EXISTS " . $data['db_name'])) {
+ throw new Exception(__("Unable to create database: ") . $link->error);
+ }
+
+ // Wählen Sie die Datenbank aus
+ if (!$link->select_db($data['db_name'])) {
+ throw new Exception(__("Unable to select database: ") . $link->error);
+ }
+
$result = $link->query("SHOW TABLES");
if ($result->num_rows > 0) {
throw new Exception(__("Database is not empty."));
}
-
+
$mysql_version = $link->server_info;
-
+
$link->close();
-
+
return $mysql_version;
} catch (Exception $e) {
return 'Error: ' . $e->getMessage();
From bd46a5c78ad85f2981d3a3e1b7efbfeada396239 Mon Sep 17 00:00:00 2001
From: HB9HIL
Date: Wed, 24 Jul 2024 21:14:06 +0200
Subject: [PATCH 35/86] hard fences
---
install/index.php | 142 ++++++++++++++++++++++++++++------------------
1 file changed, 86 insertions(+), 56 deletions(-)
diff --git a/install/index.php b/install/index.php
index c3cce9cba..9369192c5 100644
--- a/install/index.php
+++ b/install/index.php
@@ -325,7 +325,10 @@ if (!file_exists('.lock')) {
">
- = __("This field can't be empty and have to end with a slash 'example/'!"); ?>
+ = __("This field
+ - can't be empty
+ - have to end with a slash 'example/'
+ - have to start with 'http'"); ?>
@@ -1131,6 +1134,8 @@ if (!file_exists('.lock')) {
field.removeClass('is-valid');
field.addClass('is-invalid');
}
+
+ return check;
}
function websiteurl_check() {
@@ -1153,61 +1158,68 @@ if (!file_exists('.lock')) {
field.removeClass('is-valid');
field.addClass('is-invalid');
}
+
+ return check;
}
function db_connection_test() {
- var db_hostname = $('#db_hostname').val();
- var db_username = $('#db_username').val();
- var db_password = $('#db_password').val();
- var db_name = $('#db_name').val();
+ return new Promise((resolve, reject) => {
+ var db_hostname = $('#db_hostname').val();
+ var db_username = $('#db_username').val();
+ var db_password = $('#db_password').val();
+ var db_name = $('#db_name').val();
- if (db_hostname === '' || db_username === '' || db_name === '') {
- $('#db_connection_testresult').addClass('alert-danger');
- $('#db_connection_testresult').html('= __("Error: At least Hostname/IP, Database Name and Username are required."); ?>');
- return;
- }
-
- var originalButtonText = $('#db_connection_test_button').html();
- $('#db_connection_test_button').html(' = __("Connecting..."); ?>').prop('disabled', true);
-
- clear_db_testresult();
-
- $.ajax({
- type: 'POST',
- url: 'index.php',
- data: {
- db_hostname: db_hostname,
- db_username: db_username,
- db_password: db_password,
- db_name: db_name,
- database_check: 1
- },
- success: function(response) {
- $('#db_connection_testresult').html(response);
- if (response.indexOf('Error') !== -1) {
- $('#db_connection_testresult').addClass('alert-danger');
- $('#db_connection_test_button').html(originalButtonText).prop('disabled', false);
- } else {
-
- if (sql_version_checker(response) == true) {
- $('#db_connection_testresult').addClass('alert-success');
- $('#db_connection_test_button').html(originalButtonText).prop('disabled', false);
- $('#db_connection_testresult').html('= __("Connection was successful and your database should be compatible"); ?> ');
- } else {
- $('#db_connection_testresult').addClass('alert-warning');
- $('#db_connection_test_button').html(originalButtonText).prop('disabled', false);
- $('#db_connection_testresult').html('= __("Connection was successful but your database seems too old for Wavelog. You can try to continue but you could run into issues."); ?> ');
- }
- }
- checklist_database();
- },
- error: function(error) {
- $('#db_connection_testresult').html('Error: ' + error.statusText);
- if ($('#db_connection_testresult').text().indexOf('Error') !== -1) {
- $('#db_connection_testresult').addClass('alert-danger');
- }
- checklist_database();
+ if (db_hostname === '' || db_username === '' || db_name === '') {
+ $('#db_connection_testresult').addClass('alert-danger');
+ $('#db_connection_testresult').html('= __("Error: At least Hostname/IP, Database Name and Username are required."); ?>');
+ resolve(false);
+ return;
}
+
+ var originalButtonText = $('#db_connection_test_button').html();
+ $('#db_connection_test_button').html(' = __("Connecting..."); ?>').prop('disabled', true);
+
+ clear_db_testresult();
+
+ $.ajax({
+ type: 'POST',
+ url: 'index.php',
+ data: {
+ db_hostname: db_hostname,
+ db_username: db_username,
+ db_password: db_password,
+ db_name: db_name,
+ database_check: 1
+ },
+ success: function(response) {
+ $('#db_connection_testresult').html(response);
+ if (response.indexOf('Error') !== -1) {
+ $('#db_connection_testresult').addClass('alert-danger');
+ $('#db_connection_test_button').html(originalButtonText).prop('disabled', false);
+ resolve(false);
+ } else {
+ if (sql_version_checker(response) == true) {
+ $('#db_connection_testresult').addClass('alert-success');
+ $('#db_connection_test_button').html(originalButtonText).prop('disabled', false);
+ $('#db_connection_testresult').html('= __("Connection was successful and your database should be compatible"); ?> ');
+ } else {
+ $('#db_connection_testresult').addClass('alert-warning');
+ $('#db_connection_test_button').html(originalButtonText).prop('disabled', false);
+ $('#db_connection_testresult').html('= __("Connection was successful but your database seems too old for Wavelog. You can try to continue but you could run into issues."); ?> ');
+ }
+ resolve(true);
+ }
+ checklist_database();
+ },
+ error: function(error) {
+ $('#db_connection_testresult').html('Error: ' + error.statusText);
+ if ($('#db_connection_testresult').text().indexOf('Error') !== -1) {
+ $('#db_connection_testresult').addClass('alert-danger');
+ }
+ checklist_database();
+ resolve(false);
+ }
+ });
});
}
@@ -1369,10 +1381,29 @@ if (!file_exists('.lock')) {
const activeTab = $('.nav-link.active');
- function nextTab() {
+ async function nextTab() {
const activeTab = $('.nav-link.active');
const nextTab = activeTab.parent().next().find('.nav-link');
+ if (nextTab.attr('id') == fourthTabId) {
+ if (!directory_check() || !websiteurl_check()) {
+ return;
+ }
+ }
+
+ if (nextTab.attr('id') == fifthTabId) {
+ await db_connection_test();
+ if ($('#db_connection_testresult').hasClass('alert-danger')) {
+ return;
+ }
+ }
+
+ if (nextTab.attr('id') == lastTabId) {
+ if (!checklist_firstuser()) {
+ return;
+ }
+ }
+
if (nextTab.length > 0) {
const tab = new bootstrap.Tab(nextTab[0]);
tab.show();
@@ -1384,7 +1415,6 @@ if (!file_exists('.lock')) {
} else {
$('#ContinueButton').css('display', 'none');
}
-
}
function prevTab() {
@@ -1463,6 +1493,7 @@ if (!file_exists('.lock')) {
let secondTabId = 'precheck-tab';
let thirdTabId = 'configuration-tab';
let fourthTabId = 'database-tab';
+ let fifthTabId = 'firstuser-tab';
let lastTabId = 'finish-tab';
function openTab(tabId) {
@@ -1516,7 +1547,6 @@ if (!file_exists('.lock')) {
// comment: Checklist for Pre-Checks is handled in PHP. See '$prechecks_passed'
function checklist_configuration() {
- console.log('run checklist_configuration');
var checklist_configuration = true;
if ($('#directory').hasClass('is-invalid')) {
@@ -1597,7 +1627,7 @@ if (!file_exists('.lock')) {
}
if (checklist_firstuser) {
- if($('#password').hasClass('has-warning')) {
+ if ($('#password').hasClass('has-warning')) {
$('#checklist_firstuser').removeClass('fa-times-circle');
$('#checklist_firstuser').removeClass('fa-check-circle');
$('#checklist_firstuser').addClass('fa-exclamation-triangle').css('color', '#ffc107');
@@ -1612,6 +1642,7 @@ if (!file_exists('.lock')) {
$('#checklist_firstuser').addClass('fa-times-circle').css('color', 'red');
}
+ return checklist_firstuser;
}
@@ -1622,7 +1653,6 @@ if (!file_exists('.lock')) {