created installer software
This commit is contained in:
6
src/server/cyberhex-code/config.php
Normal file
6
src/server/cyberhex-code/config.php
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
$servername = "cyberhex-db";
|
||||||
|
$username = "root";
|
||||||
|
$password = "1234";
|
||||||
|
$database = "cyberhex_db";
|
||||||
|
?>
|
||||||
84
src/server/cyberhex-code/install/create_admin.php
Normal file
84
src/server/cyberhex-code/install/create_admin.php
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Cyberhex Installation</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: 'Arial', sans-serif;
|
||||||
|
text-align: center;
|
||||||
|
margin: 50px;
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
form {
|
||||||
|
display: inline-block;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
label {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
input {
|
||||||
|
width: 200px;
|
||||||
|
padding: 8px;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
button {
|
||||||
|
padding: 10px 20px;
|
||||||
|
background-color: #4CAF50;
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
border-radius: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Please create an admin user:</h1>
|
||||||
|
<form action="create_admin.php?create=true" method="post">
|
||||||
|
<label for="username">Username:</label>
|
||||||
|
<input type="text" id="username" name="username" required>
|
||||||
|
|
||||||
|
<label for="email">email:</label>
|
||||||
|
<input type="text" id="email" name="email" required>
|
||||||
|
|
||||||
|
<label for="password">Password:</label>
|
||||||
|
<input type="password" id="password" name="password" required>
|
||||||
|
|
||||||
|
<button type="submit">Submit</button>
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
<?php
|
||||||
|
include "../config.php";
|
||||||
|
if(isset($_GET["create"])){
|
||||||
|
$email=htmlspecialchars($_POST["email"]);
|
||||||
|
$username=htmlspecialchars($_POST["username"]);
|
||||||
|
$password=htmlspecialchars($_POST["password"]);
|
||||||
|
$permissions="1111111111";
|
||||||
|
// Create connection
|
||||||
|
$conn = new mysqli($servername, $username, $password);
|
||||||
|
|
||||||
|
// Check connection
|
||||||
|
if ($conn->connect_error) {
|
||||||
|
$success=0;
|
||||||
|
die("Connection failed: " . $conn->connect_error);
|
||||||
|
}
|
||||||
|
$stmt = $conn->prepare("INSERT INTO users (email, username, password,perms) VALUES (?, ?, ?)");
|
||||||
|
$stmt->bind_param("sss", $email, $username, $hash, $permissions);
|
||||||
|
|
||||||
|
$email=htmlspecialchars($_POST["email"]);
|
||||||
|
$username=htmlspecialchars($_POST["username"]);
|
||||||
|
$password=htmlspecialchars($_POST["password"]);
|
||||||
|
$permissions="1111111111";
|
||||||
|
$hash=password_hash('user_password_here', PASSWORD_BCRYPT);
|
||||||
|
|
||||||
|
$conn->execute();
|
||||||
|
$conn->close();
|
||||||
|
echo('<p style="font-size: 20px; color: green;">Admin created successfully! <a href="end.php">Continue installation</a></p>');
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
</html>
|
||||||
@@ -1,24 +1,46 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
$servername = "cyberhex-db";
|
<!DOCTYPE html>
|
||||||
$username = "root";
|
<html lang="en">
|
||||||
$password = "1234";
|
<head>
|
||||||
$database = "cyberhex_db";
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Cyberhex Installation</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: 'Arial', sans-serif;
|
||||||
|
text-align: center;
|
||||||
|
margin: 50px;
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>We are creating the databases used in cyberhex, please stand by</h1>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
$success=1;
|
||||||
|
include "../config.php";
|
||||||
|
|
||||||
// Create connection
|
// Create connection
|
||||||
$conn = new mysqli($servername, $username, $password);
|
$conn = new mysqli($servername, $username, $password);
|
||||||
|
|
||||||
// Check connection
|
// Check connection
|
||||||
if ($conn->connect_error) {
|
if ($conn->connect_error) {
|
||||||
|
$success=0;
|
||||||
die("Connection failed: " . $conn->connect_error);
|
die("Connection failed: " . $conn->connect_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create database
|
// Create database
|
||||||
$sql = "CREATE DATABASE IF NOT EXISTS $database";
|
$sql = "CREATE DATABASE IF NOT EXISTS $database";
|
||||||
if ($conn->query($sql) === TRUE) {
|
if ($conn->query($sql) === TRUE) {
|
||||||
echo "Database created successfully\n";
|
echo "Database created successfully<br>";
|
||||||
} else {
|
} else {
|
||||||
echo "Error creating database: " . $conn->error;
|
$success=0;
|
||||||
|
echo "Error creating database: " . $conn->error ."<br>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$conn->close();
|
$conn->close();
|
||||||
@@ -28,6 +50,7 @@ $conn = new mysqli($servername, $username, $password, $database);
|
|||||||
|
|
||||||
// Check connection
|
// Check connection
|
||||||
if ($conn->connect_error) {
|
if ($conn->connect_error) {
|
||||||
|
$success=0;
|
||||||
die("Connection failed: " . $conn->connect_error);
|
die("Connection failed: " . $conn->connect_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,9 +64,10 @@ $sql = "CREATE TABLE IF NOT EXISTS users (
|
|||||||
)";
|
)";
|
||||||
|
|
||||||
if ($conn->query($sql) === TRUE) {
|
if ($conn->query($sql) === TRUE) {
|
||||||
echo "Table 'users' created successfully\n";
|
echo "Table 'users' created successfully<br>";
|
||||||
} else {
|
} else {
|
||||||
echo "Error creating table: " . $conn->error;
|
$success=0;
|
||||||
|
echo "Error creating table: " . $conn->error ."<br>";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create log table
|
// Create log table
|
||||||
@@ -55,9 +79,10 @@ $sql = "CREATE TABLE IF NOT EXISTS log (
|
|||||||
)";
|
)";
|
||||||
|
|
||||||
if ($conn->query($sql) === TRUE) {
|
if ($conn->query($sql) === TRUE) {
|
||||||
echo "Table 'log' created successfully\n";
|
echo "Table 'log' created successfully<br>";
|
||||||
} else {
|
} else {
|
||||||
echo "Error creating table: " . $conn->error;
|
$success=0;
|
||||||
|
echo "Error creating table: " . $conn->error ."<br>";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create settings table
|
// Create settings table
|
||||||
@@ -68,9 +93,10 @@ $sql = "CREATE TABLE IF NOT EXISTS settings (
|
|||||||
)";
|
)";
|
||||||
|
|
||||||
if ($conn->query($sql) === TRUE) {
|
if ($conn->query($sql) === TRUE) {
|
||||||
echo "Table 'settings' created successfully\n";
|
echo "Table 'settings' created successfully<br>";
|
||||||
} else {
|
} else {
|
||||||
echo "Error creating table: " . $conn->error;
|
$success=0;
|
||||||
|
echo "Error creating table: " . $conn->error ."<br>";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create api table
|
// Create api table
|
||||||
@@ -81,9 +107,10 @@ $sql = "CREATE TABLE IF NOT EXISTS api (
|
|||||||
)";
|
)";
|
||||||
|
|
||||||
if ($conn->query($sql) === TRUE) {
|
if ($conn->query($sql) === TRUE) {
|
||||||
echo "Table 'api' created successfully\n";
|
echo "Table 'api' created successfully<br>";
|
||||||
} else {
|
} else {
|
||||||
echo "Error creating table: " . $conn->error;
|
$success=0;
|
||||||
|
echo "Error creating table: " . $conn->error ."<br>";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create secrets table
|
// Create secrets table
|
||||||
@@ -94,9 +121,10 @@ $sql = "CREATE TABLE IF NOT EXISTS secrets (
|
|||||||
)";
|
)";
|
||||||
|
|
||||||
if ($conn->query($sql) === TRUE) {
|
if ($conn->query($sql) === TRUE) {
|
||||||
echo "Table 'secrets' created successfully\n";
|
echo "Table 'secrets' created successfully<br>";
|
||||||
} else {
|
} else {
|
||||||
echo "Error creating table: " . $conn->error;
|
$success=0;
|
||||||
|
echo "Error creating table: " . $conn->error ."<br>";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create machine table
|
// Create machine table
|
||||||
@@ -108,9 +136,16 @@ $sql = "CREATE TABLE IF NOT EXISTS machines (
|
|||||||
)";
|
)";
|
||||||
|
|
||||||
if ($conn->query($sql) === TRUE) {
|
if ($conn->query($sql) === TRUE) {
|
||||||
echo "Table 'machines' created successfully\n";
|
echo "Table 'machines' created successfully<br>";
|
||||||
} else {
|
} else {
|
||||||
echo "Error creating table: " . $conn->error;
|
$success=0;
|
||||||
|
echo "Error creating table: " . $conn->error ."<br>";
|
||||||
|
}
|
||||||
|
|
||||||
|
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>');
|
||||||
|
}else{
|
||||||
|
echo('<p style="font-size: 20px; color: green;">Database created successfully! <a href="create_admin.php">Continue installation</a></p>');
|
||||||
}
|
}
|
||||||
|
|
||||||
$conn->close();
|
$conn->close();
|
||||||
|
|||||||
41
src/server/cyberhex-code/install/end.php
Normal file
41
src/server/cyberhex-code/install/end.php
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Cyberhex Installation</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: 'Arial', sans-serif;
|
||||||
|
text-align: center;
|
||||||
|
margin: 50px;
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>You have installed cyberhex! Thank you for choosing us!</h1>
|
||||||
|
<a href="end.php?end=true">Finish installation.</a>
|
||||||
|
</body>
|
||||||
|
<?php
|
||||||
|
if(isset($_GET["end"])){
|
||||||
|
$success=1;
|
||||||
|
if(!unlink("create_admin.php")){
|
||||||
|
$success=0;
|
||||||
|
}if(!unlink("welcome.php")){
|
||||||
|
$success=0;
|
||||||
|
}if(!unlink("create_db.php")){
|
||||||
|
$success=0;
|
||||||
|
}
|
||||||
|
if($success!==1){
|
||||||
|
echo('<p style="font-size: 20px; color: red;">There was an error finishing the installation. Please try again or contact support at: <a href="mailto:info.jakach@gmail.com">info.jakach@gmail.com</a></p>');
|
||||||
|
}else{
|
||||||
|
echo('<p style="font-size: 20px; color: green;">All done, you can now start using cyberhex! <a href="/login.php">Go to login page</a></p>');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</html>
|
||||||
@@ -17,6 +17,8 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Welcome to the Cyberhex Installation</h1>
|
<h1>Welcome to the Cyberhex Installation</h1>
|
||||||
<p>This is a simple webpage for the Cyberhex installation. Customize it as needed for your specific requirements.</p>
|
<p>The installer will guide you through the installation.</p>
|
||||||
|
<p>If there are any errors during installation or you are stuck, please contatact <a href="mailto:info.jakach@gmail.com">info.jakach@gmail.com</a></p>
|
||||||
|
<a href="create_db.php">Start installation.</a>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user