"; $lnum = 0; $total_unread = 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"; $total_unread += $unread; print ""; $feed = "$feed"; print "$feed"; print ""; print "$unread / "; print "$total"; print ""; print ""; ++$lnum; } // print " // Update all feeds"; // print " "; // print ""; print ""; print "

All feeds: Update"; print " Mark as read

"; print "
$total_unread
"; } if ($op == "view") { $id = $_GET["id"]; $result = pg_query("UPDATE ttrss_entries SET unread = false,last_read = NOW() 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"]; $subop = $_GET["subop"]; if (!$skip) $skip = 0; if ($subop == "undefined") $subop = ""; // 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 ($subop == "ForceUpdate" || (!$subop && $line["update_timeout"] > MIN_UPDATE_TIME)) { update_rss_feed($link, $line["feed_url"], $feed); } else { if ($subop == "MarkAllRead") { pg_query("UPDATE ttrss_entries SET unread = false,last_read = NOW() WHERE feed_id = '$feed'"); } if ($subop == "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 count(id) AS total_entries FROM ttrss_entries WHERE feed_id = '$feed'"); $total_entries = pg_fetch_result($result, 0, "total_entries"); $result = pg_query("SELECT id,title,updated,unread,feed_id, EXTRACT(EPOCH FROM last_read) AS last_read_ts, EXTRACT(EPOCH FROM updated) AS updated_ts 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["last_read_ts"] < $line["updated_ts"] && $line["unread"] == "f") { $update_pic = "\"Updated\""; } else { $update_pic = " "; } if ($line["unread"] == "t") $class .= "Unread"; $id = $line["id"]; $feed_id = $line["feed_id"]; $content_link = "" . $line["title"] . ""; print ""; print ""; print ""; print ""; print ""; ++$lnum; } if ($lnum == 0) { print ""; } print ""; print "
Search:
" . $line["title"] . "
$update_pic".$line["updated"]."$content_link
No entries found.
"; $next_skip = $skip + HEADLINES_PER_PAGE; $prev_skip = $skip - HEADLINES_PER_PAGE; print "Navigate: "; if ($prev_skip >= 0) { print "Previous Page"; } else { print "Previous Page"; } print " "; if ($next_skip < $total_entries) { print "Next Page"; } else { print "Next Page"; } print " "; print "Refresh Page"; print " "; print "Update Feed"; 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,last_read = NOW() 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); ?>