Update create_db.php

This commit is contained in:
jakani24
2024-01-20 10:59:36 +01:00
parent 84cfd2a4e5
commit 1a2953825a

View File

@@ -1,30 +1,34 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<title>Cyberhex Installation</title> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<style> <title>Cyberhex login page</title>
body {
font-family: 'Arial', sans-serif;
text-align: center;
margin: 50px;
}
h1 {
color: #333;
}
footer {
text-align: center;
position: fixed;
bottom: 0;
width: 100%;
}
</style>
</head> </head>
<body> <body>
<h1>We are creating the databases used in cyberhex, please stand by</h1>
<br>If the creation fails, please wait a minute and try again. The database server might still be starting at the time.</p> <div class="container mt-5">
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card">
<div class="card-header">
<h4>We are creating the databases used in cyberhex, please stand by</h4>
</div>
<div class="card-body">
<p>If the creation fails, please wait a minute and try again. The database server might still be starting at the time.</p>
<br>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
<?php <?php
@@ -43,10 +47,14 @@ if ($conn->connect_error) {
// Create database // Create database
$sql = "CREATE DATABASE IF NOT EXISTS $DB_DATABASE"; $sql = "CREATE DATABASE IF NOT EXISTS $DB_DATABASE";
if ($conn->query($sql) === TRUE) { if ($conn->query($sql) === TRUE) {
echo "Database created successfully<br>"; echo '<br><div class="alert alert-success" role="alert">
Database created successfully!
</div>';
} else { } else {
$success=0; $success=0;
echo "Error creating database: " . $conn->error ."<br>"; echo '<br><div class="alert alert-danger" role="alert">
Error creating database: ' . $conn->error .'
</div>';
} }
$conn->close(); $conn->close();
@@ -71,10 +79,14 @@ $sql = "CREATE TABLE IF NOT EXISTS users (
)"; )";
if ($conn->query($sql) === TRUE) { if ($conn->query($sql) === TRUE) {
echo "Table 'users' created successfully<br>"; echo '<br><div class="alert alert-success" role="alert">
Table users created successfully!
</div>';
} else { } else {
$success=0; $success=0;
echo "Error creating table: " . $conn->error ."<br>"; echo '<br><div class="alert alert-danger" role="alert">
Error creating table users: ' . $conn->error .'
</div>';
} }
// Create log table // Create log table
@@ -86,10 +98,14 @@ $sql = "CREATE TABLE IF NOT EXISTS log (
)"; )";
if ($conn->query($sql) === TRUE) { if ($conn->query($sql) === TRUE) {
echo "Table 'log' created successfully<br>"; echo '<br><div class="alert alert-success" role="alert">
Table log created successfully!
</div>';
} else { } else {
$success=0; $success=0;
echo "Error creating table: " . $conn->error ."<br>"; echo '<br><div class="alert alert-danger" role="alert">
Error creating table log: ' . $conn->error .'
</div>';
} }
// Create settings table // Create settings table
@@ -100,10 +116,14 @@ $sql = "CREATE TABLE IF NOT EXISTS settings (
)"; )";
if ($conn->query($sql) === TRUE) { if ($conn->query($sql) === TRUE) {
echo "Table 'settings' created successfully<br>"; echo '<br><div class="alert alert-success" role="alert">
Table settings created successfully!
</div>';
} else { } else {
$success=0; $success=0;
echo "Error creating table: " . $conn->error ."<br>"; echo '<br><div class="alert alert-danger" role="alert">
Error creating table settings: ' . $conn->error .'
</div>';
} }
// Create api table // Create api table
@@ -114,10 +134,14 @@ $sql = "CREATE TABLE IF NOT EXISTS api (
)"; )";
if ($conn->query($sql) === TRUE) { if ($conn->query($sql) === TRUE) {
echo "Table 'api' created successfully<br>"; echo '<br><div class="alert alert-success" role="alert">
Table api created successfully!
</div>';
} else { } else {
$success=0; $success=0;
echo "Error creating table: " . $conn->error ."<br>"; echo '<br><div class="alert alert-danger" role="alert">
Error creating table api: ' . $conn->error .'
</div>';
} }
// Create secrets table // Create secrets table
@@ -128,10 +152,14 @@ $sql = "CREATE TABLE IF NOT EXISTS secrets (
)"; )";
if ($conn->query($sql) === TRUE) { if ($conn->query($sql) === TRUE) {
echo "Table 'secrets' created successfully<br>"; echo '<br><div class="alert alert-success" role="alert">
Table secrets created successfully!
</div>';
} else { } else {
$success=0; $success=0;
echo "Error creating table: " . $conn->error ."<br>"; echo '<br><div class="alert alert-danger" role="alert">
Error creating table secrets: ' . $conn->error .'
</div>';
} }
// Create machine table // Create machine table
@@ -143,22 +171,27 @@ $sql = "CREATE TABLE IF NOT EXISTS machines (
)"; )";
if ($conn->query($sql) === TRUE) { if ($conn->query($sql) === TRUE) {
echo "Table 'machines' created successfully<br>"; echo '<br><div class="alert alert-success" role="alert">
Table machines created successfully!
</div>';
} else { } else {
$success=0; $success=0;
echo "Error creating table: " . $conn->error ."<br>"; echo '<br><div class="alert alert-danger" role="alert">
Error creating table machines: ' . $conn->error .'
</div>';
} }
if($success!==1){ if($success!==1){
echo('<p style="font-size: 20px; color: red;">There was an error creating the databases. Please try again or contact support at: <a href="mailto:info.jakach@gmail.com">info.jakach@gmail.com</a></p>'); echo '<br><div class="alert alert-danger" role="alert">
There was an error creating the databases. Please try again or contact support at: <a href="mailto:info.jakach@gmail.com">info.jakach@gmail.com</a>
</div>';
}else{ }else{
echo('<p style="font-size: 20px; color: green;">Database created successfully! <a href="create_admin.php">Continue installation</a></p>'); echo '<br><div class="alert alert-success" role="alert">
Database created successfully! <a href="create_admin.php">Continue installation</a>
</div>';
} }
$conn->close(); $conn->close();
?> ?>
<footer>
<p>&copy; 2024 Cyberhex Antivirus by Jakach Software <a href="mailto:info.jakach@gmail.com">info.jakach@gmail.com</a></p>
</footer>
</body> </body>
</html> </html>