$subop = $_REQUEST["subop"];
$seq = (int) $_REQUEST["seq"];
+ // Silent
if ($subop == "setprofile") {
$id = db_escape_string($_REQUEST["id"]);
return;
}
+ // 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) {
return;
}
+ // Silent
if ($subop == "addprofile") {
$title = db_escape_string(trim($_REQUEST["title"]));
if ($title) {
db_query($link, "INSERT INTO ttrss_settings_profiles (title, owner_uid)
VALUES ('$title', ".$_SESSION["uid"] .")");
-
+
$result = db_query($link, "SELECT id FROM ttrss_settings_profiles WHERE
title = '$title'");
-
+
if (db_num_rows($result) != 0) {
$profile_id = db_fetch_result($result, 0, "id");
-
+
if ($profile_id) {
- initialize_user_prefs($link, $_SESSION["uid"], $profile_id);
+ initialize_user_prefs($link, $_SESSION["uid"], $profile_id);
}
}
}
return;
}
+ // Silent
if ($subop == "saveprofile") {
$id = db_escape_string($_REQUEST["id"]);
$title = db_escape_string(trim($_REQUEST["value"]));
}
db_query($link, "COMMIT");
- }
+ }
return;
}
+ // 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
- (SELECT COUNT(*) FROM ttrss_user_entries
+ (SELECT COUNT(*) FROM ttrss_user_entries
WHERE orig_feed_id = '$id') = 0 AND
id = '$id' AND owner_uid = ".$_SESSION["uid"]);
$rc = db_affected_rows($link, $result);
}
-
return;
}
if ($subop == "addfeed") {
- header("Content-Type: text/plain");
-
$feed = db_escape_string($_REQUEST['feed']);
$cat = db_escape_string($_REQUEST['cat']);
$login = db_escape_string($_REQUEST['login']);
}
if ($subop == "extractfeedurls") {
- header("Content-Type: text/plain");
$urls = get_feeds_from_html($_REQUEST['url']);
}
if ($subop == "togglepref") {
- header("Content-Type: text/plain");
-
$key = db_escape_string($_REQUEST["key"]);
set_pref($link, $key, !get_pref($link, $key));
$value = get_pref($link, $key);
}
if ($subop == "setpref") {
- header("Content-Type: text/plain");
+ $value = str_replace("\n", "<br/>", $_REQUEST['value']);
$key = db_escape_string($_REQUEST["key"]);
- $value = db_escape_string($_REQUEST["value"]);
+ $value = db_escape_string($value);
set_pref($link, $key, $value);
}
if ($subop == "mark") {
- header("Content-Type: text/plain");
-
$mark = $_REQUEST["mark"];
$id = db_escape_string($_REQUEST["id"]);
$mark = "false";
}
- // FIXME this needs collision testing
-
$result = db_query($link, "UPDATE ttrss_user_entries SET marked = $mark
WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
}
if ($subop == "delete") {
- header("Content-Type: text/plain");
-
$ids = db_escape_string($_REQUEST["ids"]);
- $result = db_query($link, "DELETE FROM ttrss_user_entries
+ $result = db_query($link, "DELETE FROM ttrss_user_entries
WHERE ref_id IN ($ids) AND owner_uid = " . $_SESSION["uid"]);
print json_encode(array("message" => "UPDATE_COUNTERS"));
}
if ($subop == "unarchive") {
- header("Content-Type: text/plain");
-
$ids = db_escape_string($_REQUEST["ids"]);
- $result = db_query($link, "UPDATE ttrss_user_entries
+ $result = db_query($link, "UPDATE ttrss_user_entries
SET feed_id = orig_feed_id, orig_feed_id = NULL
WHERE ref_id IN ($ids) AND owner_uid = " . $_SESSION["uid"]);
}
if ($subop == "archive") {
- header("Content-Type: text/plain");
-
- $ids = split(",", db_escape_string($_REQUEST["ids"]));
+ $ids = explode(",", db_escape_string($_REQUEST["ids"]));
foreach ($ids as $id) {
archive_article($link, $id, $_SESSION["uid"]);
return;
}
- // XML method
if ($subop == "publ") {
$pub = $_REQUEST["pub"];
$id = db_escape_string($_REQUEST["id"]);
$pub = "false";
}
- if ($note != 'undefined') {
- $note_qpart = "note = '$note',";
- }
-
- // FIXME this needs collision testing
-
- $result = db_query($link, "UPDATE ttrss_user_entries SET
- $note_qpart
+ $result = db_query($link, "UPDATE ttrss_user_entries SET
published = $pub
WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
+ $pubsub_result = false;
- print "<rpc-reply>";
-
- if ($note != 'undefined') {
- $note_size = strlen($note);
- print "<note id=\"$id\" size=\"$note_size\">";
- print "<![CDATA[" . format_article_note($id, $note) . "]]>";
- print "</note>";
- }
+ if (PUBSUBHUBBUB_HUB) {
+ $rss_link = get_self_url_prefix() .
+ "/public.php?op=rss&id=-2&key=" .
+ get_feed_access_key($link, -2, false);
- print "<message>UPDATE_COUNTERS</message>";
+ $p = new Publisher(PUBSUBHUBBUB_HUB);
- print "</rpc-reply>";
+ $pubsub_result = $p->publish_update($rss_link);
+ }
+ print json_encode(array("message" => "UPDATE_COUNTERS",
+ "pubsub_result" => $pubsub_result));
return;
}
-/* if ($subop == "updateFeed") {
+ // Silent
+ /* if ($subop == "update") {
$feed_id = db_escape_string($_REQUEST["feed"]);
-
update_rss_feed($link, $feed_id);
-
- print "<rpc-reply>";
- print "<message>UPDATE_COUNTERS</message>";
- print "</rpc-reply>";
-
return;
} */
if ($subop == "updateAllFeeds" || $subop == "getAllCounters") {
-
- header("Content-Type: text/plain");
-
- $last_article_id = (int) $_REQUEST["last_article_id"];
+ $last_article_id = (int) $_REQUEST["last_article_id"];
$reply = array();
if ($last_article_id != getLastArticleId($link)) {
$omode = $_REQUEST["omode"];
- if ($omode != "T")
+ if ($omode != "T")
$reply['counters'] = getAllCounters($link, $omode);
else
$reply['counters'] = getGlobalCounters($link);
}
-
+
$reply['runtime-info'] = make_runtime_info($link);
/* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */
if ($subop == "catchupSelected") {
- header("Content-Type: text/plain");
-
- $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") {
- header("Content-Type: text/plain");
-
- $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") {
- header("Content-Type: text/plain");
-
- $ids = split(",", db_escape_string($_REQUEST["ids"]));
+ $ids = explode(",", db_escape_string($_REQUEST["ids"]));
$cmode = sprintf("%d", $_REQUEST["cmode"]);
publishArticlesById($link, $ids, $cmode);
return;
}
- // XML method
if ($subop == "sanityCheck") {
- print "<rpc-reply>";
- if (sanity_check($link)) {
- print "<error error-code=\"0\"/>";
+ $_SESSION["hasAudio"] = $_REQUEST["hasAudio"] === "true";
+
+ $reply = array();
- print "<init-params><![CDATA[";
- print json_encode(make_init_params($link));
- print "]]></init-params>";
+ $reply['error'] = sanity_check($link);
- print_runtime_info($link);
+ if ($reply['error']['code'] == 0) {
+ $reply['init-params'] = make_init_params($link);
+ $reply['runtime-info'] = make_runtime_info($link);
}
- print "</rpc-reply>";
+ print json_encode($reply);
return;
- }
+ }
/* if ($subop == "globalPurge") {
} */
if ($subop == "setArticleTags") {
- header("Content-Type: text/plain");
-
global $memcache;
$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");
$int_id = db_fetch_result($result, 0, "int_id");
- db_query($link, "DELETE FROM ttrss_tags WHERE
+ db_query($link, "DELETE FROM ttrss_tags WHERE
post_int_id = $int_id AND owner_uid = '".$_SESSION["uid"]."'");
foreach ($tags as $tag) {
- $tag = sanitize_tag($tag);
+ $tag = sanitize_tag($tag);
if (!tag_is_valid($tag)) {
continue;
}
// print "<!-- $id : $int_id : $tag -->";
-
+
if ($tag != '') {
- db_query($link, "INSERT INTO ttrss_tags
+ db_query($link, "INSERT INTO ttrss_tags
(post_int_id, owner_uid, tag_name) VALUES ('$int_id', '".$_SESSION["uid"]."', '$tag')");
}
/* update tag cache */
+ sort($tags_to_cache);
$tags_str = join(",", $tags_to_cache);
- db_query($link, "UPDATE ttrss_user_entries
+ db_query($link, "UPDATE ttrss_user_entries
SET tag_cache = '$tags_str' WHERE ref_id = '$id'
AND owner_uid = " . $_SESSION["uid"]);
}
$memcache->delete($obj_id);
}
- $tags_str = format_tags_string(get_article_tags($link, $id), $id);
+ $tags = get_article_tags($link, $id);
+ $tags_str = format_tags_string($tags, $id);
+ $tags_str_full = join(", ", $tags);
+
+ if (!$tags_str_full) $tags_str_full = __("no tags");
print json_encode(array("tags_str" => array("id" => $id,
- "content" => $tags_str)));
+ "content" => $tags_str, "content_full" => $tags_str_full)));
return;
}
- // XML method
if ($subop == "regenOPMLKey") {
-
- print "<rpc-reply>";
-
- update_feed_access_key($link, 'OPML:Publish',
+ update_feed_access_key($link, 'OPML:Publish',
false, $_SESSION["uid"]);
- $new_link = opml_publish_url($link);
- print "<link><![CDATA[$new_link]]></link>";
- print "</rpc-reply>";
- return;
- }
+ $new_link = opml_publish_url($link);
- // XML method
- if ($subop == "logout") {
- logout_user();
- print_error_xml(6);
+ print json_encode(array("link" => $new_link));
return;
}
if ($subop == "completeTags") {
- header("Content-Type: text/plain");
-
$search = db_escape_string($_REQUEST["search"]);
- $result = db_query($link, "SELECT DISTINCT tag_name FROM ttrss_tags
+ $result = db_query($link, "SELECT DISTINCT tag_name FROM ttrss_tags
WHERE owner_uid = '".$_SESSION["uid"]."' AND
tag_name LIKE '$search%' ORDER BY tag_name
LIMIT 10");
}
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) {
} */
- // XML method
if ($subop == "getArticles") {
- $ids = split(",", db_escape_string($_REQUEST["ids"]));
-
- print "<rpc-reply>";
+ $ids = explode(",", db_escape_string($_REQUEST["ids"]));
+ $articles = array();
foreach ($ids as $id) {
if ($id) {
- outputArticleXML($link, $id, 0, false);
+ array_push($articles, format_article($link, $id, 0, false));
}
}
- print "</rpc-reply>";
- return;
+ print json_encode($articles);
+ return;
}
if ($subop == "checkDate") {
- header("Content-Type: text/plain");
-
$date = db_escape_string($_REQUEST["date"]);
$date_parsed = strtotime($date);
- print json_encode(array("result" => (bool)$date_parsed));
+ print json_encode(array("result" => (bool)$date_parsed,
+ "date" => date("c", $date_parsed)));
return;
}
if ($subop == "assignToLabel" || $subop == "removeFromLabel") {
- header("Content-Type: text/plain");
-
$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,
+ $label = db_escape_string(label_find_caption($link, $label_id,
$_SESSION["uid"]));
$reply["info-for-headlines"] = array();
label_remove_article($link, $id, $label, $_SESSION["uid"]);
$labels = get_article_labels($link, $id, $_SESSION["uid"]);
-
+
array_push($reply["info-for-headlines"],
array("id" => $id, "labels" => format_article_labels($labels, $id)));
}
if ($subop == "updateFeedBrowser") {
- header("Content-Type: text/plain");
-
$search = db_escape_string($_REQUEST["search"]);
$limit = db_escape_string($_REQUEST["limit"]);
$mode = (int) db_escape_string($_REQUEST["mode"]);
return;
}
+ // 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) {
$orig_id = db_escape_string(db_fetch_result($result, 0, "id"));
$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"));
-
+
$title_orig = 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) {
+
+ if (db_num_rows($result) == 0) {
if ($mode == 1) {
$result = db_query($link,
- "INSERT INTO ttrss_feeds (owner_uid,feed_url,title,cat_id)
+ "INSERT INTO ttrss_feeds (owner_uid,feed_url,title,cat_id)
VALUES ('".$_SESSION["uid"]."', '$feed_url', '$title', NULL)");
} else if ($mode == 2) {
$result = db_query($link,
- "INSERT INTO ttrss_feeds (id,owner_uid,feed_url,title,cat_id,site_url)
+ "INSERT INTO ttrss_feeds (id,owner_uid,feed_url,title,cat_id,site_url)
VALUES ('$orig_id','".$_SESSION["uid"]."', '$feed_url', '$title', NULL, '$site_url')");
}
array_push($subscribed, $title_orig);
}
- }
+ } */
return;
- }
+ }
if ($subop == "digest-get-contents") {
- header("Content-Type: text/plain");
-
$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;
}
if ($subop == "digest-update") {
- header("Content-Type: text/plain");
-
$feed_id = db_escape_string($_REQUEST['feed_id']);
$offset = db_escape_string($_REQUEST['offset']);
$seq = db_escape_string($_REQUEST['seq']);
-
+
if (!$feed_id) $feed_id = -4;
if (!$offset) $offset = 0;
$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") {
- header("Content-Type: text/plain");
-
- $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 == "sendEmail") {
- header("Content-Type: text/plain");
-
$secretkey = $_REQUEST['secretkey'];
$reply = array();
- if (DIGEST_ENABLE && $_SESSION['email_secretkey'] &&
+ if (DIGEST_ENABLE && $_SESSION['email_secretkey'] &&
$secretkey == $_SESSION['email_secretkey']) {
$_SESSION['email_secretkey'] = '';
}
if ($subop == "completeEmails") {
-
$search = db_escape_string($_REQUEST["search"]);
print "<ul>";
}
if ($subop == "quickAddCat") {
- print "<rpc-reply>";
-
$cat = db_escape_string($_REQUEST["cat"]);
add_feed_category($link, $cat);
print_feed_cat_select($link, "cat_id", $id);
- print "</rpc-reply>";
-
return;
}
if ($subop == "regenFeedKey") {
$feed_id = db_escape_string($_REQUEST['id']);
- $is_cat = (bool) db_escape_string($_REQUEST['is_cat']);
-
- print "<rpc-reply>";
+ $is_cat = db_escape_string($_REQUEST['is_cat']) == "true";
$new_key = update_feed_access_key($link, $feed_id, $is_cat);
- print "<link><![CDATA[$new_key]]></link>";
-
- print "</rpc-reply>";
-
+ print json_encode(array("link" => $new_key));
return;
}
+ // Silent
if ($subop == "clearKeys") {
-
db_query($link, "DELETE FROM ttrss_access_keys WHERE
owner_uid = " . $_SESSION["uid"]);
- print "<rpc-reply>";
- print "<message>UPDATE_COUNTERS</message>";
- print "</rpc-reply>";
+ 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"];
- print "<rpc-reply><status>";
-
- if (@preg_match("/$reg_exp/i", "TEST") === false) {
- print "INVALID";
- } else {
- print "OK";
- }
-
- print "</status></rpc-reply>";
+ $status = @preg_match("/$reg_exp/i", "TEST") !== false;
+ print json_encode(array("status" => $status));
return;
}
+ // TODO: unify with digest-get-contents?
if ($subop == "cdmGetArticle") {
- header("Content-Type: text/plain");
+ $ids = array(db_escape_string($_REQUEST["id"]));
+ $cids = explode(",", $_REQUEST["cids"]);
- $id = db_escape_string($_REQUEST["id"]);
+ $ids = array_merge($ids, $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"]);
+ $rv = array();
- if (db_num_rows($result) != 0) {
- $line = db_fetch_assoc($result);
+ foreach ($ids as $id) {
+ $id = (int)$id;
- $article_content = sanitize_rss($link, $line["content"],
- false, false, $line['site_url']);
-
- } 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;
}
if ($subop == "scheduleFeedUpdate") {
- header("Content-Type: text/plain");
-
$feed_id = db_escape_string($_REQUEST["id"]);
$is_cat = db_escape_string($_REQUEST['is_cat']) == 'true';
} else {
$message = __("Category update has been scheduled.");
- if ($feed_id)
+ if ($feed_id)
$cat_query = "cat_id = '$feed_id'";
else
$cat_query = "cat_id IS NULL";
}
if ($subop == "getTweetInfo") {
- header("Content-Type: text/plain");
$id = db_escape_string($_REQUEST['id']);
- $result = db_query($link, "SELECT title, link
+ $result = db_query($link, "SELECT title, link
FROM ttrss_entries, ttrss_user_entries
WHERE id = '$id' AND ref_id = id AND owner_uid = " .$_SESSION['uid']);
return;
}
- print "<rpc-reply><error>Unknown method: $subop</error></rpc-reply>";
+ if ($subop == "setNote") {
+ $id = db_escape_string($_REQUEST["id"]);
+ $note = trim(strip_tags(db_escape_string($_REQUEST["note"])));
+
+ db_query($link, "UPDATE ttrss_user_entries SET note = '$note'
+ WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
+
+ $formatted_note = format_article_note($id, $note);
+
+ print json_encode(array("note" => $formatted_note,
+ "raw_length" => mb_strlen($note)));
+ return;
+ }
+
+ if ($subop == "genHash") {
+ $hash = sha1(uniqid(rand(), true));
+
+ print json_encode(array("hash" => $hash));
+ return;
+ }
+
+ print json_encode(array("error" => array("code" => 7,
+ "message" => "Unknown method: $subop")));
}
?>