Add login
This commit is contained in:
@@ -50,8 +50,14 @@ $device_id = rand(1, 999);
|
|||||||
$json[$device_id] = json_encode($session);
|
$json[$device_id] = json_encode($session);
|
||||||
$json["array"] = true;
|
$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));
|
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: /");
|
header("Location: /");
|
||||||
exit;
|
exit;
|
||||||
?>
|
?>
|
||||||
@@ -14,7 +14,10 @@ body {
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
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-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;
|
display: grid;
|
||||||
place-items: center;
|
place-items: center;
|
||||||
transition: all 0.3s ease-in-out;
|
transition: all 0.3s ease-in-out;
|
||||||
@@ -53,10 +56,15 @@ input {
|
|||||||
height: 30px;
|
height: 30px;
|
||||||
border-radius: 10pt;
|
border-radius: 10pt;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
|
background: rgba(255, 255, 255, 0.3);
|
||||||
|
backdrop-filter: blur(5px);
|
||||||
|
-webkit-backdrop-filter: blur(5px);
|
||||||
}
|
}
|
||||||
|
|
||||||
input:focus {
|
input:focus {
|
||||||
outline: 2px solid #000000;
|
backdrop-filter: blur(10px);
|
||||||
|
-webkit-backdrop-filter: blur(10pxr);
|
||||||
|
outline: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
| | | | | | (__ ____) | __/ | \ V /| |___| (_) | | | | |_| | | (_) | |
|
| | | | | | (__ ____) | __/ | \ V /| |___| (_) | | | | |_| | | (_) | |
|
||||||
|_| |_| |_|\___|_____/ \___|_| \_/ \_____\___/|_| |_|\__|_| \___/|_|
|
|_| |_| |_|\___|_____/ \___|_| \_/ \_____\___/|_| |_|\__|_| \___/|_|
|
||||||
|
|
||||||
* By RootMarc
|
* By marc-go
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require "../main.php";
|
require "../main.php";
|
||||||
@@ -20,5 +20,8 @@ if (!$mcServ->checkConf()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$mcServ->checkLogin()) {
|
if (!$mcServ->checkLogin()) {
|
||||||
|
header("Location: /admin");
|
||||||
|
exit;
|
||||||
|
}else{
|
||||||
|
echo "true";
|
||||||
}
|
}
|
||||||
0
front/login.php
Normal file
0
front/login.php
Normal file
18
main.php
18
main.php
@@ -7,7 +7,7 @@
|
|||||||
| | | | | | (__ ____) | __/ | \ V /| |___| (_) | | | | |_| | | (_) | |
|
| | | | | | (__ ____) | __/ | \ V /| |___| (_) | | | | |_| | | (_) | |
|
||||||
|_| |_| |_|\___|_____/ \___|_| \_/ \_____\___/|_| |_|\__|_| \___/|_|
|
|_| |_| |_|\___|_____/ \___|_| \_/ \_____\___/|_| |_|\__|_| \___/|_|
|
||||||
|
|
||||||
* By RootMarc
|
* By marc-go
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class mcServ {
|
class mcServ {
|
||||||
@@ -24,9 +24,23 @@ class mcServ {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function checkLogin() {
|
public function checkLogin() {
|
||||||
if (!isset($_COOKIE["session_id"]) || !isset($_COOKIE["user_id"])) {
|
if (!isset($_COOKIE["session_id"]) || !isset($_COOKIE["device_id"])) {
|
||||||
return false;
|
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() {
|
public function generateSessionID() {
|
||||||
|
|||||||
Reference in New Issue
Block a user