Files
panel/main.php
2026-02-14 21:30:57 +01:00

61 lines
1.7 KiB
PHP
Executable File

<?php
/*
_____ _____ _ _
/ ____| / ____| | | | |
_ __ ___ ___| (___ ___ _ ____ _| | ___ _ __ | |_ _ __ ___ | |
| '_ ` _ \ / __|\___ \ / _ \ '__\ \ / / | / _ \| '_ \| __| '__/ _ \| |
| | | | | | (__ ____) | __/ | \ V /| |___| (_) | | | | |_| | | (_) | |
|_| |_| |_|\___|_____/ \___|_| \_/ \_____\___/|_| |_|\__|_| \___/|_|
* By marc-go
*/
ini_set("display_errors", 1);
ini_set("display_startup_errors", 1);
error_reporting(E_ALL);
class mcServ {
public function checkConf() {
if (!file_exists("../mcServ.db")) {
return false;
}
return true;
}
public function getConf() {
$env = parse_ini_file(__DIR__ . "/.env");
return $env;
}
public function checkLogin() {
if (!isset($_COOKIE["session_id"]) || !isset($_COOKIE["device_id"])) {
echo "Keine Cookies gesetzt";
return false;
}
$config = $this->getConf();
$json = json_decode(file_get_contents($config["PATH"] . "/tmp/user_sessions/" . $_COOKIE["username"] . ".json"), true);
if (!isset($json[$_COOKIE["device_id"]])) {
echo "Device ID gibt es nicht im JSON";
return false;
}
$device = json_decode($json[$_COOKIE["device_id"]], true);
if ($device["session_id"] !== $_COOKIE["session_id"]) {
echo "Session IDs stimmen nicht überein";
return false;
}
return true;
}
public function generateSessionID() {
$num = rand(1, 999999);
$hash = hash("sha256", $num);
return $hash;
}
}