"; $lnum = 0; while ($line = pg_fetch_assoc($result)) { $feed = $line["title"]; $feed_id = $line["id"]; $total = $line["total"]; $unread = $line["unread"]; $class = ($lnum % 2) ? "even" : "odd"; if ($unread > 0) $class .= "Unread"; print ""; $feed = "$feed"; print "$feed"; print ""; print "$unread / "; print "$total"; print ""; print ""; ++$lnum; } print " Update all feeds"; print ""; } if ($op == "view") { $id = $_GET["id"]; $result = pg_query("UPDATE ttrss_entries SET unread = false WHERE id = '$id'"); $result = pg_query("SELECT title,link,content FROM ttrss_entries WHERE id = '$id'"); if ($result) { $line = pg_fetch_assoc($result); print ""; print ""; print ""; print "
Title:".$line["title"]."
Link:".$line["link"]."
"; print $line["content"]; } } if ($op == "viewfeed") { $feed = $_GET["feed"]; $skip = $_GET["skip"]; $ext = $_GET["ext"]; if (!$skip) $skip = 0; if ($ext == "undefined") $ext = ""; // FIXME: check for null value here $result = pg_query("SELECT *, EXTRACT(EPOCH FROM NOW()) - EXTRACT(EPOCH FROM last_updated) as update_timeout FROM ttrss_feeds WHERE id = '$feed'"); if ($result) { $line = pg_fetch_assoc($result); if (!$ext && $line["update_timeout"] > MIN_UPDATE_TIME) { update_rss_feed($link, $line["feed_url"], $feed); } else { if ($ext == "MarkAllRead") { pg_query("UPDATE ttrss_entries SET unread = false WHERE feed_id = '$feed'"); } if ($ext == "MarkPageRead") { // pg_query("UPDATE ttrss_entries SET unread = false // WHERE feed_id = '$feed' ORDER BY updated OFFSET $skip LIMIT 1"); } } } print ""; print ""; print ""; if ($ext == "SEARCH") { $search = $_GET["search"]; $search_query_part = "(upper(title) LIKE upper('%$search%') OR content LIKE '%$search%') AND"; } $result = pg_query("SELECT id,title,updated,unread,feed_id FROM ttrss_entries WHERE $search_query_part feed_id = '$feed' ORDER BY updated DESC LIMIT ".HEADLINES_PER_PAGE." OFFSET $skip"); $lnum = 0; while ($line = pg_fetch_assoc($result)) { $class = ($lnum % 2) ? "even" : "odd"; if ($line["unread"] == "t") $class .= "Unread"; $content_link = "".$line["title"].""; print ""; print ""; print ""; print ""; ++$lnum; } if ($lnum == 0) { print ""; } print ""; print "
Search:
" . $line["title"] . "
".$line["updated"]."$content_link
No entries found.
"; $next_skip = $skip + HEADLINES_PER_PAGE; $prev_skip = $skip - HEADLINES_PER_PAGE; print "Navigate: "; print "Previous Page"; print " "; print "Next Page"; print " "; print "Refresh"; print "  Mark as read: "; print "This Page"; print " "; print "All Posts"; print "
"; $result = pg_query("SELECT id, (SELECT count(id) FROM ttrss_entries WHERE feed_id = ttrss_feeds.id) AS total, (SELECT count(id) FROM ttrss_entries WHERE feed_id = ttrss_feeds.id AND unread = true) as unread FROM ttrss_feeds WHERE id = '$feed'"); $total = pg_fetch_result($result, 0, "total"); $unread = pg_fetch_result($result, 0, "unread"); print "
$feed
"; print "
$total
"; print "
$unread
"; } if ($op == "pref-rpc") { $subop = $_GET["subop"]; if ($subop == "unread") { $ids = split(",", $_GET["ids"]); foreach ($ids as $id) { pg_query("UPDATE ttrss_entries SET unread = true WHERE feed_id = '$id'"); } print "Marked selected feeds as read."; } if ($subop == "read") { $ids = split(",", $_GET["ids"]); foreach ($ids as $id) { pg_query("UPDATE ttrss_entries SET unread = false WHERE feed_id = '$id'"); } print "Marked selected feeds as unread."; } } if ($op == "pref-feeds") { $subop = $_GET["subop"]; if ($subop == "edit") { print "

[Edit feed placeholder]

"; } if ($subop == "remove") { $ids = split(",", $_GET["ids"]); foreach ($ids as $id) { pg_query("BEGIN"); pg_query("DELETE FROM ttrss_entries WHERE feed_id = '$id'"); pg_query("DELETE FROM ttrss_feeds WHERE id = '$id'"); pg_query("COMMIT"); } } if ($subop == "add") { $feed_link = pg_escape_string($_GET["link"]); $result = pg_query( "INSERT INTO ttrss_feeds (feed_url,title) VALUES ('$feed_link', '')"); $result = pg_query("SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_link'"); $feed_id = pg_fetch_result($result, 0, "id"); if ($feed_id) { update_rss_feed($link, $feed_link, $feed_id); } } $result = pg_query("SELECT * FROM ttrss_feeds ORDER by title"); print "

"; print ""; $lnum = 0; while ($line = pg_fetch_assoc($result)) { $class = ($lnum % 2) ? "even" : "odd"; $feed_id = $line["id"]; print ""; print ""; print ""; print ""; print ""; print ""; ++$lnum; } print "
SelectTitleLinkLast Updated
" . $line["title"] . "" . $line["feed_url"] . "" . $line["last_updated"] . "
"; } pg_close($link); ?>