diff --git a/.gitignore b/.gitignore
index 70612e70d..51979c1a6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,13 +1,13 @@
/application/config/database.php
/application/config/config.php
-/application/logs/*.php
+/application/logs/*
/application/cache/*
/uploads
/uploads/*.adi
/uploads/*.ADI
/uploads/*.tq8
/uploads/*.TQ8
-/install/*
+/install/.lock
/updates/*.xml
/updates/*.html
/images/eqsl_card_images/*.jpg
diff --git a/application/controllers/Migrate.php b/application/controllers/Migrate.php
index 0b8bb1216..65bf69dba 100644
--- a/application/controllers/Migrate.php
+++ b/application/controllers/Migrate.php
@@ -1,13 +1,24 @@
-load->library('Migration');
+ public function index() {
+ $this->load->library('Migration');
- if (!$this->migration->latest()) {
- show_error($this->migration->error_string());
+ $result = array();
+ $latest = $this->migration->latest();
+
+ if (!$latest) {
+ show_error($this->migration->error_string());
+ log_message('error', 'Migration failed');
+ $result['status'] = 'error';
+ } else {
+ while (file_exists(APPPATH . 'cache/.migration_running')) {
+ sleep(1);
+ }
+ $result['status'] = 'success';
+ $result['version'] = $latest;
+ }
+ header('Content-Type: application/json');
+ echo json_encode($result);
}
-
- }
-
-} ?>
+}
diff --git a/application/controllers/Update.php b/application/controllers/Update.php
index dd9674e72..f334fc73c 100644
--- a/application/controllers/Update.php
+++ b/application/controllers/Update.php
@@ -36,7 +36,9 @@ class Update extends CI_Controller {
public function dxcc_entities() {
// Load the cty file
- $this->load->library('Paths');
+ if(!$this->load->is_loaded('Paths')) {
+ $this->load->library('Paths');
+ }
$xml_data = simplexml_load_file($this->paths->make_update_path("cty.xml"));
//$xml_data->entities->entity->count();
@@ -87,7 +89,9 @@ class Update extends CI_Controller {
public function dxcc_exceptions() {
// Load the cty file
- $this->load->library('Paths');
+ if(!$this->load->is_loaded('Paths')) {
+ $this->load->library('Paths');
+ }
$xml_data = simplexml_load_file($this->paths->make_update_path("cty.xml"));
$count = 0;
@@ -129,7 +133,9 @@ class Update extends CI_Controller {
public function dxcc_prefixes() {
// Load the cty file
- $this->load->library('Paths');
+ if(!$this->load->is_loaded('Paths')) {
+ $this->load->library('Paths');
+ }
$xml_data = simplexml_load_file($this->paths->make_update_path("cty.xml"));
$count = 0;
@@ -169,7 +175,9 @@ class Update extends CI_Controller {
// Updates the DXCC & Exceptions from the Club Log Cty.xml file.
public function dxcc() {
- $this->load->library('Paths');
+ if(!$this->load->is_loaded('Paths')) {
+ $this->load->library('Paths');
+ }
// set the last run in cron table for the correct cron id
$this->load->model('cron_model');
@@ -192,7 +200,7 @@ class Update extends CI_Controller {
if ($gz === FALSE) {
$this->update_status("FAILED: Could not download from clublog.org");
log_message('error', 'FAILED: Could not download exceptions from clublog.org');
- return;
+ exit();
}
$data = "";
@@ -203,7 +211,7 @@ class Update extends CI_Controller {
if (file_put_contents($this->paths->make_update_path("cty.xml"), $data) === FALSE) {
$this->update_status("FAILED: Could not write to cty.xml file");
- return;
+ exit();
}
// Clear the tables, ready for new data
@@ -220,21 +228,25 @@ class Update extends CI_Controller {
$this->db->trans_complete();
$this->update_status(__("DONE"));
+
+ echo 'success';
}
public function update_status($done=""){
- $this->load->library('Paths');
+ if(!$this->load->is_loaded('Paths')) {
+ $this->load->library('Paths');
+ }
if ($done != "Downloading file"){
// Check that everything is done?
if ($done == ""){
- $done = "Updating...";
+ $done = __("Updating...");
}
$html = $done."
";
- $html .= "Dxcc Entities: ".$this->db->count_all('dxcc_entities')."
";
- $html .= "Dxcc Exceptions: ".$this->db->count_all('dxcc_exceptions')."
";
- $html .= "Dxcc Prefixes: ".$this->db->count_all('dxcc_prefixes')."
";
+ $html .= __("Dxcc Entities:")." ".$this->db->count_all('dxcc_entities')."
";
+ $html .= __("Dxcc Exceptions:")." ".$this->db->count_all('dxcc_exceptions')."
";
+ $html .= __("Dxcc Prefixes:")." ".$this->db->count_all('dxcc_prefixes')."
";
} else {
$html = $done."....
";
}
diff --git a/application/controllers/User.php b/application/controllers/User.php
index c53f396da..f6345645f 100644
--- a/application/controllers/User.php
+++ b/application/controllers/User.php
@@ -765,7 +765,7 @@ class User extends CI_Controller {
}
}
- function login() {
+ function login($firstlogin = false) {
// Check our version and run any migrations
if (!$this->load->is_loaded('Migration')) {
$this->load->library('Migration');
@@ -775,6 +775,10 @@ class User extends CI_Controller {
}
$this->migration->current();
+ if($firstlogin == true) {
+ $this->session->set_flashdata('success', __("Congrats! Wavelog was successfully installed. You can now login for the first time."));
+ }
+
$this->load->model('user_model');
$query = $this->user_model->get($this->input->post('user_name', true));
diff --git a/application/views/debug/index.php b/application/views/debug/index.php
index ebb91eabb..658073d47 100644
--- a/application/views/debug/index.php
+++ b/application/views/debug/index.php
@@ -272,7 +272,7 @@
- | max_upload_file_size |
- ' . $max_upload_file_size . 'M'; ?> |
+ upload_max_filesize |
+ ' . $upload_max_filesize . 'M'; ?> |
= ($max_upload_file_size * 1024 * 1024)) { // compare with given value in bytes
+ if ($maxUploadFileSizeBytes >= ($upload_max_filesize * 1024 * 1024)) { // compare with given value in bytes
?>
@@ -631,4 +631,4 @@
= __("Spanish"); ?>
= __("Swedish"); ?>
= __("Turkish"); ?>
-
\ No newline at end of file
+
diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php
index d60cd5fda..233659d82 100644
--- a/application/views/interface_assets/footer.php
+++ b/application/views/interface_assets/footer.php
@@ -1292,7 +1292,15 @@ $(document).ready(function(){
$(".ld-ext-right").addClass("running");
$(".ld-ext-right").prop("disabled", true);
$('#dxcc_update_status').show();
- $.ajax({url:"update/dxcc"});
+ $.ajax({
+ url:"update/dxcc",
+ success: function(response) {
+ if (response == 'success') {
+ $(".ld-ext-right").removeClass("running");
+ $(".ld-ext-right").prop("disabled", false);
+ }
+ }
+ });
setTimeout(update_stats,5000);
});
function update_stats(){
diff --git a/assets/js/country-flag-emoji-polyfill.js b/assets/js/country-flag-emoji-polyfill.js
index f6c55ae84..c5865335b 100644
--- a/assets/js/country-flag-emoji-polyfill.js
+++ b/assets/js/country-flag-emoji-polyfill.js
@@ -36,7 +36,7 @@ function l(o) {
const t = a(), e = i(t, o, "#fff"), n = i(t, o, "#000");
return n === e && !n.startsWith("0,0,0,");
}
-function f(o = "Twemoji Country Flags", t = base_url + 'assets/fonts/TwemojiCountryFlags/TwemojiCountryFlags.woff2') {
+function f(o = "Twemoji Country Flags", t = '../assets/fonts/TwemojiCountryFlags/TwemojiCountryFlags.woff2') {
if (typeof window < "u" && l("\u{1F60A}") && !l("\u{1F1E8}\u{1F1ED}")) {
const e = document.createElement("style");
return e.textContent = `@font-face {
diff --git a/install/ajax.php b/install/ajax.php
new file mode 100644
index 000000000..8c5cce181
--- /dev/null
+++ b/install/ajax.php
@@ -0,0 +1,17 @@
+query("CREATE DATABASE IF NOT EXISTS " . $data['db_name']);
-
- // Close the connection
- $mysqli->close();
-
- return true;
- }
+class Database {
// Function to create the tables and fill them with the default data
- function create_tables($data)
- {
+ function create_tables($data) {
// Connect to the database
$mysqli = new mysqli($data['db_hostname'], $data['db_username'], $data['db_password'], $data['db_name']);
@@ -39,8 +18,8 @@ class Database
$newquery = str_replace("%%FIRSTUSER_NAME%%", $data['username'], $query);
$newquery = str_replace("%%FIRSTUSER_PASS%%", $newpw, $newquery);
$newquery = str_replace("%%FIRSTUSER_MAIL%%", $data['user_email'], $newquery);
- $newquery = str_replace("%%FIRSTUSER_CALL%%", $data['callsign'], $newquery);
- $newquery = str_replace("%%FIRSTUSER_LOCATOR%%", $data['userlocator'], $newquery);
+ $newquery = str_replace("%%FIRSTUSER_CALL%%", strtoupper($data['callsign']), $newquery);
+ $newquery = str_replace("%%FIRSTUSER_LOCATOR%%", strtoupper($data['userlocator']), $newquery);
$newquery = str_replace("%%FIRSTUSER_FIRSTNAME%%", $data['firstname'], $newquery);
$newquery = str_replace("%%FIRSTUSER_LASTNAME%%", $data['lastname'], $newquery);
$newquery = str_replace("%%FIRSTUSER_TIMEZONE%%", $data['timezone'], $newquery);
@@ -67,24 +46,38 @@ class Database
return true;
}
- function database_check($data)
- {
+ function database_check($data) {
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);
+ 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();
diff --git a/install/includes/gettext/gettext.php b/install/includes/gettext/gettext.php
index 9e174a528..b3aee208d 100644
--- a/install/includes/gettext/gettext.php
+++ b/install/includes/gettext/gettext.php
@@ -76,10 +76,9 @@ function _get_client_language() {
global $default_lang;
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$code = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
- $lang = find_by('code', $code) ?: $default_lang;
+ $lang = find_by('code', $code) ?? find_by('folder', $default_lang);
} else {
- $code = 'en';
- $lang = find_by('code', $code);
+ $lang = find_by('folder', $default_lang);
}
return $lang;
}
diff --git a/install/includes/gettext/gettext_conf.php b/install/includes/gettext/gettext_conf.php
index 06da946a0..b0b1bf8e4 100644
--- a/install/includes/gettext/gettext_conf.php
+++ b/install/includes/gettext/gettext_conf.php
@@ -8,8 +8,6 @@
*
*/
-
-
$gt_conf['default_domain'] = 'installer';
$gt_conf['default_lang'] = 'english';
diff --git a/install/includes/install_config/install_config.php b/install/includes/install_config/install_config.php
new file mode 100644
index 000000000..2a5b772ea
--- /dev/null
+++ b/install/includes/install_config/install_config.php
@@ -0,0 +1,41 @@
+ ['condition' => isExtensionInstalled('curl')],
+ 'php-mysql' => ['condition' => isExtensionInstalled('mysqli')],
+ 'php-mbstring' => ['condition' => isExtensionInstalled('mbstring')],
+ 'php-xml' => ['condition' => isExtensionInstalled('xml')],
+ 'php-zip' => ['condition' => isExtensionInstalled('zip')],
+];
+
+// MariaDB / MySQL
+$mariadb_version = 10.1;
+$mysql_version = 5.7;
diff --git a/install/includes/install_config/install_lib.php b/install/includes/install_config/install_lib.php
new file mode 100644
index 000000000..f2555fc29
--- /dev/null
+++ b/install/includes/install_config/install_lib.php
@@ -0,0 +1,135 @@
+isDir() && basename($item->getPathName()) != '..') {
+ if (!is_writable($item->getRealPath())) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+ } catch (Exception $e) {
+ log_message('error', 'is_really_writable(): Something went wrong while testing write permissions.');
+ return false;
+ }
+
+ return false;
+}
+
+function verify_log() {
+ global $logfile;
+
+ if (!file_exists($logfile)) {
+ if (touch($logfile)) {
+ if(is_writable($logfile)) {
+ $log_header = "Wavelog Installer Debug Log\n-------\nLog Location: $logfile\n\n";
+ file_put_contents($logfile, $log_header, FILE_APPEND);
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ } else {
+ return is_writable($logfile);
+ }
+}
+
+function country2flag($code) {
+ $code = strtoupper($code);
+
+ $offset = 0x1F1E6;
+ $code_p1 = $offset + ord($code[0]) - ord('A');
+ $code_p2 = $offset + ord($code[1]) - ord('A');
+
+ $flag = mb_chr($code_p1, 'UTF-8') . mb_chr($code_p2, 'UTF-8');
+ return $flag;
+}
+
+// Function to read the debug logfile
+function read_logfile() {
+ if (verify_log()) {
+ global $logfile;
+ $file_content = file_get_contents($logfile);
+ echo $file_content;
+ } else {
+ echo "Log file is not available.";
+ }
+}
+
+// Function to log messages in the installer logfile
+function log_message($level, $message) {
+ if (verify_log()) {
+ global $logfile;
+ $level = strtoupper($level);
+ $timestamp = date("Y-m-d H:i:s");
+ $logMessage = $level . " - " . $timestamp . " --> " . $message . PHP_EOL;
+ file_put_contents($logfile, $logMessage, FILE_APPEND);
+ } else {
+ echo "Log file is not available or not writable.";
+ }
+}
+
+// Custom error handler
+function customError($errno, $errstr, $errfile, $errline) {
+ $message = "[$errno] $errstr in $errfile on line $errline";
+ log_message('error', $message);
+}
+
+// Detect webserver and version
+function detect_webserver() {
+ return $_SERVER['SERVER_SOFTWARE'] ?? __("not detected");
+}
+
+// Detect nginx setting for PHP file processing
+function detect_nginx_php_setting($http_scheme) {
+ $ch = curl_init($http_scheme.'://'.$_SERVER['HTTP_HOST'].'/install/nginx.php/test');
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($ch, CURLOPT_HEADER, 0);
+ $data = curl_exec($ch);
+ $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+ curl_close($ch);
+ return $code;
+}
diff --git a/install/includes/interface_assets/footer.php b/install/includes/interface_assets/footer.php
new file mode 100644
index 000000000..2e40816ff
--- /dev/null
+++ b/install/includes/interface_assets/footer.php
@@ -0,0 +1,66 @@
+
\ No newline at end of file
diff --git a/install/includes/interface_assets/header.php b/install/includes/interface_assets/header.php
new file mode 100644
index 000000000..371d71849
--- /dev/null
+++ b/install/includes/interface_assets/header.php
@@ -0,0 +1,105 @@
+
+
+
+
+
+
+
+
+
+ = __("Install | Wavelog"); ?>
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/install/includes/interface_assets/triggers.php b/install/includes/interface_assets/triggers.php
new file mode 100644
index 000000000..9d059868a
--- /dev/null
+++ b/install/includes/interface_assets/triggers.php
@@ -0,0 +1,110 @@
+database_check($_POST);
+ echo $result;
+ exit;
+
+}
+
+if ($_POST['read_logfile'] ?? false == true) {
+
+ $result = read_logfile();
+ echo $result;
+ exit;
+
+}
+
+if ($_POST['write_to_logfile'] ?? false == true) {
+
+ $level = $_POST['log_level'];
+ $message = $_POST['log_message'];
+
+ if(log_message($level, $message)) {
+ $result = 'success';
+ } else {
+ $result = 'error';
+ }
+ echo $result;
+ exit;
+
+}
+
+/**
+ *
+ * Install Triggers
+ *
+ */
+
+if ($_POST['check_lockfile'] ?? false == true) {
+
+ $lockfile = '../install/.lock';
+
+ if (file_exists($lockfile)) {
+ $result = 'installer_locked';
+ } else {
+ $result = 'no_lockfile';
+ }
+ echo $result;
+ exit;
+}
+
+// config_file()
+if ($_POST['run_config_file'] ?? false == true) {
+ sleep(1);
+ $data = $_POST['data'];
+ if ($core->validate_post($data)) {
+ if($core->write_configfile($data)) {
+ $result = 'success';
+ } else {
+ $result = 'error';
+ }
+ } else {
+ $result = 'error';
+ }
+ echo $result;
+ exit;
+}
+
+if ($_POST['run_database_file'] ?? false == true) {
+ sleep(1);
+ $data = $_POST['data'];
+ if ($core->validate_post($data)) {
+ if($core->write_config($data)) {
+ $result = 'success';
+ } else {
+ $result = 'error';
+ }
+ } else {
+ $result = 'error';
+ }
+ echo $result;
+ exit;
+}
+
+if ($_POST['run_database_tables'] ?? false == true) {
+ $data = $_POST['data'];
+ if ($core->validate_post($data)) {
+ $result = $database->create_tables($data);
+ } else {
+ $result = 'error';
+ }
+ echo $result ? 'success' : 'error';
+ exit;
+}
+
+if ($_POST['run_installer_lock'] ?? false == true) {
+ exec('touch .lock', $output, $return_var);
+ if ($return_var === 0 && file_exists('.lock')) {
+ echo 'success';
+ } else {
+ echo 'error';
+ }
+ exit;
+}
diff --git a/install/index.php b/install/index.php
index 82fdf0e7d..27f06fd93 100644
--- a/install/index.php
+++ b/install/index.php
@@ -1,232 +1,18 @@
['condition' => isExtensionInstalled('curl')],
- 'php-mysql' => ['condition' => isExtensionInstalled('mysqli')],
- 'php-mbstring' => ['condition' => isExtensionInstalled('mbstring')],
- 'php-xml' => ['condition' => isExtensionInstalled('xml')],
- 'php-zip' => ['condition' => isExtensionInstalled('zip')],
-];
-
-// MariaDB / MySQL
-$mariadb_version = 10.1;
-$mysql_version = 5.7;
-
-// #########################################################
-// Gettext Implementation
-// #########################################################
-
-// include the lib and the conf file
-require_once('includes/gettext/gettext.php');
-require_once('includes/gettext/gettext_conf.php');
-
-/**
- * save all available languages
- * @var array $languages
- */
-$languages = $gt_conf['languages'];
-
-// if we come with a get call we can switch the language cookie
-if (isset($_GET['lang'])) {
- switch_lang($_GET['lang']);
-}
-
-// get the browsers language if no cookie exists and set one
-if (!isset($_COOKIE[$gt_conf['lang_cookie']])) {
- $browser_language = _get_client_language();
- setcookie($gt_conf['lang_cookie'], $browser_language['gettext']);
- header("Location: " . $installer_url);
- exit();
-}
-// get the language from the cookie
-$language = $_COOKIE[$gt_conf['lang_cookie']];
-
-// and set the locale for gettext
-T_setlocale(LC_MESSAGES, $language);
-
-// function to switch the language based on the user selection
-function switch_lang($new_language) {
- global $gt_conf, $installer_url;
- setcookie($gt_conf['lang_cookie'], $new_language);
- header("Location: " . $installer_url);
- exit();
-}
-
-// ######################################################### END OF PRECONFIGURATION
-
-// Function to check if a PHP extension is installed
-function isExtensionInstalled($extensionName) {
- return in_array($extensionName, get_loaded_extensions());
-}
-
-function delDir($dir) {
- $files = glob($dir . '*', GLOB_MARK);
- foreach ($files as $file) {
- if (substr($file, -1) == '/') {
- if (file_exists($file)) {
- delDir($file);
- }
- } else {
- if (file_exists($file)) {
- unlink($file);
- }
- }
- }
-}
-
-if (file_exists($db_file_path)) {
- delDir(getcwd());
- header("../");
- exit;
-}
-
-if (file_exists($root_mode_file)) {
- $root_mode = true;
-} else {
- $root_mode = false;
-}
-
-// Only load the classes in case the user submitted the form
-if ($_POST) {
-
- // Load the classes and create the new objects
- require_once('includes/core_class.php');
- require_once('includes/database_class.php');
-
- $core = new Core();
- $database = new Database();
-
- if ($_POST['database_check'] ?? false == true) {
-
- $result = $database->database_check($_POST);
- echo $result;
- exit;
- } else {
- // Validate the post data
- if ($core->validate_post($_POST) == true) {
-
- // First create the database, then create tables, then write config file
- if ($database->create_database($_POST) == false) {
- $message = $core->show_message('error', "The database could not be created, please verify your settings.");
- } 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 " . $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 " . $db_config_path . "/config.php file to 777");
- }
-
- // If no errors, redirect to registration page
- if (!isset($message)) {
- sleep(1);
- $ch = curl_init();
- list($realHost,) = explode(':', $_SERVER['HTTP_HOST']);
- $wavelog_url = $http_scheme . "://" . $realHost . ":" . $_SERVER['SERVER_PORT'];
- curl_setopt($ch, CURLOPT_URL, $wavelog_url);
- curl_setopt($ch, CURLOPT_VERBOSE, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- $result = curl_exec($ch);
- curl_setopt($ch, CURLOPT_URL, $wavelog_url . "/index.php/update/dxcc");
- $result = curl_exec($ch);
- delDir(getcwd());
- header('Location: ' . $http_scheme . "://" . $_SERVER['HTTP_HOST'] . '/' . $_POST['directory']);
- exit;
- }
- } else {
- $message = $core->show_message('error', 'Not all fields have been filled in correctly. The host, username, password, and database name are required.');
- }
- }
-}
-global $wavelog_url;
-
-?>
-
-
-
-
-
-
- = __("Install | Wavelog"); ?>
-
-
-
-
-
-
-
-
-
-
-
- ' . $message . ''; // TODO Integrate Message into the design, Dialog???
- } ?>
+ include 'includes/interface_assets/header.php'; ?>
@@ -257,13 +43,13 @@ global $wavelog_url;
|