<?
session_start();
+ if ($_GET["debug"]) {
+ define('DEFAULT_ERROR_LEVEL', E_ALL);
+ } else {
+ define('DEFAULT_ERROR_LEVEL', E_ERROR | E_WARNING | E_PARSE);
+ }
+
+ error_reporting(DEFAULT_ERROR_LEVEL);
+
$op = $_REQUEST["op"];
- if (($op == "rpc" || $op == "updateAllFeeds" ||
- $op == "forceUpdateAllFeeds") && !$_REQUEST["noxml"]) {
+ if ((!$op || $op == "rpc" || $op == "globalUpdateFeeds") && !$_REQUEST["noxml"]) {
header("Content-Type: application/xml");
}
- if (!$_SESSION["uid"]) {
+ if (!$_SESSION["uid"] && $op != "globalUpdateFeeds") {
- if (($op == "rpc" || $op == "updateAllFeeds" ||
- $op == "forceUpdateAllFeeds")) {
+ if ($op == "rpc") {
print "<error error-code=\"6\"/>";
}
exit;
}
- define(SCHEMA_VERSION, 2);
+ if (!$op) {
+ print "<error error-code=\"7\"/>";
+ exit;
+ }
+
+ define('SCHEMA_VERSION', 2);
+ require_once "sanity_check.php";
require_once "config.php";
require_once "db.php";
require_once "db-prefs.php";
pg_query("set client_encoding = 'utf-8'");
}
-/*
- $result = db_query($link, "SELECT schema_version FROM ttrss_version");
-
- $schema_version = db_fetch_result($result, 0, "schema_version");
-
- if ($schema_version != SCHEMA_VERSION) {
- print "Error: database schema is invalid
- (got version $schema_version; expected ".SCHEMA_VERSION.")";
- return;
- }
-*/
-
$fetch = $_GET["fetch"];
+ function getAllCounters($link) {
+ getLabelCounters($link);
+ getFeedCounters($link);
+ getTagCounters($link);
+ getGlobalCounters($link);
+ }
+
/* FIXME this needs reworking */
function getGlobalCounters($link) {
print "<label id=\"$id\" counter=\"$count\"/>";
- error_reporting (E_ERROR | E_WARNING | E_PARSE);
+ error_reporting (DEFAULT_ERROR_LEVEL);
}
}
<title>Tiny Tiny RSS : Feedlist</title>
<link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">";
+ $user_theme = $_SESSION["theme"];
+ if ($user_theme) {
+ print "<link rel=\"stylesheet\" type=\"text/css\"
+ href=\"themes/$user_theme/theme.css\">";
+ }
+
if (get_pref($link, 'USE_COMPACT_STYLESHEET')) {
print "<link rel=\"stylesheet\" type=\"text/css\"
href=\"tt-rss_compact.css\"/>";
/* virtual feeds */
+ if (get_pref($link, 'ENABLE_FEED_CATS')) {
+ print "<li class=\"feedCat\">Special</li>";
+ print "<li id=\"feedCatHolder\"><ul class=\"feedCatList\">";
+ }
+
$result = db_query($link, "SELECT count(id) as num_starred
FROM ttrss_entries,ttrss_user_entries
WHERE marked = true AND
printFeedEntry(-1, $class, "Starred articles", $num_starred,
"images/mark_set.png", $link);
+ if (get_pref($link, 'ENABLE_FEED_CATS')) {
+ print "</li></ul>";
+ }
+
if (get_pref($link, 'ENABLE_LABELS')) {
$result = db_query($link, "SELECT id,sql_exp,description FROM
ttrss_labels WHERE owner_uid = '$owner_uid' ORDER by description");
if (db_num_rows($result) > 0) {
- print "<li><hr></li>";
+ if (get_pref($link, 'ENABLE_FEED_CATS')) {
+ print "<li class=\"feedCat\">Labels</li>";
+ print "<li id=\"feedCatHolder\"><ul class=\"feedCatList\">";
+ } else {
+ print "<li><hr></li>";
+ }
}
while ($line = db_fetch_assoc($result)) {
$class .= "Unread";
}
- error_reporting (E_ERROR | E_WARNING | E_PARSE);
+ error_reporting (DEFAULT_ERROR_LEVEL);
printFeedEntry(-$line["id"]-11,
$class, $line["description"], $count, "images/label.png", $link);
}
+
+ if (db_num_rows($result) > 0) {
+ if (get_pref($link, 'ENABLE_FEED_CATS')) {
+ print "</li></ul>";
+ }
+ }
+
+ }
+
+// if (!get_pref($link, 'ENABLE_FEED_CATS')) {
+ print "<li><hr></li>";
+// }
+
+ if (get_pref($link, 'ENABLE_FEED_CATS')) {
+ $order_by_qpart = "category,title";
+ } else {
+ $order_by_qpart = "title";
}
-
- print "<li><hr></li>";
$result = db_query($link, "SELECT *,
(SELECT count(id) FROM ttrss_entries,ttrss_user_entries
(SELECT count(id) FROM ttrss_entries,ttrss_user_entries
WHERE feed_id = ttrss_feeds.id AND unread = true
AND ttrss_user_entries.ref_id = ttrss_entries.id
- AND owner_uid = '$owner_uid') as unread
- FROM ttrss_feeds WHERE owner_uid = '$owner_uid' ORDER BY title");
+ AND owner_uid = '$owner_uid') as unread,
+ (SELECT title FROM ttrss_feed_categories
+ WHERE id = cat_id) AS category
+ FROM ttrss_feeds WHERE owner_uid = '$owner_uid' ORDER BY $order_by_qpart");
$actid = $_GET["actid"];
$lnum = 0;
$total_unread = 0;
+
+ $category = "";
while ($line = db_fetch_assoc($result)) {
$total = $line["total"];
$unread = $line["unread"];
+
+ $tmp_category = $line["category"];
+
+ if (!$tmp_category) {
+ $tmp_category = "Uncategorized";
+ }
// $class = ($lnum % 2) ? "even" : "odd";
}
$total_unread += $unread;
+
+ if ($category != $tmp_category && get_pref($link, 'ENABLE_FEED_CATS')) {
+
+ if ($category) {
+ print "</li></ul></li>";
+ }
+
+ $category = $tmp_category;
+
+ print "<li class=\"feedCat\">$category</li>";
+ print "<li id=\"feedCatHolder\"><ul class=\"feedCatList\">";
+ }
- printFeedEntry($feed_id, $class, $feed, $unread, "icons/$feed_id.ico", $link);
+ printFeedEntry($feed_id, $class, $feed, $unread,
+ "icons/$feed_id.ico", $link);
++$lnum;
}
+
} else {
// tags
$unread = $tags[$tag];
- $class = "odd";
+ $class = "tag";
if ($unread > 0) {
$class .= "Unread";
}
if (db_num_rows($result) == 0) {
- print "<li>No tags/feeds to display.</li>";
+ if ($tags) {
+ $what = "tags";
+ } else {
+ $what = "feeds";
+ }
+ print "<li>No $what to display.</li>";
}
print "</ul>";
if ($subop == "getAllCounters") {
print "<rpc-reply>";
- getLabelCounters($link);
- getFeedCounters($link);
- getTagCounters($link);
- getGlobalCounters($link);
+ getAllCounters($link);
print "</rpc-reply>";
}
getGlobalCounters($link);
print "</rpc-reply>";
}
-
+
+ /* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */
if ($subop == "catchupSelected") {
$ids = split(",", $_GET["ids"]);
- foreach ($ids as $id) {
+ $cmode = sprintf("%d", $_GET["cmode"]);
- db_query($link, "UPDATE ttrss_user_entries SET unread=false,last_read = NOW()
- WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
+ foreach ($ids as $id) {
+ if ($cmode == 0) {
+ db_query($link, "UPDATE ttrss_user_entries SET
+ unread = false,last_read = NOW()
+ WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
+ } else if ($cmode == 1) {
+ db_query($link, "UPDATE ttrss_user_entries SET
+ unread = true
+ WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
+ } else {
+ db_query($link, "UPDATE ttrss_user_entries SET
+ unread = NOT unread,last_read = NOW()
+ WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
+ }
}
+ print "<rpc-reply>";
+ getAllCounters($link);
+ print "</rpc-reply>";
+ }
+
+ if ($subop == "markSelected") {
+
+ $ids = split(",", $_GET["ids"]);
+
+ $cmode = sprintf("%d", $_GET["cmode"]);
- print "Marked active page as read.";
+ foreach ($ids as $id) {
+
+ if ($cmode == 0) {
+ db_query($link, "UPDATE ttrss_user_entries SET
+ marked = false
+ WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
+ } else if ($cmode == 1) {
+ db_query($link, "UPDATE ttrss_user_entries SET
+ marked = true
+ WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
+ } else {
+ db_query($link, "UPDATE ttrss_user_entries SET
+ marked = NOT marked
+ WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
+ }
+ }
+ print "<rpc-reply>";
+ getAllCounters($link);
+ print "</rpc-reply>";
}
if ($subop == "sanityCheck") {
$addheader = $_GET["addheader"];
- $result = db_query($link, "SELECT title,link,content,feed_id,comments,
- (SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url
+ $result = db_query($link, "SELECT title,link,content,feed_id,comments,int_id,
+ (SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url
FROM ttrss_entries,ttrss_user_entries
WHERE id = '$id' AND ref_id = id");
if ($addheader) {
print "<html><head>
<title>Tiny Tiny RSS : Article $id</title>
- <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">
- <script type=\"text/javascript\" src=\"functions.js\"></script>
+ <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">";
+
+ $user_theme = $_SESSION["theme"];
+ if ($user_theme) {
+ print "<link rel=\"stylesheet\" type=\"text/css\"
+ href=\"themes/$user_theme/theme.css\">";
+ }
+
+ if (get_pref($link, 'USE_COMPACT_STYLESHEET')) {
+ print "<link rel=\"stylesheet\" type=\"text/css\"
+ href=\"tt-rss_compact.css\"/>";
+ } else {
+ print "<link title=\"Compact Stylesheet\" rel=\"alternate stylesheet\"
+ type=\"text/css\" href=\"tt-rss_compact.css\"/>";
+ }
+
+ print "<script type=\"text/javascript\" src=\"functions.js\"></script>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
</head><body>";
}
print "<div class=\"postReply\">";
- print "<div class=\"postHeader\"><table>";
+ print "<div class=\"postHeader\"><table width=\"100%\">";
- print "<tr><td><b>Title:</b></td>
- <td width='100%'>" . $line["title"] . "</td></tr>";
-
- print "<tr><td><b>Link:</b></td>
- <td width='100%'>
+ print "<tr><td colspan='2'>" . $line["title"] . "</td></tr>";
+
+ $tmp_result = db_query($link, "SELECT DISTINCT tag_name FROM
+ ttrss_tags WHERE post_int_id = " . $line["int_id"] . "
+ ORDER BY tag_name");
+
+ $tags_str = "";
+
+ while ($tmp_line = db_fetch_assoc($tmp_result)) {
+ $tag = $tmp_line["tag_name"];
+ $tags_str .= "<a href=\"javascript:parent.viewfeed('$tag')\">$tag</a>, ";
+ }
+
+ $tags_str = preg_replace("/, $/", "", $tags_str);
+
+ print "<tr><td width='50%'>
<a href=\"" . $line["link"] . "\">".$line["link"]."</a>
- $entry_comments</td></tr>";
-
+ $entry_comments</td>
+ <td align=\"right\">$tags_str</td></tr>";
+
+/* if ($tags_str) {
+ print "<tr><td><b>Tags:</b></td>
+ <td width='100%'>$tags_str</td></tr>";
+ } */
+
print "</table></div>";
print "<div class=\"postIcon\">" . $feed_icon . "</div>";
print "</div>";
print "<script type=\"text/javascript\">
- update_label_counters('$feed_id');
+ update_all_counters('$feed_id');
</script>";
}
$limit = $_GET["limit"];
if (!$feed) {
- print "Error: no feed to display.";
return;
}
<title>Tiny Tiny RSS : Feed $feed</title>
<link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">";
+ $user_theme = $_SESSION["theme"];
+ if ($user_theme) {
+ print "<link rel=\"stylesheet\" type=\"text/css\"
+ href=\"themes/$user_theme/theme.css\">";
+ }
+
if (get_pref($link, 'USE_COMPACT_STYLESHEET')) {
print "<link rel=\"stylesheet\"
type=\"text/css\" href=\"tt-rss_compact.css\"/>";
print "<link title=\"Compact Stylesheet\" rel=\"alternate stylesheet\"
type=\"text/css\" href=\"tt-rss_compact.css\"/>";
}
+
print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
<script type=\"text/javascript\" src=\"functions.js\"></script>
<script type=\"text/javascript\" src=\"viewfeed.js\"></script>
}
}
} else { // tag
- // FIXME, implement catchup for tags
+ db_query($link, "BEGIN");
+
+ $tag_name = db_escape_string($feed);
+
+ $result = db_query($link, "SELECT post_int_id FROM ttrss_tags
+ WHERE tag_name = '$tag_name' AND owner_uid = " . $_SESSION["uid"]);
+
+ while ($line = db_fetch_assoc($result)) {
+ db_query($link, "UPDATE ttrss_user_entries SET
+ unread = false, last_read = NOW()
+ WHERE int_id = " . $line["post_int_id"]);
+ }
+ db_query($link, "COMMIT");
}
}
- print "<table class=\"headlinesList\" id=\"headlinesList\" width=\"100%\">";
-
$search = $_GET["search"];
$search_mode = $_GET["smode"];
$query_strategy_part = "id > 0"; // dumb
}
-
$order_by = "updated DESC";
// if ($feed < -10) {
// $order_by = "feed_id,updated DESC";
// }
+ $feed_title = "";
+
+ if ($search && $search_mode == "All feeds") {
+ $feed_title = "Search results";
+ } else if (sprintf("%d", $feed) == 0) {
+ $feed_title = $feed;
+ } else if ($feed > 0) {
+ $result = db_query($link, "SELECT title,site_url FROM ttrss_feeds
+ WHERE id = '$feed'");
+
+ $feed_title = db_fetch_result($result, 0, "title");
+ $feed_site_url = db_fetch_result($result, 0, "site_url");
+
+ } else if ($feed == -1) {
+ $feed_title = "Starred articles";
+ } else if ($feed < -10) {
+ $label_id = -$feed - 11;
+ $result = db_query($link, "SELECT description FROM ttrss_labels
+ WHERE id = '$label_id'");
+ $feed_title = db_fetch_result($result, 0, "description");
+ } else {
+ $feed_title = "?";
+ }
+
+ print "<table class=\"headlinesSubToolbar\"
+ width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><tr>";
+
+ print "<td class=\"headlineActions\">
+ Select:
+ <a href=\"javascript:selectTableRowsByIdPrefix('headlinesList',
+ 'RROW-', 'RCHK-', true)\">All</a>,
+ <a href=\"javascript:selectTableRowsByIdPrefix('headlinesList',
+ 'RROW-', 'RCHK-', true, 'Unread')\">Unread</a>,
+ <a href=\"javascript:selectTableRowsByIdPrefix('headlinesList',
+ 'RROW-', 'RCHK-', false)\">None</a>
+
+ Toggle: <a href=\"javascript:toggleUnread()\">Unread</a>,
+ <a href=\"javascript:toggleStarred()\">Starred</a>";
+
+/* print "
+ View:
+ <a href=\"javascript:limitView('All')\">All</a>,
+ <a href=\"javascript:limitView('Unread')\">Unread</a>,
+ <a href=\"javascript:limitView('Starred')\">Starred</a>
+
+ Feed:
+ <a href=\"javascript:updateCurrentFeed()\">Update</a>,
+ <a href=\"javascript:catchupCurrentFeed()\">Mark as read</a>"; */
+
+ print "</td>";
+
+ print "<td class=\"headlineTitle\">";
+
+ if ($feed_site_url) {
+ print "<a href=\"$feed_site_url\">$feed_title</a>";
+ } else {
+ print $feed_title;
+ }
+
+ print "</td>";
+ print "</tr></table>";
+
+ print "<table class=\"headlinesList\" id=\"headlinesList\" width=\"100%\">";
+
+
if ($feed < -10) error_reporting (0);
if (sprintf("%d", $feed) != 0) {
+ if ($feed > 0) {
+ $feed_kind = "Feeds";
+ } else {
+ $feed_kind = "Labels";
+ }
+
$result = db_query($link, "SELECT
- id,title,updated,unread,feed_id,marked,link,last_read,
+ id,title,
+ SUBSTRING(updated,1,16) as updated,
+ unread,feed_id,marked,link,last_read,
SUBSTRING(last_read,1,19) as last_read_noms,
$vfeed_query_part
SUBSTRING(updated,1,19) as updated_noms
} else {
// browsing by tag
+ $feed_kind = "Tags";
+
$result = db_query($link, "SELECT
- ttrss_entries.id as id,title,updated,unread,feed_id,
+ ttrss_entries.id as id,title,
+ SUBSTRING(updated,1,16) as updated,
+ unread,feed_id,
marked,link,last_read,
SUBSTRING(last_read,1,19) as last_read_noms,
$vfeed_query_part
$lnum = 0;
- error_reporting (E_ERROR | E_WARNING | E_PARSE);
+ error_reporting (DEFAULT_ERROR_LEVEL);
$num_unread = 0;
// onclick=\"javascript:view($id,$feed_id)\">
print "<td valign='center' align='center'>$update_pic</td>";
+
+ print "<td valign='center' align='center'>
+ <input type=\"checkbox\" onclick=\"toggleSelectRow(this)\"
+ class=\"feedCheckBox\" id=\"RCHK-$id\">
+ </td>";
+
print "<td valign='center' align='center'>$marked_pic</td>";
- print "<td width='25%'>
+ print "<td width='20%'>
<a href=\"javascript:view($id,$feed_id);\">".$line["updated"]."</a></td>";
if ($line["feed_title"]) {
- print "<td width='50%'>$content_link</td>";
+ print "<td width='55%'>$content_link</td>";
print "<td width='20%'>
<a href='javascript:viewfeed($feed_id)'>".$line["feed_title"]."</a></td>";
} else {
- print "<td width='70%'>$content_link</td>";
+ print "<td width='75%'>$content_link</td>";
}
print "</tr>";
print "<script type=\"text/javascript\">
document.onkeydown = hotkey_handler;
- update_label_counters('$feed');
+ update_all_counters('$feed');
</script>";
if ($addheader) {
$feed_link = db_escape_string($_GET["l"]);
$upd_intl = db_escape_string($_GET["ui"]);
$purge_intl = db_escape_string($_GET["pi"]);
- $feed_id = $_GET["id"];
+ $feed_id = db_escape_string($_GET["id"]);
+ $cat_id = db_escape_string($_GET["catid"]);
if (strtoupper($upd_intl) == "DEFAULT")
$upd_intl = 0;
if (strtoupper($purge_intl) == "DISABLED")
$purge_intl = -1;
+ if ($cat_id != 0) {
+ $category_qpart = "cat_id = '$cat_id'";
+ } else {
+ $category_qpart = 'cat_id = NULL';
+ }
+
$result = db_query($link, "UPDATE ttrss_feeds SET
+ $category_qpart,
title = '$feed_title', feed_url = '$feed_link',
update_interval = '$upd_intl',
- purge_interval = '$purge_intl'
+ purge_interval = '$purge_intl'
WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]);
}
}
}
- $result = db_query($link, "SELECT id,title,feed_url,last_error
- FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
-
- if (db_num_rows($result) > 0) {
-
- print "<div class=\"warning\">";
-
- print "<b>Feeds with update errors:</b>";
-
- print "<ul class=\"nomarks\">";
-
- while ($line = db_fetch_assoc($result)) {
- print "<li>" . $line["title"] . " (" . $line["feed_url"] . "): " .
- $line["last_error"];
- }
-
- print "</ul>";
- print "</div>";
-
- }
+ if ($subop == "addCat") {
- print "<table class=\"prefAddFeed\"><tr>
- <td><input id=\"fadd_link\"></td>
- <td colspan=\"4\" align=\"right\">
- <a class=\"button\" href=\"javascript:addFeed()\">Add feed</a></td></tr>
- </table>";
+ if (!WEB_DEMO_MODE) {
- $result = db_query($link, "SELECT
- id,title,feed_url,substring(last_updated,1,16) as last_updated,
- update_interval,purge_interval
- FROM
- ttrss_feeds WHERE owner_uid = '".$_SESSION["uid"]."' ORDER by title");
+ $feed_cat = db_escape_string(trim($_GET["cat"]));
- print "<div id=\"infoBox\">PLACEHOLDER</div>";
+ $result = db_query($link,
+ "SELECT id FROM ttrss_feed_categories
+ WHERE title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]);
- print "<p><table width=\"100%\" class=\"prefFeedList\" id=\"prefFeedList\">";
- print "<tr class=\"title\">
- <td> </td><td>Select</td><td width=\"30%\">Title</td>
- <td width=\"30%\">Link</td>
- <td width=\"10%\">Update Interval</td>
- <td width=\"10%\">Purge Days</td>
- <td>Last updated</td></tr>";
-
- $lnum = 0;
-
- while ($line = db_fetch_assoc($result)) {
+ if (db_num_rows($result) == 0) {
+
+ $result = db_query($link,
+ "INSERT INTO ttrss_feed_categories (owner_uid,title)
+ VALUES ('".$_SESSION["uid"]."', '$feed_cat')");
- $class = ($lnum % 2) ? "even" : "odd";
+ } else {
- $feed_id = $line["id"];
+ print "<div class=\"warning\">
+ Category <b>$feed_cat</b> already exists in the database.
+ </div>";
+ }
- $edit_feed_id = $_GET["id"];
- if ($subop == "edit" && $feed_id != $edit_feed_id) {
- $class .= "Grayed";
}
+ }
- print "<tr class=\"$class\" id=\"FEEDR-$feed_id\">";
-
- $icon_file = ICONS_DIR . "/$feed_id.ico";
-
- if (file_exists($icon_file) && filesize($icon_file) > 0) {
- $feed_icon = "<img width=\"16\" height=\"16\"
- src=\"" . ICONS_URL . "/$feed_id.ico\">";
- } else {
- $feed_icon = " ";
- }
- print "<td align='center'>$feed_icon</td>";
+ if ($subop == "removeCats") {
- $edit_title = htmlspecialchars(db_unescape_string($line["title"]));
- $edit_link = htmlspecialchars(db_unescape_string($line["feed_url"]));
+ if (!WEB_DEMO_MODE) {
- if (!$edit_feed_id || $subop != "edit") {
+ $ids = split(",", $_GET["ids"]);
- print "<td><input onclick='toggleSelectRow(this);'
- type=\"checkbox\" id=\"FRCHK-".$line["id"]."\"></td>";
+ foreach ($ids as $id) {
- print "<td><a href=\"javascript:editFeed($feed_id);\">" .
- $edit_title . "</a></td>";
- print "<td><a href=\"javascript:editFeed($feed_id);\">" .
- $edit_link . "</a></td>";
+ db_query($link, "BEGIN");
- if ($line["update_interval"] == "0")
- $line["update_interval"] = "Default";
+ $result = db_query($link,
+ "SELECT count(id) as num_feeds FROM ttrss_feeds
+ WHERE cat_id = '$id'");
- print "<td><a href=\"javascript:editFeed($feed_id);\">" .
- $line["update_interval"] . "</a></td>";
+ $num_feeds = db_fetch_result($result, 0, "num_feeds");
- if ($line["purge_interval"] == "0")
- $line["purge_interval"] = "Default";
+ if ($num_feeds == 0) {
+ db_query($link, "DELETE FROM ttrss_feed_categories
+ WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
+ } else {
- if ($line["purge_interval"] < 0)
- $line["purge_interval"] = "Disabled";
+ print "<div class=\"warning\">
+ Unable to delete non empty feed categories.</div>";
+
+ }
- print "<td><a href=\"javascript:editFeed($feed_id);\">" .
- $line["purge_interval"] . "</a></td>";
+ db_query($link, "COMMIT");
+ }
+ }
+ }
- } else if ($feed_id != $edit_feed_id) {
+// print "<h3>Edit Feeds</h3>";
- print "<td><input disabled=\"true\" type=\"checkbox\"
- id=\"FRCHK-".$line["id"]."\"></td>";
+ $result = db_query($link, "SELECT id,title,feed_url,last_error
+ FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
- print "<td>$edit_title</td>";
- print "<td>$edit_link</td>";
+ if (db_num_rows($result) > 0) {
+
+ print "<div class=\"warning\">";
+
+ print "<b>Feeds with update errors:</b>";
- if ($line["update_interval"] == "0")
- $line["update_interval"] = "Default";
+ print "<ul class=\"nomarks\">";
+
+ while ($line = db_fetch_assoc($result)) {
+ print "<li>" . $line["title"] . " (" . $line["feed_url"] . "): " .
+ $line["last_error"];
+ }
- print "<td>" . $line["update_interval"] . "</td>";
+ print "</ul>";
+ print "</div>";
- if ($line["purge_interval"] == "0")
- $line["purge_interval"] = "Default";
+ }
- if ($line["purge_interval"] < 0)
- $line["purge_interval"] = "Disabled";
+ print "<p><div class=\"prefGenericAddBox\">
+ <input id=\"fadd_link\" size=\"40\"> <input
+ type=\"submit\" class=\"button\"
+ onclick=\"javascript:addFeed()\" value=\"Add feed\"></div>";
- print "<td>" . $line["purge_interval"] . "</td>";
+ $feeds_sort = db_escape_string($_GET["sort"]);
- } else {
+ if (!$feeds_sort || $feeds_sort == "undefined") {
+ $feeds_sort = $_SESSION["pref_sort_feeds"];
+ if (!$feeds_sort) $feeds_sort = "title";
+ }
- print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>";
+ $_SESSION["pref_sort_feeds"] = $feeds_sort;
- print "<td><input id=\"iedit_title\" value=\"$edit_title\"></td>";
- print "<td><input id=\"iedit_link\" value=\"$edit_link\"></td>";
- print "<td><input id=\"iedit_updintl\" value=\"".$line["update_interval"]."\"></td>";
- print "<td><input id=\"iedit_purgintl\" value=\"".$line["purge_interval"]."\"></td>";
-
+ $result = db_query($link, "SELECT
+ id,title,feed_url,substring(last_updated,1,16) as last_updated,
+ update_interval,purge_interval,
+ (SELECT title FROM ttrss_feed_categories
+ WHERE id = cat_id) AS category
+ FROM
+ ttrss_feeds WHERE owner_uid = '".$_SESSION["uid"]."'
+ ORDER by $feeds_sort,title");
+
+ if (db_num_rows($result) != 0) {
+
+ print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>";
+
+ print "<p><table width=\"100%\" class=\"prefFeedList\" id=\"prefFeedList\">";
+ print "<tr><td class=\"selectPrompt\" colspan=\"8\">
+ Select:
+ <a href=\"javascript:selectTableRowsByIdPrefix('prefFeedList',
+ 'FEEDR-', 'FRCHK-', true)\">All</a>,
+ <a href=\"javascript:selectTableRowsByIdPrefix('prefFeedList',
+ 'FEEDR-', 'FRCHK-', false)\">None</a>
+ </td</tr>";
+
+ print "<tr class=\"title\">
+ <td width=\"3%\"> </td>
+ <td width=\"3%\">Select</td>
+ <td width=\"20%\">
+ <a href=\"javascript:updateFeedList('title')\">Title</a></td>
+ <td width=\"20%\">
+ <a href=\"javascript:updateFeedList('feed_url')\">Link</a>
+ </td>";
+
+ if (get_pref($link, 'ENABLE_FEED_CATS')) {
+ print "<td width=\"10%\">
+ <a href=\"javascript:updateFeedList('category')\">Category</a></td>";
}
-
- if (!$line["last_updated"]) $line["last_updated"] = "Never";
-
- print "<td>" . $line["last_updated"] . "</td>";
- print "</tr>";
-
- ++$lnum;
- }
-
- if ($lnum == 0) {
- print "<tr><td colspan=\"5\" align=\"center\">No feeds defined.</td></tr>";
- }
+ print "
+ <td width=\"10%\">
+ <a href=\"javascript:updateFeedList('update_interval')\">Update Interval</a>
+ </td>
+ <td width=\"10%\">
+ <a href=\"javascript:updateFeedList('purge_interval')\">Purge Days</a>
+ </td>
+ </tr>";
+
+ $lnum = 0;
+
+ while ($line = db_fetch_assoc($result)) {
+
+ $class = ($lnum % 2) ? "even" : "odd";
+
+ $feed_id = $line["id"];
+
+ $edit_feed_id = $_GET["id"];
+
+ if ($subop == "edit" && $feed_id != $edit_feed_id) {
+ $class .= "Grayed";
+ $this_row_id = "";
+ } else {
+ $this_row_id = "id=\"FEEDR-$feed_id\"";
+ }
+
+ print "<tr class=\"$class\" $this_row_id>";
+
+ $icon_file = ICONS_DIR . "/$feed_id.ico";
+
+ if (file_exists($icon_file) && filesize($icon_file) > 0) {
+ $feed_icon = "<img width=\"16\" height=\"16\"
+ src=\"" . ICONS_URL . "/$feed_id.ico\">";
+ } else {
+ $feed_icon = " ";
+ }
+ print "<td align='center'>$feed_icon</td>";
+
+ $edit_title = htmlspecialchars(db_unescape_string($line["title"]));
+ $edit_link = htmlspecialchars(db_unescape_string($line["feed_url"]));
+ $edit_cat = htmlspecialchars(db_unescape_string($line["category"]));
+
+ if (!$edit_cat) $edit_cat = "Uncategorized";
+
+ if (!$edit_feed_id || $subop != "edit") {
+
+ print "<td><input onclick='toggleSelectRow(this);'
+ type=\"checkbox\" id=\"FRCHK-".$line["id"]."\"></td>";
- print "</table>";
+ $edit_title = truncate_string($edit_title, 40);
+ $edit_link = truncate_string($edit_link, 60);
+
+ print "<td><a href=\"javascript:editFeed($feed_id);\">" .
+ $edit_title . "</a></td>";
+
+ print "<td><a href=\"javascript:editFeed($feed_id);\">" .
+ $edit_link . "</a></td>";
+
+ if (get_pref($link, 'ENABLE_FEED_CATS')) {
+ print "<td><a href=\"javascript:editFeed($feed_id);\">" .
+ $edit_cat . "</a></td>";
+ }
+
+ if ($line["update_interval"] == "0")
+ $line["update_interval"] = "Default";
+
+ print "<td><a href=\"javascript:editFeed($feed_id);\">" .
+ $line["update_interval"] . "</a></td>";
+
+ if ($line["purge_interval"] == "0")
+ $line["purge_interval"] = "Default";
+
+ if ($line["purge_interval"] < 0)
+ $line["purge_interval"] = "Disabled";
+
+ print "<td><a href=\"javascript:editFeed($feed_id);\">" .
+ $line["purge_interval"] . "</a></td>";
+
+ } else if ($feed_id != $edit_feed_id) {
+
+ print "<td><input disabled=\"true\" type=\"checkbox\"
+ id=\"FRCHK-".$line["id"]."\"></td>";
- print "<p>";
+ $edit_title = truncate_string($edit_title, 40);
+ $edit_link = truncate_string($edit_link, 60);
- if ($subop == "edit") {
- print "Edit feed:
- <input type=\"submit\" class=\"button\"
- onclick=\"javascript:feedEditCancel()\" value=\"Cancel\">
- <input type=\"submit\" class=\"button\"
- onclick=\"javascript:feedEditSave()\" value=\"Save\">";
- } else {
+ print "<td>$edit_title</td>";
+ print "<td>$edit_link</td>";
+
+ if (get_pref($link, 'ENABLE_FEED_CATS')) {
+ print "<td>$edit_cat</td>";
+ }
+
+ if ($line["update_interval"] == "0")
+ $line["update_interval"] = "Default";
+
+ print "<td>" . $line["update_interval"] . "</td>";
+
+ if ($line["purge_interval"] == "0")
+ $line["purge_interval"] = "Default";
+
+ if ($line["purge_interval"] < 0)
+ $line["purge_interval"] = "Disabled";
+
+ print "<td>" . $line["purge_interval"] . "</td>";
+
+ } else {
+
+ print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>";
+
+ print "<td><input id=\"iedit_title\" value=\"$edit_title\"></td>";
+ print "<td><input id=\"iedit_link\" value=\"$edit_link\"></td>";
+
+ if (get_pref($link, 'ENABLE_FEED_CATS')) {
+
+ print "<td>";
+ print "<select id=\"iedit_fcat\">";
+ print "<option id=\"0\">Uncategorized</option>";
+
+ $tmp_result = db_query($link, "SELECT id,title FROM ttrss_feed_categories
+ WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
+
+ if (db_num_rows($tmp_result) > 0) {
+ print "<option disabled>--------</option>";
+ }
- print "
- Selection:
- <input type=\"submit\" class=\"button\"
- onclick=\"javascript:selectedFeedDetails()\" value=\"Details\">
- <input type=\"submit\" class=\"button\"
- onclick=\"javascript:editSelectedFeed()\" value=\"Edit\">
- <input type=\"submit\" class=\"button\"
- onclick=\"javascript:removeSelectedFeeds()\" value=\"Remove\">";
+ while ($tmp_line = db_fetch_assoc($tmp_result)) {
+ if ($tmp_line["id"] == $line["cat_id"]) {
+ $is_selected = "selected";
+ } else {
+ $is_selected = "";
+ }
+ printf("<option $is_selected id='%d'>%s</option>",
+ $tmp_line["id"], $tmp_line["title"]);
+ }
+
+ print "</select></td>";
+ print "</td>";
+
+ }
+
+ print "<td><input id=\"iedit_updintl\"
+ value=\"".$line["update_interval"]."\"></td>";
+ print "<td><input id=\"iedit_purgintl\"
+ value=\"".$line["purge_interval"]."\"></td>";
+
+ }
+
+/* if (!$line["last_updated"]) $line["last_updated"] = "Never";
+
+ print "<td>" . $line["last_updated"] . "</td>"; */
- if (get_pref($link, 'ENABLE_PREFS_CATCHUP_UNCATCHUP')) {
+ print "</tr>";
+
+ ++$lnum;
+ }
+
+ print "</table>";
+
+ print "<p>";
+
+ if ($subop == "edit") {
+ print "Edit feed:
+ <input type=\"submit\" class=\"button\"
+ onclick=\"javascript:feedEditCancel()\" value=\"Cancel\">
+ <input type=\"submit\" class=\"button\"
+ onclick=\"javascript:feedEditSave()\" value=\"Save\">";
+ } else {
+
print "
+ Selection:
<input type=\"submit\" class=\"button\"
- onclick=\"javascript:readSelectedFeeds()\" value=\"Mark as read\">
+ onclick=\"javascript:selectedFeedDetails()\" value=\"Details\">
<input type=\"submit\" class=\"button\"
- onclick=\"javascript:unreadSelectedFeeds()\" value=\"Mark as unread\"> ";
- }
- print "
- All feeds:
- <input type=\"submit\"
- class=\"button\" onclick=\"gotoExportOpml()\" value=\"Export OPML\">";
+ onclick=\"javascript:editSelectedFeed()\" value=\"Edit\">
+ <input type=\"submit\" class=\"button\"
+ onclick=\"javascript:removeSelectedFeeds()\" value=\"Remove\">";
+
+ if (get_pref($link, 'ENABLE_PREFS_CATCHUP_UNCATCHUP')) {
+ print "
+ <input type=\"submit\" class=\"button\"
+ onclick=\"javascript:readSelectedFeeds(true)\" value=\"Mark as read\">
+ <input type=\"submit\" class=\"button\"
+ onclick=\"javascript:readSelectedFeeds(false)\"
+ value=\"Mark as unread\"> ";
+ }
+
+ print "
+ All feeds: <input type=\"submit\"
+ class=\"button\" onclick=\"gotoExportOpml()\"
+ value=\"Export OPML\">";
+ }
+ } else {
+
+ print "<p>No feeds defined.</p>";
+
+ }
+
+ if (get_pref($link, 'ENABLE_FEED_CATS')) {
+
+ print "<h3>Edit Categories</h3>";
+
+ // print "<h3>Categories</h3>";
+
+ print "<div class=\"prefGenericAddBox\">
+ <input id=\"fadd_cat\" size=\"40\"> <input
+ type=\"submit\" class=\"button\"
+ onclick=\"javascript:addFeedCat()\" value=\"Add category\"></div>";
+
+ $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories
+ WHERE owner_uid = ".$_SESSION["uid"]."
+ ORDER BY title");
+
+ if (db_num_rows($result) != 0) {
+
+ print "<p><table width=\"100%\" class=\"prefFeedCatList\"
+ id=\"prefFeedCatList\">";
+
+ print "<tr><td class=\"selectPrompt\" colspan=\"8\">
+ Select:
+ <a href=\"javascript:selectTableRowsByIdPrefix('prefFeedCatList',
+ 'FCATR-', 'FCCHK-', true)\">All</a>,
+ <a href=\"javascript:selectTableRowsByIdPrefix('prefFeedCatList',
+ 'FCATR-', 'FCCHK-', false)\">None</a>
+ </td</tr>";
+
+ print "<tr class=\"title\">
+ <td width=\"10%\">Select</td><td width=\"80%\">Title</td>
+ </tr>";
+
+ $lnum = 0;
+
+ while ($line = db_fetch_assoc($result)) {
- }
+ $class = ($lnum % 2) ? "even" : "odd";
+
+ $cat_id = $line["id"];
+
+ $edit_cat_id = $_GET["id"];
+
+ if ($subop == "editCat" && $cat_id != $edit_cat_id) {
+ $class .= "Grayed";
+ $this_row_id = "";
+ } else {
+ $this_row_id = "id=\"FCATR-$cat_id\"";
+ }
+
+ print "<tr class=\"$class\" $this_row_id>";
+
+ $edit_title = htmlspecialchars(db_unescape_string($line["title"]));
+
+ if (!$edit_cat_id || $subop != "editCat") {
+
+ print "<td><input onclick='toggleSelectRow(this);'
+ type=\"checkbox\" id=\"FCCHK-".$line["id"]."\"></td>";
+
+ print "<td><a href=\"javascript:editFeedCat($cat_id);\">" .
+ $edit_title . "</a></td>";
+
+ } else if ($cat_id != $edit_cat_id) {
+
+ print "<td><input disabled=\"true\" type=\"checkbox\"
+ id=\"FRCHK-".$line["id"]."\"></td>";
+
+ print "<td>$edit_title</td>";
+
+ } else {
+
+ print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>";
+
+ print "<td><input id=\"iedit_title\" value=\"$edit_title\"></td>";
+
+ }
+
+ print "</tr>";
+
+ ++$lnum;
+ }
+
+ print "</table>";
+
+ print "<p>";
+
+ if ($subop == "editCat") {
+ print "Edit category:
+ <input type=\"submit\" class=\"button\"
+ onclick=\"javascript:feedCatEditCancel()\" value=\"Cancel\">
+ <input type=\"submit\" class=\"button\"
+ onclick=\"javascript:feedCatEditSave()\" value=\"Save\">";
+ } else {
+
+ print "
+ Selection:
+ <input type=\"submit\" class=\"button\"
+ onclick=\"javascript:editSelectedFeedCat()\" value=\"Edit\">
+ <input type=\"submit\" class=\"button\"
+ onclick=\"javascript:removeSelectedFeedCats()\" value=\"Remove\">";
+
+ }
+
+ } else {
+ print "<p>No feed categories defined.</p>";
+ }
+ }
- print "<h3>OPML Import</h3>
+ print "<h3>Import OPML</h3>
<form enctype=\"multipart/form-data\" method=\"POST\" action=\"opml.php\">
File: <input id=\"opml_file\" name=\"opml_file\" type=\"file\">
<input class=\"button\" name=\"op\" onclick=\"return validateOpmlImport();\"
$descr = db_escape_string($_GET["d"]);
$match = db_escape_string($_GET["m"]);
$filter_id = db_escape_string($_GET["id"]);
+ $feed_id = db_escape_string($_GET["fid"]);
+
+ if (!$feed_id) {
+ $feed_id = 'NULL';
+ } else {
+ $feed_id = sprintf("'%s'", db_escape_string($feed_id));
+ }
$result = db_query($link, "UPDATE ttrss_filters SET
reg_exp = '$regexp',
description = '$descr',
+ feed_id = $feed_id,
filter_type = (SELECT id FROM ttrss_filter_types WHERE
description = '$match')
WHERE id = '$filter_id'");
$regexp = db_escape_string(trim($_GET["regexp"]));
$match = db_escape_string(trim($_GET["match"]));
+ $feed_id = db_escape_string($_GET["fid"]);
+
+ if (!$feed_id) {
+ $feed_id = 'NULL';
+ } else {
+ $feed_id = sprintf("'%s'", db_escape_string($feed_id));
+ }
$result = db_query($link,
- "INSERT INTO ttrss_filters (reg_exp,filter_type,owner_uid) VALUES
+ "INSERT INTO ttrss_filters (reg_exp,filter_type,owner_uid,feed_id) VALUES
('$regexp', (SELECT id FROM ttrss_filter_types WHERE
- description = '$match'),'".$_SESSION["uid"]."')");
+ description = '$match'),'".$_SESSION["uid"]."', $feed_id)");
}
}
array_push($filter_types, $line["description"]);
}
- print "<table class=\"prefAddFeed\"><tr>
- <td><input id=\"fadd_regexp\"></td>
- <td>";
- print_select("fadd_match", "Title", $filter_types);
-
- print"</td><td colspan=\"4\" align=\"right\">
- <a class=\"button\" href=\"javascript:addFilter()\">Add filter</a></td></tr>
- </table>";
+ print "<div class=\"prefGenericAddBox\">
+ <input id=\"fadd_regexp\" size=\"40\"> ";
+
+ print_select("fadd_match", "Title", $filter_types);
- $result = db_query($link, "SELECT
- id,reg_exp,description,
- (SELECT name FROM ttrss_filter_types WHERE
- id = filter_type) as filter_type_name,
- (SELECT description FROM ttrss_filter_types
- WHERE id = filter_type) as filter_type_descr
- FROM
- ttrss_filters
- WHERE
- owner_uid = ".$_SESSION["uid"]."
- ORDER by reg_exp");
+ print " <select id=\"fadd_feed\">";
- print "<p><table width=\"100%\" class=\"prefFilterList\" id=\"prefFilterList\">";
+ print "<option selected id=\"0\">All feeds</option>";
- print "<tr class=\"title\">
- <td width=\"5%\">Select</td><td width=\"40%\">Filter expression</td>
- <td width=\"40%\">Description</td><td width=\"10%\">Match</td></tr>";
-
- $lnum = 0;
-
- while ($line = db_fetch_assoc($result)) {
+ $result = db_query($link, "SELECT id,title FROM ttrss_feeds
+ WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
- $class = ($lnum % 2) ? "even" : "odd";
+ if (db_num_rows($result) > 0) {
+ print "<option disabled>--------</option>";
+ }
- $filter_id = $line["id"];
- $edit_filter_id = $_GET["id"];
+ while ($line = db_fetch_assoc($result)) {
+ printf("<option id='%d'>%s</option>", $line["id"], $line["title"]);
+ }
- if ($subop == "edit" && $filter_id != $edit_filter_id) {
- $class .= "Grayed";
- }
+ print "</select> ";
+
+ print "<input type=\"submit\"
+ class=\"button\" onclick=\"javascript:addFilter()\"
+ value=\"Add filter\">";
- print "<tr class=\"$class\" id=\"FILRR-$filter_id\">";
+ $result = db_query($link, "SELECT
+ ttrss_filters.id AS id,reg_exp,
+ ttrss_filters.description AS description,
+ ttrss_filter_types.name AS filter_type_name,
+ ttrss_filter_types.description AS filter_type_descr,
+ feed_id,
+ (SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title
+ FROM
+ ttrss_filters,ttrss_filter_types
+ WHERE
+ filter_type = ttrss_filter_types.id AND
+ ttrss_filters.owner_uid = ".$_SESSION["uid"]."
+ ORDER by reg_exp");
- $line["regexp"] = htmlspecialchars($line["reg_exp"]);
- $line["description"] = htmlspecialchars($line["description"]);
+ if (db_num_rows($result) != 0) {
- if (!$edit_filter_id || $subop != "edit") {
+ print "<p><table width=\"100%\" class=\"prefFilterList\" id=\"prefFilterList\">";
- if (!$line["description"]) $line["description"] = "[No description]";
+ print "<tr><td class=\"selectPrompt\" colspan=\"8\">
+ Select:
+ <a href=\"javascript:selectTableRowsByIdPrefix('prefFilterList',
+ 'FILRR-', 'FICHK-', true)\">All</a>,
+ <a href=\"javascript:selectTableRowsByIdPrefix('prefFilterList',
+ 'FILRR-', 'FICHK-', false)\">None</a>
+ </td</tr>";
- print "<td><input onclick='toggleSelectRow(this);'
- type=\"checkbox\" id=\"FICHK-".$line["id"]."\"></td>";
+ print "<tr class=\"title\">
+ <td width=\"5%\">Select</td><td width=\"30%\">Filter expression</td>
+ <td width=\"30%\">Feed</td><td width=\"10%\">Match</td>
+ <td width=\"30%\">Description</td></tr>";
+
+ $lnum = 0;
+
+ while ($line = db_fetch_assoc($result)) {
+
+ $class = ($lnum % 2) ? "even" : "odd";
+
+ $filter_id = $line["id"];
+ $edit_filter_id = $_GET["id"];
+
+ if ($subop == "edit" && $filter_id != $edit_filter_id) {
+ $class .= "Grayed";
+ $this_row_id = "";
+ } else {
+ $this_row_id = "id=\"FILRR-$filter_id\"";
+ }
+
+ print "<tr class=\"$class\" $this_row_id>";
+
+ $line["regexp"] = htmlspecialchars($line["reg_exp"]);
+ $line["description"] = htmlspecialchars($line["description"]);
+
+ if (!$line["feed_title"]) $line["feed_title"] = "All feeds";
+
+ if (!$edit_filter_id || $subop != "edit") {
+
+ if (!$line["description"]) $line["description"] = "[No description]";
+
+ print "<td><input onclick='toggleSelectRow(this);'
+ type=\"checkbox\" id=\"FICHK-".$line["id"]."\"></td>";
+
+ print "<td><a href=\"javascript:editFilter($filter_id);\">" .
+ $line["reg_exp"] . "</td>";
+
+ print "<td><a href=\"javascript:editFilter($filter_id);\">" .
+ $line["feed_title"] . "</td>";
+
+ print "<td><a href=\"javascript:editFilter($filter_id);\">" .
+ $line["filter_type_descr"] . "</td>";
+
+ print "<td><a href=\"javascript:editFilter($filter_id);\">" .
+ $line["description"] . "</td>";
+
+ } else if ($filter_id != $edit_filter_id) {
+
+ if (!$line["description"]) $line["description"] = "[No description]";
+
+ print "<td><input disabled=\"true\" type=\"checkbox\"
+ id=\"FICHK-".$line["id"]."\"></td>";
+
+ print "<td>".$line["reg_exp"]."</td>";
+ print "<td>".$line["feed_title"]."</td>";
+ print "<td>".$line["filter_type_descr"]."</td>";
+ print "<td>".$line["description"]."</td>";
+
+ } else {
+
+ print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>";
+
+ print "<td><input id=\"iedit_regexp\" value=\"".$line["reg_exp"].
+ "\"></td>";
+
+ print "<td>";
+
+ print "<select id=\"iedit_feed\">";
+
+ print "<option id=\"0\">All feeds</option>";
+
+ if (db_num_rows($result) > 0) {
+ print "<option disabled>--------</option>";
+ }
+
+ $tmp_result = db_query($link, "SELECT id,title FROM ttrss_feeds
+ WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
+
+ while ($tmp_line = db_fetch_assoc($tmp_result)) {
+ if ($tmp_line["id"] == $line["feed_id"]) {
+ $is_selected = "selected";
+ } else {
+ $is_selected = "";
+ }
+ printf("<option $is_selected id='%d'>%s</option>",
+ $tmp_line["id"], $tmp_line["title"]);
+ }
+
+ print "</select></td>";
+
+ print "<td>";
+ print_select("iedit_match", $line["filter_type_descr"], $filter_types);
+ print "</td>";
+
+ print "<td><input id=\"iedit_descr\" value=\"".$line["description"].
+ "\"></td>";
+
+ print "</td>";
+ }
+
+ print "</tr>";
+
+ ++$lnum;
+ }
+
+ if ($lnum == 0) {
+ print "<tr><td colspan=\"4\" align=\"center\">No filters defined.</td></tr>";
+ }
+
+ print "</table>";
+
+ print "<p>";
+
+ if ($subop == "edit") {
+ print "Edit feed:
+ <input type=\"submit\" class=\"button\"
+ onclick=\"javascript:filterEditCancel()\" value=\"Cancel\">
+ <input type=\"submit\" class=\"button\"
+ onclick=\"javascript:filterEditSave()\" value=\"Save\">";
+
+ } else {
+
+ print "
+ Selection:
+ <input type=\"submit\" class=\"button\"
+ onclick=\"javascript:editSelectedFilter()\" value=\"Edit\">
+ <input type=\"submit\" class=\"button\"
+ onclick=\"javascript:removeSelectedFilters()\" value=\"Remove\">";
+ }
- print "<td><a href=\"javascript:editFilter($filter_id);\">" .
- $line["reg_exp"] . "</td>";
-
- print "<td><a href=\"javascript:editFilter($filter_id);\">" .
- $line["description"] . "</td>";
+ } else {
- print "<td>".$line["filter_type_descr"]."</td>";
+ print "<p>No filters defined.</p>";
- } else if ($filter_id != $edit_filter_id) {
+ }
+ }
- if (!$line["description"]) $line["description"] = "[No description]";
+ if ($op == "pref-labels") {
- print "<td><input disabled=\"true\" type=\"checkbox\"
- id=\"FICHK-".$line["id"]."\"></td>";
+ $subop = $_GET["subop"];
- print "<td>".$line["reg_exp"]."</td>";
- print "<td>".$line["description"]."</td>";
- print "<td>".$line["filter_type_descr"]."</td>";
+ if ($subop == "test") {
- } else {
+ $expr = $_GET["expr"];
+ $descr = $_GET["descr"];
- print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>";
+ print "<div class='infoBoxContents'>";
+
+ print "<h1>Label «$descr»</h1>";
- print "<td><input id=\"iedit_regexp\" value=\"".$line["reg_exp"].
- "\"></td>";
+// print "<p><b>Expression</b>: $expr</p>";
- print "<td><input id=\"iedit_descr\" value=\"".$line["description"].
- "\"></td>";
+ $result = db_query($link,
+ "SELECT count(id) AS num_matches
+ FROM ttrss_entries,ttrss_user_entries
+ WHERE ($expr) AND
+ ttrss_user_entries.ref_id = ttrss_entries.id AND
+ owner_uid = " . $_SESSION["uid"]);
- print "<td>";
- print_select("iedit_match", $line["filter_type_descr"], $filter_types);
- print "</td>";
-
- }
-
+ $num_matches = db_fetch_result($result, 0, "num_matches");;
- print "</tr>";
+ if ($num_matches > 0) {
- ++$lnum;
- }
+ print "<p>Query returned <b>$num_matches</b> matches, first 5 follow:</p>";
- if ($lnum == 0) {
- print "<tr><td colspan=\"4\" align=\"center\">No filters defined.</td></tr>";
- }
+ $result = db_query($link,
+ "SELECT title,
+ (SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title
+ FROM ttrss_entries,ttrss_user_entries
+ WHERE ($expr) AND
+ ttrss_user_entries.ref_id = ttrss_entries.id
+ AND owner_uid = " . $_SESSION["uid"] . "
+ ORDER BY date_entered DESC LIMIT 5");
- print "</table>";
+ print "<ul class=\"nomarks\">";
+ while ($line = db_fetch_assoc($result)) {
+ print "<li>".$line["title"].
+ " <span class=\"insensitive\">(".$line["feed_title"].")</span></li>";
+ }
+ print "</ul>";
- print "<p>";
+ } else {
+ print "<p>Query didn't return any matches.</p>";
+ }
- if ($subop == "edit") {
- print "Edit feed:
- <input type=\"submit\" class=\"button\"
- onclick=\"javascript:filterEditCancel()\" value=\"Cancel\">
- <input type=\"submit\" class=\"button\"
- onclick=\"javascript:filterEditSave()\" value=\"Save\">";
-
- } else {
+ print "</div>";
- print "
- Selection:
- <input type=\"submit\" class=\"button\"
- onclick=\"javascript:editSelectedFilter()\" value=\"Edit\">
- <input type=\"submit\" class=\"button\"
- onclick=\"javascript:removeSelectedFilters()\" value=\"Remove\">";
+ print "<div align='center'>
+ <input type='submit' class='button'
+ onclick=\"closeInfoBox()\" value=\"Close this window\"></div>";
+ return;
}
- }
-
- if ($op == "pref-labels") {
-
- $subop = $_GET["subop"];
if ($subop == "editSave") {
}
}
- print "<table class=\"prefAddFeed\"><tr>
- <td><input id=\"ladd_expr\"></td>";
+ print "<div class=\"prefGenericAddBox\">
+ <input size=\"40\" id=\"ladd_expr\"> ";
- print"<td colspan=\"4\" align=\"right\">
- <a class=\"button\" href=\"javascript:addLabel()\">Add label</a></td></tr>
- </table>";
+ print"<input type=\"submit\" class=\"button\"
+ onclick=\"javascript:addLabel()\" value=\"Add label\"></div>";
$result = db_query($link, "SELECT
id,sql_exp,description
owner_uid = ".$_SESSION["uid"]."
ORDER by description");
- print "<p><table width=\"100%\" class=\"prefLabelList\" id=\"prefLabelList\">";
-
- print "<tr class=\"title\">
- <td width=\"5%\">Select</td><td width=\"40%\">SQL expression
- <a class=\"helpLink\" href=\"javascript:popupHelp(1)\">(?)</a>
- </td>
- <td width=\"40%\">Caption</td></tr>";
-
- $lnum = 0;
-
- while ($line = db_fetch_assoc($result)) {
-
- $class = ($lnum % 2) ? "even" : "odd";
-
- $label_id = $line["id"];
- $edit_label_id = $_GET["id"];
-
- if ($subop == "edit" && $label_id != $edit_label_id) {
- $class .= "Grayed";
- }
-
- print "<tr class=\"$class\" id=\"LILRR-$label_id\">";
-
- $line["sql_exp"] = htmlspecialchars($line["sql_exp"]);
- $line["description"] = htmlspecialchars($line["description"]);
-
- if (!$edit_label_id || $subop != "edit") {
-
- if (!$line["description"]) $line["description"] = "[No caption]";
-
- print "<td><input onclick='toggleSelectRow(this);'
- type=\"checkbox\" id=\"LICHK-".$line["id"]."\"></td>";
-
- print "<td><a href=\"javascript:editLabel($label_id);\">" .
- $line["sql_exp"] . "</td>";
-
- print "<td><a href=\"javascript:editLabel($label_id);\">" .
- $line["description"] . "</td>";
+ print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>";
- } else if ($label_id != $edit_label_id) {
+ if (db_num_rows($result) != 0) {
- if (!$line["description"]) $line["description"] = "[No description]";
+ print "<p><table width=\"100%\" class=\"prefLabelList\" id=\"prefLabelList\">";
- print "<td><input disabled=\"true\" type=\"checkbox\"
- id=\"LICHK-".$line["id"]."\"></td>";
-
- print "<td>".$line["sql_exp"]."</td>";
- print "<td>".$line["description"]."</td>";
-
- } else {
+ print "<tr><td class=\"selectPrompt\" colspan=\"8\">
+ Select:
+ <a href=\"javascript:selectTableRowsByIdPrefix('prefLabelList',
+ 'LILRR-', 'LICHK-', true)\">All</a>,
+ <a href=\"javascript:selectTableRowsByIdPrefix('prefLabelList',
+ 'LILRR-', 'LICHK-', false)\">None</a>
+ </td</tr>";
- print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>";
-
- print "<td><input id=\"iedit_expr\" value=\"".$line["sql_exp"].
- "\"></td>";
-
- print "<td><input id=\"iedit_descr\" value=\"".$line["description"].
- "\"></td>";
+ print "<tr class=\"title\">
+ <td width=\"5%\">Select</td><td width=\"40%\">SQL expression
+ <a class=\"helpLink\" href=\"javascript:displayHelpInfobox(1)\">(?)</a>
+ </td>
+ <td width=\"40%\">Caption</td></tr>";
+
+ $lnum = 0;
+
+ while ($line = db_fetch_assoc($result)) {
+
+ $class = ($lnum % 2) ? "even" : "odd";
+
+ $label_id = $line["id"];
+ $edit_label_id = $_GET["id"];
+
+ if ($subop == "edit" && $label_id != $edit_label_id) {
+ $class .= "Grayed";
+ $this_row_id = "";
+ } else {
+ $this_row_id = "id=\"LILRR-$label_id\"";
+ }
+
+ print "<tr class=\"$class\" $this_row_id>";
+
+ $line["sql_exp"] = htmlspecialchars($line["sql_exp"]);
+ $line["description"] = htmlspecialchars($line["description"]);
+
+ if (!$edit_label_id || $subop != "edit") {
+
+ if (!$line["description"]) $line["description"] = "[No caption]";
+
+ print "<td><input onclick='toggleSelectRow(this);'
+ type=\"checkbox\" id=\"LICHK-".$line["id"]."\"></td>";
+
+ print "<td><a href=\"javascript:editLabel($label_id);\">" .
+ $line["sql_exp"] . "</td>";
- }
+ print "<td><a href=\"javascript:editLabel($label_id);\">" .
+ $line["description"] . "</td>";
+
+ } else if ($label_id != $edit_label_id) {
+
+ if (!$line["description"]) $line["description"] = "[No description]";
+
+ print "<td><input disabled=\"true\" type=\"checkbox\"
+ id=\"LICHK-".$line["id"]."\"></td>";
+
+ print "<td>".$line["sql_exp"]."</td>";
+ print "<td>".$line["description"]."</td>";
+
+ } else {
+
+ print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>";
+
+ print "<td><input id=\"iedit_expr\" value=\"".$line["sql_exp"].
+ "\"></td>";
+
+ print "<td><input id=\"iedit_descr\" value=\"".$line["description"].
+ "\"></td>";
+
+ }
+
-
- print "</tr>";
-
- ++$lnum;
- }
-
- if ($lnum == 0) {
- print "<tr><td colspan=\"4\" align=\"center\">No labels defined.</td></tr>";
- }
-
- print "</table>";
-
- print "<p>";
-
- if ($subop == "edit") {
- print "Edit label:
+ print "</tr>";
+
+ ++$lnum;
+ }
+
+ if ($lnum == 0) {
+ print "<tr><td colspan=\"4\" align=\"center\">No labels defined.</td></tr>";
+ }
+
+ print "</table>";
+
+ print "<p>";
+
+ if ($subop == "edit") {
+ print "Edit label:
+ <input type=\"submit\" class=\"button\"
+ onclick=\"javascript:labelTest()\" value=\"Test\">
+ <input type=\"submit\" class=\"button\"
+ onclick=\"javascript:labelEditCancel()\" value=\"Cancel\">
+ <input type=\"submit\" class=\"button\"
+ onclick=\"javascript:labelEditSave()\" value=\"Save\">";
+
+ } else {
+
+ print "
+ Selection:
<input type=\"submit\" class=\"button\"
- onclick=\"javascript:labelEditCancel()\" value=\"Cancel\">
+ onclick=\"javascript:editSelectedLabel()\" value=\"Edit\">
<input type=\"submit\" class=\"button\"
- onclick=\"javascript:labelEditSave()\" value=\"Save\">";
-
+ onclick=\"javascript:removeSelectedLabels()\" value=\"Remove\">";
+ }
} else {
-
- print "
- Selection:
- <input type=\"submit\" class=\"button\"
- onclick=\"javascript:editSelectedLabel()\" value=\"Edit\">
- <input type=\"submit\" class=\"button\"
- onclick=\"javascript:removeSelectedLabels()\" value=\"Remove\">";
+ print "<p>No labels defined.</p>";
}
}
}
if ($op == "help") {
- print "<html><head>
- <title>Tiny Tiny RSS : Help</title>
- <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">
- <script type=\"text/javascript\" src=\"functions.js\"></script>
- <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
- </head><body>";
+ if (!$_GET["noheaders"]) {
+ print "<html><head>
+ <title>Tiny Tiny RSS : Help</title>
+ <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">
+ <script type=\"text/javascript\" src=\"functions.js\"></script>
+ <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
+ </head><body>";
+ }
$tid = sprintf("%d", $_GET["tid"]);
- /* FIXME this badly needs real implementation */
-
- print "<div class='helpResponse'>";
-
- ?>
-
- <h1>Help for SQL expressions</h1>
-
- <h2>Description</h2>
-
- <p>The «SQL expression» is added to WHERE clause of
- view feed query. You can match on ttrss_entries table fields
- and even use subselect to query additional information. This
- functionality is considered to be advanced and requires basic
- understanding of SQL.</p>
-
- <h2>Examples</h2>
-
- <pre>unread = true</pre>
-
- Matches all unread articles
-
- <pre>title like '%Linux%'</pre>
-
- Matches all articles which mention Linux in the title. You get the idea.
+ print "<div class='infoBoxContents'>";
- <p>See the database schema included in the distribution package for gruesome
- details.</p>
+ if (file_exists("help/$tid.php")) {
+ include("help/$tid.php");
+ } else {
+ print "<p>Help topic not found.</p>";
+ }
- <?
+ print "</div>";
print "<div align='center'>
- <a class=\"helpLink\"
- href=\"javascript:window.close()\">(Close this window)</a></div>";
-
- print "</div>";
+ <input type='submit' class='button'
+ onclick=\"closeInfoBox()\" value=\"Close this window\"></div>";
- print "</body></html>";
+ if (!$_GET["noheaders"]) {
+ print "</body></html>";
+ }
}
$param = $_GET["param"];
if ($id == "quickAddFeed") {
- print "Feed URL: <input
+ print "
+ Feed URL: <input
onblur=\"javascript:enableHotkeys()\" onfocus=\"javascript:disableHotkeys()\"
id=\"qafInput\">
<input class=\"button\"
$f_title = db_fetch_result($result, 0, "title");
- print "Remove current feed ($f_title)?
+ print "Remove current feed (<b>$f_title</b>)?
<input class=\"button\"
type=\"submit\" onclick=\"javascript:qfdDelete($param)\" value=\"Remove\">
<input class=\"button\"
}
- if ($op == "updateAllFeeds") {
- update_all_feeds($link, true);
+ // update feeds of all users, may be used anonymously
+ if ($op == "globalUpdateFeeds") {
- print "<rpc-reply>";
- getLabelCounters($link);
- getFeedCounters($link);
- getTagCounters($link);
- getGlobalCounters($link);
- print "</rpc-reply>";
+ $result = db_query($link, "SELECT id FROM ttrss_users");
+
+ while ($line = db_fetch_assoc($result)) {
+ $user_id = $line["id"];
+// print "<!-- updating feeds of uid $user_id -->";
+ update_all_feeds($link, false, $user_id);
+ }
+
+ print "<rpc-reply>
+ <message msg=\"All feeds updated\"/>
+ </rpc-reply>";
}
if ($subop == "Save configuration") {
- if (WEB_DEMO_MODE) return;
+ if (WEB_DEMO_MODE) {
+ header("Location: prefs.php");
+ return;
+ }
$_SESSION["prefs_op_result"] = "save-config";
} else if ($subop == "Change password") {
- if (WEB_DEMO_MODE) return;
+ if (WEB_DEMO_MODE) {
+ header("Location: prefs.php");
+ return;
+ }
$old_pw = $_POST["OLD_PASSWORD"];
$new_pw = $_POST["OLD_PASSWORD"];
} else if ($subop == "Reset to defaults") {
- if (WEB_DEMO_MODE) return;
+ if (WEB_DEMO_MODE) {
+ header("Location: prefs.php");
+ return;
+ }
$_SESSION["prefs_op_result"] = "reset-to-defaults";
header("Location: prefs.php");
+ } else if ($subop == "Change theme") {
+
+ $theme = db_escape_string($_POST["theme"]);
+
+ if ($theme == "Default") {
+ $theme_qpart = 'NULL';
+ } else {
+ $theme_qpart = "'$theme'";
+ }
+
+ $result = db_query($link, "SELECT id,theme_path FROM ttrss_themes
+ WHERE theme_name = '$theme'");
+
+ if (db_num_rows($result) == 1) {
+ $theme_id = db_fetch_result($result, 0, "id");
+ $theme_path = db_fetch_result($result, 0, "theme_path");
+ } else {
+ $theme_id = "NULL";
+ $theme_path = "";
+ }
+
+ db_query($link, "UPDATE ttrss_users SET
+ theme_id = $theme_id WHERE id = " . $_SESSION["uid"]);
+
+ $_SESSION["theme"] = $theme_path;
+
+ header("Location: prefs.php");
+
} else {
if (!SINGLE_USER_MODE) {
}
+ $result = db_query($link, "SELECT
+ theme_id FROM ttrss_users WHERE id = " . $_SESSION["uid"]);
+
+ $user_theme_id = db_fetch_result($result, 0, "theme_id");
+
+ $result = db_query($link, "SELECT
+ id,theme_name FROM ttrss_themes ORDER BY theme_name");
+
+ if (db_num_rows($result) > 0) {
+
+ print "<form action=\"backend.php\" method=\"POST\">";
+ print "<table width=\"100%\" class=\"prefPrefsList\">";
+ print "<tr><td colspan='3'><h3>Themes</h3></tr></td>";
+ print "<tr><td width=\"40%\">Select theme</td>";
+ print "<td><select name=\"theme\">";
+ print "<option>Default</option>";
+ print "<option disabled>--------</option>";
+
+ while ($line = db_fetch_assoc($result)) {
+ if ($line["id"] == $user_theme_id) {
+ $selected = "selected";
+ } else {
+ $selected = "";
+ }
+ print "<option $selected>" . $line["theme_name"] . "</option>";
+ }
+ print "</select></td></tr>";
+ print "</table>";
+ print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">";
+ print "<p><input class=\"button\" type=\"submit\"
+ value=\"Change theme\" name=\"subop\">";
+ print "</form>";
+ }
+
$result = db_query($link, "SELECT
ttrss_user_prefs.pref_name,short_desc,help_text,value,type_name,
section_name,def_value
}
}
- print "<table class=\"prefAddFeed\"><tr>
- <td><input id=\"uadd_box\"></td>";
+ print "<div class=\"prefGenericAddBox\">
+ <input id=\"uadd_box\" size=\"40\"> ";
- print"<td colspan=\"4\" align=\"right\">
- <a class=\"button\" href=\"javascript:addUser()\">Add user</a></td></tr>
- </table>";
+ print"<input type=\"submit\" class=\"button\"
+ onclick=\"javascript:addUser()\" value=\"Add user\"></div>";
$result = db_query($link, "SELECT
- id,login,access_level,last_login
+ id,login,access_level,
+ SUBSTRING(last_login,1,16) as last_login
FROM
ttrss_users
ORDER by login");
- print "<div id=\"infoBox\">PLACEHOLDER</div>";
+ print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>";
print "<p><table width=\"100%\" class=\"prefUserList\" id=\"prefUserList\">";
+ print "<tr><td class=\"selectPrompt\" colspan=\"8\">
+ Select:
+ <a href=\"javascript:selectTableRowsByIdPrefix('prefUserList',
+ 'UMRR-', 'UMCHK-', true)\">All</a>,
+ <a href=\"javascript:selectTableRowsByIdPrefix('prefUserList',
+ 'UMRR-', 'UMCHK-', false)\">None</a>
+ </td</tr>";
+
print "<tr class=\"title\">
<td width=\"5%\">Select</td>
<td width='30%'>Username</td>
if ($uid == $_SESSION["uid"] || ($subop == "edit" && $uid != $edit_uid)) {
$class .= "Grayed";
- }
-
- print "<tr class=\"$class\" id=\"UMRR-$uid\">";
+ $this_row_id = "";
+ } else {
+ $this_row_id = "id=\"UMRR-$uid\"";
+ }
+
+ print "<tr class=\"$class\" $this_row_id>";
$line["login"] = htmlspecialchars($line["login"]);
print "<div class='infoBoxContents'>";
- $result = db_query($link, "SELECT login,last_login,access_level,
+ $result = db_query($link, "SELECT login,
+ SUBSTRING(last_login,1,16) AS last_login,
+ access_level,
(SELECT COUNT(int_id) FROM ttrss_user_entries
WHERE owner_uid = id) AS stored_articles
FROM ttrss_users
if (file_exists($icon_file) && filesize($icon_file) > 0) {
$feed_icon = "<img class=\"tinyFeedIcon\" src=\"$icon_file\">";
} else {
- $feed_icon = "<img class=\"feedIcon\" src=\"images/blank_icon.gif\">";
+ $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
}
print "<li>$feed_icon <a href=\"".$line["feed_url"]."\">".$line["title"]."</a></li>";
$result = db_query($link,
"SELECT
- title,feed_url,last_updated,
+ title,feed_url,last_updated,icon_url,site_url,
(SELECT COUNT(int_id) FROM ttrss_user_entries
WHERE feed_id = id) AS total,
(SELECT COUNT(int_id) FROM ttrss_user_entries
$title = db_fetch_result($result, 0, "title");
$last_updated = db_fetch_result($result, 0, "last_updated");
$feed_url = db_fetch_result($result, 0, "feed_url");
+ $icon_url = db_fetch_result($result, 0, "icon_url");
$total = db_fetch_result($result, 0, "total");
$unread = db_fetch_result($result, 0, "unread");
$marked = db_fetch_result($result, 0, "marked");
+ $site_url = db_fetch_result($result, 0, "site_url");
+
+ $result = db_query($link, "SELECT COUNT(id) AS subscribed
+ FROM ttrss_feeds WHERE feed_url = '$feed_url'");
+
+ $subscribed = db_fetch_result($result, 0, "subscribed");
+
+ print "<div class=\"infoBoxContents\">";
+
+ $icon_file = ICONS_DIR . "/$feed_id.ico";
+
+ if (file_exists($icon_file) && filesize($icon_file) > 0) {
+ $feed_icon = "<img width=\"16\" height=\"16\"
+ src=\"" . ICONS_URL . "/$feed_id.ico\">";
+ } else {
+ $feed_icon = "";
+ }
- print "<div class=\"infoBoxContents\"><h1>$title</h1>";
+ print "<h1>$feed_icon $title</h1>";
print "<table width='100%'>";
- print "<tr><td>Feed URL</td><td><a href=\"$feed_url\">$feed_url</a></td></tr>";
+ if ($site_url) {
+ print "<tr><td width='30%'>Link</td>
+ <td><a href=\"$site_url\">$site_url</a>
+ <a href=\"$feed_url\">(feed)</a></td>
+ </td></tr>";
+ } else {
+ print "<tr><td width='30%'>Feed URL</td>
+ <td><a href=\"$feed_url\">$feed_url</a></td></tr>";
+ }
print "<tr><td>Last updated</td><td>$last_updated</td></tr>";
print "<tr><td>Total articles</td><td>$total</td></tr>";
print "<tr><td>Unread articles</td><td>$unread</td></tr>";
print "<tr><td>Starred articles</td><td>$marked</td></tr>";
+ print "<tr><td>Subscribed users</td><td>$subscribed</td></tr>";
print "</table>";
- print "</div>";
+ $result = db_query($link, "SELECT title,
+ SUBSTRING(updated,1,16) AS updated,unread
+ FROM ttrss_entries,ttrss_user_entries
+ WHERE ref_id = id AND feed_id = '$feed_id'
+ ORDER BY date_entered DESC LIMIT 5");
- print "<div align='center'>
- <input type='submit' class='button'
- onclick=\"closeInfoBox()\" value=\"Close this window\"></div>";
+ if (db_num_rows($result) > 0) {
+ print "<h1>Latest headlines</h1>";
+
+ print "<ul class=\"nomarks\">";
+
+ while ($line = db_fetch_assoc($result)) {
+ if ($line["unread"] == "t" || $line["unread"] == "1") {
+ $line["title"] = "<b>" . $line["title"] . "</b>";
+ }
+ print "<li>" . $line["title"].
+ " <span class=\"insensitive\">(" .$line["updated"].")</span></li>";
+ }
+
+ print "</ul>";
+
+ print "</div>";
+
+ print "<div align='center'>
+ <input type='submit' class='button'
+ onclick=\"closeInfoBox()\" value=\"Close this window\"></div>";
+ }
}
db_close($link);