Fix bugs
This commit is contained in:
6
api/setup/setup.php
Normal file → Executable file
6
api/setup/setup.php
Normal file → Executable file
@@ -54,9 +54,9 @@ mkdir($config["PATH"] . "/tmp/user_sessions", 0700, true);
|
|||||||
|
|
||||||
file_put_contents($config["PATH"] . "/tmp/user_sessions/" . $admin_user . ".json", json_encode($json));
|
file_put_contents($config["PATH"] . "/tmp/user_sessions/" . $admin_user . ".json", json_encode($json));
|
||||||
|
|
||||||
setcookie("session_id", $session);
|
setcookie("session_id", $session["session_id"], time() + 3600, "/");
|
||||||
setcookie("device_id", $device_id);
|
setcookie("device_id", $device_id, time() + 3600, "/");
|
||||||
setcookie("username", $admin_user);
|
setcookie("username", $admin_user, time() + 3600, "/");
|
||||||
|
|
||||||
header("Location: /");
|
header("Location: /");
|
||||||
exit;
|
exit;
|
||||||
|
|||||||
0
front/css/setup.png → front/css/background.png
Normal file → Executable file
0
front/css/setup.png → front/css/background.png
Normal file → Executable file
|
Before Width: | Height: | Size: 2.7 MiB After Width: | Height: | Size: 2.7 MiB |
86
front/css/login.css
Normal file
86
front/css/login.css
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
body {
|
||||||
|
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
||||||
|
display: grid;
|
||||||
|
place-items: center;
|
||||||
|
height: 100vh;
|
||||||
|
overflow: hidden;
|
||||||
|
background-image: url("/css/background.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-content {
|
||||||
|
padding: 10px;
|
||||||
|
width: 350px;
|
||||||
|
height: 625px;
|
||||||
|
text-align: center;
|
||||||
|
box-shadow: 0 2px 100px rgba(0, 0, 0, 0.1), 0 8px 16px rgba(0, 0, 0, 0.1);
|
||||||
|
border-radius: 30pt;
|
||||||
|
background: rgba(255, 255, 255, 0.3);
|
||||||
|
backdrop-filter: rgba(255, 255, 255, 0.3);
|
||||||
|
backdrop-filter: blur(5px);
|
||||||
|
-webkit-backdrop-filter: blur(5px);
|
||||||
|
display: grid;
|
||||||
|
place-items: center;
|
||||||
|
transition: all 0.3s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
text-align: center;
|
||||||
|
gap: 10px;
|
||||||
|
transition: all 0.3s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header {
|
||||||
|
position: relative;
|
||||||
|
top: 10px;
|
||||||
|
bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 30pt;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
font-size: 20pt;
|
||||||
|
}
|
||||||
|
|
||||||
|
input {
|
||||||
|
border: 1px solid #e0e0e0;
|
||||||
|
width: 200px;
|
||||||
|
height: 30px;
|
||||||
|
border-radius: 10pt;
|
||||||
|
padding: 5px;
|
||||||
|
background: rgba(255, 255, 255, 0.3);
|
||||||
|
backdrop-filter: blur(5px);
|
||||||
|
-webkit-backdrop-filter: blur(5px);
|
||||||
|
}
|
||||||
|
|
||||||
|
input:focus {
|
||||||
|
backdrop-filter: blur(10px);
|
||||||
|
-webkit-backdrop-filter: blur(10pxr);
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
width: 100px;
|
||||||
|
height: 30px;
|
||||||
|
background-color: #000000;
|
||||||
|
color: #ffffff;
|
||||||
|
display: grid;
|
||||||
|
place-items: center;
|
||||||
|
text-align: center;
|
||||||
|
border: none;
|
||||||
|
border-radius: 20pt;
|
||||||
|
transition: all 0.3s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:hover {
|
||||||
|
transform: scale(1.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
button:active {
|
||||||
|
transform: scale(0.8);
|
||||||
|
}
|
||||||
4
front/css/setup.css
Normal file → Executable file
4
front/css/setup.css
Normal file → Executable file
@@ -4,7 +4,7 @@ body {
|
|||||||
place-items: center;
|
place-items: center;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background-image: url("/css/setup.png");
|
background-image: url("/css/background.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-content {
|
.page-content {
|
||||||
@@ -15,7 +15,7 @@ body {
|
|||||||
box-shadow: 0 2px 100px rgba(0, 0, 0, 0.1), 0 8px 16px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 2px 100px rgba(0, 0, 0, 0.1), 0 8px 16px rgba(0, 0, 0, 0.1);
|
||||||
border-radius: 30pt;
|
border-radius: 30pt;
|
||||||
background: rgba(255, 255, 255, 0.3);
|
background: rgba(255, 255, 255, 0.3);
|
||||||
backdrop-filtbackground: rgba(255, 255, 255, 0.3);
|
backdrop-filter: rgba(255, 255, 255, 0.3);
|
||||||
backdrop-filter: blur(5px);
|
backdrop-filter: blur(5px);
|
||||||
-webkit-backdrop-filter: blur(5px);
|
-webkit-backdrop-filter: blur(5px);
|
||||||
display: grid;
|
display: grid;
|
||||||
|
|||||||
7
front/index.php
Normal file → Executable file
7
front/index.php
Normal file → Executable file
@@ -20,8 +20,9 @@ if (!$mcServ->checkConf()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$mcServ->checkLogin()) {
|
if (!$mcServ->checkLogin()) {
|
||||||
header("Location: /admin");
|
/*header("Location: /login.php");
|
||||||
exit;
|
exit;*/
|
||||||
}else{
|
}else{
|
||||||
echo "true";
|
echo "angemeldet";
|
||||||
}
|
}
|
||||||
|
?>
|
||||||
29
front/login.php
Normal file → Executable file
29
front/login.php
Normal file → Executable file
@@ -0,0 +1,29 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>mcServ // Login</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="css/login.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="page-content" id="block">
|
||||||
|
<div class="header">
|
||||||
|
<h1>mcServControl</h1>
|
||||||
|
<h2>Login</h2>
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
<form action="/api/setup/setup.php" method="post">
|
||||||
|
<div id="admin_user" class="page">
|
||||||
|
<a href="/resetpasswd.php">Forget Passwort</a>
|
||||||
|
|
||||||
|
<input type="text" name="username" placeholder="Username" id="user" required><br><br>
|
||||||
|
<input type="password" name="passwd" placeholder="Password" id="passwd" required><br><br>
|
||||||
|
|
||||||
|
<button type="submit">Login</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
0
front/setup.html
Normal file → Executable file
0
front/setup.html
Normal file → Executable file
0
front/test.php
Normal file → Executable file
0
front/test.php
Normal file → Executable file
11
main.php
Normal file → Executable file
11
main.php
Normal file → Executable file
@@ -10,6 +10,10 @@
|
|||||||
* By marc-go
|
* By marc-go
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
ini_set("display_errors", 1);
|
||||||
|
ini_set("display_startup_errors", 1);
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
class mcServ {
|
class mcServ {
|
||||||
public function checkConf() {
|
public function checkConf() {
|
||||||
if (!file_exists("../mcServ.db")) {
|
if (!file_exists("../mcServ.db")) {
|
||||||
@@ -25,18 +29,23 @@ class mcServ {
|
|||||||
|
|
||||||
public function checkLogin() {
|
public function checkLogin() {
|
||||||
if (!isset($_COOKIE["session_id"]) || !isset($_COOKIE["device_id"])) {
|
if (!isset($_COOKIE["session_id"]) || !isset($_COOKIE["device_id"])) {
|
||||||
|
echo "Keine Cookies gesetzt";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$json = json_decode(file_get_contents(this->getConf() . "/tmp/user_sessions/" . $_COOKIE["username"] . ".json"), true);
|
$config = $this->getConf();
|
||||||
|
|
||||||
|
$json = json_decode(file_get_contents($config["PATH"] . "/tmp/user_sessions/" . $_COOKIE["username"] . ".json"), true);
|
||||||
|
|
||||||
if (!isset($json[$_COOKIE["device_id"]])) {
|
if (!isset($json[$_COOKIE["device_id"]])) {
|
||||||
|
echo "Device ID gibt es nicht im JSON";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$device = json_decode($json[$_COOKIE["device_id"]], true);
|
$device = json_decode($json[$_COOKIE["device_id"]], true);
|
||||||
|
|
||||||
if ($device["session_id"] !== $_COOKIE["session_id"]) {
|
if ($device["session_id"] !== $_COOKIE["session_id"]) {
|
||||||
|
echo "Session IDs stimmen nicht überein";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user