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
$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,
use_2fa INT,
send_login_message 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 incident table
$sql = "CREATE TABLE IF NOT EXISTS incidents (
id INT AUTO_INCREMENT PRIMARY KEY,
status VARCHAR(50) NOT NULL,
description VARCHAR(255) NOT NULL,
opened VARCHAR(50),
closed VARCHAR(50)
)";
if ($conn->query($sql) === TRUE) {
echo '
Table incidents created successfully!
';
} else {
$success=0;
echo '
Error creating table incidents: ' . $conn->error .'
';
}
// Create todo_items table
$sql = "CREATE TABLE IF NOT EXISTS todo_items (
id INT AUTO_INCREMENT PRIMARY KEY,
done INT,
done_by INT,
belongs_to_list INT,
text VARCHAR(500) NOT NULL
)";
if ($conn->query($sql) === TRUE) {
echo '
Table todo_items created successfully!
';
} else {
$success=0;
echo '
Error creating table todo_items: ' . $conn->error .'
';
}
// Create todo lists table
$sql = "CREATE TABLE IF NOT EXISTS todo_lists (
id INT AUTO_INCREMENT PRIMARY KEY,
belongs_to_incident INT,
name VARCHAR(255) NOT NULL
)";
if ($conn->query($sql) === TRUE) {
echo '
Table todo_items created successfully!
';
} else {
$success=0;
echo '
Error creating table todo_items: ' . $conn->error .'
';
}
// Create chat table
$sql = "CREATE TABLE IF NOT EXISTS chats (
id INT AUTO_INCREMENT PRIMARY KEY,
belongs_to_incident INT,
text TEXT NOT NULL,
sent VARCHAR(50),
from_userid INT
)";
if ($conn->query($sql) === TRUE) {
echo '
Table todo_items created successfully!
';
} else {
$success=0;
echo '
Error creating table todo_items: ' . $conn->error .'
';
}
// Create server log table
$sql = "CREATE TABLE IF NOT EXISTS server_log (
id INT AUTO_INCREMENT PRIMARY KEY,
logtext VARCHAR(500) NOT NULL,
loglevel VARCHAR(255) NOT NULL,
userid INT,
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 dissalowed_start table
$sql = "CREATE TABLE IF NOT EXISTS disallowed_start (
id INT AUTO_INCREMENT PRIMARY KEY,
path VARCHAR(255) NOT NULL UNIQUE
)";
if ($conn->query($sql) === TRUE) {
echo '
Table disalowed_start created successfully!
';
} else {
$success=0;
echo '
Error creating table disalowed_start: ' . $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.
';
}
//Attempt to create the directory where log backup files will be stored later on
if (mkdir("/var/www/html/backup", 0777, true)) {
echo '
Created backup dir successfully.
';
} else {
$success=0;
echo '
Error creating backup dir.
';
}*/
if($success!==1){
echo '
';
}else{
echo '
';
}
$conn->close();
?>