<?php\r
-class Feeds extends Handler {\r
- \r
+class Feeds extends Protected_Handler {\r
+\r
function catchupAll() {\r
db_query($this->link, "UPDATE ttrss_user_entries SET\r
last_read = NOW(),unread = false WHERE owner_uid = " . $_SESSION["uid"]);\r
ccache_zero_all($this->link, $_SESSION["uid"]);\r
- } \r
+ }\r
\r
function collapse() {\r
$cat_id = db_escape_string($_REQUEST["cid"]);\r
\r
function index() {\r
$root = (bool)$_REQUEST["root"];\r
- \r
+\r
if (!$root) {\r
print json_encode(outputFeedList($this->link));\r
} else {\r
- \r
+\r
$feeds = outputFeedList($this->link, false);\r
- \r
+\r
$root = array();\r
$root['id'] = 'root';\r
$root['name'] = __('Feeds');\r
$root['items'] = $feeds['items'];\r
- \r
+\r
$fl = array();\r
$fl['identifier'] = 'id';\r
$fl['label'] = 'name';\r
$fl['items'] = array($root);\r
- \r
+\r
print json_encode($fl);\r
}\r
- } \r
- \r
+ }\r
+\r
function view() {\r
$timing_info = getmicrotime();\r
- \r
+\r
$reply = array();\r
- \r
+\r
if ($_REQUEST["debug"]) $timing_info = print_checkpoint("0", $timing_info);\r
- \r
+\r
$omode = db_escape_string($_REQUEST["omode"]);\r
- \r
+\r
$feed = db_escape_string($_REQUEST["feed"]);\r
$method = db_escape_string($_REQUEST["m"]);\r
$view_mode = db_escape_string($_REQUEST["view_mode"]);\r
@$offset = db_escape_string($_REQUEST["skip"]);\r
@$vgroup_last_feed = db_escape_string($_REQUEST["vgrlf"]);\r
$order_by = db_escape_string($_REQUEST["order_by"]);\r
- \r
+\r
if (is_numeric($feed)) $feed = (int) $feed;\r
- \r
+\r
/* Feed -5 is a special case: it is used to display auxiliary information\r
* when there's nothing to load - e.g. no stuff in fresh feed */\r
- \r
+\r
if ($feed == -5) {\r
print json_encode(generate_dashboard_feed($this->link));\r
return;\r
}\r
- \r
+\r
$result = false;\r
- \r
+\r
if ($feed < -10) {\r
$label_feed = -11-$feed;\r
$result = db_query($this->link, "SELECT id FROM ttrss_labels2 WHERE\r
$result = db_query($this->link, "SELECT id FROM ttrss_feed_categories WHERE\r
id = '$feed' AND owner_uid = " . $_SESSION['uid']);\r
}\r
- \r
+\r
if ($result && db_num_rows($result) == 0) {\r
print json_encode(generate_error_feed($this->link, __("Feed not found.")));\r
return;\r
}\r
- \r
+\r
/* Updating a label ccache means recalculating all of the caches\r
* so for performance reasons we don't do that here */\r
- \r
+\r
if ($feed >= 0) {\r
ccache_update($this->link, $feed, $_SESSION["uid"], $cat_view);\r
}\r
- \r
+\r
set_pref($this->link, "_DEFAULT_VIEW_MODE", $view_mode);\r
set_pref($this->link, "_DEFAULT_VIEW_LIMIT", $limit);\r
set_pref($this->link, "_DEFAULT_VIEW_ORDER_BY", $order_by);\r
- \r
+\r
if (!$cat_view && preg_match("/^[0-9][0-9]*$/", $feed)) {\r
db_query($this->link, "UPDATE ttrss_feeds SET last_viewed = NOW()\r
WHERE id = '$feed' AND owner_uid = ".$_SESSION["uid"]);\r
}\r
- \r
+\r
$reply['headlines'] = array();\r
- \r
+\r
if (!$next_unread_feed)\r
$reply['headlines']['id'] = $feed;\r
else\r
$reply['headlines']['id'] = $next_unread_feed;\r
- \r
+\r
$reply['headlines']['is_cat'] = (bool) $cat_view;\r
- \r
+\r
$override_order = false;\r
- \r
+\r
if (get_pref($this->link, "SORT_HEADLINES_BY_FEED_DATE", $owner_uid)) {\r
$date_sort_field = "updated";\r
} else {\r
$date_sort_field = "date_entered";\r
}\r
- \r
+\r
switch ($order_by) {\r
case "date":\r
if (get_pref($this->link, 'REVERSE_HEADLINES', $owner_uid)) {\r
$override_order = "$date_sort_field DESC";\r
}\r
break;\r
- \r
+\r
case "title":\r
if (get_pref($this->link, 'REVERSE_HEADLINES', $owner_uid)) {\r
$override_order = "title DESC, $date_sort_field";\r
$override_order = "title, $date_sort_field DESC";\r
}\r
break;\r
- \r
+\r
case "score":\r
if (get_pref($this->link, 'REVERSE_HEADLINES', $owner_uid)) {\r
$override_order = "score, $date_sort_field";\r
}\r
break;\r
}\r
- \r
+\r
if ($_REQUEST["debug"]) $timing_info = print_checkpoint("04", $timing_info);\r
- \r
+\r
$ret = format_headlines_list($this->link, $feed, $method,\r
$view_mode, $limit, $cat_view, $next_unread_feed, $offset,\r
$vgroup_last_feed, $override_order);\r
- \r
+\r
$topmost_article_ids = $ret[0];\r
$headlines_count = $ret[1];\r
$returned_feed = $ret[2];\r
$disable_cache = $ret[3];\r
$vgroup_last_feed = $ret[4];\r
- \r
+\r
$reply['headlines']['content'] =& $ret[5]['content'];\r
$reply['headlines']['toolbar'] =& $ret[5]['toolbar'];\r
- \r
+\r
if ($_REQUEST["debug"]) $timing_info = print_checkpoint("05", $timing_info);\r
- \r
+\r
$reply['headlines-info'] = array("count" => (int) $headlines_count,\r
"vgroup_last_feed" => $vgroup_last_feed,\r
"disable_cache" => (bool) $disable_cache);\r
- \r
+\r
if ($_REQUEST["debug"]) $timing_info = print_checkpoint("20", $timing_info);\r
- \r
+\r
if (is_array($topmost_article_ids) && !get_pref($this->link, 'COMBINED_DISPLAY_MODE') && !$_SESSION["bw_limit"]) {\r
$articles = array();\r
- \r
+\r
foreach ($topmost_article_ids as $id) {\r
array_push($articles, format_article($this->link, $id, false));\r
}\r
- \r
+\r
$reply['articles'] = $articles;\r
}\r
- \r
+\r
if ($_REQUEST["debug"]) $timing_info = print_checkpoint("30", $timing_info);\r
- \r
+\r
$reply['runtime-info'] = make_runtime_info($this->link);\r
- \r
+\r
print json_encode($reply);\r
- \r
+\r
}\r
}\r
-?>
\ No newline at end of file
+?>\r