diff options
Diffstat (limited to 'api')
-rw-r--r-- | api/computer.php | 42 | ||||
-rw-r--r-- | api/docs.php | 6 | ||||
-rw-r--r-- | api/save.php | 2 | ||||
-rw-r--r-- | api/test1.php | 8 | ||||
-rw-r--r-- | api/video.php | 7 |
5 files changed, 54 insertions, 11 deletions
diff --git a/api/computer.php b/api/computer.php new file mode 100644 index 0000000..a4ead80 --- /dev/null +++ b/api/computer.php @@ -0,0 +1,42 @@ +<?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 "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("OK");
\ No newline at end of file diff --git a/api/docs.php b/api/docs.php index 1c9429b..89e9216 100644 --- a/api/docs.php +++ b/api/docs.php @@ -13,12 +13,10 @@ if (isset($select)) { $id = $select; $data = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/docs/" . $select . ".json"), true); } else { - header("Location: /-/docs"); - die(); + die("Not found"); } } else { - header("Location: /-/docs"); - die(); + die("Not set"); } if ($json_object["content"]) $data["contents"] = $json_object["content"]; diff --git a/api/save.php b/api/save.php index ed6cc17..52cdebe 100644 --- a/api/save.php +++ b/api/save.php @@ -29,7 +29,7 @@ if ($member !== null && $member !== "null") { if ($subsystem !== null && $subsystem !== "null") { $file = $_SERVER['DOCUMENT_ROOT'] . "/includes/data/subsystems/" . $system . "-" . $subsystem . ".html"; } else { - $file = $_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $system . ".html"; + $file = $_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $system . "/content.html"; } } diff --git a/api/test1.php b/api/test1.php new file mode 100644 index 0000000..6d25f85 --- /dev/null +++ b/api/test1.php @@ -0,0 +1,8 @@ +<?php + +$img = imagecreate(2048, 1024); +$color = imagecolorallocate($img, 255, 0, 0); + +header("Content-type: image/jpeg"); +imagejpeg($img); +imagedestroy($img);
\ No newline at end of file diff --git a/api/video.php b/api/video.php index 00c8214..21af642 100644 --- a/api/video.php +++ b/api/video.php @@ -25,15 +25,10 @@ if (isset($_GET['id'])) { echo(json_encode([ "title" => $data["fulltitle"], "author" => $data["channel"], - "count" => [ - "channel" => $data["channel_follower_count"], - "likes" => $data["like_count"], - "views" => $data["view_count"] - ], "duration" => $data["duration"], "stream" => $selected, "url" => $stream["url"], - "duration_pretty" => $stream["duration_string"], + "duration_pretty" => $data["duration_string"], "poster" => $data["thumbnail"], ], JSON_PRETTY_PRINT)); }
\ No newline at end of file |