If the creation fails, please wait a minute and try again. The database server might still be starting at the time.
connect_error) {
$success=0;
die("Connection failed: " . $conn->connect_error);
}
// Create database
$sql = "CREATE DATABASE IF NOT EXISTS $DB_DATABASE";
if ($conn->query($sql) === TRUE) {
echo '
Database created successfully!
';
} else {
$success=0;
echo '
Error creating database: ' . $conn->error .'
';
}
$conn->close();
// Connect to the new database
$conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD,$DB_DATABASE);
// Check connection
if ($conn->connect_error) {
$success=0;
die("Connection failed: " . $conn->connect_error);
}
// Create user table
//INSERT INTO registrations (userId, credentialId, publicKey, counter) VALUES (?, ?, ?, ?)");
$sql = "CREATE TABLE IF NOT EXISTS users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
perms VARCHAR(255),
password VARCHAR(255),
2fa VARCHAR(255),
telegram_id VARCHAR(255),
user_hex_id VARCHAR(255),
credential_id VARBINARY(64),
allow_pw_login INT,
public_key TEXT,
counter INT
)";
if ($conn->query($sql) === TRUE) {
echo '
Table users created successfully!
';
} else {
$success=0;
echo '
Error creating table users: ' . $conn->error .'
';
}
// Create log table
$sql = "CREATE TABLE IF NOT EXISTS log (
id INT AUTO_INCREMENT PRIMARY KEY,
logtext VARCHAR(500) NOT NULL,
loglevel VARCHAR(255) NOT NULL,
machine_id VARCHAR(255),
time VARCHAR(255)
)";
if ($conn->query($sql) === TRUE) {
echo '
Table log created successfully!
';
} else {
$success=0;
echo '
Error creating table log: ' . $conn->error .'
';
}
// Create settings table
$sql = "CREATE TABLE IF NOT EXISTS settings (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL UNIQUE,
value VARCHAR(255) NOT NULL
)";
if ($conn->query($sql) === TRUE) {
echo '
Table settings created successfully!
';
} else {
$success=0;
echo '
Error creating table settings: ' . $conn->error .'
';
}
//user tasks table
$sql = "CREATE TABLE IF NOT EXISTS user_tasks (
id INT AUTO_INCREMENT PRIMARY KEY,
task VARCHAR(255) NOT NULL UNIQUE
)";
if ($conn->query($sql) === TRUE) {
echo '
Table settings created successfully!
';
} else {
$success=0;
echo '
Error creating table settings: ' . $conn->error .'
';
}
//system tasks table
$sql = "CREATE TABLE IF NOT EXISTS system_tasks (
id INT AUTO_INCREMENT PRIMARY KEY,
task VARCHAR(255) NOT NULL UNIQUE
)";
if ($conn->query($sql) === TRUE) {
echo '
Table settings created successfully!
';
} else {
$success=0;
echo '
Error creating table settings: ' . $conn->error .'
';
}
// Create rtp_included table
$sql = "CREATE TABLE IF NOT EXISTS rtp_included (
id INT AUTO_INCREMENT PRIMARY KEY,
path VARCHAR(255) NOT NULL UNIQUE
)";
if ($conn->query($sql) === TRUE) {
echo '
Table rtp_included created successfully!
';
} else {
$success=0;
echo '
Error creating table rtp_included: ' . $conn->error .'
';
}
// Create rtp_excluded table
$sql = "CREATE TABLE IF NOT EXISTS rtp_excluded (
id INT AUTO_INCREMENT PRIMARY KEY,
path VARCHAR(255) NOT NULL UNIQUE
)";
if ($conn->query($sql) === TRUE) {
echo '
Table rtp_excluded created successfully!
';
} else {
$success=0;
echo '
Error creating table rtp_excluded: ' . $conn->error .'
';
}
// Create api table
$sql = "CREATE TABLE IF NOT EXISTS api (
id INT AUTO_INCREMENT PRIMARY KEY,
apikey VARCHAR(500) NOT NULL,
machine_id VARCHAR(255) NOT NULL
)";
if ($conn->query($sql) === TRUE) {
echo '
Table api created successfully!
';
} else {
$success=0;
echo '
Error creating table api: ' . $conn->error .'
';
}
// Create secrets table
$sql = "CREATE TABLE IF NOT EXISTS secrets (
id INT AUTO_INCREMENT PRIMARY KEY,
cert VARCHAR(500) NOT NULL,
machine_id VARCHAR(255) NOT NULL
)";
if ($conn->query($sql) === TRUE) {
echo '
Table secrets created successfully!
';
} else {
$success=0;
echo '
Error creating table secrets: ' . $conn->error .'
';
}
// Create machine table
$sql = "CREATE TABLE IF NOT EXISTS machines (
id INT AUTO_INCREMENT PRIMARY KEY,
machine_name VARCHAR(255) NOT NULL,
machine_location VARCHAR(255) NOT NULL,
machine_ip VARCHAR(255) NOT NULL
)";
if ($conn->query($sql) === TRUE) {
echo '
Table machines created successfully!
';
} else {
$success=0;
echo '
Error creating table machines: ' . $conn->error .'
';
}
// Create vir_notify messages table
$sql = "CREATE TABLE IF NOT EXISTS vir_notify (
id INT AUTO_INCREMENT PRIMARY KEY,
machine_id VARCHAR(255) NOT NULL,
path VARCHAR(255) NOT NULL,
hash VARCHAR(255) NOT NULL,
action VARCHAR(255) NOT NULL
)";
if ($conn->query($sql) === TRUE) {
echo '
Table machines created successfully!
';
} else {
$success=0;
echo '
Error creating table machines: ' . $conn->error .'
';
}
// Create sig_ex messages table
$sql = "CREATE TABLE IF NOT EXISTS sig_ex (
id INT AUTO_INCREMENT PRIMARY KEY,
signature VARCHAR(255) NOT NULL,
description VARCHAR(255) NOT NULL
)";
if ($conn->query($sql) === TRUE) {
echo '
Table excluded signatures created successfully!
';
} else {
$success=0;
echo '
Error creating table excluded signatures: ' . $conn->error .'
';
}
// Create sig_in messages table
$sql = "CREATE TABLE IF NOT EXISTS sig_in (
id INT AUTO_INCREMENT PRIMARY KEY,
signature VARCHAR(255) NOT NULL,
description VARCHAR(255) NOT NULL
)";
if ($conn->query($sql) === TRUE) {
echo '
Table included signatures created successfully!
';
} else {
$success=0;
echo '
Error creating table included signatures: ' . $conn->error .'
';
}
// Attempt to create the directory where export files will be stored later on
//if (mkdir("/var/www/html/export", 0777, true)) {
// echo '
// Created export dir successfully.
//
';
//} else {
// $success=0;
// echo '
// Error creating export dir.
//
';
//}
// Attempt to create the directory where import files will be stored later on
//if (mkdir("/var/www/html/import", 0777, true)) {
// echo '
// Created export dir successfully.
//
';
//} else {
// $success=0;
// echo '
// Error creating export dir.
//
';
//}
if($success!==1){
echo '
';
}else{
echo '
';
}
$conn->close();
?>