Updated 21 files and added 8 files (automated)
parent
dc1de74470
commit
7da58b75da
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="48" width="48"><path d="m12.6 36.7-1.25-1.3L22.75 24l-11.4-11.45 1.25-1.3L24.05 22.7 35.4 11.25l1.25 1.3L25.3 24l11.35 11.4-1.25 1.3-11.35-11.45Z" fill="#000000"/></svg>
|
After Width: | Height: | Size: 217 B |
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="48" width="48"><path d="M6.85 34.65V32.9H41.2v1.75Zm0-9.8V23.1H41.2v1.75Zm0-9.75v-1.75H41.2v1.75Z" fill="#000000"/></svg>
|
After Width: | Height: | Size: 169 B |
Binary file not shown.
Binary file not shown.
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
header("Content-Type: application/json");
|
||||
$requests = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/../kiosk.json"), true);
|
||||
|
||||
$data = [
|
||||
"success" => false
|
||||
];
|
||||
|
||||
function encode($string) {
|
||||
return preg_replace("/[^a-zA-Z0-9.]/m", "", base64_encode($string));
|
||||
}
|
||||
|
||||
if (isset($_GET["id"]) && isset($_GET["key"]) && in_array($_GET["id"], array_map(function ($i) { return $i["id"]; }, $requests))) {
|
||||
foreach ($requests as $index => $request) {
|
||||
if ($request["id"] === $_GET["id"] && $request["key"] === $_GET["key"] && time() - strtotime($request["date"]) < 60) {
|
||||
$data["success"] = true;
|
||||
|
||||
$token = encode(openssl_random_pseudo_bytes(128));
|
||||
file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/../tokens/" . $token, json_encode([
|
||||
"user" => $request["user"],
|
||||
"date" => date('c')
|
||||
]));
|
||||
|
||||
$requests[$index]["token"] = $token;
|
||||
file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/../kiosk.json", json_encode($requests, JSON_PRETTY_PRINT));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
die(json_encode($data, JSON_PRETTY_PRINT));
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
header("Content-Type: application/json");
|
||||
$requests = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/../kiosk.json"), true);
|
||||
|
||||
$data = [
|
||||
"token" => null
|
||||
];
|
||||
|
||||
if (isset($_GET["id"]) && in_array($_GET["id"], array_map(function ($i) { return $i["id"]; }, $requests))) {
|
||||
foreach ($requests as $index => $request) {
|
||||
if ($request["id"] === $_GET["id"] && isset($request["token"]) && time() - strtotime($request["date"]) < 90) {
|
||||
$data["token"] = $request["token"];
|
||||
unset($requests[$index]["token"]);
|
||||
file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/../kiosk.json", json_encode($requests, JSON_PRETTY_PRINT));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
die(json_encode($data, JSON_PRETTY_PRINT));
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
header("Content-Type: application/json");
|
||||
|
||||
$users = array_map(function ($i) { return substr($i, 0, -5); }, array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/../data/profiles"), function ($i) { return !str_starts_with($i, "."); }));
|
||||
|
||||
$users = array_filter($users, function ($id) {
|
||||
$data = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/../data/profiles/" . $id . ".json"), true);
|
||||
return $data["kiosk"] && $data["blocked"] < 3;
|
||||
});
|
||||
|
||||
$data = [];
|
||||
|
||||
foreach ($users as $user) {
|
||||
$userData = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/../data/profiles/" . $user . ".json"), true);
|
||||
|
||||
$data[] = [
|
||||
"id" => $user,
|
||||
"name" => strtoupper($userData["last_name"]) . " " . ucwords($userData["first_name"])
|
||||
];
|
||||
}
|
||||
|
||||
die(json_encode($data, JSON_PRETTY_PRINT));
|
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
header("Content-Type: application/json");
|
||||
|
||||
$config = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/../email.json"), true);
|
||||
$users = array_map(function ($i) { return substr($i, 0, -5); }, array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/../data/profiles"), function ($i) { return !str_starts_with($i, "."); }));
|
||||
|
||||
$users = array_filter($users, function ($id) {
|
||||
$data = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/../data/profiles/" . $id . ".json"), true);
|
||||
return $data["kiosk"];
|
||||
});
|
||||
|
||||
function uuid() {
|
||||
$data = openssl_random_pseudo_bytes(16);
|
||||
assert(strlen($data) == 16);
|
||||
|
||||
$data[6] = chr(ord($data[6]) & 0x0f | 0x40);
|
||||
$data[8] = chr(ord($data[8]) & 0x3f | 0x80);
|
||||
|
||||
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
|
||||
}
|
||||
|
||||
function token() {
|
||||
$data = openssl_random_pseudo_bytes(64);
|
||||
return bin2hex($data);
|
||||
}
|
||||
|
||||
$data = [
|
||||
"id" => uuid(),
|
||||
"ok" => false
|
||||
];
|
||||
|
||||
$key = token();
|
||||
|
||||
if (isset($_GET["id"]) && in_array($_GET["id"], $users)) {
|
||||
$userData = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/../data/profiles/" . $_GET["id"] . ".json"), true);
|
||||
|
||||
$requests = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/../kiosk.json"), true);
|
||||
$requests[] = [
|
||||
"id" => $data["id"],
|
||||
"user" => $_GET["id"],
|
||||
"key" => $key,
|
||||
"date" => date('c')
|
||||
];
|
||||
file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/../kiosk.json", json_encode($requests, JSON_PRETTY_PRINT));
|
||||
|
||||
file_get_contents('https://notifications.equestria.dev/delta', false, stream_context_create([
|
||||
'http' => [
|
||||
'method' => 'POST',
|
||||
'header' =>
|
||||
"Content-Type: text/plain\r\n" .
|
||||
"Title: Approve log in request?\r\n" .
|
||||
"Priority: default\r\n" .
|
||||
"Tags: delta\r\n" .
|
||||
"Actions: http, Approve, http://192.168.1.121:8081/dev.equestria.delta.kiosk.ApproveLogin/?id=" . $data["id"] . "&key=" . $key . ", clear=true\r\n" .
|
||||
"Authorization: Basic " . base64_encode($config["ntfyuser"] . ":" . $config["ntfypass"]),
|
||||
'content' => $userData["first_name"] . " " . $userData["last_name"] . " (" . $_GET["id"] . ") is trying to log in to Delta from a kiosk, do you want to approve it?"
|
||||
]
|
||||
]));
|
||||
|
||||
$data["ok"] = true;
|
||||
}
|
||||
|
||||
die(json_encode($data, JSON_PRETTY_PRINT));
|
@ -1 +1,4 @@
|
||||
kiosk
|
||||
<?php
|
||||
|
||||
header("HTTP/1.1 400 Bad Request");
|
||||
die();
|
@ -1,5 +1,7 @@
|
||||
{
|
||||
"title": "[insert here]",
|
||||
"title": {
|
||||
"en": "[insert here]"
|
||||
},
|
||||
"contents": null,
|
||||
"update": null,
|
||||
"update_user": null
|
||||
|
Loading…
Reference in New Issue