summaryrefslogtreecommitdiff
path: root/pages/api/computer.php
diff options
context:
space:
mode:
Diffstat (limited to 'pages/api/computer.php')
-rw-r--r--pages/api/computer.php68
1 files changed, 0 insertions, 68 deletions
diff --git a/pages/api/computer.php b/pages/api/computer.php
deleted file mode 100644
index 2c75183..0000000
--- a/pages/api/computer.php
+++ /dev/null
@@ -1,68 +0,0 @@
-<?php
-
-if (time() >= 1688169600) die();
-
-if (isset($_GET["chrome"])) {
- header("Access-Control-Allow-Origin: chrome-extension://" . preg_replace("/[^a-z]/m", "", $_GET["chrome"]));
- header("Access-Control-Allow-Credentials: true");
-}
-
-require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $_PROFILE;
-
-if (!$isLoggedIn || !isset($_PROFILE) || !isset($_PROFILE["login"])) {
- header("Location: /-/login");
- die();
-}
-
-$request_raw = file_get_contents('php://input');
-$json_object = json_decode($request_raw, true);
-
-$host = md5($json_object['host'] ?? $_GET["host"]);
-
-switch ($_GET['type']) {
- case "heartbeat":
- if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/metadata/" . $_PROFILE['login'] . "-" . $host . ".json")) {
- $data = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/metadata/" . $_PROFILE['login'] . "-" . $host . ".json"), true);
- $data["date"] = date('c');
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/metadata/" . $_PROFILE['login'] . "-" . $host . ".json", json_encode($data));
- }
- break;
-
- case "screenshot":
- $id = $json_object['id'];
- $data = base64_decode($json_object['data']);
-
- if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/screens")) mkdir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/screens");
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/screens/" . $_PROFILE['login'] . "-" . $host . "-" . $id . ".jpg", $data);
- break;
-
- case "window":
- $id = sha1($json_object['id']);
- $data = base64_decode($json_object['data']);
-
- if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/windows")) mkdir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/windows");
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/windows/" . $_PROFILE['login'] . "-" . $host . "-" . $id . ".jpg", $data);
-
- if (isset($json_object['icon'])) {
- $data2 = base64_decode($json_object['icon']);
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/windows/" . $_PROFILE['login'] . "-" . $host . "-" . $id . ".png", $data2);
- } else {
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/windows/" . $_PROFILE['login'] . "-" . $host . "-" . $id . ".png", "");
- }
-
- break;
-
- case "data":
- if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/metadata")) mkdir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/metadata");
- if (isset($json_object["_session"])) unset($json_object["_session"]);
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/metadata/" . $_PROFILE['login'] . "-" . $host . ".json", json_encode($json_object));
- break;
-}
-
-if (isset($_GET["json"])) {
- die(json_encode([
- "id" => $_PROFILE['login'] . "-" . $host
- ]));
-} else {
- die($_PROFILE['login'] . "-" . $host);
-} \ No newline at end of file