diff --git a/.env b/.env new file mode 100644 index 0000000..6b89daa --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +PATH=/var/www/panel +DB_PATH=/var/www/panel/mcServ.db \ No newline at end of file diff --git a/api/setup/setup.php b/api/setup/setup.php index 58a7765..a17553f 100644 --- a/api/setup/setup.php +++ b/api/setup/setup.php @@ -1,8 +1,14 @@ getConf(); + +$db = new PDO("sqlite:" . $config["DB_PATH"]); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql = " CREATE TABLE IF NOT EXISTS users ( - id INT(11) PRIMARY KEY AUTOINCREMENT, - username VARCHAR(30) PRIMARY KEY, + id INTEGER PRIMARY KEY AUTOINCREMENT, + username VARCHAR(30) UNIQUE NOT NULL, mail VARCHAR(50), passwd VARCHAR(100) ) -"; \ No newline at end of file +"; + +$db->exec($sql); + +$sql = " +INSERT INTO users (username, mail, passwd) VALUES (:user, :mail, :passwd) +"; + +$stmt = $db->prepare($sql); +$stmt->execute([':user' => $admin_user, ':mail' => $admin_mail, ':passwd' => $admin_passwd]); + +$session["session_id"] = $mcServ->generateSessionID(); +$device_id = rand(1, 999); + +$json[$device_id] = json_encode($session); +$json["array"] = true; + +file_put_contents($config["PATH"] . "/tmp/user_sessions/" . $admin_user . ".json", json_encode($json)); + +header("Location: /"); +exit; +?> \ No newline at end of file diff --git a/front/css/setup.css b/front/css/setup.css index a74f0b1..e219046 100644 --- a/front/css/setup.css +++ b/front/css/setup.css @@ -4,7 +4,7 @@ body { place-items: center; height: 100vh; overflow: hidden; - background-color: #fafafa; + background-image: url("/css/setup.png"); } .page-content { @@ -69,6 +69,7 @@ button { place-items: center; text-align: center; border: none; + border-radius: 20pt; transition: all 0.3s ease-in-out; } diff --git a/front/css/setup.png b/front/css/setup.png new file mode 100644 index 0000000..4926171 Binary files /dev/null and b/front/css/setup.png differ diff --git a/front/index.php b/front/index.php index bb99f22..9255bf0 100644 --- a/front/index.php +++ b/front/index.php @@ -10,11 +10,15 @@ * By RootMarc */ -require "main.php"; +require "../main.php"; $mcServ = new mcServ(); if (!$mcServ->checkConf()) { header("Location: /setup.html"); exit; +} + +if (!$mcServ->checkLogin()) { + } \ No newline at end of file diff --git a/front/main.php b/front/main.php deleted file mode 100644 index 64208b8..0000000 --- a/front/main.php +++ /dev/null @@ -1,14 +0,0 @@ - -