blob: d3ec15a91f523ca02a7804d84f92f8d1f332845f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.inc"; global $isLoggedIn; global $_PROFILE;
if (!$isLoggedIn) header("Location: /-/login") and die();
$request_raw = file_get_contents('php://input');
$json_object = json_decode($request_raw, true);
$host = md5($json_object['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");
file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/metadata/" . $_PROFILE['login'] . "-" . $host . ".json", json_encode($json_object));
break;
}
die($_PROFILE['login'] . "-" . $host);
|