We are creating the databases used in cyberhex, please stand by
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)
)";
if ($conn->query($sql) === TRUE) {
echo "Table 'users' created successfully
";
} else {
$success=0;
echo "Error creating table: " . $conn->error ."
";
}
// Create log table
$sql = "CREATE TABLE IF NOT EXISTS log (
id INT AUTO_INCREMENT PRIMARY KEY,
logtext VARCHAR(255) NOT NULL,
loglevel VARCHAR(255) NOT NULL,
machine_id VARCHAR(255)
)";
if ($conn->query($sql) === TRUE) {
echo "Table 'log' created successfully
";
} else {
$success=0;
echo "Error creating table: " . $conn->error ."
";
}
// Create settings table
$sql = "CREATE TABLE IF NOT EXISTS settings (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
value VARCHAR(255) NOT NULL
)";
if ($conn->query($sql) === TRUE) {
echo "Table 'settings' created successfully
";
} else {
$success=0;
echo "Error creating table: " . $conn->error ."
";
}
// Create api table
$sql = "CREATE TABLE IF NOT EXISTS api (
id INT AUTO_INCREMENT PRIMARY KEY,
apikey VARCHAR(255) 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: " . $conn->error ."
";
}
// Create secrets table
$sql = "CREATE TABLE IF NOT EXISTS secrets (
id INT AUTO_INCREMENT PRIMARY KEY,
cert VARCHAR(255) 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: " . $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: " . $conn->error ."
";
}
if($success!==1){
echo('There was an error creating the databases. Please try again or contact support at: info.jakach@gmail.com
');
}else{
echo('Database created successfully! Continue installation
');
}
$conn->close();
?>