mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
next install refactoring
This commit is contained in:
@@ -205,8 +205,18 @@ div.alert-danger {
|
||||
--bs-tooltip-opacity: 1;
|
||||
}
|
||||
|
||||
#languageButton {
|
||||
#languageButton, #advancedSettingsButton, #resetButton {
|
||||
position: absolute;
|
||||
bottom: 70px;
|
||||
right: 20px;
|
||||
}
|
||||
|
||||
.required:after {
|
||||
content: " *";
|
||||
color: red;
|
||||
}
|
||||
|
||||
.required-prefix:before {
|
||||
content: "* ";
|
||||
color: red;
|
||||
}
|
||||
@@ -286,7 +286,7 @@ $config['allow_get_array'] = TRUE;
|
||||
| your log files will fill up very fast.
|
||||
|
|
||||
*/
|
||||
$config['log_threshold'] = 0;
|
||||
$config['log_threshold'] = '%log_threshold%';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -400,7 +400,7 @@ $config['cache_query_string'] = FALSE;
|
||||
| https://codeigniter.com/user_guide/libraries/encryption.html
|
||||
|
|
||||
*/
|
||||
$config['encryption_key'] = 'flossie1234555541';
|
||||
$config['encryption_key'] = '%encryptionkey%';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
||||
@@ -26,7 +26,7 @@ class Core
|
||||
$counter++;
|
||||
}
|
||||
|
||||
if ($data['directory'] != "") {
|
||||
if ($data['directory'] ?? '' != "") {
|
||||
if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/' . $data['directory'])) {
|
||||
//pass folders real
|
||||
$counter++;
|
||||
@@ -151,14 +151,17 @@ class Core
|
||||
function write_configfile($data) {
|
||||
|
||||
$template_path = 'config/config.php';
|
||||
$output_path = $_SERVER['DOCUMENT_ROOT'] . '/' . $data['directory'] . '/application/config/config.php';
|
||||
$output_path = '../application/config/config.php';
|
||||
if (isset($_ENV['CI_ENV'])) {
|
||||
$output_path = $_SERVER['DOCUMENT_ROOT'] . '/' . $data['directory'] . '/application/config/'.$_ENV['CI_ENV'].'/config.php';
|
||||
$output_path = '../application/config/'.$_ENV['CI_ENV'].'/config.php';
|
||||
}
|
||||
|
||||
// Open the file
|
||||
$database_file = file_get_contents($template_path);
|
||||
|
||||
// creating a unique encryption key
|
||||
$encryptionkey = uniqid(bin2hex(random_bytes(8)), false);
|
||||
|
||||
$new = str_replace("%baselocator%", $data['locator'], $database_file);
|
||||
$new = str_replace("%websiteurl%", $data['websiteurl'], $new);
|
||||
$new = str_replace("%directory%", $data['directory'], $new);
|
||||
@@ -174,13 +177,12 @@ class Core
|
||||
$new = str_replace("%hamqth_username%", $data['callbook_username'], $new);
|
||||
$new = str_replace("%hamqth_password%", $data['callbook_password'], $new);
|
||||
}
|
||||
$new = str_replace("%encryptionkey%", $encryptionkey, $new);
|
||||
$new = str_replace("'%log_threshold%'", $data['log_threshold'], $new);
|
||||
|
||||
// Write the new config.php file
|
||||
$handle = fopen($output_path, 'w+');
|
||||
|
||||
// Chmod the file, in case the user forgot
|
||||
@chmod($output_path, 0777);
|
||||
|
||||
// Verify file permissions
|
||||
if (is_writable($output_path)) {
|
||||
|
||||
@@ -1,30 +1,9 @@
|
||||
<?php
|
||||
|
||||
class Database
|
||||
{
|
||||
|
||||
// Function to the database and tables and fill them with the default data
|
||||
function create_database($data)
|
||||
{
|
||||
// Connect to the database
|
||||
$mysqli = new mysqli($data['db_hostname'], $data['db_username'], $data['db_password'], '');
|
||||
|
||||
// Check for errors
|
||||
if (mysqli_connect_errno())
|
||||
return false;
|
||||
|
||||
// Create the prepared statement
|
||||
$mysqli->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']);
|
||||
|
||||
@@ -67,8 +46,7 @@ class Database
|
||||
return true;
|
||||
}
|
||||
|
||||
function database_check($data)
|
||||
{
|
||||
function database_check($data) {
|
||||
try {
|
||||
$timeout = 5; /* five seconds for timeout */
|
||||
$link = mysqli_init();
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
$gt_conf['default_domain'] = 'installer';
|
||||
|
||||
$gt_conf['default_lang'] = 'english';
|
||||
|
||||
35
install/includes/install_config/install_config.php
Normal file
35
install/includes/install_config/install_config.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PRECONFIGURATION
|
||||
*/
|
||||
$http_scheme = is_https() ? "https" : "http";
|
||||
|
||||
// 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";
|
||||
|
||||
// Wanted Pre-Check Parameters
|
||||
// PHP
|
||||
$min_php_version = '7.4.0';
|
||||
$max_execution_time = 600; // Seconds
|
||||
$upload_max_filesize = 8; // Megabyte
|
||||
$post_max_size = 8; // Megabyte
|
||||
$req_allow_url_fopen = '1'; // 1 = on
|
||||
|
||||
// Array of PHP modules to check
|
||||
global $required_php_modules;
|
||||
$required_php_modules = [
|
||||
'php-curl' => ['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;
|
||||
56
install/includes/install_config/install_lib.php
Normal file
56
install/includes/install_config/install_lib.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
// Function to check if a PHP extension is installed
|
||||
function isExtensionInstalled($extensionName) {
|
||||
return in_array($extensionName, get_loaded_extensions());
|
||||
}
|
||||
|
||||
// function to switch the language based on the user selection
|
||||
function switch_lang($new_language) {
|
||||
global $gt_conf;
|
||||
setcookie($gt_conf['lang_cookie'], $new_language);
|
||||
}
|
||||
|
||||
// check if page is called with https or not
|
||||
function is_https() {
|
||||
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') {
|
||||
return true;
|
||||
}
|
||||
if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
|
||||
return true;
|
||||
}
|
||||
if (!empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] === 'on') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Folder permission checks
|
||||
function is_really_writable($path) {
|
||||
|
||||
// Check if the folder exists
|
||||
if (!file_exists($path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the folder is writable
|
||||
try {
|
||||
if (is_writable($path)) {
|
||||
// Check if the subdirectories are writable (recursive check)
|
||||
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
|
||||
foreach ($iterator as $item) {
|
||||
if ($item->isDir() && basename($item->getPathName()) != '..') {
|
||||
if (!is_writable($item->getRealPath())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
59
install/includes/interface_assets/footer.php
Normal file
59
install/includes/interface_assets/footer.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<footer>
|
||||
<script>
|
||||
// restore data from the localstorage if available
|
||||
$('#install_form input').each(function() {
|
||||
var inputId = $(this).attr('id');
|
||||
if (localStorage.getItem(inputId)) {
|
||||
$(this).val(localStorage.getItem(inputId));
|
||||
}
|
||||
});
|
||||
$('#install_form select').each(function() {
|
||||
var inputId = $(this).attr('id');
|
||||
if (localStorage.getItem(inputId)) {
|
||||
$(this).val(localStorage.getItem(inputId));
|
||||
}
|
||||
});
|
||||
|
||||
// save data in the localstorage
|
||||
$('#install_form input').on('input', function() {
|
||||
var inputId = $(this).attr('id');
|
||||
var inputValue = $(this).val();
|
||||
localStorage.setItem(inputId, inputValue);
|
||||
});
|
||||
$('#install_form select').on('input', function() {
|
||||
var inputId = $(this).attr('id');
|
||||
var inputValue = $(this).val();
|
||||
localStorage.setItem(inputId, inputValue);
|
||||
});
|
||||
|
||||
// delete all data in localStorage and reload page
|
||||
$('#resetInstaller').click(function() {
|
||||
localStorage.clear();
|
||||
location.reload();
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
/**
|
||||
* Hidden field to be able to translate the language names
|
||||
* Add english Language Name here if you add new languages to application/config/gettext.php
|
||||
* This helps the po scanner to make them translatable
|
||||
*/
|
||||
?>
|
||||
<div style="display: none">
|
||||
<?= __("Bulgarian"); ?>
|
||||
<?= __("Chinese (Simplified)"); ?>
|
||||
<?= __("Czech"); ?>
|
||||
<?= __("Dutch"); ?>
|
||||
<?= __("English"); ?>
|
||||
<?= __("Finnish"); ?>
|
||||
<?= __("French"); ?>
|
||||
<?= __("German"); ?>
|
||||
<?= __("Greek"); ?>
|
||||
<?= __("Italian"); ?>
|
||||
<?= __("Polish"); ?>
|
||||
<?= __("Russian"); ?>
|
||||
<?= __("Spanish"); ?>
|
||||
<?= __("Swedish"); ?>
|
||||
<?= __("Turkish"); ?>
|
||||
</div>
|
||||
</footer>
|
||||
69
install/includes/interface_assets/header.php
Normal file
69
install/includes/interface_assets/header.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Includes needed stuff
|
||||
*/
|
||||
|
||||
require_once('includes/install_config/install_lib.php');
|
||||
require_once('includes/install_config/install_config.php');
|
||||
|
||||
require_once('includes/gettext/gettext.php');
|
||||
require_once('includes/gettext/gettext_conf.php');
|
||||
|
||||
require_once('includes/core/core_class.php');
|
||||
require_once('includes/core/database_class.php');
|
||||
|
||||
$core = new Core();
|
||||
$database = new Database();
|
||||
|
||||
include('includes/interface_assets/triggers.php');
|
||||
|
||||
/**
|
||||
* Gettext Implementation
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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']);
|
||||
header("Location: " . strtok($_SERVER['REQUEST_URI'], '?'));
|
||||
exit();
|
||||
}
|
||||
|
||||
// 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: " . $_SERVER['REQUEST_URI']);
|
||||
exit();
|
||||
}
|
||||
// get the language from the cookie
|
||||
$language = $_COOKIE[$gt_conf['lang_cookie']];
|
||||
|
||||
// and set the locale for gettext
|
||||
T_setlocale(LC_MESSAGES, $language);
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="<?= $language; ?>">
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
|
||||
<title><?= __("Install | Wavelog"); ?></title>
|
||||
<link rel="icon" type="image/x-icon" href="../favicon.ico">
|
||||
|
||||
<link rel="stylesheet" href="../assets/css/darkly/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="assets/css/installer.css">
|
||||
<link rel="stylesheet" href="../assets/fontawesome/css/all.min.css">
|
||||
<link rel="stylesheet" href="../assets/css/ldbtn.min.css">
|
||||
<link rel="stylesheet" href="../assets/css/loading.min.css">
|
||||
|
||||
<script type="text/javascript" src="../assets/js/bootstrap.bundle.min.js"></script>
|
||||
<script type="text/javascript" src="../assets/js/jquery-3.3.1.min.js"></script>
|
||||
</head>
|
||||
58
install/includes/interface_assets/triggers.php
Normal file
58
install/includes/interface_assets/triggers.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Triggers for Ajax Calls
|
||||
*/
|
||||
|
||||
// Database Check
|
||||
if ($_POST['database_check'] ?? false == true) {
|
||||
|
||||
$result = $database->database_check($_POST);
|
||||
echo $result;
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Install Triggers
|
||||
*
|
||||
*/
|
||||
|
||||
// config_file()
|
||||
// if ($core->validate_post($_POST) == true) {
|
||||
|
||||
if ($_POST['run_config_file'] ?? false == true) {
|
||||
sleep(1);
|
||||
$data = json_decode($_POST['data'], true);
|
||||
$result = $core->write_configfile($data);
|
||||
echo $result ? 'success' : 'error';
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($_POST['run_database_file'] ?? false == true) {
|
||||
sleep(1);
|
||||
$data = json_decode($_POST['data'], true);
|
||||
$result = $core->write_config($data);
|
||||
echo $result ? 'success' : 'error';
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($_POST['run_database_tables'] ?? false == true) {
|
||||
$data = json_decode($_POST['data'], true);
|
||||
$result = $database->create_tables($data);
|
||||
echo $result ? 'success' : 'error';
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($_POST['run_installer_lock'] ?? false) {
|
||||
exec('touch .lock', $output, $return_var);
|
||||
if ($return_var === 0 && file_exists('.lock')) {
|
||||
echo 'success';
|
||||
} else {
|
||||
echo 'error';
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
// }
|
||||
2880
install/index.php
2880
install/index.php
File diff suppressed because it is too large
Load Diff
238
install/run.php
Normal file
238
install/run.php
Normal file
@@ -0,0 +1,238 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<?php include 'includes/interface_assets/header.php'; ?>
|
||||
|
||||
<body>
|
||||
<div class="container" style="max-width: 1200px; margin-top: 8rem; ">
|
||||
<div class="card mt-4" style="min-height: 750px; margin: 0 auto;">
|
||||
<div class="card-body text-center">
|
||||
<h3 style="margin-top: 150px;"><?= __("Installation"); ?></h3>
|
||||
|
||||
<p style="margin-bottom: 60px;"><?= __("Please wait..."); ?></p>
|
||||
|
||||
<div class="mb-3" id="config_file" style="opacity: 50%;">
|
||||
<i id="config_file_spinner" class="ld-ext-right"><?= __("Copy config.php to application/config/") ?><div class="ld ld-ring ld-spin"></div></i><i id="config_file_check" class="ms-2 fas fa-check-circle" style="display: none;"></i>
|
||||
</div>
|
||||
<div class="mb-3" id="database_file" style="opacity: 50%;">
|
||||
<i id="database_file_spinner" class="ld-ext-right"><?= __("Copy database.php to application/config/") ?><div class="ld ld-ring ld-spin"></div></i><i id="database_file_check" class="ms-2 fas fa-check-circle" style="display: none;"></i>
|
||||
</div>
|
||||
<div class="mb-3" id="database_tables" style="opacity: 50%;">
|
||||
<i id="database_tables_spinner" class="ld-ext-right"><?= __("Creating database tables") ?><div class="ld ld-ring ld-spin"></div></i><i id="database_tables_check" class="ms-2 fas fa-check-circle" style="display: none;"></i>
|
||||
</div>
|
||||
<div class="mb-3" id="database_migrations" style="opacity: 50%;">
|
||||
<i id="database_migrations_spinner" class="ld-ext-right"><?= __("Running database migrations") ?><div class="ld ld-ring ld-spin"></div></i><i id="database_migrations_check" class="ms-2 fas fa-check-circle" style="display: none;"></i>
|
||||
</div>
|
||||
<div class="mb-3" id="update_dxcc" style="opacity: 50%;">
|
||||
<i id="update_dxcc_spinner" class="ld-ext-right"><?= __("Updating DXCC data") ?><div class="ld ld-ring ld-spin"></div></i><i id="update_dxcc_check" class="ms-2 fas fa-check-circle" style="display: none;"></i>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
// we can easily add more steps here if necessary
|
||||
?>
|
||||
|
||||
<div class="mb-3" id="installer_lock" style="opacity: 50%;">
|
||||
<i id="installer_lock_spinner" class="ld-ext-right"><?= __("Lock the installer") ?><div class="ld ld-ring ld-spin"></div></i><i id="installer_lock_check" class="ms-2 fas fa-check-circle" style="display: none;"></i>
|
||||
</div>
|
||||
|
||||
<div class="mb-3" id="success_message" style="display: none;">
|
||||
<p><?= sprintf(__("All install steps went through. Redirect to user login in %s seconds..."), "<span id='countdown'>4</span>"); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
<script>
|
||||
$(document).ready(async function() {
|
||||
|
||||
await config_file();
|
||||
await database_file();
|
||||
await database_tables();
|
||||
await database_migrations();
|
||||
await update_dxcc();
|
||||
await installer_lock();
|
||||
|
||||
// after all install steps went through we can show a success message and redirect to the user/login
|
||||
$("#success_message").show();
|
||||
|
||||
// Initialize the countdown
|
||||
var countdown = 4;
|
||||
var countdownInterval = setInterval(function() {
|
||||
countdown--;
|
||||
$("#countdown").text(countdown);
|
||||
if (countdown <= 0) {
|
||||
clearInterval(countdownInterval);
|
||||
window.location.href = "/index.php/user/login/1";
|
||||
}
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
let _POST = '<?php echo json_encode($_POST); ?>';
|
||||
|
||||
async function config_file() {
|
||||
|
||||
var field = '#config_file';
|
||||
|
||||
running(field, true);
|
||||
|
||||
await $.ajax({
|
||||
type: 'POST',
|
||||
url: 'index.php',
|
||||
data: {
|
||||
data: _POST,
|
||||
run_config_file: 1
|
||||
},
|
||||
success: function(response) {
|
||||
if (response == 'success') {
|
||||
running(field, false);
|
||||
} else {
|
||||
running(field, true, true);
|
||||
}
|
||||
},
|
||||
error: function(error) {
|
||||
running(field, true, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function database_file() {
|
||||
|
||||
var field = '#database_file';
|
||||
|
||||
running(field, true);
|
||||
|
||||
await $.ajax({
|
||||
type: 'POST',
|
||||
url: 'index.php',
|
||||
data: {
|
||||
data: _POST,
|
||||
run_database_file: 1
|
||||
},
|
||||
success: function(response) {
|
||||
if (response == 'success') {
|
||||
running(field, false);
|
||||
} else {
|
||||
running(field, true, true);
|
||||
}
|
||||
},
|
||||
error: function(error) {
|
||||
running(field, true, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function database_tables() {
|
||||
var field = '#database_tables';
|
||||
|
||||
running(field, true);
|
||||
|
||||
await $.ajax({
|
||||
type: 'POST',
|
||||
url: 'index.php',
|
||||
data: {
|
||||
data: _POST,
|
||||
run_database_tables: 1
|
||||
},
|
||||
success: function(response) {
|
||||
if (response == 'success') {
|
||||
running(field, false);
|
||||
} else {
|
||||
running(field, true, true);
|
||||
}
|
||||
},
|
||||
error: function(error) {
|
||||
running(field, true, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function database_migrations() {
|
||||
var field = '#database_migrations';
|
||||
|
||||
running(field, true);
|
||||
|
||||
await $.ajax({
|
||||
url: "<?php echo $_POST['websiteurl']; ?>" + "index.php/migrate",
|
||||
success: function(response) {
|
||||
if (response == 'success') {
|
||||
running(field, false);
|
||||
} else {
|
||||
running(field, true, true);
|
||||
}
|
||||
},
|
||||
error: function(error) {
|
||||
running(field, true, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function update_dxcc() {
|
||||
var field = '#update_dxcc';
|
||||
|
||||
running(field, true);
|
||||
|
||||
await $.ajax({
|
||||
url: "<?php echo $_POST['websiteurl']; ?>" + "index.php/update/dxcc",
|
||||
success: function(response) {
|
||||
if (response == 'success') {
|
||||
running(field, false);
|
||||
} else {
|
||||
running(field, true, true);
|
||||
}
|
||||
},
|
||||
error: function(error) {
|
||||
running(field, true, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function installer_lock() {
|
||||
var field = '#installer_lock';
|
||||
|
||||
running(field, true);
|
||||
|
||||
await $.ajax({
|
||||
type: 'POST',
|
||||
url: 'index.php',
|
||||
data: {
|
||||
run_installer_lock: 1
|
||||
},
|
||||
success: function(response) {
|
||||
if (response == 'success') {
|
||||
running(field, false);
|
||||
} else {
|
||||
running(field, true, true);
|
||||
}
|
||||
},
|
||||
error: function(error) {
|
||||
running(field, true, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
function running(field, running, failure = false) {
|
||||
|
||||
if (running) {
|
||||
$(field).css('opacity', '100%');
|
||||
$(field + '_spinner').addClass("running");
|
||||
} else {
|
||||
$(field + '_spinner').removeClass("running");
|
||||
if (failure) {
|
||||
$(field + '_check').addClass('fa-times-circle');
|
||||
$(field + '_check').css('color', 'red');
|
||||
} else {
|
||||
$(field + '_check').addClass('fa-check-circle');
|
||||
$(field + '_check').css('color', '#04a004');
|
||||
}
|
||||
$(field + '_check').css('display', 'inline');
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php include 'includes/interface_assets/footer.php'; ?>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user