Files
panel/main.php
2026-02-14 19:06:07 +01:00

52 lines
1.4 KiB
PHP

<?php
/*
_____ _____ _ _
/ ____| / ____| | | | |
_ __ ___ ___| (___ ___ _ ____ _| | ___ _ __ | |_ _ __ ___ | |
| '_ ` _ \ / __|\___ \ / _ \ '__\ \ / / | / _ \| '_ \| __| '__/ _ \| |
| | | | | | (__ ____) | __/ | \ V /| |___| (_) | | | | |_| | | (_) | |
|_| |_| |_|\___|_____/ \___|_| \_/ \_____\___/|_| |_|\__|_| \___/|_|
* By marc-go
*/
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"])) {
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() {
$num = rand(1, 999999);
$hash = hash("sha256", $num);
return $hash;
}
}