If Restore from Backup is chosen show message must configure database first if DB and config dont exist
This commit is contained in:
@@ -18,17 +18,23 @@ if ($config_enable_setup == 0) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$mysqli_available = isset($mysqli) && $mysqli instanceof mysqli;
|
$mysqli_available = isset($mysqli) && $mysqli instanceof mysqli;
|
||||||
$db_tables_exist = false;
|
$can_show_restore = false;
|
||||||
|
$should_skip_to_user = false;
|
||||||
|
|
||||||
if ($mysqli_available) {
|
if (file_exists("config.php") && $mysqli_available) {
|
||||||
$check = mysqli_query($mysqli, "SHOW TABLES LIKE 'users'");
|
$table_result = mysqli_query($mysqli, "SHOW TABLES LIKE 'users'");
|
||||||
if ($check && mysqli_num_rows($check) > 0) {
|
if ($table_result && mysqli_num_rows($table_result) > 0) {
|
||||||
$db_tables_exist = true;
|
$can_show_restore = true;
|
||||||
|
$should_skip_to_user = true;
|
||||||
|
} else {
|
||||||
|
// If DB exists but doesn't have user table yet, maybe still allow restore
|
||||||
|
$all_tables = mysqli_query($mysqli, "SHOW TABLES");
|
||||||
|
if ($all_tables && mysqli_num_rows($all_tables) > 0) {
|
||||||
|
$can_show_restore = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$minimal_setup_mode = file_exists("config.php") && $config_enable_setup == 1 && $mysqli_available && $db_tables_exist;
|
|
||||||
|
|
||||||
include_once "includes/settings_localization_array.php";
|
include_once "includes/settings_localization_array.php";
|
||||||
$errorLog = ini_get('error_log') ?: "Debian/Ubuntu default is usually /var/log/apache2/error.log";
|
$errorLog = ini_get('error_log') ?: "Debian/Ubuntu default is usually /var/log/apache2/error.log";
|
||||||
|
|
||||||
@@ -1063,21 +1069,35 @@ if (isset($_POST['add_telemetry'])) {
|
|||||||
|
|
||||||
<?php } elseif (isset($_GET['restore'])) { ?>
|
<?php } elseif (isset($_GET['restore'])) { ?>
|
||||||
|
|
||||||
<div class="card card-dark">
|
<?php if (!$can_show_restore) { ?>
|
||||||
<div class="card-header">
|
<div class="card card-danger">
|
||||||
<h3 class="card-title"><i class="fas fa-fw fa-database mr-2"></i>Restore from Backup</h3>
|
<div class="card-header">
|
||||||
|
<h3 class="card-title"><i class="fas fa-exclamation-triangle mr-2"></i>Database Not Ready</h3>
|
||||||
|
</div>
|
||||||
|
<div class="card-body text-center">
|
||||||
|
<p>You must configure the database before restoring a backup.</p>
|
||||||
|
<a href="?database" class="btn btn-primary text-bold">
|
||||||
|
Go to Database Setup <i class="fas fa-arrow-right ml-2"></i>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<?php } else { ?>
|
||||||
<form method="post" enctype="multipart/form-data">
|
<div class="card card-dark">
|
||||||
<label>Restore ITFlow Backup (.zip)</label>
|
<div class="card-header">
|
||||||
<input type="file" name="backup_zip" accept=".zip" required>
|
<h3 class="card-title"><i class="fas fa-fw fa-database mr-2"></i>Restore from Backup</h3>
|
||||||
<hr>
|
</div>
|
||||||
<button type="submit" name="restore" class="btn btn-primary text-bold">
|
<div class="card-body">
|
||||||
Restore Backup<i class="fas fa-fw fa-upload ml-2"></i>
|
<form method="post" enctype="multipart/form-data">
|
||||||
</button>
|
<label>Restore ITFlow Backup (.zip)</label>
|
||||||
</form>
|
<input type="file" name="backup_zip" accept=".zip" required>
|
||||||
|
<hr>
|
||||||
|
<button type="submit" name="restore" class="btn btn-primary text-bold">
|
||||||
|
Restore Backup<i class="fas fa-fw fa-upload ml-2"></i>
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<?php } ?>
|
||||||
|
|
||||||
<?php } elseif (isset($_GET['user'])) { ?>
|
<?php } elseif (isset($_GET['user'])) { ?>
|
||||||
|
|
||||||
@@ -1388,14 +1408,19 @@ if (isset($_POST['add_telemetry'])) {
|
|||||||
?>
|
?>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<?php if ($minimal_setup_mode): ?>
|
<?php if ($should_skip_to_user): ?>
|
||||||
<a href="?user" class="btn btn-primary text-bold mr-2">
|
<a href="?user" class="btn btn-primary text-bold mr-2">
|
||||||
Create First User <i class="fas fa-fw fa-user ml-2"></i>
|
Create First User <i class="fas fa-fw fa-user ml-2"></i>
|
||||||
</a>
|
</a>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if ($can_show_restore): ?>
|
||||||
<a href="?restore" class="btn btn-warning text-bold">
|
<a href="?restore" class="btn btn-warning text-bold">
|
||||||
Restore from Backup <i class="fas fa-fw fa-upload ml-2"></i>
|
Restore from Backup <i class="fas fa-fw fa-upload ml-2"></i>
|
||||||
</a>
|
</a>
|
||||||
<?php else: ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if (!$should_skip_to_user && !$can_show_restore): ?>
|
||||||
<a href="?checks" class="btn btn-primary text-bold">
|
<a href="?checks" class="btn btn-primary text-bold">
|
||||||
Begin Setup <i class="fas fa-fw fa-arrow-alt-circle-right ml-2"></i>
|
Begin Setup <i class="fas fa-fw fa-arrow-alt-circle-right ml-2"></i>
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user