summaryrefslogtreecommitdiff
path: root/backend.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2017-07-21 14:39:14 +0300
committerAndrew Dolgov <[email protected]>2017-07-21 14:39:14 +0300
commit55f2b0090a9f711cfa383b0d3b3253c9431b93e9 (patch)
treed87f1cbccbc066d264922518e631189227397693 /backend.php
parentee4c7c44adabd057014b3c62cf16c6c4947ecc1a (diff)
add basic favorites via a horrible hack
Diffstat (limited to 'backend.php')
-rw-r--r--backend.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/backend.php b/backend.php
index 7cd15bb..0ca006b 100644
--- a/backend.php
+++ b/backend.php
@@ -76,6 +76,29 @@
break;
+ case "togglefav":
+ $id = (int) $_REQUEST["id"];
+
+ $result = $ldb->query("SELECT id FROM epube_favorites WHERE bookid = '$id'
+ AND owner = '$owner' LIMIT 1");
+
+ $found_id = false;
+ $status = -1;
+
+ while ($line = $result->fetchArray(SQLITE3_ASSOC)) {
+ $found_id = $line["id"];
+ }
+
+ if ($found_id) {
+ $ldb->query("DELETE FROM epube_favorites WHERE id = " . $found_id);
+ $status = 0;
+ } else {
+ $ldb->query("INSERT INTO epube_favorites (bookid, owner) VALUES ($id, '$owner')");
+ $status = 1;
+ }
+
+ print json_encode(["id" => $id, "status" => $status]);
+
case "download":
$id = (int) $_REQUEST["id"];