Fixed some bugs and added a cookies disclaimer

This commit is contained in:
2022-11-10 21:56:38 +01:00
commit d39b7214b8
27 changed files with 9158 additions and 0 deletions

120
install/index.php Normal file
View File

@@ -0,0 +1,120 @@
<?php
session_start();
if(file_exists("../config.php")) {
header("Location: ../index.php");
die();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link type="text/css" rel="stylesheet" href="style.css" />
<title>WebStatus - Simplesetup</title>
</head>
<body>
<div class="center">
<form method="POST" action="index.php">
<h2 class="text">Setup</h2>
<?php
if(isset($_GET['mysqlerror'])) {
echo '<p class="error">MySQL Connection failed, please check your inputs!</p>';
}
if(isset($_GET['passwordnotmatch'])) {
echo '<p class="error">Passwords do not match!</p>';
}
?>
<p class="subtext">Website Settings:</p>
<input type="text" class="" placeholder="Websitetitle" name="websitename" required>
<p class="subtext">Database Setup:</p>
<input type="text" placeholder="Host" name="dbhost" required>
<input type="text" placeholder="Databasename" name="dbname" required>
<input type="text" placeholder="User" name="dbuser" required>
<input type="password" placeholder="Password" name="dbpwd" required>
<p class="subtext">Administrative User:</p>
<input type="text" placeholder="Username" name="username" required>
<input type="password" placeholder="Password" name="password" required>
<input type="password" placeholder="repeat password" name="password2" required>
<input class="button-green" value="Submit" type="submit">
</form>
</div>
</body>
</html>
<?php
if(isset($_POST['dbhost']) && isset($_POST['dbname']) && isset($_POST['dbpwd']) && isset($_POST['dbuser'])
&& isset($_POST['websitename']) && isset($_POST['username']) && isset($_POST['password']) && isset($_POST['password2'])) {
if(!file_exists("../config.php")) {
//Inputs read in, check inputs, start infliating database
$instancename = $_POST['websitename'];
$dbhost = $_POST['dbhost'];
$dbname = $_POST['dbname'];
$dbpwd = $_POST['dbpwd'];
$dbuser = $_POST['dbuser'];
$admin_username = $_POST['username'];
$admin_password = $_POST['password'];
$admin_password2 = $_POST['password2'];
$admin_password_hash = password_hash($_POST['password'], PASSWORD_DEFAULT);
//Check if passwords of the administrative user match
if(strcmp($admin_password, $admin_password2)) {
header("Location: index.php?passwordnotmatch");
die();
}
$con = mysqli_connect($dbhost, $dbuser, $dbpwd, $dbname) OR header("Location: index.php?mysqlerror") && die();
//Creating Tables
mysqli_query($con, "CREATE TABLE IF NOT EXISTS accounts(id int(255) PRIMARY KEY AUTO_INCREMENT, username varchar(255), password varchar(255), role varchar(255));");
mysqli_query($con, "CREATE TABLE IF NOT EXISTS groups(id int(255) PRIMARY KEY AUTO_INCREMENT, priority int(255), name varchar(255));");
mysqli_query($con, "CREATE TABLE IF NOT EXISTS incidents(id int(255) PRIMARY KEY AUTO_INCREMENT, status varchar(255), services varchar(255), text varchar(255), date varchar(255), childof int(255));");
mysqli_query($con, "CREATE TABLE IF NOT EXISTS services(id int(255) PRIMARY KEY AUTO_INCREMENT, priority int(255), groupid int(255), name varchar(255), status varchar(255), cmaintenance int(255), sname varchar(255));");
mysqli_query($con, "CREATE TABLE IF NOT EXISTS settings(type varchar(255), value varchar(255));");
//Infliating Settings
mysqli_query($con, "INSERT INTO settings(type, value) VALUES ('instancename', '".mysqli_real_escape_string($con,$instancename)."')");
mysqli_query($con, "INSERT INTO settings(type, value) VALUES ('autoreload', 'enabled')");
mysqli_query($con, "INSERT INTO settings(type, value) VALUES ('impressum', '#')");
mysqli_query($con, "INSERT INTO settings(type, value) VALUES ('privacy', '#')");
mysqli_query($con, "INSERT INTO settings(type, value) VALUES ('newtab', 'same tab')");
//Creating Administrative User
mysqli_query($con, "INSERT INTO accounts (username, password, role) VALUES ('".mysqli_real_escape_string($con,$admin_username)."',
'".mysqli_real_escape_string($con,$admin_password_hash)."', 'administrator')");
//Create Config
if($con != null) {
$config = ('<?php
$config=array(
"DBHOST"=>"'.$dbhost.'",
"DBNAME"=>"'.$dbname.'",
"DBPWD"=>"'.$dbpwd.'",
"DBUSER"=>"'.$dbuser.'"
);
?>');
file_put_contents("../config.php",$config);
header("Location: ../admin.php");
}
//Setup File already exists
} else {
header("Location: ../index.php");
die();
}
}
?>

114
install/style.css Normal file
View File

@@ -0,0 +1,114 @@
body {
background: #233142;
}
input {
text-align: center;
background-color: #ECF0F1;
border: 2px solid transparent;
border-radius: 3px;
font-size: 15px;
font-weight: 200;
padding: 10px 0;
width: 200px;
transition: border .5s;
margin-left: -2px;
margin-top: 2px;
color: #7996b9;
background-color: #2c3e54;
display: block !important;
}
input:focus {
border: 2px solid #3498DB;
box-shadow: none;
}
.center {
transform: translate(440%, 10%);
width: 10%;
}
.text {
font-family: "Lato", sans-serif;
color: #a6a6a6;
}
.subtext {
font-family: "Lato", sans-serif;
color: #a6a6a6;
}
.error {
font-family: "Lato", sans-serif;
size: 1em;
color: #800000;
}
button {
position: relative;
margin-bottom: 2px;
font-size: 15px !important;
font-weight: 200 !important;
color: #7996b9 !important;
}
button:focus {
outline: 0;
}
button:before {
content: "";
display: block;
position: absolute;
background: rgba(255, 255, 255, 0.5);
width: 60px;
height: 100%;
left: 0;
top: 0;
opacity: 0.5;
filter: blur(30px);
transform: translateX(-100px) skewX(-15deg);
}
button:after {
content: "";
display: block;
position: absolute;
background: rgba(255, 255, 255, 0.2);
width: 30px;
height: 100%;
left: 30px;
top: 0;
opacity: 0;
filter: blur(5px);
transform: translateX(-100px) skewX(-15deg);
}
button:hover:before {
transform: translateX(300px) skewX(-15deg);
opacity: 0.6;
transition: 0.7s;
}
button:hover:after {
transform: translateX(300px) skewX(-15deg);
opacity: 1;
transition: 0.7s;
}
.button-green {
background: #2c3e54;
color: #ccc;
width: 80px;
height: 42px;
border: 0;
font-size: 18px;
border-radius: 4px;
font-family: "Raleway", sans-serif;
transition: 0.6s;
overflow: hidden;
}
.button-green:hover {
background: #338033;
cursor: pointer;
}