From 94b8ce6cec3cdc8548cdfa7d1cd0d5d06a518886 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 15 Sep 2015 12:33:58 +0300 Subject: queryfeedheadlines: remove disable_offsets hack --- classes/api.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'classes/api.php') diff --git a/classes/api.php b/classes/api.php index 2d420e527..08c1846d2 100644 --- a/classes/api.php +++ b/classes/api.php @@ -686,8 +686,7 @@ class API extends Handler { "offset" => $offset, "since_id" => $since_id, "include_children" => $include_nested, - "check_first_id" => $check_first_id, - "api_request" => true + "check_first_id" => $check_first_id ); $qfh_ret = queryFeedHeadlines($params); -- cgit v1.2.3-54-g00ecf From 19e47ad60bc390b52cfe1545a6d401545e6568a5 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 21 Nov 2015 22:20:00 +0300 Subject: queryFeedHeadlines: don't check first_id when sorting by oldest first --- classes/api.php | 10 +++++++--- classes/feeds.php | 10 +++++++--- include/functions2.php | 3 ++- 3 files changed, 16 insertions(+), 7 deletions(-) mode change 100644 => 100755 classes/api.php mode change 100644 => 100755 classes/feeds.php (limited to 'classes/api.php') diff --git a/classes/api.php b/classes/api.php old mode 100644 new mode 100755 index 08c1846d2..dfe9ef6cb --- a/classes/api.php +++ b/classes/api.php @@ -210,6 +210,8 @@ class API extends Handler { $_SESSION['hasSandbox'] = $has_sandbox; + $skip_first_id_check = false; + $override_order = false; switch ($_REQUEST["order_by"]) { case "title": @@ -217,6 +219,7 @@ class API extends Handler { break; case "date_reverse": $override_order = "score DESC, date_entered, updated"; + $skip_first_id_check = true; break; case "feed_dates": $override_order = "updated DESC"; @@ -230,7 +233,7 @@ class API extends Handler { list($headlines, $headlines_header) = $this->api_get_headlines($feed_id, $limit, $offset, $filter, $is_cat, $show_excerpt, $show_content, $view_mode, $override_order, $include_attachments, $since_id, $search, - $include_nested, $sanitize_content, $force_update, $excerpt_length, $check_first_id); + $include_nested, $sanitize_content, $force_update, $excerpt_length, $check_first_id, $skip_first_id_check); if ($include_header) { $this->wrap(self::STATUS_OK, array($headlines_header, $headlines)); @@ -644,7 +647,7 @@ class API extends Handler { $filter, $is_cat, $show_excerpt, $show_content, $view_mode, $order, $include_attachments, $since_id, $search = "", $include_nested = false, $sanitize_content = true, - $force_update = false, $excerpt_length = 100, $check_first_id = false) { + $force_update = false, $excerpt_length = 100, $check_first_id = false, $skip_first_id_check = false) { if ($force_update && $feed_id > 0 && is_numeric($feed_id)) { // Update the feed if required with some basic flood control @@ -686,7 +689,8 @@ class API extends Handler { "offset" => $offset, "since_id" => $since_id, "include_children" => $include_nested, - "check_first_id" => $check_first_id + "check_first_id" => $check_first_id, + "skip_first_id_check" => $skip_first_id_check ); $qfh_ret = queryFeedHeadlines($params); diff --git a/classes/feeds.php b/classes/feeds.php old mode 100644 new mode 100755 index c3cb72da8..07a18741d --- a/classes/feeds.php +++ b/classes/feeds.php @@ -148,7 +148,8 @@ class Feeds extends Handler_Protected { private function format_headlines_list($feed, $method, $view_mode, $limit, $cat_view, $next_unread_feed, $offset, $vgr_last_feed = false, - $override_order = false, $include_children = false, $check_first_id = false) { + $override_order = false, $include_children = false, $check_first_id = false, + $skip_first_id_check = false) { $disable_cache = false; @@ -252,7 +253,8 @@ class Feeds extends Handler_Protected { "override_order" => $override_order, "offset" => $offset, "include_children" => $include_children, - "check_first_id" => $check_first_id + "check_first_id" => $check_first_id, + "skip_first_id_check" => $skip_first_id_check ); $qfh_ret = queryFeedHeadlines($params); @@ -903,6 +905,7 @@ class Feeds extends Handler_Protected { $reply['headlines'] = array(); $override_order = false; + $skip_first_id_check = false; switch ($order_by) { case "title": @@ -910,6 +913,7 @@ class Feeds extends Handler_Protected { break; case "date_reverse": $override_order = "score DESC, date_entered, updated"; + $skip_first_id_check = true; break; case "feed_dates": $override_order = "updated DESC"; @@ -920,7 +924,7 @@ class Feeds extends Handler_Protected { $ret = $this->format_headlines_list($feed, $method, $view_mode, $limit, $cat_view, $next_unread_feed, $offset, - $vgroup_last_feed, $override_order, true, $check_first_id); + $vgroup_last_feed, $override_order, true, $check_first_id, $skip_first_id_check); //$topmost_article_ids = $ret[0]; $headlines_count = $ret[1]; diff --git a/include/functions2.php b/include/functions2.php index 779688716..0386b52ed 100755 --- a/include/functions2.php +++ b/include/functions2.php @@ -465,6 +465,7 @@ $override_vfeed = isset($params["override_vfeed"]) ? $params["override_vfeed"] : false; $start_ts = isset($params["start_ts"]) ? $params["start_ts"] : false; $check_first_id = isset($params["check_first_id"]) ? $params["check_first_id"] : false; + $skip_first_id_check = isset($params["skip_first_id_check"]) ? $params["skip_first_id_check"] : false; $ext_tables_part = ""; $query_strategy_part = ""; @@ -731,7 +732,7 @@ $sanity_interval_qpart = "date_entered >= DATE_SUB(NOW(), INTERVAL 1 hour) AND"; } - if (!$search) { + if (!$search && !$skip_first_id_check) { // if previous topmost article id changed that means our current pagination is no longer valid $query = "SELECT DISTINCT ttrss_feeds.title, -- cgit v1.2.3-54-g00ecf From 73c77ab0a5d4ac714abf09f9730b75556481bb88 Mon Sep 17 00:00:00 2001 From: JustAMacUser Date: Mon, 23 Nov 2015 14:25:04 -0500 Subject: Add optional (default: true), boolean "sanitize" parameter to API::getArticle() method. --- classes/api.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) mode change 100755 => 100644 classes/api.php (limited to 'classes/api.php') diff --git a/classes/api.php b/classes/api.php old mode 100755 new mode 100644 index dfe9ef6cb..c3ea627fd --- a/classes/api.php +++ b/classes/api.php @@ -2,7 +2,7 @@ class API extends Handler { - const API_LEVEL = 12; + const API_LEVEL = 13; const STATUS_OK = 0; const STATUS_ERR = 1; @@ -325,13 +325,17 @@ class API extends Handler { function getArticle() { $article_id = join(",", array_filter(explode(",", $this->dbh->escape_string($_REQUEST["article_id"])), is_numeric)); + $sanitize_content = !isset($_REQUEST["sanitize"]) || + sql_bool_to_bool($_REQUEST["sanitize"]); if ($article_id) { $query = "SELECT id,title,link,content,feed_id,comments,int_id, marked,unread,published,score,note,lang, ".SUBSTRING_FOR_DATE."(updated,1,16) as updated, - author,(SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title + author,(SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title, + (SELECT site_url FROM ttrss_feeds WHERE id = feed_id) AS site_url, + (SELECT hide_images FROM ttrss_feeds WHERE id = feed_id) AS hide_images FROM ttrss_entries,ttrss_user_entries WHERE id IN ($article_id) AND ref_id = id AND owner_uid = " . $_SESSION["uid"] ; @@ -357,7 +361,6 @@ class API extends Handler { "comments" => $line["comments"], "author" => $line["author"], "updated" => (int) strtotime($line["updated"]), - "content" => $line["content"], "feed_id" => $line["feed_id"], "attachments" => $attachments, "score" => (int)$line["score"], @@ -366,6 +369,15 @@ class API extends Handler { "lang" => $line["lang"] ); + if ($sanitize_content) { + $article["content"] = sanitize( + $line["content"], + sql_bool_to_bool($line['hide_images']), + false, $line["site_url"], false, $line["id"]); + } else { + $article["content"] = $line["content"]; + } + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_API) as $p) { $article = $p->hook_render_article_api(array("article" => $article)); } -- cgit v1.2.3-54-g00ecf