summaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
authorRaindropsSys <raindrops@equestria.dev>2023-10-31 17:04:34 +0100
committerRaindropsSys <raindrops@equestria.dev>2023-10-31 17:04:34 +0100
commite61e581a2b66b0444db01d884465ea913929e343 (patch)
treeb49eaedb3681c4b26637acdd375cda4c3d37b07c /api
parent41c51b8bdb9c8e9fa4a7d56f260d594739d4107e (diff)
downloadmist-e61e581a2b66b0444db01d884465ea913929e343.tar.gz
mist-e61e581a2b66b0444db01d884465ea913929e343.tar.bz2
mist-e61e581a2b66b0444db01d884465ea913929e343.zip
Updated 27 files, added 12 files and deleted 3 files (automated)
Diffstat (limited to 'api')
-rw-r--r--api/addHistory.php5
-rw-r--r--api/savePrivacy.php13
-rw-r--r--api/saveProfile.php40
3 files changed, 57 insertions, 1 deletions
diff --git a/api/addHistory.php b/api/addHistory.php
index 117fc06..e5dea25 100644
--- a/api/addHistory.php
+++ b/api/addHistory.php
@@ -5,6 +5,9 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php";
global $songs; global $_PROFILE; global $history;
if (!isset($_GET["i"]) || !isset($songs[$_GET["i"]])) return;
-$history[] = $_GET["i"];
+$history[] = [
+ "item" => $_GET["i"],
+ "date" => date('c')
+];
file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/users/" . $_PROFILE["id"] . "-history.json", json_encode($history)); \ No newline at end of file
diff --git a/api/savePrivacy.php b/api/savePrivacy.php
new file mode 100644
index 0000000..b18f0f2
--- /dev/null
+++ b/api/savePrivacy.php
@@ -0,0 +1,13 @@
+<?php
+
+header("X-Frame-Options: SAMEORIGIN");
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php";
+global $songs; global $_PROFILE; global $favorites; global $privacy;
+
+foreach ($privacy as $item => $_) {
+ if (isset($_GET[$item]) && ($_GET[$item] === "0" || $_GET[$item] === "1" || $_GET[$item] === "2")) {
+ $privacy[$item] = (int)$_GET[$item];
+ }
+}
+
+file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/users/" . $_PROFILE["id"] . "-privacy.json", json_encode($privacy)); \ No newline at end of file
diff --git a/api/saveProfile.php b/api/saveProfile.php
new file mode 100644
index 0000000..eee3e9c
--- /dev/null
+++ b/api/saveProfile.php
@@ -0,0 +1,40 @@
+<?php
+
+header("X-Frame-Options: SAMEORIGIN");
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $profile; global $_PROFILE;
+
+if (isset($_POST["nsfw"])) {
+ if ($_POST["nsfw"] === "false") {
+ $profile["nsfw"] = false;
+ } else {
+ $profile["nsfw"] = true;
+ }
+}
+
+if (isset($_POST["description"])) {
+ $profile["description"] = substr(strip_tags($_POST["description"]), 0, 500);
+}
+
+if (isset($_POST["url"])) {
+ $derpibooruID = preg_replace("/^http(s|):\/\/(www\.|)derpibooru\.org\/images\/(\d+).*$/m", "$3", $_POST["url"]);
+
+ if ($derpibooruID === $_POST["url"]) {
+ $profile["banner"] = $profile["banner_orig"] = substr(strip_tags($_POST["url"]), 0, 120);
+ } else {
+ $data = json_decode(file_get_contents("https://derpibooru.org/api/v1/json/images/" . $derpibooruID, false, stream_context_create([
+ "http" => [
+ "method" => "GET",
+ "header" => "User-Agent: Mozilla/5.0 (+MistProfile/1.0; raindrops@equestria.dev)\r\n"
+ ]
+ ])), true);
+
+ if (isset($data) && json_last_error() === JSON_ERROR_NONE && isset($data["image"]) && isset($data["image"]["view_url"])) {
+ $profile["banner"] = $data["image"]["view_url"];
+ $profile["banner_orig"] = substr(strip_tags($_POST["url"]), 0, 120);
+ } else {
+ $profile["banner"] = $profile["banner_orig"] = substr(strip_tags($_POST["url"]), 0, 120);
+ }
+ }
+}
+
+file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/users/" . $_PROFILE["id"] . "-profileSettings.json", json_encode($profile)); \ No newline at end of file