summaryrefslogtreecommitdiff
path: root/modules/backend-rpc.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2011-04-20 18:39:30 +0400
committerAndrew Dolgov <[email protected]>2011-04-20 18:39:30 +0400
commit6f907113ef20b09976b1fddbc698a49dbe283519 (patch)
treec926bb96ffcab108f739e56b43a905824e3c27c3 /modules/backend-rpc.php
parent572d66c6ee10cd86c64416abf2200cd3abec20a1 (diff)
feed browser: allow subscribing by url for linked feeds
Diffstat (limited to 'modules/backend-rpc.php')
-rw-r--r--modules/backend-rpc.php48
1 files changed, 46 insertions, 2 deletions
diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php
index 75ce6886a..4f2465e73 100644
--- a/modules/backend-rpc.php
+++ b/modules/backend-rpc.php
@@ -514,9 +514,53 @@
// Silent
if ($subop == "massSubscribe") {
- $ids = split(",", db_escape_string($_REQUEST["ids"]));
+ $payload = json_decode($_REQUEST["payload"], false);
$mode = $_REQUEST["mode"];
+ if (!$payload || !is_array($payload)) return;
+
+ if ($mode == 1) {
+ foreach ($payload as $feed) {
+
+ $title = db_escape_string($feed[0]);
+ $feed_url = db_escape_string($feed[1]);
+
+ $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE
+ feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
+
+ if (db_num_rows($result) == 0) {
+ $result = db_query($link, "INSERT INTO ttrss_feeds
+ (owner_uid,feed_url,title,cat_id,site_url)
+ VALUES ('".$_SESSION["uid"]."',
+ '$feed_url', '$title', NULL, '')");
+ }
+ }
+ } else if ($mode == 2) {
+ // feed archive
+ foreach ($payload as $id) {
+ $result = db_query($link, "SELECT * FROM ttrss_archived_feeds
+ WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
+
+ if (db_num_rows($result) != 0) {
+ $site_url = db_escape_string(db_fetch_result($result, 0, "site_url"));
+ $feed_url = db_escape_string(db_fetch_result($result, 0, "feed_url"));
+ $title = db_escape_string(db_fetch_result($result, 0, "title"));
+
+ $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE
+ feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
+
+ if (db_num_rows($result) == 0) {
+ $result = db_query($link, "INSERT INTO ttrss_feeds
+ (owner_uid,feed_url,title,cat_id,site_url)
+ VALUES ('$id','".$_SESSION["uid"]."',
+ '$feed_url', '$title', NULL, '$site_url')");
+ }
+ }
+ }
+ }
+
+/* $ids = split(",", db_escape_string($_REQUEST["ids"]));
+
$subscribed = array();
foreach ($ids as $id) {
@@ -551,7 +595,7 @@
}
array_push($subscribed, $title_orig);
}
- }
+ } */
return;
}