// Silent
if ($subop == "remprofiles") {
- $ids = split(",", db_escape_string(trim($_REQUEST["ids"])));
+ $ids = explode(",", db_escape_string(trim($_REQUEST["ids"])));
foreach ($ids as $id) {
if ($_SESSION["profile"] != $id) {
// Silent
if ($subop == "remarchive") {
- $ids = split(",", db_escape_string($_REQUEST["ids"]));
+ $ids = explode(",", db_escape_string($_REQUEST["ids"]));
foreach ($ids as $id) {
$result = db_query($link, "DELETE FROM ttrss_archived_feeds WHERE
}
if ($subop == "archive") {
- $ids = split(",", db_escape_string($_REQUEST["ids"]));
+ $ids = explode(",", db_escape_string($_REQUEST["ids"]));
foreach ($ids as $id) {
archive_article($link, $id, $_SESSION["uid"]);
if (PUBSUBHUBBUB_HUB) {
$rss_link = get_self_url_prefix() .
- "/backend.php?op=rss&id=-2&key=" .
+ "/public.php?op=rss&id=-2&key=" .
get_feed_access_key($link, -2, false);
$p = new Publisher(PUBSUBHUBBUB_HUB);
/* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */
if ($subop == "catchupSelected") {
- $ids = split(",", db_escape_string($_REQUEST["ids"]));
+ $ids = explode(",", db_escape_string($_REQUEST["ids"]));
$cmode = sprintf("%d", $_REQUEST["cmode"]);
catchupArticlesById($link, $ids, $cmode);
}
if ($subop == "markSelected") {
- $ids = split(",", db_escape_string($_REQUEST["ids"]));
+ $ids = explode(",", db_escape_string($_REQUEST["ids"]));
$cmode = sprintf("%d", $_REQUEST["cmode"]);
markArticlesById($link, $ids, $cmode);
}
if ($subop == "publishSelected") {
- $ids = split(",", db_escape_string($_REQUEST["ids"]));
+ $ids = explode(",", db_escape_string($_REQUEST["ids"]));
$cmode = sprintf("%d", $_REQUEST["cmode"]);
publishArticlesById($link, $ids, $cmode);
$id = db_escape_string($_REQUEST["id"]);
$tags_str = db_escape_string($_REQUEST["tags_str"]);
- $tags = array_unique(trim_array(split(",", $tags_str)));
+ $tags = array_unique(trim_array(explode(",", $tags_str)));
db_query($link, "BEGIN");
/* update tag cache */
- $tags_str = asort(join(",", $tags_to_cache));
+ sort($tags_to_cache);
+ $tags_str = join(",", $tags_to_cache);
db_query($link, "UPDATE ttrss_user_entries
SET tag_cache = '$tags_str' WHERE ref_id = '$id'
}
if ($subop == "purge") {
- $ids = split(",", db_escape_string($_REQUEST["ids"]));
+ $ids = explode(",", db_escape_string($_REQUEST["ids"]));
$days = sprintf("%d", $_REQUEST["days"]);
foreach ($ids as $id) {
} */
if ($subop == "getArticles") {
- $ids = split(",", db_escape_string($_REQUEST["ids"]));
+ $ids = explode(",", db_escape_string($_REQUEST["ids"]));
$articles = array();
foreach ($ids as $id) {
if ($subop == "assignToLabel" || $subop == "removeFromLabel") {
$reply = array();
- $ids = split(",", db_escape_string($_REQUEST["ids"]));
+ $ids = explode(",", db_escape_string($_REQUEST["ids"]));
$label_id = db_escape_string($_REQUEST["lid"]);
$label = db_escape_string(label_find_caption($link, $label_id,
// 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 = explode(",", db_escape_string($_REQUEST["ids"]));
+
$subscribed = array();
foreach ($ids as $id) {
}
array_push($subscribed, $title_orig);
}
- }
+ } */
return;
}
if ($subop == "digest-get-contents") {
$article_id = db_escape_string($_REQUEST['article_id']);
- $result = db_query($link, "SELECT content
+ $result = db_query($link, "SELECT content,title,link,marked,published
FROM ttrss_entries, ttrss_user_entries
WHERE id = '$article_id' AND ref_id = id AND owner_uid = ".$_SESSION['uid']);
$content = sanitize_rss($link, db_fetch_result($result, 0, "content"));
+ $title = strip_tags(db_fetch_result($result, 0, "title"));
+ $article_url = htmlspecialchars(db_fetch_result($result, 0, "link"));
+ $marked = sql_bool_to_bool(db_fetch_result($result, 0, "marked"));
+ $published = sql_bool_to_bool(db_fetch_result($result, 0, "published"));
+
print json_encode(array("article" =>
- array("id" => $id, "content" => $content)));
+ array("id" => $article_id, "url" => $article_url,
+ "tags" => get_article_tags($link, $article_id),
+ "marked" => $marked, "published" => $published,
+ "title" => $title, "content" => $content)));
return;
}
$reply['seq'] = $seq;
- $headlines = api_get_headlines($link, $feed_id, 10, $offset,
- '', ($feed_id == -4), true, false, "unread", "updated DESC");
+ $headlines = api_get_headlines($link, $feed_id, 30, $offset,
+ '', ($feed_id == -4), true, false, "unread", "updated DESC", 0, 0);
//function api_get_headlines($link, $feed_id, $limit, $offset,
// $filter, $is_cat, $show_excerpt, $show_content, $view_mode) {
}
if ($subop == "digest-init") {
- $tmp_feeds = api_get_feeds($link, -3, true, false, 0);
+ $tmp_feeds = api_get_feeds($link, -4, true, false, 0);
$feeds = array();
if ($subop == "catchupFeed") {
$feed_id = db_escape_string($_REQUEST['feed_id']);
- $is_cat = db_escape_string($_REQUEST['is_cat']);
+ $is_cat = db_escape_string($_REQUEST['is_cat']) == "true";
catchup_feed($link, $feed_id, $is_cat);
+ print json_encode(array("message" => "UPDATE_COUNTERS"));
return;
}
if ($subop == "regenFeedKey") {
$feed_id = db_escape_string($_REQUEST['id']);
- $is_cat = (bool) db_escape_string($_REQUEST['is_cat']);
+ $is_cat = db_escape_string($_REQUEST['is_cat']) == "true";
$new_key = update_feed_access_key($link, $feed_id, $is_cat);
return;
}
+ // Silent
+ if ($subop == "clearArticleKeys") {
+ db_query($link, "UPDATE ttrss_user_entries SET uuid = '' WHERE
+ owner_uid = " . $_SESSION["uid"]);
+
+ return;
+ }
+
+
if ($subop == "verifyRegexp") {
$reg_exp = $_REQUEST["reg_exp"];
// TODO: unify with digest-get-contents?
if ($subop == "cdmGetArticle") {
- $id = db_escape_string($_REQUEST["id"]);
+ $ids = array(db_escape_string($_REQUEST["id"]));
+ $cids = explode(",", $_REQUEST["cids"]);
- $result = db_query($link, "SELECT content,
- ttrss_feeds.site_url AS site_url FROM ttrss_user_entries, ttrss_feeds,
- ttrss_entries
- WHERE feed_id = ttrss_feeds.id AND ref_id = '$id' AND
- ttrss_entries.id = ref_id AND
- ttrss_user_entries.owner_uid = ".$_SESSION["uid"]);
+ $ids = array_merge($ids, $cids);
- if (db_num_rows($result) != 0) {
- $line = db_fetch_assoc($result);
+ $rv = array();
- $article_content = sanitize_rss($link, $line["content"],
- false, false, $line['site_url']);
+ foreach ($ids as $id) {
+ $id = (int)$id;
- } else {
- $article_content = '';
+ $result = db_query($link, "SELECT content,
+ ttrss_feeds.site_url AS site_url FROM ttrss_user_entries, ttrss_feeds,
+ ttrss_entries
+ WHERE feed_id = ttrss_feeds.id AND ref_id = '$id' AND
+ ttrss_entries.id = ref_id AND
+ ttrss_user_entries.owner_uid = ".$_SESSION["uid"]);
+
+ if (db_num_rows($result) != 0) {
+ $line = db_fetch_assoc($result);
+
+ $article_content = sanitize_rss($link, $line["content"],
+ false, false, $line['site_url']);
+
+ array_push($rv,
+ array("id" => $id, "content" => $article_content));
+ }
}
- print json_encode(array("article" =>
- array("id" => $id, "content" => $article_content)));
+ print json_encode($rv);
return;
}