From e12ad0ad7e29ed653b354339401835aef1ce0c31 Mon Sep 17 00:00:00 2001 From: marc-go Date: Sat, 14 Feb 2026 19:06:07 +0100 Subject: [PATCH] Add login --- api/setup/setup.php | 6 ++++++ front/css/setup.css | 12 ++++++++++-- front/index.php | 7 +++++-- front/login.php | 0 main.php | 18 ++++++++++++++++-- mcServ.db | Bin 16384 -> 16384 bytes 6 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 front/login.php diff --git a/api/setup/setup.php b/api/setup/setup.php index a17553f..aa1a4c1 100644 --- a/api/setup/setup.php +++ b/api/setup/setup.php @@ -50,8 +50,14 @@ $device_id = rand(1, 999); $json[$device_id] = json_encode($session); $json["array"] = true; +mkdir($config["PATH"] . "/tmp/user_sessions", 0700, true); + file_put_contents($config["PATH"] . "/tmp/user_sessions/" . $admin_user . ".json", json_encode($json)); +setcookie("session_id", $session); +setcookie("device_id", $device_id); +setcookie("username", $admin_user); + header("Location: /"); exit; ?> \ No newline at end of file diff --git a/front/css/setup.css b/front/css/setup.css index e219046..3733901 100644 --- a/front/css/setup.css +++ b/front/css/setup.css @@ -14,7 +14,10 @@ body { 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-color: #ffffff; + background: rgba(255, 255, 255, 0.3); + backdrop-filtbackground: 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; @@ -53,10 +56,15 @@ input { 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 { - outline: 2px solid #000000; + backdrop-filter: blur(10px); + -webkit-backdrop-filter: blur(10pxr); + outline: none; } button { diff --git a/front/index.php b/front/index.php index 9255bf0..8417fa8 100644 --- a/front/index.php +++ b/front/index.php @@ -7,7 +7,7 @@ | | | | | | (__ ____) | __/ | \ V /| |___| (_) | | | | |_| | | (_) | | |_| |_| |_|\___|_____/ \___|_| \_/ \_____\___/|_| |_|\__|_| \___/|_| -* By RootMarc +* By marc-go */ require "../main.php"; @@ -20,5 +20,8 @@ if (!$mcServ->checkConf()) { } if (!$mcServ->checkLogin()) { - + header("Location: /admin"); + exit; +}else{ + echo "true"; } \ No newline at end of file diff --git a/front/login.php b/front/login.php new file mode 100644 index 0000000..e69de29 diff --git a/main.php b/main.php index 4ac6e8c..843a430 100644 --- a/main.php +++ b/main.php @@ -7,7 +7,7 @@ | | | | | | (__ ____) | __/ | \ V /| |___| (_) | | | | |_| | | (_) | | |_| |_| |_|\___|_____/ \___|_| \_/ \_____\___/|_| |_|\__|_| \___/|_| -* By RootMarc +* By marc-go */ class mcServ { @@ -24,9 +24,23 @@ class mcServ { } public function checkLogin() { - if (!isset($_COOKIE["session_id"]) || !isset($_COOKIE["user_id"])) { + if (!isset($_COOKIE["session_id"]) || !isset($_COOKIE["device_id"])) { return false; } + + $json = json_decode(file_get_contents(this->getConf() . "/tmp/user_sessions/" . $_COOKIE["username"] . ".json"), true); + + if (!isset($json[$_COOKIE["device_id"]])) { + return false; + } + + $device = json_decode($json[$_COOKIE["device_id"]], true); + + if ($device["session_id"] !== $_COOKIE["session_id"]) { + return false; + } + + return true; } public function generateSessionID() { diff --git a/mcServ.db b/mcServ.db index 2a1303cd90f38c52da7467a4c51d9b378459d0ff..d58b0eddd2045af1bcb902c5537780a5b31886e4 100644 GIT binary patch delta 61 zcmZo@U~Fh$+`uNlvVehq!Dc~)Y5Y8KjBE^|rj5M0iABki*T_e){9xe!0hD^iKQVxV OgPmEF6C|_9KmY(GZxO=) delta 63 zcmZo@U~Fh$+`uNlGM|Be{$@disrlh?>cv3zIX{|=OU&Ob4L Pjgx~}oD(dy$Up!9Oo0-S