summaryrefslogtreecommitdiff
path: root/api/removeFavorite.php
diff options
context:
space:
mode:
Diffstat (limited to 'api/removeFavorite.php')
-rw-r--r--api/removeFavorite.php14
1 files changed, 14 insertions, 0 deletions
diff --git a/api/removeFavorite.php b/api/removeFavorite.php
new file mode 100644
index 0000000..86f41c7
--- /dev/null
+++ b/api/removeFavorite.php
@@ -0,0 +1,14 @@
+<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php";
+global $songs; global $_PROFILE; global $favorites;
+
+if (!isset($_GET["i"])) return;
+
+if (in_array($_GET["i"], $favorites)) {
+ $favorites = array_filter($favorites, function ($i) {
+ return $i !== $_GET["i"];
+ });
+}
+
+file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/users/" . $_PROFILE["id"] . "-favorites.json", json_encode($favorites)); \ No newline at end of file