6 if ((!$op ||
$op == "rpc" ||
$op == "globalUpdateFeeds") && !$_REQUEST["noxml"]) {
7 header("Content-Type: application/xml");
10 if (!$_SESSION["uid"] && $op != "globalUpdateFeeds") {
13 print "<error error-code=\"6\"/>";
19 print "<error error-code=\"7\"/>";
23 define(SCHEMA_VERSION
, 2);
25 require_once "config.php";
26 require_once "db.php";
27 require_once "db-prefs.php";
28 require_once "functions.php";
29 require_once "magpierss/rss_fetch.inc";
31 $script_started = getmicrotime();
33 $link = db_connect(DB_HOST
, DB_USER
, DB_PASS
, DB_NAME
);
36 if (DB_TYPE
== "mysql") {
39 // PG seems to display its own errors just fine by default.
43 if (DB_TYPE
== "pgsql") {
44 pg_query("set client_encoding = 'utf-8'");
47 $fetch = $_GET["fetch"];
49 /* FIXME this needs reworking */
51 function getGlobalCounters($link) {
52 $result = db_query($link, "SELECT count(id) as c_id FROM ttrss_entries,ttrss_user_entries
53 WHERE unread = true AND
54 ttrss_user_entries.ref_id = ttrss_entries.id AND
55 owner_uid = " . $_SESSION["uid"]);
56 $c_id = db_fetch_result($result, 0, "c_id");
57 print "<counter id='global-unread' counter='$c_id'/>";
60 function getTagCounters($link) {
62 $result = db_query($link, "SELECT tag_name,count(ttrss_entries.id) AS count
63 FROM ttrss_tags,ttrss_entries,ttrss_user_entries WHERE
64 ttrss_user_entries.ref_id = ttrss_entries.id AND
65 ttrss_tags.owner_uid = ".$_SESSION["uid"]." AND
66 post_int_id = ttrss_user_entries.int_id AND unread = true GROUP BY tag_name
68 select tag_name,0 as count FROM ttrss_tags
69 WHERE ttrss_tags.owner_uid = ".$_SESSION["uid"]);
73 while ($line = db_fetch_assoc($result)) {
74 $tags[$line["tag_name"]] +
= $line["count"];
77 foreach (array_keys($tags) as $tag) {
78 $unread = $tags[$tag];
80 $tag = htmlspecialchars($tag);
81 print "<tag id=\"$tag\" counter=\"$unread\"/>";
85 function getLabelCounters($link) {
87 $result = db_query($link, "SELECT count(id) as count FROM ttrss_entries,ttrss_user_entries
88 WHERE marked = true AND ttrss_user_entries.ref_id = ttrss_entries.id AND
89 unread = true AND owner_uid = ".$_SESSION["uid"]);
91 $count = db_fetch_result($result, 0, "count");
93 print "<label id=\"-1\" counter=\"$count\"/>";
95 $result = db_query($link, "SELECT owner_uid,id,sql_exp,description FROM
96 ttrss_labels WHERE owner_uid = ".$_SESSION["uid"]." ORDER by description");
98 while ($line = db_fetch_assoc($result)) {
100 $id = -$line["id"] - 11;
104 $tmp_result = db_query($link, "SELECT count(id) as count FROM ttrss_user_entries,ttrss_entries
105 WHERE (" . $line["sql_exp"] . ") AND unread = true AND
106 ttrss_user_entries.ref_id = ttrss_entries.id AND
107 owner_uid = ".$_SESSION["uid"]);
109 $count = db_fetch_result($tmp_result, 0, "count");
111 print "<label id=\"$id\" counter=\"$count\"/>";
113 error_reporting (E_ERROR | E_WARNING | E_PARSE
);
118 function getFeedCounter($link, $id) {
120 $result = db_query($link, "SELECT
121 count(id) as count FROM ttrss_entries,ttrss_user_entries
122 WHERE feed_id = '$id' AND unread = true
123 AND ttrss_user_entries.ref_id = ttrss_entries.id");
125 $count = db_fetch_result($result, 0, "count");
127 print "<feed id=\"$id\" counter=\"$count\"/>";
130 function getFeedCounters($link) {
132 $result = db_query($link, "SELECT id,
134 FROM ttrss_entries,ttrss_user_entries
135 WHERE feed_id = ttrss_feeds.id AND ttrss_user_entries.ref_id = ttrss_entries.id
136 AND unread = true AND owner_uid = ".$_SESSION["uid"].") as count
137 FROM ttrss_feeds WHERE owner_uid = ".$_SESSION["uid"]);
139 while ($line = db_fetch_assoc($result)) {
142 $count = $line["count"];
144 print "<feed id=\"$id\" counter=\"$count\"/>";
148 function outputFeedList($link, $tags = false) {
151 <title>Tiny Tiny RSS : Feedlist</title>
152 <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">";
154 if (get_pref($link, 'USE_COMPACT_STYLESHEET')) {
155 print "<link rel=\"stylesheet\" type=\"text/css\"
156 href=\"tt-rss_compact.css\"/>";
158 print "<link title=\"Compact Stylesheet\" rel=\"alternate stylesheet\"
159 type=\"text/css\" href=\"tt-rss_compact.css\"/>";
162 print "<script type=\"text/javascript\" src=\"functions.js\"></script>
163 <script type=\"text/javascript\" src=\"feedlist.js\"></script>
164 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
165 </head><body onload=\"init()\">";
167 print "<ul class=\"feedList\" id=\"feedList\">";
169 $owner_uid = $_SESSION["uid"];
175 if (get_pref($link, 'ENABLE_FEED_CATS')) {
176 print "<li class=\"feedCat\">Special</li>";
177 print "<li id=\"feedCatHolder\"><ul class=\"feedCatList\">";
180 $result = db_query($link, "SELECT count(id) as num_starred
181 FROM ttrss_entries,ttrss_user_entries
182 WHERE marked = true AND
183 ttrss_user_entries.ref_id = ttrss_entries.id AND
184 unread = true AND owner_uid = '$owner_uid'");
185 $num_starred = db_fetch_result($result, 0, "num_starred");
189 if ($num_starred > 0) $class .= "Unread";
191 printFeedEntry(-1, $class, "Starred articles", $num_starred,
192 "images/mark_set.png", $link);
194 if (get_pref($link, 'ENABLE_FEED_CATS')) {
198 if (get_pref($link, 'ENABLE_LABELS')) {
200 $result = db_query($link, "SELECT id,sql_exp,description FROM
201 ttrss_labels WHERE owner_uid = '$owner_uid' ORDER by description");
203 if (db_num_rows($result) > 0) {
204 if (get_pref($link, 'ENABLE_FEED_CATS')) {
205 print "<li class=\"feedCat\">Labels</li>";
206 print "<li id=\"feedCatHolder\"><ul class=\"feedCatList\">";
208 print "<li><hr></li>";
212 while ($line = db_fetch_assoc($result)) {
216 $tmp_result = db_query($link, "SELECT count(id) as count FROM ttrss_entries,ttrss_user_entries
217 WHERE (" . $line["sql_exp"] . ") AND unread = true AND
218 ttrss_user_entries.ref_id = ttrss_entries.id
219 AND owner_uid = '$owner_uid'");
221 $count = db_fetch_result($tmp_result, 0, "count");
229 error_reporting (E_ERROR | E_WARNING | E_PARSE
);
231 printFeedEntry(-$line["id"]-11,
232 $class, $line["description"], $count, "images/label.png", $link);
236 if (db_num_rows($result) > 0) {
237 if (get_pref($link, 'ENABLE_FEED_CATS')) {
244 // if (!get_pref($link, 'ENABLE_FEED_CATS')) {
245 print "<li><hr></li>";
248 if (get_pref($link, 'ENABLE_FEED_CATS')) {
249 $order_by_qpart = "category,title";
251 $order_by_qpart = "title";
254 $result = db_query($link, "SELECT *,
255 (SELECT count(id) FROM ttrss_entries,ttrss_user_entries
256 WHERE feed_id = ttrss_feeds.id AND
257 ttrss_user_entries.ref_id = ttrss_entries.id AND
258 owner_uid = '$owner_uid') AS total,
259 (SELECT count(id) FROM ttrss_entries,ttrss_user_entries
260 WHERE feed_id = ttrss_feeds.id AND unread = true
261 AND ttrss_user_entries.ref_id = ttrss_entries.id
262 AND owner_uid = '$owner_uid') as unread,
263 (SELECT title FROM ttrss_feed_categories
264 WHERE id = cat_id) AS category
265 FROM ttrss_feeds WHERE owner_uid = '$owner_uid' ORDER BY $order_by_qpart");
267 $actid = $_GET["actid"];
277 while ($line = db_fetch_assoc($result)) {
279 $feed = $line["title"];
280 $feed_id = $line["id"];
282 $subop = $_GET["subop"];
284 $total = $line["total"];
285 $unread = $line["unread"];
287 $tmp_category = $line["category"];
289 if (!$tmp_category) {
290 $tmp_category = "Uncategorized";
293 // $class = ($lnum % 2) ? "even" : "odd";
297 if ($unread > 0) $class .= "Unread";
299 if ($actid == $feed_id) {
300 $class .= "Selected";
303 $total_unread +
= $unread;
305 if ($category != $tmp_category && get_pref($link, 'ENABLE_FEED_CATS')) {
308 print "</li></ul></li>";
311 $category = $tmp_category;
313 print "<li class=\"feedCat\">$category</li>";
314 print "<li id=\"feedCatHolder\"><ul class=\"feedCatList\">";
317 printFeedEntry($feed_id, $class, $feed, $unread,
318 "icons/$feed_id.ico", $link);
327 $result = db_query($link, "SELECT tag_name,count(ttrss_entries.id) AS count
328 FROM ttrss_tags,ttrss_entries,ttrss_user_entries WHERE
329 post_int_id = ttrss_user_entries.int_id AND
330 unread = true AND ref_id = ttrss_entries.id
331 AND ttrss_tags.owner_uid = '$owner_uid' GROUP BY tag_name
333 select tag_name,0 as count FROM ttrss_tags WHERE owner_uid = '$owner_uid'
338 while ($line = db_fetch_assoc($result)) {
339 $tags[$line["tag_name"]] +
= $line["count"];
342 foreach (array_keys($tags) as $tag) {
344 $unread = $tags[$tag];
352 printFeedEntry($tag, $class, $tag, $unread, "images/tag.png", $link);
358 if (db_num_rows($result) == 0) {
359 print "<li>No tags/feeds to display.</li>";
364 print "<div class=\"invisible\" id=\"FEEDTU\">$total_unread</div>";
371 $subop = $_GET["subop"];
373 if ($subop == "getLabelCounters") {
376 getLabelCounters($link);
378 getFeedCounter($link, $aid);
380 print "</rpc-reply>";
383 if ($subop == "getFeedCounters") {
385 getFeedCounters($link);
386 print "</rpc-reply>";
389 if ($subop == "getAllCounters") {
391 getLabelCounters($link);
392 getFeedCounters($link);
393 getTagCounters($link);
394 getGlobalCounters($link);
395 print "</rpc-reply>";
398 if ($subop == "mark") {
399 $mark = $_GET["mark"];
400 $id = db_escape_string($_GET["id"]);
408 // FIXME this needs collision testing
410 $result = db_query($link, "UPDATE ttrss_user_entries SET marked = $mark
411 WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
414 if ($subop == "updateFeed") {
415 $feed_id = db_escape_string($_GET["feed"]);
417 $result = db_query($link,
418 "SELECT feed_url FROM ttrss_feeds WHERE id = '$feed_id'
419 AND owner_uid = " . $_SESSION["uid"]);
421 if (db_num_rows($result) > 0) {
422 $feed_url = db_fetch_result($result, 0, "feed_url");
423 update_rss_feed($link, $feed_url, $feed_id);
427 getFeedCounter($link, $feed_id);
428 print "</rpc-reply>";
433 if ($subop == "forceUpdateAllFeeds" ||
$subop == "updateAllFeeds") {
435 update_all_feeds($link, $subop == "forceUpdateAllFeeds");
437 $omode = $_GET["omode"];
439 if (!$omode) $omode = "tfl";
442 if (strchr($omode, "l")) getLabelCounters($link);
443 if (strchr($omode, "f")) getFeedCounters($link);
444 if (strchr($omode, "t")) getTagCounters($link);
445 getGlobalCounters($link);
446 print "</rpc-reply>";
449 if ($subop == "catchupSelected") {
451 $ids = split(",", $_GET["ids"]);
453 foreach ($ids as $id) {
455 db_query($link, "UPDATE ttrss_user_entries SET unread=false,last_read = NOW()
456 WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
460 print "Marked active page as read.";
463 if ($subop == "sanityCheck") {
467 $result = db_query($link, "SELECT schema_version FROM ttrss_version");
469 $schema_version = db_fetch_result($result, 0, "schema_version");
471 if ($schema_version != SCHEMA_VERSION
) {
475 print "<error error-code='$error_code'/>";
478 if ($subop == "globalPurge") {
481 global_purge_old_posts($link, true);
482 print "</rpc-reply>";
488 if ($op == "feeds") {
490 $tags = $_GET["tags"];
492 $subop = $_GET["subop"];
494 if ($subop == "catchupAll") {
495 db_query($link, "UPDATE ttrss_user_entries SET
496 last_read = NOW(),unread = false WHERE owner_uid = " . $_SESSION["uid"]);
499 outputFeedList($link, $tags);
506 $feed_id = $_GET["feed"];
508 $result = db_query($link, "UPDATE ttrss_user_entries
509 SET unread = false,last_read = NOW()
510 WHERE ref_id = '$id' AND feed_id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]);
512 $addheader = $_GET["addheader"];
514 $result = db_query($link, "SELECT title,link,content,feed_id,comments,
515 (SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url
516 FROM ttrss_entries,ttrss_user_entries
517 WHERE id = '$id' AND ref_id = id");
521 <title>Tiny Tiny RSS : Article $id</title>
522 <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">
523 <script type=\"text/javascript\" src=\"functions.js\"></script>
524 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
530 $line = db_fetch_assoc($result);
532 if ($line["icon_url"]) {
533 $feed_icon = "<img class=\"feedIcon\" src=\"" . $line["icon_url"] . "\">";
535 $feed_icon = " ";
538 if ($line["comments"] && $line["link"] != $line["comments"]) {
539 $entry_comments = "(<a href=\"".$line["comments"]."\">Comments</a>)";
541 $entry_comments = "";
544 print "<div class=\"postReply\">";
546 print "<div class=\"postHeader\"><table>";
548 print "<tr><td><b>Title:</b></td>
549 <td width='100%'>" . $line["title"] . "</td></tr>";
551 print "<tr><td><b>Link:</b></td>
553 <a href=\"" . $line["link"] . "\">".$line["link"]."</a>
554 $entry_comments</td></tr>";
556 print "</table></div>";
558 print "<div class=\"postIcon\">" . $feed_icon . "</div>";
559 print "<div class=\"postContent\">" . $line["content"] . "</div>";
563 print "<script type=\"text/javascript\">
564 update_label_counters('$feed_id');
569 print "</body></html>";
573 if ($op == "viewfeed") {
575 $feed = $_GET["feed"];
576 $skip = $_GET["skip"];
577 $subop = $_GET["subop"];
578 $view_mode = $_GET["view"];
579 $addheader = $_GET["addheader"];
580 $limit = $_GET["limit"];
586 if (!$skip) $skip = 0;
588 if ($subop == "undefined") $subop = "";
592 <title>Tiny Tiny RSS : Feed $feed</title>
593 <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">";
595 if (get_pref($link, 'USE_COMPACT_STYLESHEET')) {
596 print "<link rel=\"stylesheet\"
597 type=\"text/css\" href=\"tt-rss_compact.css\"/>";
600 print "<link title=\"Compact Stylesheet\" rel=\"alternate stylesheet\"
601 type=\"text/css\" href=\"tt-rss_compact.css\"/>";
603 print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
604 <script type=\"text/javascript\" src=\"functions.js\"></script>
605 <script type=\"text/javascript\" src=\"viewfeed.js\"></script>
606 </head><body onload='init()'>";
609 if ($subop == "ForceUpdate" && sprintf("%d", $feed) > 0) {
611 $tmp_result = db_query($link, "SELECT feed_url FROM ttrss_feeds
612 WHERE id = '$feed'");
614 $feed_url = db_fetch_result($tmp_result, 0, "feed_url");
616 update_rss_feed($link, $feed_url, $feed);
620 if ($subop == "MarkAllRead") {
622 if (sprintf("%d", $feed) != 0) {
625 db_query($link, "UPDATE ttrss_user_entries
626 SET unread = false,last_read = NOW()
627 WHERE feed_id = '$feed' AND owner_uid = " . $_SESSION["uid"]);
629 } else if ($feed < 0 && $feed > -10) { // special, like starred
632 db_query($link, "UPDATE ttrss_user_entries
633 SET unread = false,last_read = NOW()
634 WHERE marked = true AND owner_uid = ".$_SESSION["uid"]);
637 } else if ($feed < -10) { // label
639 // TODO make this more efficient
641 $label_id = -$feed - 11;
643 $tmp_result = db_query($link, "SELECT sql_exp FROM ttrss_labels
644 WHERE id = '$label_id'");
647 $sql_exp = db_fetch_result($tmp_result, 0, "sql_exp");
649 db_query($link, "BEGIN");
651 $tmp2_result = db_query($link,
655 ttrss_user_entries,ttrss_entries
659 owner_uid = " . $_SESSION["uid"]);
661 while ($tmp_line = db_fetch_assoc($tmp2_result)) {
662 db_query($link, "UPDATE
665 unread = false, last_read = NOW()
667 int_id = " . $tmp_line["int_id"]);
670 db_query($link, "COMMIT");
672 /* db_query($link, "UPDATE ttrss_user_entries,ttrss_entries
673 SET unread = false,last_read = NOW()
676 AND owner_uid = ".$_SESSION["uid"]); */
680 // FIXME, implement catchup for tags
685 print "<table class=\"headlinesList\" id=\"headlinesList\" width=\"100%\">";
687 $search = $_GET["search"];
689 $search_mode = $_GET["smode"];
692 $search_query_part = "(upper(title) LIKE upper('%$search%')
693 OR content LIKE '%$search%') AND";
695 $search_query_part = "";
698 $view_query_part = "";
700 if ($view_mode == "Starred") {
701 $view_query_part = " marked = true AND ";
704 if ($view_mode == "Unread") {
705 $view_query_part = " unread = true AND ";
708 if ($view_mode == "Unread or Starred") {
709 $view_query_part = " (unread = true OR marked = true) AND ";
712 if ($view_mode == "Unread or Updated") {
713 $view_query_part = " (unread = true OR last_read is NULL) AND ";
716 /* $result = db_query($link, "SELECT count(id) AS total_entries
717 FROM ttrss_entries WHERE
721 $total_entries = db_fetch_result($result, 0, "total_entries"); */
723 /* $result = db_query("SELECT count(id) AS unread_entries
724 FROM ttrss_entries WHERE
729 $unread_entries = db_fetch_result($result, 0, "unread_entries"); */
731 if ($limit && $limit != "All") {
732 $limit_query_part = "LIMIT " . $limit;
735 $vfeed_query_part = "";
737 // override query strategy and enable feed display when searching globally
738 if ($search && $search_mode == "All feeds") {
739 $query_strategy_part = "id > 0";
740 $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE
741 id = feed_id) as feed_title,";
742 } else if (sprintf("%d", $feed) == 0) {
743 $query_strategy_part = "ttrss_entries.id > 0";
744 $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE
745 id = feed_id) as feed_title,";
746 } else if ($feed >= 0) {
747 $query_strategy_part = "feed_id = '$feed'";
748 } else if ($feed == -1) { // starred virtual feed
749 $query_strategy_part = "marked = true";
750 $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE
751 id = feed_id) as feed_title,";
752 } else if ($feed <= -10) { // labels
753 $label_id = -$feed - 11;
755 $tmp_result = db_query($link, "SELECT sql_exp FROM ttrss_labels
756 WHERE id = '$label_id'");
758 $query_strategy_part = db_fetch_result($tmp_result, 0, "sql_exp");
760 $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE
761 id = feed_id) as feed_title,";
763 $query_strategy_part = "id > 0"; // dumb
767 $order_by = "updated DESC";
769 // if ($feed < -10) {
770 // $order_by = "feed_id,updated DESC";
773 if ($feed < -10) error_reporting (0);
775 if (sprintf("%d", $feed) != 0) {
777 $result = db_query($link, "SELECT
778 id,title,updated,unread,feed_id,marked,link,last_read,
779 SUBSTRING(last_read,1,19) as last_read_noms,
781 SUBSTRING(updated,1,19) as updated_noms
783 ttrss_entries,ttrss_user_entries
785 ttrss_user_entries.ref_id = ttrss_entries.id AND
786 owner_uid = '".$_SESSION["uid"]."' AND
789 $query_strategy_part ORDER BY $order_by
795 $result = db_query($link, "SELECT
796 ttrss_entries.id as id,title,updated,unread,feed_id,
797 marked,link,last_read,
798 SUBSTRING(last_read,1,19) as last_read_noms,
800 SUBSTRING(updated,1,19) as updated_noms
802 ttrss_entries,ttrss_user_entries,ttrss_tags
804 ref_id = ttrss_entries.id AND
805 ttrss_user_entries.owner_uid = '".$_SESSION["uid"]."' AND
806 post_int_id = int_id AND tag_name = '$feed' AND
809 $query_strategy_part ORDER BY $order_by
814 print "<tr><td colspan='4' align='center'>
815 Could not display feed (query failed). Please check match syntax or local configuration.</td></tr>";
821 error_reporting (E_ERROR | E_WARNING | E_PARSE
);
825 while ($line = db_fetch_assoc($result)) {
827 $class = ($lnum %
2) ?
"even" : "odd";
830 $feed_id = $line["feed_id"];
832 // printf("L %d (%s) > U %d (%s) = %d<br>",
833 // strtotime($line["last_read_noms"]), $line["last_read_noms"],
834 // strtotime($line["updated"]), $line["updated"],
835 // strtotime($line["last_read"]) >= strtotime($line["updated"]));
837 /* if ($line["last_read"] != "" && $line["updated"] != "" &&
838 strtotime($line["last_read_noms"]) < strtotime($line["updated_noms"])) {
840 $update_pic = "<img id='FUPDPIC-$id' src=\"images/updated.png\"
845 $update_pic = "<img id='FUPDPIC-$id' src=\"images/blank_icon.gif\"
850 if ($line["last_read"] == "" &&
851 ($line["unread"] != "t" && $line["unread"] != "1")) {
853 $update_pic = "<img id='FUPDPIC-$id' src=\"images/updated.png\"
856 $update_pic = "<img id='FUPDPIC-$id' src=\"images/blank_icon.gif\"
860 if ($line["unread"] == "t" ||
$line["unread"] == "1") {
865 if ($line["marked"] == "t" ||
$line["marked"] == "1") {
866 $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_set.png\"
867 alt=\"Reset mark\" onclick='javascript:toggleMark($id, false)'>";
869 $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_unset.png\"
870 alt=\"Set mark\" onclick='javascript:toggleMark($id, true)'>";
873 $content_link = "<a id=\"FTITLE-$id\" href=\"javascript:view($id,$feed_id);\">" .
874 $line["title"] . "</a>";
876 print "<tr class='$class' id='RROW-$id'>";
877 // onclick=\"javascript:view($id,$feed_id)\">
879 print "<td valign='center' align='center'>$update_pic</td>";
880 print "<td valign='center' align='center'>$marked_pic</td>";
882 print "<td width='25%'>
883 <a href=\"javascript:view($id,$feed_id);\">".$line["updated"]."</a></td>";
885 if ($line["feed_title"]) {
886 print "<td width='50%'>$content_link</td>";
887 print "<td width='20%'>
888 <a href='javascript:viewfeed($feed_id)'>".$line["feed_title"]."</a></td>";
890 print "<td width='70%'>$content_link</td>";
899 print "<tr><td align='center'>No articles found.</td></tr>";
904 print "<script type=\"text/javascript\">
905 document.onkeydown = hotkey_handler;
906 update_label_counters('$feed');
910 print "</body></html>";
915 if ($op == "pref-rpc") {
917 $subop = $_GET["subop"];
919 if ($subop == "unread") {
920 $ids = split(",", $_GET["ids"]);
921 foreach ($ids as $id) {
922 db_query($link, "UPDATE ttrss_user_entries SET unread = true
923 WHERE feed_id = '$id' AND owner_uid = ".$_SESSION["uid"]);
926 print "Marked selected feeds as unread.";
929 if ($subop == "read") {
930 $ids = split(",", $_GET["ids"]);
931 foreach ($ids as $id) {
932 db_query($link, "UPDATE ttrss_user_entries
933 SET unread = false,last_read = NOW() WHERE
934 feed_id = '$id' AND owner_uid = ".$_SESSION["uid"]);
937 print "Marked selected feeds as read.";
943 if ($op == "pref-feeds") {
945 $subop = $_GET["subop"];
947 if ($subop == "editSave") {
948 $feed_title = db_escape_string($_GET["t"]);
949 $feed_link = db_escape_string($_GET["l"]);
950 $upd_intl = db_escape_string($_GET["ui"]);
951 $purge_intl = db_escape_string($_GET["pi"]);
952 $feed_id = db_escape_string($_GET["id"]);
953 $cat_id = db_escape_string($_GET["catid"]);
955 if (strtoupper($upd_intl) == "DEFAULT")
958 if (strtoupper($purge_intl) == "DEFAULT")
961 if (strtoupper($purge_intl) == "DISABLED")
965 $category_qpart = "cat_id = '$cat_id'";
967 $category_qpart = 'cat_id = NULL';
970 $result = db_query($link, "UPDATE ttrss_feeds SET
972 title = '$feed_title', feed_url = '$feed_link',
973 update_interval = '$upd_intl',
974 purge_interval = '$purge_intl'
975 WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]);
979 if ($subop == "remove") {
981 if (!WEB_DEMO_MODE
) {
983 $ids = split(",", $_GET["ids"]);
985 foreach ($ids as $id) {
986 db_query($link, "DELETE FROM ttrss_feeds
987 WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
989 $icons_dir = ICONS_DIR
;
991 if (file_exists($icons_dir . "/$id.ico")) {
992 unlink($icons_dir . "/$id.ico");
998 if ($subop == "add") {
1000 if (!WEB_DEMO_MODE
) {
1002 $feed_link = db_escape_string(trim($_GET["link"]));
1004 $result = db_query($link,
1005 "SELECT id FROM ttrss_feeds
1006 WHERE feed_url = '$feed_link' AND owner_uid = ".$_SESSION["uid"]);
1008 if (db_num_rows($result) == 0) {
1010 $result = db_query($link,
1011 "INSERT INTO ttrss_feeds (owner_uid,feed_url,title)
1012 VALUES ('".$_SESSION["uid"]."', '$feed_link', '')");
1014 $result = db_query($link,
1015 "SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_link'
1016 AND owner_uid = " . $_SESSION["uid"]);
1018 $feed_id = db_fetch_result($result, 0, "id");
1021 update_rss_feed($link, $feed_link, $feed_id);
1025 print "<div class=\"warning\">
1026 Feed <b>$feed_link</b> already exists in the database.
1032 if ($subop == "addCat") {
1034 if (!WEB_DEMO_MODE
) {
1036 $feed_cat = db_escape_string(trim($_GET["cat"]));
1038 $result = db_query($link,
1039 "SELECT id FROM ttrss_feed_categories
1040 WHERE title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]);
1042 if (db_num_rows($result) == 0) {
1044 $result = db_query($link,
1045 "INSERT INTO ttrss_feed_categories (owner_uid,title)
1046 VALUES ('".$_SESSION["uid"]."', '$feed_cat')");
1050 print "<div class=\"warning\">
1051 Category <b>$feed_cat</b> already exists in the database.
1059 if ($subop == "removeCats") {
1061 if (!WEB_DEMO_MODE
) {
1063 $ids = split(",", $_GET["ids"]);
1065 foreach ($ids as $id) {
1067 db_query($link, "BEGIN");
1069 $result = db_query($link,
1070 "SELECT count(id) as num_feeds FROM ttrss_feeds
1071 WHERE cat_id = '$id'");
1073 $num_feeds = db_fetch_result($result, 0, "num_feeds");
1075 if ($num_feeds == 0) {
1076 db_query($link, "DELETE FROM ttrss_feed_categories
1077 WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
1080 print "<div class=\"warning\">
1081 Unable to delete non empty feed categories.</div>";
1085 db_query($link, "COMMIT");
1090 // print "<h3>Edit Feeds</h3>";
1092 $result = db_query($link, "SELECT id,title,feed_url,last_error
1093 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
1095 if (db_num_rows($result) > 0) {
1097 print "<div class=\"warning\">";
1099 print "<b>Feeds with update errors:</b>";
1101 print "<ul class=\"nomarks\">";
1103 while ($line = db_fetch_assoc($result)) {
1104 print "<li>" . $line["title"] . " (" . $line["feed_url"] . "): " .
1105 $line["last_error"];
1113 print "<p><div class=\"prefGenericAddBox\">
1114 <input id=\"fadd_link\" size=\"40\"> <input
1115 type=\"submit\" class=\"button\"
1116 onclick=\"javascript:addFeed()\" value=\"Add feed\"></div>";
1118 $feeds_sort = db_escape_string($_GET["sort"]);
1120 if (!$feeds_sort ||
$feeds_sort == "undefined") {
1121 $feeds_sort = $_SESSION["pref_sort_feeds"];
1122 if (!$feeds_sort) $feeds_sort = "title";
1125 $_SESSION["pref_sort_feeds"] = $feeds_sort;
1127 $result = db_query($link, "SELECT
1128 id,title,feed_url,substring(last_updated,1,16) as last_updated,
1129 update_interval,purge_interval,
1130 (SELECT title FROM ttrss_feed_categories
1131 WHERE id = cat_id) AS category
1133 ttrss_feeds WHERE owner_uid = '".$_SESSION["uid"]."'
1134 ORDER by $feeds_sort,title");
1136 if (db_num_rows($result) != 0) {
1138 print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>";
1140 print "<p><table width=\"100%\" class=\"prefFeedList\" id=\"prefFeedList\">";
1141 print "<tr class=\"title\">
1145 <a href=\"javascript:updateFeedList('title')\">Title</a></td>
1147 <a href=\"javascript:updateFeedList('feed_url')\">Link</a>
1150 if (get_pref($link, 'ENABLE_FEED_CATS')) {
1151 print "<td width=\"10%\">
1152 <a href=\"javascript:updateFeedList('category')\">Category</a></td>";
1157 <a href=\"javascript:updateFeedList('update_interval')\">Update Interval</a>
1160 <a href=\"javascript:updateFeedList('purge_interval')\">Purge Days</a>
1163 <a href=\"javascript:updateFeedList('last_updated')\">Last updated</a>
1169 while ($line = db_fetch_assoc($result)) {
1171 $class = ($lnum %
2) ?
"even" : "odd";
1173 $feed_id = $line["id"];
1175 $edit_feed_id = $_GET["id"];
1177 if ($subop == "edit" && $feed_id != $edit_feed_id) {
1181 print "<tr class=\"$class\" id=\"FEEDR-$feed_id\">";
1183 $icon_file = ICONS_DIR
. "/$feed_id.ico";
1185 if (file_exists($icon_file) && filesize($icon_file) > 0) {
1186 $feed_icon = "<img width=\"16\" height=\"16\"
1187 src=\"" . ICONS_URL
. "/$feed_id.ico\">";
1189 $feed_icon = " ";
1191 print "<td align='center'>$feed_icon</td>";
1193 $edit_title = htmlspecialchars(db_unescape_string($line["title"]));
1194 $edit_link = htmlspecialchars(db_unescape_string($line["feed_url"]));
1195 $edit_cat = htmlspecialchars(db_unescape_string($line["category"]));
1197 if (!$edit_cat) $edit_cat = "Uncategorized";
1199 if (!$edit_feed_id ||
$subop != "edit") {
1201 print "<td><input onclick='toggleSelectRow(this);'
1202 type=\"checkbox\" id=\"FRCHK-".$line["id"]."\"></td>";
1204 print "<td><a href=\"javascript:editFeed($feed_id);\">" .
1205 $edit_title . "</a></td>";
1207 print "<td><a href=\"javascript:editFeed($feed_id);\">" .
1208 $edit_link . "</a></td>";
1210 if (get_pref($link, 'ENABLE_FEED_CATS')) {
1211 print "<td><a href=\"javascript:editFeed($feed_id);\">" .
1212 $edit_cat . "</a></td>";
1215 if ($line["update_interval"] == "0")
1216 $line["update_interval"] = "Default";
1218 print "<td><a href=\"javascript:editFeed($feed_id);\">" .
1219 $line["update_interval"] . "</a></td>";
1221 if ($line["purge_interval"] == "0")
1222 $line["purge_interval"] = "Default";
1224 if ($line["purge_interval"] < 0)
1225 $line["purge_interval"] = "Disabled";
1227 print "<td><a href=\"javascript:editFeed($feed_id);\">" .
1228 $line["purge_interval"] . "</a></td>";
1230 } else if ($feed_id != $edit_feed_id) {
1232 print "<td><input disabled=\"true\" type=\"checkbox\"
1233 id=\"FRCHK-".$line["id"]."\"></td>";
1235 print "<td>$edit_title</td>";
1236 print "<td>$edit_link</td>";
1238 if (get_pref($link, 'ENABLE_FEED_CATS')) {
1239 print "<td>$edit_cat</td>";
1242 if ($line["update_interval"] == "0")
1243 $line["update_interval"] = "Default";
1245 print "<td>" . $line["update_interval"] . "</td>";
1247 if ($line["purge_interval"] == "0")
1248 $line["purge_interval"] = "Default";
1250 if ($line["purge_interval"] < 0)
1251 $line["purge_interval"] = "Disabled";
1253 print "<td>" . $line["purge_interval"] . "</td>";
1257 print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>";
1259 print "<td><input id=\"iedit_title\" value=\"$edit_title\"></td>";
1260 print "<td><input id=\"iedit_link\" value=\"$edit_link\"></td>";
1262 if (get_pref($link, 'ENABLE_FEED_CATS')) {
1265 print "<select id=\"iedit_fcat\">";
1266 print "<option id=\"0\">Uncategorized</option>";
1268 $tmp_result = db_query($link, "SELECT id,title FROM ttrss_feed_categories
1269 WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
1271 if (db_num_rows($tmp_result) > 0) {
1272 print "<option disabled>--------</option>";
1275 while ($tmp_line = db_fetch_assoc($tmp_result)) {
1276 if ($tmp_line["id"] == $line["cat_id"]) {
1277 $is_selected = "selected";
1281 printf("<option $is_selected id='%d'>%s</option>",
1282 $tmp_line["id"], $tmp_line["title"]);
1285 print "</select></td>";
1290 print "<td><input id=\"iedit_updintl\"
1291 value=\"".$line["update_interval"]."\"></td>";
1292 print "<td><input id=\"iedit_purgintl\"
1293 value=\"".$line["purge_interval"]."\"></td>";
1297 if (!$line["last_updated"]) $line["last_updated"] = "Never";
1299 print "<td>" . $line["last_updated"] . "</td>";
1310 if ($subop == "edit") {
1311 print "Edit feed:
1312 <input type=\"submit\" class=\"button\"
1313 onclick=\"javascript:feedEditCancel()\" value=\"Cancel\">
1314 <input type=\"submit\" class=\"button\"
1315 onclick=\"javascript:feedEditSave()\" value=\"Save\">";
1320 <input type=\"submit\" class=\"button\"
1321 onclick=\"javascript:selectedFeedDetails()\" value=\"Details\">
1322 <input type=\"submit\" class=\"button\"
1323 onclick=\"javascript:editSelectedFeed()\" value=\"Edit\">
1324 <input type=\"submit\" class=\"button\"
1325 onclick=\"javascript:removeSelectedFeeds()\" value=\"Remove\">";
1327 if (get_pref($link, 'ENABLE_PREFS_CATCHUP_UNCATCHUP')) {
1329 <input type=\"submit\" class=\"button\"
1330 onclick=\"javascript:readSelectedFeeds()\" value=\"Mark as read\">
1331 <input type=\"submit\" class=\"button\"
1332 onclick=\"javascript:unreadSelectedFeeds()\"
1333 value=\"Mark as unread\"> ";
1337 All feeds: <input type=\"submit\"
1338 class=\"button\" onclick=\"gotoExportOpml()\"
1339 value=\"Export OPML\">";
1343 print "<p>No feeds defined.</p>";
1347 if (get_pref($link, 'ENABLE_FEED_CATS')) {
1349 print "<h3>Edit Categories</h3>";
1351 // print "<h3>Categories</h3>";
1353 print "<div class=\"prefGenericAddBox\">
1354 <input id=\"fadd_cat\" size=\"40\"> <input
1355 type=\"submit\" class=\"button\"
1356 onclick=\"javascript:addFeedCat()\" value=\"Add category\"></div>";
1358 $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories
1359 WHERE owner_uid = ".$_SESSION["uid"]."
1362 if (db_num_rows($result) != 0) {
1364 print "<p><table width=\"100%\" class=\"prefFeedCatList\" id=\"prefFeedCatList\">";
1365 print "<tr class=\"title\">
1366 <td width=\"10%\">Select</td><td width=\"80%\">Title</td>
1371 while ($line = db_fetch_assoc($result)) {
1373 $class = ($lnum %
2) ?
"even" : "odd";
1375 $cat_id = $line["id"];
1377 $edit_cat_id = $_GET["id"];
1379 if ($subop == "editCat" && $cat_id != $edit_cat_id) {
1383 print "<tr class=\"$class\" id=\"FCATR-$cat_id\">";
1385 $edit_title = htmlspecialchars(db_unescape_string($line["title"]));
1387 if (!$edit_cat_id ||
$subop != "editCat") {
1389 print "<td><input onclick='toggleSelectRow(this);'
1390 type=\"checkbox\" id=\"FCCHK-".$line["id"]."\"></td>";
1392 print "<td><a href=\"javascript:editFeedCat($cat_id);\">" .
1393 $edit_title . "</a></td>";
1395 } else if ($cat_id != $edit_cat_id) {
1397 print "<td><input disabled=\"true\" type=\"checkbox\"
1398 id=\"FRCHK-".$line["id"]."\"></td>";
1400 print "<td>$edit_title</td>";
1404 print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>";
1406 print "<td><input id=\"iedit_title\" value=\"$edit_title\"></td>";
1419 if ($subop == "editCat") {
1420 print "Edit category:
1421 <input type=\"submit\" class=\"button\"
1422 onclick=\"javascript:feedCatEditCancel()\" value=\"Cancel\">
1423 <input type=\"submit\" class=\"button\"
1424 onclick=\"javascript:feedCatEditSave()\" value=\"Save\">";
1429 <input type=\"submit\" class=\"button\"
1430 onclick=\"javascript:editSelectedFeedCat()\" value=\"Edit\">
1431 <input type=\"submit\" class=\"button\"
1432 onclick=\"javascript:removeSelectedFeedCats()\" value=\"Remove\">";
1437 print "<p>No feed categories defined.</p>";
1441 print "<h3>Import OPML</h3>
1442 <form enctype=\"multipart/form-data\" method=\"POST\" action=\"opml.php\">
1443 File: <input id=\"opml_file\" name=\"opml_file\" type=\"file\">
1444 <input class=\"button\" name=\"op\" onclick=\"return validateOpmlImport();\"
1445 type=\"submit\" value=\"Import\">
1450 if ($op == "pref-filters") {
1452 $subop = $_GET["subop"];
1454 if ($subop == "editSave") {
1456 $regexp = db_escape_string($_GET["r"]);
1457 $descr = db_escape_string($_GET["d"]);
1458 $match = db_escape_string($_GET["m"]);
1459 $filter_id = db_escape_string($_GET["id"]);
1460 $feed_id = db_escape_string($_GET["fid"]);
1465 $feed_id = sprintf("'%s'", db_escape_string($feed_id));
1468 $result = db_query($link, "UPDATE ttrss_filters SET
1469 reg_exp = '$regexp',
1470 description = '$descr',
1472 filter_type = (SELECT id FROM ttrss_filter_types WHERE
1473 description = '$match')
1474 WHERE id = '$filter_id'");
1477 if ($subop == "remove") {
1479 if (!WEB_DEMO_MODE
) {
1481 $ids = split(",", $_GET["ids"]);
1483 foreach ($ids as $id) {
1484 db_query($link, "DELETE FROM ttrss_filters WHERE id = '$id'");
1490 if ($subop == "add") {
1492 if (!WEB_DEMO_MODE
) {
1494 $regexp = db_escape_string(trim($_GET["regexp"]));
1495 $match = db_escape_string(trim($_GET["match"]));
1496 $feed_id = db_escape_string($_GET["fid"]);
1501 $feed_id = sprintf("'%s'", db_escape_string($feed_id));
1504 $result = db_query($link,
1505 "INSERT INTO ttrss_filters (reg_exp,filter_type,owner_uid,feed_id) VALUES
1506 ('$regexp', (SELECT id FROM ttrss_filter_types WHERE
1507 description = '$match'),'".$_SESSION["uid"]."', $feed_id)");
1511 $result = db_query($link, "SELECT description
1512 FROM ttrss_filter_types ORDER BY description");
1514 $filter_types = array();
1516 while ($line = db_fetch_assoc($result)) {
1517 array_push($filter_types, $line["description"]);
1520 print "<div class=\"prefGenericAddBox\">
1521 <input id=\"fadd_regexp\" size=\"40\"> ";
1523 print_select("fadd_match", "Title", $filter_types);
1525 print " <select id=\"fadd_feed\">";
1527 print "<option selected id=\"0\">All feeds</option>";
1529 $result = db_query($link, "SELECT id,title FROM ttrss_feeds
1530 WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
1532 if (db_num_rows($result) > 0) {
1533 print "<option disabled>--------</option>";
1536 while ($line = db_fetch_assoc($result)) {
1537 printf("<option id='%d'>%s</option>", $line["id"], $line["title"]);
1540 print "</select> ";
1542 print "<input type=\"submit\"
1543 class=\"button\" onclick=\"javascript:addFilter()\"
1544 value=\"Add filter\">";
1546 $result = db_query($link, "SELECT
1547 ttrss_filters.id AS id,reg_exp,
1548 ttrss_filters.description AS description,
1549 ttrss_filter_types.name AS filter_type_name,
1550 ttrss_filter_types.description AS filter_type_descr,
1552 (SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title
1554 ttrss_filters,ttrss_filter_types
1556 filter_type = ttrss_filter_types.id AND
1557 ttrss_filters.owner_uid = ".$_SESSION["uid"]."
1560 if (db_num_rows($result) != 0) {
1562 print "<p><table width=\"100%\" class=\"prefFilterList\" id=\"prefFilterList\">";
1564 print "<tr class=\"title\">
1565 <td width=\"5%\">Select</td><td width=\"30%\">Filter expression</td>
1566 <td width=\"30%\">Feed</td><td width=\"10%\">Match</td>
1567 <td width=\"30%\">Description</td></tr>";
1571 while ($line = db_fetch_assoc($result)) {
1573 $class = ($lnum %
2) ?
"even" : "odd";
1575 $filter_id = $line["id"];
1576 $edit_filter_id = $_GET["id"];
1578 if ($subop == "edit" && $filter_id != $edit_filter_id) {
1582 print "<tr class=\"$class\" id=\"FILRR-$filter_id\">";
1584 $line["regexp"] = htmlspecialchars($line["reg_exp"]);
1585 $line["description"] = htmlspecialchars($line["description"]);
1587 if (!$line["feed_title"]) $line["feed_title"] = "All feeds";
1589 if (!$edit_filter_id ||
$subop != "edit") {
1591 if (!$line["description"]) $line["description"] = "[No description]";
1593 print "<td><input onclick='toggleSelectRow(this);'
1594 type=\"checkbox\" id=\"FICHK-".$line["id"]."\"></td>";
1596 print "<td><a href=\"javascript:editFilter($filter_id);\">" .
1597 $line["reg_exp"] . "</td>";
1599 print "<td><a href=\"javascript:editFilter($filter_id);\">" .
1600 $line["feed_title"] . "</td>";
1602 print "<td><a href=\"javascript:editFilter($filter_id);\">" .
1603 $line["filter_type_descr"] . "</td>";
1605 print "<td><a href=\"javascript:editFilter($filter_id);\">" .
1606 $line["description"] . "</td>";
1608 } else if ($filter_id != $edit_filter_id) {
1610 if (!$line["description"]) $line["description"] = "[No description]";
1612 print "<td><input disabled=\"true\" type=\"checkbox\"
1613 id=\"FICHK-".$line["id"]."\"></td>";
1615 print "<td>".$line["reg_exp"]."</td>";
1616 print "<td>".$line["feed_title"]."</td>";
1617 print "<td>".$line["filter_type_descr"]."</td>";
1618 print "<td>".$line["description"]."</td>";
1622 print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>";
1624 print "<td><input id=\"iedit_regexp\" value=\"".$line["reg_exp"].
1629 print "<select id=\"iedit_feed\">";
1631 print "<option id=\"0\">All feeds</option>";
1633 if (db_num_rows($result) > 0) {
1634 print "<option disabled>--------</option>";
1637 $tmp_result = db_query($link, "SELECT id,title FROM ttrss_feeds
1638 WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
1640 while ($tmp_line = db_fetch_assoc($tmp_result)) {
1641 if ($tmp_line["id"] == $line["feed_id"]) {
1642 $is_selected = "selected";
1646 printf("<option $is_selected id='%d'>%s</option>",
1647 $tmp_line["id"], $tmp_line["title"]);
1650 print "</select></td>";
1653 print_select("iedit_match", $line["filter_type_descr"], $filter_types);
1656 print "<td><input id=\"iedit_descr\" value=\"".$line["description"].
1668 print "<tr><td colspan=\"4\" align=\"center\">No filters defined.</td></tr>";
1675 if ($subop == "edit") {
1677 <input type=\"submit\" class=\"button\"
1678 onclick=\"javascript:filterEditCancel()\" value=\"Cancel\">
1679 <input type=\"submit\" class=\"button\"
1680 onclick=\"javascript:filterEditSave()\" value=\"Save\">";
1686 <input type=\"submit\" class=\"button\"
1687 onclick=\"javascript:editSelectedFilter()\" value=\"Edit\">
1688 <input type=\"submit\" class=\"button\"
1689 onclick=\"javascript:removeSelectedFilters()\" value=\"Remove\">";
1694 print "<p>No filters defined.</p>";
1699 if ($op == "pref-labels") {
1701 $subop = $_GET["subop"];
1703 if ($subop == "editSave") {
1705 $sql_exp = $_GET["s"];
1706 $descr = $_GET["d"];
1707 $label_id = db_escape_string($_GET["id"]);
1709 // print "$sql_exp : $descr : $label_id";
1711 $result = db_query($link, "UPDATE ttrss_labels SET
1712 sql_exp = '$sql_exp',
1713 description = '$descr'
1714 WHERE id = '$label_id'");
1717 if ($subop == "remove") {
1719 if (!WEB_DEMO_MODE
) {
1721 $ids = split(",", $_GET["ids"]);
1723 foreach ($ids as $id) {
1724 db_query($link, "DELETE FROM ttrss_labels WHERE id = '$id'");
1730 if ($subop == "add") {
1732 if (!WEB_DEMO_MODE
) {
1734 // no escaping is done here on purpose
1735 $exp = trim($_GET["exp"]);
1737 $result = db_query($link,
1738 "INSERT INTO ttrss_labels (sql_exp,description,owner_uid)
1739 VALUES ('$exp', '$exp', '".$_SESSION["uid"]."')");
1743 print "<div class=\"prefGenericAddBox\">
1744 <input size=\"40\" id=\"ladd_expr\"> ";
1746 print"<input type=\"submit\" class=\"button\"
1747 onclick=\"javascript:addLabel()\" value=\"Add label\"></div>";
1749 $result = db_query($link, "SELECT
1750 id,sql_exp,description
1754 owner_uid = ".$_SESSION["uid"]."
1755 ORDER by description");
1757 if (db_num_rows($result) != 0) {
1759 print "<p><table width=\"100%\" class=\"prefLabelList\" id=\"prefLabelList\">";
1761 print "<tr class=\"title\">
1762 <td width=\"5%\">Select</td><td width=\"40%\">SQL expression
1763 <a class=\"helpLink\" href=\"javascript:popupHelp(1)\">(?)</a>
1765 <td width=\"40%\">Caption</td></tr>";
1769 while ($line = db_fetch_assoc($result)) {
1771 $class = ($lnum %
2) ?
"even" : "odd";
1773 $label_id = $line["id"];
1774 $edit_label_id = $_GET["id"];
1776 if ($subop == "edit" && $label_id != $edit_label_id) {
1780 print "<tr class=\"$class\" id=\"LILRR-$label_id\">";
1782 $line["sql_exp"] = htmlspecialchars($line["sql_exp"]);
1783 $line["description"] = htmlspecialchars($line["description"]);
1785 if (!$edit_label_id ||
$subop != "edit") {
1787 if (!$line["description"]) $line["description"] = "[No caption]";
1789 print "<td><input onclick='toggleSelectRow(this);'
1790 type=\"checkbox\" id=\"LICHK-".$line["id"]."\"></td>";
1792 print "<td><a href=\"javascript:editLabel($label_id);\">" .
1793 $line["sql_exp"] . "</td>";
1795 print "<td><a href=\"javascript:editLabel($label_id);\">" .
1796 $line["description"] . "</td>";
1798 } else if ($label_id != $edit_label_id) {
1800 if (!$line["description"]) $line["description"] = "[No description]";
1802 print "<td><input disabled=\"true\" type=\"checkbox\"
1803 id=\"LICHK-".$line["id"]."\"></td>";
1805 print "<td>".$line["sql_exp"]."</td>";
1806 print "<td>".$line["description"]."</td>";
1810 print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>";
1812 print "<td><input id=\"iedit_expr\" value=\"".$line["sql_exp"].
1815 print "<td><input id=\"iedit_descr\" value=\"".$line["description"].
1827 print "<tr><td colspan=\"4\" align=\"center\">No labels defined.</td></tr>";
1834 if ($subop == "edit") {
1836 <input type=\"submit\" class=\"button\"
1837 onclick=\"javascript:labelEditCancel()\" value=\"Cancel\">
1838 <input type=\"submit\" class=\"button\"
1839 onclick=\"javascript:labelEditSave()\" value=\"Save\">";
1845 <input type=\"submit\" class=\"button\"
1846 onclick=\"javascript:editSelectedLabel()\" value=\"Edit\">
1847 <input type=\"submit\" class=\"button\"
1848 onclick=\"javascript:removeSelectedLabels()\" value=\"Remove\">";
1851 print "<p>No labels defined.</p>";
1855 if ($op == "error") {
1856 print "<div width=\"100%\" align='center'>";
1857 $msg = $_GET["msg"];
1862 if ($op == "help") {
1864 <title>Tiny Tiny RSS : Help</title>
1865 <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">
1866 <script type=\"text/javascript\" src=\"functions.js\"></script>
1867 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
1870 $tid = sprintf("%d", $_GET["tid"]);
1872 /* FIXME this badly needs real implementation */
1874 print "<div class='helpResponse'>";
1878 <h1
>Help
for SQL expressions
</h1
>
1880 <h2
>Description
</h2
>
1882 <p
>The
«
;SQL expression
»
; is added to WHERE clause of
1883 view feed query
. You can match on ttrss_entries table fields
1884 and even
use subselect to query additional information
. This
1885 functionality is considered to be advanced
and requires basic
1886 understanding of SQL
.</p
>
1890 <pre
>unread
= true</pre
>
1892 Matches all unread articles
1894 <pre
>title like
'%Linux%'</pre
>
1896 Matches all articles which mention Linux in the title
. You get the idea
.
1898 <p
>See the database schema included in the distribution package
for gruesome
1903 print "<div align='center'>
1904 <a class=\"helpLink\"
1905 href=\"javascript:window.close()\">(Close this window)</a></div>";
1909 print "</body></html>";
1915 $param = $_GET["param"];
1917 if ($id == "quickAddFeed") {
1918 print "Feed URL: <input
1919 onblur=\"javascript:enableHotkeys()\" onfocus=\"javascript:disableHotkeys()\"
1921 <input class=\"button\"
1922 type=\"submit\" onclick=\"javascript:qafAdd()\" value=\"Add feed\">
1923 <input class=\"button\"
1924 type=\"submit\" onclick=\"javascript:closeDlg()\"
1928 if ($id == "quickDelFeed") {
1930 $param = db_escape_string($param);
1932 $result = db_query($link, "SELECT title FROM ttrss_feeds WHERE id = '$param'");
1936 $f_title = db_fetch_result($result, 0, "title");
1938 print "Remove current feed ($f_title)?
1939 <input class=\"button\"
1940 type=\"submit\" onclick=\"javascript:qfdDelete($param)\" value=\"Remove\">
1941 <input class=\"button\"
1942 type=\"submit\" onclick=\"javascript:closeDlg()\"
1945 print "Error: Feed $param not found.
1946 <input class=\"button\"
1947 type=\"submit\" onclick=\"javascript:closeDlg()\"
1952 if ($id == "search") {
1954 print "<input id=\"searchbox\" class=\"extSearch\"
1955 onblur=\"javascript:enableHotkeys()\" onfocus=\"javascript:disableHotkeys()\"
1956 onchange=\"javascript:search()\">
1957 <select id=\"searchmodebox\">
1958 <option selected>All feeds</option>
1959 <option>This feed</option>
1961 <input type=\"submit\"
1962 class=\"button\" onclick=\"javascript:search()\" value=\"Search\">
1963 <input class=\"button\"
1964 type=\"submit\" onclick=\"javascript:closeDlg()\"
1971 // update feeds of all users, may be used anonymously
1972 if ($op == "globalUpdateFeeds") {
1974 $result = db_query($link, "SELECT id FROM ttrss_users");
1976 while ($line = db_fetch_assoc($result)) {
1977 $user_id = $line["id"];
1978 // print "<!-- updating feeds of uid $user_id -->";
1979 update_all_feeds($link, false, $user_id);
1983 <message msg=\"All feeds updated\"/>
1988 if ($op == "pref-prefs") {
1990 $subop = $_REQUEST["subop"];
1992 if ($subop == "Save configuration") {
1994 if (WEB_DEMO_MODE
) {
1995 header("Location: prefs.php");
1999 $_SESSION["prefs_op_result"] = "save-config";
2001 foreach (array_keys($_POST) as $pref_name) {
2003 $pref_name = db_escape_string($pref_name);
2004 $value = db_escape_string($_POST[$pref_name]);
2006 $result = db_query($link, "SELECT type_name
2007 FROM ttrss_prefs,ttrss_prefs_types
2008 WHERE pref_name = '$pref_name' AND type_id = ttrss_prefs_types.id");
2010 if (db_num_rows($result) > 0) {
2012 $type_name = db_fetch_result($result, 0, "type_name");
2014 // print "$pref_name : $type_name : $value<br>";
2016 if ($type_name == "bool") {
2017 if ($value == "1") {
2022 } else if ($type_name == "integer") {
2023 $value = sprintf("%d", $value);
2026 // print "$pref_name : $type_name : $value<br>";
2028 db_query($link, "UPDATE ttrss_user_prefs SET value = '$value'
2029 WHERE pref_name = '$pref_name' AND owner_uid = ".$_SESSION["uid"]);
2033 header("Location: prefs.php");
2037 } else if ($subop == "getHelp") {
2039 $pref_name = db_escape_string($_GET["pn"]);
2041 $result = db_query($link, "SELECT help_text FROM ttrss_prefs
2042 WHERE pref_name = '$pref_name'");
2044 if (db_num_rows($result) > 0) {
2045 $help_text = db_fetch_result($result, 0, "help_text");
2048 print "Unknown option: $pref_name";
2051 } else if ($subop == "Change password") {
2053 if (WEB_DEMO_MODE
) {
2054 header("Location: prefs.php");
2058 $old_pw = $_POST["OLD_PASSWORD"];
2059 $new_pw = $_POST["OLD_PASSWORD"];
2061 $old_pw_hash = 'SHA1:' . sha1($_POST["OLD_PASSWORD"]);
2062 $new_pw_hash = 'SHA1:' . sha1($_POST["NEW_PASSWORD"]);
2064 $active_uid = $_SESSION["uid"];
2066 if ($old_pw && $new_pw) {
2068 $login = db_escape_string($_SERVER['PHP_AUTH_USER']);
2070 $result = db_query($link, "SELECT id FROM ttrss_users WHERE
2071 id = '$active_uid' AND (pwd_hash = '$old_pw' OR
2072 pwd_hash = '$old_pw_hash')");
2074 if (db_num_rows($result) == 1) {
2075 db_query($link, "UPDATE ttrss_users SET pwd_hash = '$new_pw_hash'
2076 WHERE id = '$active_uid'");
2078 $_SESSION["pwd_change_result"] = "ok";
2080 $_SESSION["pwd_change_result"] = "failed";
2084 header("Location: prefs.php");
2086 } else if ($subop == "Reset to defaults") {
2088 if (WEB_DEMO_MODE
) {
2089 header("Location: prefs.php");
2093 $_SESSION["prefs_op_result"] = "reset-to-defaults";
2095 if (DB_TYPE
== "pgsql") {
2096 db_query($link,"UPDATE ttrss_user_prefs
2097 SET value = ttrss_prefs.def_value
2098 WHERE owner_uid = '".$_SESSION["uid"]."' AND
2099 ttrss_prefs.pref_name = ttrss_user_prefs.pref_name");
2101 db_query($link, "DELETE FROM ttrss_user_prefs
2102 WHERE owner_uid = ".$_SESSION["uid"]);
2103 initialize_user_prefs($link, $_SESSION["uid"]);
2106 header("Location: prefs.php");
2110 if (!SINGLE_USER_MODE
) {
2112 $result = db_query($link, "SELECT id FROM ttrss_users
2113 WHERE id = ".$_SESSION["uid"]." AND (pwd_hash = 'password' OR
2114 pwd_hash = 'SHA1:".sha1("password")."')");
2116 if (db_num_rows($result) != 0) {
2117 print "<div class=\"warning\">
2118 Your password is at default value, please change it.
2122 if ($_SESSION["pwd_change_result"] == "failed") {
2123 print "<div class=\"warning\">
2124 There was an error while changing your password.
2128 if ($_SESSION["pwd_change_result"] == "ok") {
2129 print "<div class=\"notice\">
2130 Password changed successfully.
2134 $_SESSION["pwd_change_result"] = "";
2136 if ($_SESSION["prefs_op_result"] == "reset-to-defaults") {
2137 print "<div class=\"notice\">
2138 Your configuration was reset to defaults.
2142 if ($_SESSION["prefs_op_result"] == "save-config") {
2143 print "<div class=\"notice\">
2144 Your configuration was saved successfully.
2148 $_SESSION["prefs_op_result"] = "";
2150 print "<form action=\"backend.php\" method=\"POST\">";
2152 print "<table width=\"100%\" class=\"prefPrefsList\">";
2153 print "<tr><td colspan='3'><h3>Authentication</h3></tr></td>";
2155 print "<tr><td width=\"40%\">Old password</td>";
2156 print "<td><input class=\"editbox\" type=\"password\"
2157 name=\"OLD_PASSWORD\"></td></tr>";
2159 print "<tr><td width=\"40%\">New password</td>";
2161 print "<td><input class=\"editbox\" type=\"password\"
2162 name=\"NEW_PASSWORD\"></td></tr>";
2166 print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">";
2168 print "<p><input class=\"button\" type=\"submit\"
2169 value=\"Change password\" name=\"subop\">";
2175 $result = db_query($link, "SELECT
2176 ttrss_user_prefs.pref_name,short_desc,help_text,value,type_name,
2177 section_name,def_value
2178 FROM ttrss_prefs,ttrss_prefs_types,ttrss_prefs_sections,ttrss_user_prefs
2179 WHERE type_id = ttrss_prefs_types.id AND
2180 section_id = ttrss_prefs_sections.id AND
2181 ttrss_user_prefs.pref_name = ttrss_prefs.pref_name AND
2182 owner_uid = ".$_SESSION["uid"]."
2183 ORDER BY section_id,short_desc");
2185 print "<form action=\"backend.php\" method=\"POST\">";
2189 $active_section = "";
2191 while ($line = db_fetch_assoc($result)) {
2193 if ($active_section != $line["section_name"]) {
2195 if ($active_section != "") {
2199 print "<p><table width=\"100%\" class=\"prefPrefsList\">";
2201 $active_section = $line["section_name"];
2203 print "<tr><td colspan=\"3\"><h3>$active_section</h3></td></tr>";
2204 // print "<tr class=\"title\">
2205 // <td width=\"25%\">Option</td><td>Value</td></tr>";
2210 // $class = ($lnum % 2) ? "even" : "odd";
2214 $type_name = $line["type_name"];
2215 $pref_name = $line["pref_name"];
2216 $value = $line["value"];
2217 $def_value = $line["def_value"];
2218 $help_text = $line["help_text"];
2220 print "<td width=\"40%\" id=\"$pref_name\">" . $line["short_desc"];
2222 if ($help_text) print "<div class=\"prefHelp\">$help_text</div>";
2228 if ($type_name == "bool") {
2229 // print_select($pref_name, $value, array("true", "false"));
2231 if ($value == "true") {
2237 print_radio($pref_name, $value, array("Yes", "No"));
2240 print "<input class=\"editbox\" name=\"$pref_name\" value=\"$value\">";
2252 print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">";
2254 print "<p><input class=\"button\" type=\"submit\"
2255 name=\"subop\" value=\"Save configuration\">";
2257 print " <input class=\"button\" type=\"submit\"
2258 name=\"subop\" value=\"Reset to defaults\"></p>";
2266 if ($op == "pref-users") {
2268 $subop = $_GET["subop"];
2270 if ($subop == "editSave") {
2272 if (!WEB_DEMO_MODE
) {
2274 $login = db_escape_string($_GET["l"]);
2275 $uid = db_escape_string($_GET["id"]);
2276 $access_level = sprintf("%d", $_GET["al"]);
2278 db_query($link, "UPDATE ttrss_users SET login = '$login', access_level = '$access_level' WHERE id = '$uid'");
2281 } else if ($subop == "remove") {
2283 if (!WEB_DEMO_MODE
&& $_SESSION["access_level"] >= 10) {
2285 $ids = split(",", $_GET["ids"]);
2287 foreach ($ids as $id) {
2288 db_query($link, "DELETE FROM ttrss_users WHERE id = '$id' AND id != " . $_SESSION["uid"]);
2292 } else if ($subop == "add") {
2294 if (!WEB_DEMO_MODE
&& $_SESSION["access_level"] >= 10) {
2296 $login = db_escape_string(trim($_GET["login"]));
2297 $tmp_user_pwd = make_password(8);
2298 $pwd_hash = 'SHA1:' . sha1($tmp_user_pwd);
2300 db_query($link, "INSERT INTO ttrss_users (login,pwd_hash,access_level)
2301 VALUES ('$login', '$pwd_hash', 0)");
2304 $result = db_query($link, "SELECT id FROM ttrss_users WHERE
2305 login = '$login' AND pwd_hash = '$pwd_hash'");
2307 if (db_num_rows($result) == 1) {
2309 $new_uid = db_fetch_result($result, 0, "id");
2311 print "<div class=\"notice\">Added user <b>".$_GET["login"].
2312 "</b> with password <b>$tmp_user_pwd</b>.</div>";
2314 initialize_user($link, $new_uid);
2318 print "<div class=\"warning\">Error while adding user <b>".
2319 $_GET["login"].".</b></div>";
2323 } else if ($subop == "resetPass") {
2325 if (!WEB_DEMO_MODE
&& $_SESSION["access_level"] >= 10) {
2327 $uid = db_escape_string($_GET["id"]);
2329 $result = db_query($link, "SELECT login FROM ttrss_users WHERE id = '$uid'");
2331 $login = db_fetch_result($result, 0, "login");
2332 $tmp_user_pwd = make_password(8);
2333 $pwd_hash = 'SHA1:' . sha1($tmp_user_pwd);
2335 db_query($link, "UPDATE ttrss_users SET pwd_hash = '$pwd_hash'
2336 WHERE id = '$uid'");
2338 print "<div class=\"notice\">Changed password of
2339 user <b>$login</b> to <b>$tmp_user_pwd</b>.</div>";
2344 print "<div class=\"prefGenericAddBox\">
2345 <input id=\"uadd_box\" size=\"40\"> ";
2347 print"<input type=\"submit\" class=\"button\"
2348 onclick=\"javascript:addUser()\" value=\"Add user\"></div>";
2350 $result = db_query($link, "SELECT
2351 id,login,access_level,
2352 SUBSTRING(last_login,1,16) as last_login
2357 print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>";
2359 print "<p><table width=\"100%\" class=\"prefUserList\" id=\"prefUserList\">";
2361 print "<tr class=\"title\">
2362 <td width=\"5%\">Select</td>
2363 <td width='30%'>Username</td>
2364 <td width='30%'>Access Level</td>
2365 <td width='30%'>Last login</td></tr>";
2369 while ($line = db_fetch_assoc($result)) {
2371 $class = ($lnum %
2) ?
"even" : "odd";
2374 $edit_uid = $_GET["id"];
2376 if ($uid == $_SESSION["uid"] ||
($subop == "edit" && $uid != $edit_uid)) {
2380 print "<tr class=\"$class\" id=\"UMRR-$uid\">";
2382 $line["login"] = htmlspecialchars($line["login"]);
2384 if ($uid == $_SESSION["uid"]) {
2386 print "<td><input disabled=\"true\" type=\"checkbox\"
2387 id=\"UMCHK-".$line["id"]."\"></td>";
2389 print "<td>".$line["login"]."</td>";
2390 print "<td>".$line["access_level"]."</td>";
2392 } else if (!$edit_uid ||
$subop != "edit") {
2394 print "<td><input onclick='toggleSelectRow(this);'
2395 type=\"checkbox\" id=\"UMCHK-$uid\"></td>";
2397 print "<td><a href=\"javascript:editUser($uid);\">" .
2398 $line["login"] . "</td>";
2400 print "<td><a href=\"javascript:editUser($uid);\">" .
2401 $line["access_level"] . "</td>";
2403 } else if ($uid != $edit_uid) {
2405 print "<td><input disabled=\"true\" type=\"checkbox\"
2406 id=\"UMCHK-".$line["id"]."\"></td>";
2408 print "<td>".$line["login"]."</td>";
2409 print "<td>".$line["access_level"]."</td>";
2413 print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>";
2415 print "<td><input id=\"iedit_ulogin\" value=\"".$line["login"].
2418 print "<td><input id=\"iedit_ulevel\" value=\"".$line["access_level"].
2423 print "<td>".$line["last_login"]."</td>";
2434 if ($subop == "edit") {
2436 <input type=\"submit\" class=\"button\"
2437 onclick=\"javascript:userEditCancel()\" value=\"Cancel\">
2438 <input type=\"submit\" class=\"button\"
2439 onclick=\"javascript:userEditSave()\" value=\"Save\">";
2445 <input type=\"submit\" class=\"button\"
2446 onclick=\"javascript:selectedUserDetails()\" value=\"User details\">
2447 <input type=\"submit\" class=\"button\"
2448 onclick=\"javascript:editSelectedUser()\" value=\"Edit\">
2449 <input type=\"submit\" class=\"button\"
2450 onclick=\"javascript:removeSelectedUsers()\" value=\"Remove\">
2451 <input type=\"submit\" class=\"button\"
2452 onclick=\"javascript:resetSelectedUserPass()\" value=\"Reset password\">";
2457 if ($op == "user-details") {
2459 if (WEB_DEMO_MODE ||
$_SESSION["access_level"] < 10) {
2463 /* print "<html><head>
2464 <title>Tiny Tiny RSS : User Details</title>
2465 <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">
2466 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
2469 $uid = sprintf("%d", $_GET["id"]);
2471 print "<div class='infoBoxContents'>";
2473 $result = db_query($link, "SELECT login,
2474 SUBSTRING(last_login,1,16) AS last_login,
2476 (SELECT COUNT(int_id) FROM ttrss_user_entries
2477 WHERE owner_uid = id) AS stored_articles
2479 WHERE id = '$uid'");
2481 if (db_num_rows($result) == 0) {
2482 print "<h1>User not found</h1>";
2486 print "<h1>User Details</h1>";
2488 print "<table width='100%'>";
2490 $login = db_fetch_result($result, 0, "login");
2491 $last_login = db_fetch_result($result, 0, "last_login");
2492 $access_level = db_fetch_result($result, 0, "access_level");
2493 $stored_articles = db_fetch_result($result, 0, "stored_articles");
2495 print "<tr><td>Username</td><td>$login</td></tr>";
2496 print "<tr><td>Access level</td><td>$access_level</td></tr>";
2497 print "<tr><td>Last logged in</td><td>$last_login</td></tr>";
2498 print "<tr><td>Stored articles</td><td>$stored_articles</td></tr>";
2500 $result = db_query($link, "SELECT COUNT(id) as num_feeds FROM ttrss_feeds
2501 WHERE owner_uid = '$uid'");
2503 $num_feeds = db_fetch_result($result, 0, "num_feeds");
2505 print "<tr><td>Subscribed feeds count</td><td>$num_feeds</td></tr>";
2507 /* $result = db_query($link, "SELECT
2508 SUM(LENGTH(content)+LENGTH(title)+LENGTH(link)+LENGTH(guid)) AS db_size
2509 FROM ttrss_user_entries,ttrss_entries
2510 WHERE owner_uid = '$uid' AND ref_id = id");
2512 $db_size = round(db_fetch_result($result, 0, "db_size") / 1024);
2514 print "<tr><td>Approx. used DB size</td><td>$db_size KBytes</td></tr>"; */
2518 print "<h1>Subscribed feeds</h1>";
2520 $result = db_query($link, "SELECT id,title,feed_url FROM ttrss_feeds
2521 WHERE owner_uid = '$uid' ORDER BY title");
2523 print "<ul class=\"nomarks\">";
2525 while ($line = db_fetch_assoc($result)) {
2527 $icon_file = ICONS_URL
."/".$line["id"].".ico";
2529 if (file_exists($icon_file) && filesize($icon_file) > 0) {
2530 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"$icon_file\">";
2532 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
2535 print "<li>$feed_icon <a href=\"".$line["feed_url"]."\">".$line["title"]."</a></li>";
2542 print "<div align='center'>
2543 <input type='submit' class='button'
2544 onclick=\"closeInfoBox()\" value=\"Close this window\"></div>";
2546 // print "</body></html>";
2550 if ($op == "feed-details") {
2552 $feed_id = $_GET["id"];
2554 $result = db_query($link,
2556 title,feed_url,last_updated,icon_url,site_url,
2557 (SELECT COUNT(int_id) FROM ttrss_user_entries
2558 WHERE feed_id = id) AS total,
2559 (SELECT COUNT(int_id) FROM ttrss_user_entries
2560 WHERE feed_id = id AND unread = true) AS unread,
2561 (SELECT COUNT(int_id) FROM ttrss_user_entries
2562 WHERE feed_id = id AND marked = true) AS marked
2564 WHERE id = '$feed_id' AND owner_uid = ".$_SESSION["uid"]);
2566 if (db_num_rows($result) == 0) return;
2568 $title = db_fetch_result($result, 0, "title");
2569 $last_updated = db_fetch_result($result, 0, "last_updated");
2570 $feed_url = db_fetch_result($result, 0, "feed_url");
2571 $icon_url = db_fetch_result($result, 0, "icon_url");
2572 $total = db_fetch_result($result, 0, "total");
2573 $unread = db_fetch_result($result, 0, "unread");
2574 $marked = db_fetch_result($result, 0, "marked");
2575 $site_url = db_fetch_result($result, 0, "site_url");
2577 $result = db_query($link, "SELECT COUNT(id) AS subscribed
2578 FROM ttrss_feeds WHERE feed_url = '$feed_url'");
2580 $subscribed = db_fetch_result($result, 0, "subscribed");
2582 print "<div class=\"infoBoxContents\">";
2584 $icon_file = ICONS_DIR
. "/$feed_id.ico";
2586 if (file_exists($icon_file) && filesize($icon_file) > 0) {
2587 $feed_icon = "<img width=\"16\" height=\"16\"
2588 src=\"" . ICONS_URL
. "/$feed_id.ico\">";
2593 print "<h1>$feed_icon $title</h1>";
2595 print "<table width='100%'>";
2598 print "<tr><td width='30%'>Link</td>
2599 <td><a href=\"$site_url\">$site_url</a>
2600 <a href=\"$feed_url\">(feed)</a></td>
2603 print "<tr><td width='30%'>Feed URL</td>
2604 <td><a href=\"$feed_url\">$feed_url</a></td></tr>";
2606 print "<tr><td>Last updated</td><td>$last_updated</td></tr>";
2607 print "<tr><td>Total articles</td><td>$total</td></tr>";
2608 print "<tr><td>Unread articles</td><td>$unread</td></tr>";
2609 print "<tr><td>Starred articles</td><td>$marked</td></tr>";
2610 print "<tr><td>Subscribed users</td><td>$subscribed</td></tr>";
2614 $result = db_query($link, "SELECT title,
2615 SUBSTRING(updated,1,16) AS updated,unread
2616 FROM ttrss_entries,ttrss_user_entries
2617 WHERE ref_id = id AND feed_id = '$feed_id'
2618 ORDER BY date_entered DESC LIMIT 5");
2620 if (db_num_rows($result) > 0) {
2622 print "<h1>Latest headlines</h1>";
2624 print "<ul class=\"nomarks\">";
2626 while ($line = db_fetch_assoc($result)) {
2627 if ($line["unread"] == "t" ||
$line["unread"] == "1") {
2628 $line["title"] = "<b>" . $line["title"] . "</b>";
2630 print "<li>" . $line["title"].
2631 " <span class=\"insensitive\">(" .$line["updated"].")</span></li>";
2638 print "<div align='center'>
2639 <input type='submit' class='button'
2640 onclick=\"closeInfoBox()\" value=\"Close this window\"></div>";
2647 <!-- <?
= sprintf("Backend execution time: %.4f seconds", getmicrotime() - $script_started) ?
> -->