5 define('DEFAULT_ERROR_LEVEL', E_ALL
);
7 define('DEFAULT_ERROR_LEVEL', E_ERROR | E_WARNING | E_PARSE
);
10 error_reporting(DEFAULT_ERROR_LEVEL
);
12 $op = $_REQUEST["op"];
14 if ((!$op ||
$op == "rpc" ||
$op == "globalUpdateFeeds") && !$_REQUEST["noxml"]) {
15 header("Content-Type: application/xml");
18 if (!$_SESSION["uid"] && $op != "globalUpdateFeeds") {
21 print "<error error-code=\"6\"/>";
27 print "<error error-code=\"7\"/>";
31 define('SCHEMA_VERSION', 2);
33 require_once "sanity_check.php";
34 require_once "config.php";
35 require_once "db.php";
36 require_once "db-prefs.php";
37 require_once "functions.php";
38 require_once "magpierss/rss_fetch.inc";
40 $script_started = getmicrotime();
42 $link = db_connect(DB_HOST
, DB_USER
, DB_PASS
, DB_NAME
);
45 if (DB_TYPE
== "mysql") {
48 // PG seems to display its own errors just fine by default.
52 if (DB_TYPE
== "pgsql") {
53 pg_query("set client_encoding = 'utf-8'");
56 $fetch = $_GET["fetch"];
58 /* FIXME this needs reworking */
60 function getGlobalCounters($link) {
61 $result = db_query($link, "SELECT count(id) as c_id FROM ttrss_entries,ttrss_user_entries
62 WHERE unread = true AND
63 ttrss_user_entries.ref_id = ttrss_entries.id AND
64 owner_uid = " . $_SESSION["uid"]);
65 $c_id = db_fetch_result($result, 0, "c_id");
66 print "<counter id='global-unread' counter='$c_id'/>";
69 function getTagCounters($link) {
71 $result = db_query($link, "SELECT tag_name,count(ttrss_entries.id) AS count
72 FROM ttrss_tags,ttrss_entries,ttrss_user_entries WHERE
73 ttrss_user_entries.ref_id = ttrss_entries.id AND
74 ttrss_tags.owner_uid = ".$_SESSION["uid"]." AND
75 post_int_id = ttrss_user_entries.int_id AND unread = true GROUP BY tag_name
77 select tag_name,0 as count FROM ttrss_tags
78 WHERE ttrss_tags.owner_uid = ".$_SESSION["uid"]);
82 while ($line = db_fetch_assoc($result)) {
83 $tags[$line["tag_name"]] +
= $line["count"];
86 foreach (array_keys($tags) as $tag) {
87 $unread = $tags[$tag];
89 $tag = htmlspecialchars($tag);
90 print "<tag id=\"$tag\" counter=\"$unread\"/>";
94 function getLabelCounters($link) {
96 $result = db_query($link, "SELECT count(id) as count FROM ttrss_entries,ttrss_user_entries
97 WHERE marked = true AND ttrss_user_entries.ref_id = ttrss_entries.id AND
98 unread = true AND owner_uid = ".$_SESSION["uid"]);
100 $count = db_fetch_result($result, 0, "count");
102 print "<label id=\"-1\" counter=\"$count\"/>";
104 $result = db_query($link, "SELECT owner_uid,id,sql_exp,description FROM
105 ttrss_labels WHERE owner_uid = ".$_SESSION["uid"]." ORDER by description");
107 while ($line = db_fetch_assoc($result)) {
109 $id = -$line["id"] - 11;
113 $tmp_result = db_query($link, "SELECT count(id) as count FROM ttrss_user_entries,ttrss_entries
114 WHERE (" . $line["sql_exp"] . ") AND unread = true AND
115 ttrss_user_entries.ref_id = ttrss_entries.id AND
116 owner_uid = ".$_SESSION["uid"]);
118 $count = db_fetch_result($tmp_result, 0, "count");
120 print "<label id=\"$id\" counter=\"$count\"/>";
122 error_reporting (DEFAULT_ERROR_LEVEL
);
127 function getFeedCounter($link, $id) {
129 $result = db_query($link, "SELECT
130 count(id) as count FROM ttrss_entries,ttrss_user_entries
131 WHERE feed_id = '$id' AND unread = true
132 AND ttrss_user_entries.ref_id = ttrss_entries.id");
134 $count = db_fetch_result($result, 0, "count");
136 print "<feed id=\"$id\" counter=\"$count\"/>";
139 function getFeedCounters($link) {
141 $result = db_query($link, "SELECT id,
143 FROM ttrss_entries,ttrss_user_entries
144 WHERE feed_id = ttrss_feeds.id AND ttrss_user_entries.ref_id = ttrss_entries.id
145 AND unread = true AND owner_uid = ".$_SESSION["uid"].") as count
146 FROM ttrss_feeds WHERE owner_uid = ".$_SESSION["uid"]);
148 while ($line = db_fetch_assoc($result)) {
151 $count = $line["count"];
153 print "<feed id=\"$id\" counter=\"$count\"/>";
157 function outputFeedList($link, $tags = false) {
160 <title>Tiny Tiny RSS : Feedlist</title>
161 <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">";
163 if (get_pref($link, 'USE_COMPACT_STYLESHEET')) {
164 print "<link rel=\"stylesheet\" type=\"text/css\"
165 href=\"tt-rss_compact.css\"/>";
167 print "<link title=\"Compact Stylesheet\" rel=\"alternate stylesheet\"
168 type=\"text/css\" href=\"tt-rss_compact.css\"/>";
171 print "<script type=\"text/javascript\" src=\"functions.js\"></script>
172 <script type=\"text/javascript\" src=\"feedlist.js\"></script>
173 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
174 </head><body onload=\"init()\">";
176 print "<ul class=\"feedList\" id=\"feedList\">";
178 $owner_uid = $_SESSION["uid"];
184 if (get_pref($link, 'ENABLE_FEED_CATS')) {
185 print "<li class=\"feedCat\">Special</li>";
186 print "<li id=\"feedCatHolder\"><ul class=\"feedCatList\">";
189 $result = db_query($link, "SELECT count(id) as num_starred
190 FROM ttrss_entries,ttrss_user_entries
191 WHERE marked = true AND
192 ttrss_user_entries.ref_id = ttrss_entries.id AND
193 unread = true AND owner_uid = '$owner_uid'");
194 $num_starred = db_fetch_result($result, 0, "num_starred");
198 if ($num_starred > 0) $class .= "Unread";
200 printFeedEntry(-1, $class, "Starred articles", $num_starred,
201 "images/mark_set.png", $link);
203 if (get_pref($link, 'ENABLE_FEED_CATS')) {
207 if (get_pref($link, 'ENABLE_LABELS')) {
209 $result = db_query($link, "SELECT id,sql_exp,description FROM
210 ttrss_labels WHERE owner_uid = '$owner_uid' ORDER by description");
212 if (db_num_rows($result) > 0) {
213 if (get_pref($link, 'ENABLE_FEED_CATS')) {
214 print "<li class=\"feedCat\">Labels</li>";
215 print "<li id=\"feedCatHolder\"><ul class=\"feedCatList\">";
217 print "<li><hr></li>";
221 while ($line = db_fetch_assoc($result)) {
225 $tmp_result = db_query($link, "SELECT count(id) as count FROM ttrss_entries,ttrss_user_entries
226 WHERE (" . $line["sql_exp"] . ") AND unread = true AND
227 ttrss_user_entries.ref_id = ttrss_entries.id
228 AND owner_uid = '$owner_uid'");
230 $count = db_fetch_result($tmp_result, 0, "count");
238 error_reporting (DEFAULT_ERROR_LEVEL
);
240 printFeedEntry(-$line["id"]-11,
241 $class, $line["description"], $count, "images/label.png", $link);
245 if (db_num_rows($result) > 0) {
246 if (get_pref($link, 'ENABLE_FEED_CATS')) {
253 // if (!get_pref($link, 'ENABLE_FEED_CATS')) {
254 print "<li><hr></li>";
257 if (get_pref($link, 'ENABLE_FEED_CATS')) {
258 $order_by_qpart = "category,title";
260 $order_by_qpart = "title";
263 $result = db_query($link, "SELECT *,
264 (SELECT count(id) FROM ttrss_entries,ttrss_user_entries
265 WHERE feed_id = ttrss_feeds.id AND
266 ttrss_user_entries.ref_id = ttrss_entries.id AND
267 owner_uid = '$owner_uid') AS total,
268 (SELECT count(id) FROM ttrss_entries,ttrss_user_entries
269 WHERE feed_id = ttrss_feeds.id AND unread = true
270 AND ttrss_user_entries.ref_id = ttrss_entries.id
271 AND owner_uid = '$owner_uid') as unread,
272 (SELECT title FROM ttrss_feed_categories
273 WHERE id = cat_id) AS category
274 FROM ttrss_feeds WHERE owner_uid = '$owner_uid' ORDER BY $order_by_qpart");
276 $actid = $_GET["actid"];
286 while ($line = db_fetch_assoc($result)) {
288 $feed = $line["title"];
289 $feed_id = $line["id"];
291 $subop = $_GET["subop"];
293 $total = $line["total"];
294 $unread = $line["unread"];
296 $tmp_category = $line["category"];
298 if (!$tmp_category) {
299 $tmp_category = "Uncategorized";
302 // $class = ($lnum % 2) ? "even" : "odd";
306 if ($unread > 0) $class .= "Unread";
308 if ($actid == $feed_id) {
309 $class .= "Selected";
312 $total_unread +
= $unread;
314 if ($category != $tmp_category && get_pref($link, 'ENABLE_FEED_CATS')) {
317 print "</li></ul></li>";
320 $category = $tmp_category;
322 print "<li class=\"feedCat\">$category</li>";
323 print "<li id=\"feedCatHolder\"><ul class=\"feedCatList\">";
326 printFeedEntry($feed_id, $class, $feed, $unread,
327 "icons/$feed_id.ico", $link);
336 $result = db_query($link, "SELECT tag_name,count(ttrss_entries.id) AS count
337 FROM ttrss_tags,ttrss_entries,ttrss_user_entries WHERE
338 post_int_id = ttrss_user_entries.int_id AND
339 unread = true AND ref_id = ttrss_entries.id
340 AND ttrss_tags.owner_uid = '$owner_uid' GROUP BY tag_name
342 select tag_name,0 as count FROM ttrss_tags WHERE owner_uid = '$owner_uid'
347 while ($line = db_fetch_assoc($result)) {
348 $tags[$line["tag_name"]] +
= $line["count"];
351 foreach (array_keys($tags) as $tag) {
353 $unread = $tags[$tag];
361 printFeedEntry($tag, $class, $tag, $unread, "images/tag.png", $link);
367 if (db_num_rows($result) == 0) {
373 print "<li>No $what to display.</li>";
378 print "<div class=\"invisible\" id=\"FEEDTU\">$total_unread</div>";
385 $subop = $_GET["subop"];
387 if ($subop == "getLabelCounters") {
390 getLabelCounters($link);
392 getFeedCounter($link, $aid);
394 print "</rpc-reply>";
397 if ($subop == "getFeedCounters") {
399 getFeedCounters($link);
400 print "</rpc-reply>";
403 if ($subop == "getAllCounters") {
405 getLabelCounters($link);
406 getFeedCounters($link);
407 getTagCounters($link);
408 getGlobalCounters($link);
409 print "</rpc-reply>";
412 if ($subop == "mark") {
413 $mark = $_GET["mark"];
414 $id = db_escape_string($_GET["id"]);
422 // FIXME this needs collision testing
424 $result = db_query($link, "UPDATE ttrss_user_entries SET marked = $mark
425 WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
428 if ($subop == "updateFeed") {
429 $feed_id = db_escape_string($_GET["feed"]);
431 $result = db_query($link,
432 "SELECT feed_url FROM ttrss_feeds WHERE id = '$feed_id'
433 AND owner_uid = " . $_SESSION["uid"]);
435 if (db_num_rows($result) > 0) {
436 $feed_url = db_fetch_result($result, 0, "feed_url");
437 update_rss_feed($link, $feed_url, $feed_id);
441 getFeedCounter($link, $feed_id);
442 print "</rpc-reply>";
447 if ($subop == "forceUpdateAllFeeds" ||
$subop == "updateAllFeeds") {
449 update_all_feeds($link, $subop == "forceUpdateAllFeeds");
451 $omode = $_GET["omode"];
453 if (!$omode) $omode = "tfl";
456 if (strchr($omode, "l")) getLabelCounters($link);
457 if (strchr($omode, "f")) getFeedCounters($link);
458 if (strchr($omode, "t")) getTagCounters($link);
459 getGlobalCounters($link);
460 print "</rpc-reply>";
463 if ($subop == "catchupSelected") {
465 $ids = split(",", $_GET["ids"]);
467 foreach ($ids as $id) {
469 db_query($link, "UPDATE ttrss_user_entries SET unread=false,last_read = NOW()
470 WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
474 print "Marked active page as read.";
477 if ($subop == "sanityCheck") {
481 $result = db_query($link, "SELECT schema_version FROM ttrss_version");
483 $schema_version = db_fetch_result($result, 0, "schema_version");
485 if ($schema_version != SCHEMA_VERSION
) {
489 print "<error error-code='$error_code'/>";
492 if ($subop == "globalPurge") {
495 global_purge_old_posts($link, true);
496 print "</rpc-reply>";
502 if ($op == "feeds") {
504 $tags = $_GET["tags"];
506 $subop = $_GET["subop"];
508 if ($subop == "catchupAll") {
509 db_query($link, "UPDATE ttrss_user_entries SET
510 last_read = NOW(),unread = false WHERE owner_uid = " . $_SESSION["uid"]);
513 outputFeedList($link, $tags);
520 $feed_id = $_GET["feed"];
522 $result = db_query($link, "UPDATE ttrss_user_entries
523 SET unread = false,last_read = NOW()
524 WHERE ref_id = '$id' AND feed_id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]);
526 $addheader = $_GET["addheader"];
528 $result = db_query($link, "SELECT title,link,content,feed_id,comments,
529 (SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url
530 FROM ttrss_entries,ttrss_user_entries
531 WHERE id = '$id' AND ref_id = id");
535 <title>Tiny Tiny RSS : Article $id</title>
536 <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">
537 <script type=\"text/javascript\" src=\"functions.js\"></script>
538 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
544 $line = db_fetch_assoc($result);
546 if ($line["icon_url"]) {
547 $feed_icon = "<img class=\"feedIcon\" src=\"" . $line["icon_url"] . "\">";
549 $feed_icon = " ";
552 if ($line["comments"] && $line["link"] != $line["comments"]) {
553 $entry_comments = "(<a href=\"".$line["comments"]."\">Comments</a>)";
555 $entry_comments = "";
558 print "<div class=\"postReply\">";
560 print "<div class=\"postHeader\"><table>";
562 print "<tr><td><b>Title:</b></td>
563 <td width='100%'>" . $line["title"] . "</td></tr>";
565 print "<tr><td><b>Link:</b></td>
567 <a href=\"" . $line["link"] . "\">".$line["link"]."</a>
568 $entry_comments</td></tr>";
570 print "</table></div>";
572 print "<div class=\"postIcon\">" . $feed_icon . "</div>";
573 print "<div class=\"postContent\">" . $line["content"] . "</div>";
577 print "<script type=\"text/javascript\">
578 update_label_counters('$feed_id');
583 print "</body></html>";
587 if ($op == "viewfeed") {
589 $feed = $_GET["feed"];
590 $skip = $_GET["skip"];
591 $subop = $_GET["subop"];
592 $view_mode = $_GET["view"];
593 $addheader = $_GET["addheader"];
594 $limit = $_GET["limit"];
600 if (!$skip) $skip = 0;
602 if ($subop == "undefined") $subop = "";
606 <title>Tiny Tiny RSS : Feed $feed</title>
607 <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">";
609 if (get_pref($link, 'USE_COMPACT_STYLESHEET')) {
610 print "<link rel=\"stylesheet\"
611 type=\"text/css\" href=\"tt-rss_compact.css\"/>";
614 print "<link title=\"Compact Stylesheet\" rel=\"alternate stylesheet\"
615 type=\"text/css\" href=\"tt-rss_compact.css\"/>";
617 print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
618 <script type=\"text/javascript\" src=\"functions.js\"></script>
619 <script type=\"text/javascript\" src=\"viewfeed.js\"></script>
620 </head><body onload='init()'>";
623 if ($subop == "ForceUpdate" && sprintf("%d", $feed) > 0) {
625 $tmp_result = db_query($link, "SELECT feed_url FROM ttrss_feeds
626 WHERE id = '$feed'");
628 $feed_url = db_fetch_result($tmp_result, 0, "feed_url");
630 update_rss_feed($link, $feed_url, $feed);
634 if ($subop == "MarkAllRead") {
636 if (sprintf("%d", $feed) != 0) {
639 db_query($link, "UPDATE ttrss_user_entries
640 SET unread = false,last_read = NOW()
641 WHERE feed_id = '$feed' AND owner_uid = " . $_SESSION["uid"]);
643 } else if ($feed < 0 && $feed > -10) { // special, like starred
646 db_query($link, "UPDATE ttrss_user_entries
647 SET unread = false,last_read = NOW()
648 WHERE marked = true AND owner_uid = ".$_SESSION["uid"]);
651 } else if ($feed < -10) { // label
653 // TODO make this more efficient
655 $label_id = -$feed - 11;
657 $tmp_result = db_query($link, "SELECT sql_exp FROM ttrss_labels
658 WHERE id = '$label_id'");
661 $sql_exp = db_fetch_result($tmp_result, 0, "sql_exp");
663 db_query($link, "BEGIN");
665 $tmp2_result = db_query($link,
669 ttrss_user_entries,ttrss_entries
673 owner_uid = " . $_SESSION["uid"]);
675 while ($tmp_line = db_fetch_assoc($tmp2_result)) {
676 db_query($link, "UPDATE
679 unread = false, last_read = NOW()
681 int_id = " . $tmp_line["int_id"]);
684 db_query($link, "COMMIT");
686 /* db_query($link, "UPDATE ttrss_user_entries,ttrss_entries
687 SET unread = false,last_read = NOW()
690 AND owner_uid = ".$_SESSION["uid"]); */
694 db_query($link, "BEGIN");
696 $tag_name = db_escape_string($feed);
698 $result = db_query($link, "SELECT post_int_id FROM ttrss_tags
699 WHERE tag_name = '$tag_name' AND owner_uid = " . $_SESSION["uid"]);
701 while ($line = db_fetch_assoc($result)) {
702 db_query($link, "UPDATE ttrss_user_entries SET
703 unread = false, last_read = NOW()
704 WHERE int_id = " . $line["post_int_id"]);
706 db_query($link, "COMMIT");
711 print "<table class=\"headlinesList\" id=\"headlinesList\" width=\"100%\">";
713 $search = $_GET["search"];
715 $search_mode = $_GET["smode"];
718 $search_query_part = "(upper(title) LIKE upper('%$search%')
719 OR content LIKE '%$search%') AND";
721 $search_query_part = "";
724 $view_query_part = "";
726 if ($view_mode == "Starred") {
727 $view_query_part = " marked = true AND ";
730 if ($view_mode == "Unread") {
731 $view_query_part = " unread = true AND ";
734 if ($view_mode == "Unread or Starred") {
735 $view_query_part = " (unread = true OR marked = true) AND ";
738 if ($view_mode == "Unread or Updated") {
739 $view_query_part = " (unread = true OR last_read is NULL) AND ";
742 /* $result = db_query($link, "SELECT count(id) AS total_entries
743 FROM ttrss_entries WHERE
747 $total_entries = db_fetch_result($result, 0, "total_entries"); */
749 /* $result = db_query("SELECT count(id) AS unread_entries
750 FROM ttrss_entries WHERE
755 $unread_entries = db_fetch_result($result, 0, "unread_entries"); */
757 if ($limit && $limit != "All") {
758 $limit_query_part = "LIMIT " . $limit;
761 $vfeed_query_part = "";
763 // override query strategy and enable feed display when searching globally
764 if ($search && $search_mode == "All feeds") {
765 $query_strategy_part = "id > 0";
766 $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE
767 id = feed_id) as feed_title,";
768 } else if (sprintf("%d", $feed) == 0) {
769 $query_strategy_part = "ttrss_entries.id > 0";
770 $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE
771 id = feed_id) as feed_title,";
772 } else if ($feed >= 0) {
773 $query_strategy_part = "feed_id = '$feed'";
774 } else if ($feed == -1) { // starred virtual feed
775 $query_strategy_part = "marked = true";
776 $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE
777 id = feed_id) as feed_title,";
778 } else if ($feed <= -10) { // labels
779 $label_id = -$feed - 11;
781 $tmp_result = db_query($link, "SELECT sql_exp FROM ttrss_labels
782 WHERE id = '$label_id'");
784 $query_strategy_part = db_fetch_result($tmp_result, 0, "sql_exp");
786 $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE
787 id = feed_id) as feed_title,";
789 $query_strategy_part = "id > 0"; // dumb
793 $order_by = "updated DESC";
795 // if ($feed < -10) {
796 // $order_by = "feed_id,updated DESC";
799 if ($feed < -10) error_reporting (0);
801 if (sprintf("%d", $feed) != 0) {
803 $result = db_query($link, "SELECT
804 id,title,updated,unread,feed_id,marked,link,last_read,
805 SUBSTRING(last_read,1,19) as last_read_noms,
807 SUBSTRING(updated,1,19) as updated_noms
809 ttrss_entries,ttrss_user_entries
811 ttrss_user_entries.ref_id = ttrss_entries.id AND
812 owner_uid = '".$_SESSION["uid"]."' AND
815 $query_strategy_part ORDER BY $order_by
821 $result = db_query($link, "SELECT
822 ttrss_entries.id as id,title,updated,unread,feed_id,
823 marked,link,last_read,
824 SUBSTRING(last_read,1,19) as last_read_noms,
826 SUBSTRING(updated,1,19) as updated_noms
828 ttrss_entries,ttrss_user_entries,ttrss_tags
830 ref_id = ttrss_entries.id AND
831 ttrss_user_entries.owner_uid = '".$_SESSION["uid"]."' AND
832 post_int_id = int_id AND tag_name = '$feed' AND
835 $query_strategy_part ORDER BY $order_by
840 print "<tr><td colspan='4' align='center'>
841 Could not display feed (query failed). Please check match syntax or local configuration.</td></tr>";
847 error_reporting (DEFAULT_ERROR_LEVEL
);
851 while ($line = db_fetch_assoc($result)) {
853 $class = ($lnum %
2) ?
"even" : "odd";
856 $feed_id = $line["feed_id"];
858 // printf("L %d (%s) > U %d (%s) = %d<br>",
859 // strtotime($line["last_read_noms"]), $line["last_read_noms"],
860 // strtotime($line["updated"]), $line["updated"],
861 // strtotime($line["last_read"]) >= strtotime($line["updated"]));
863 /* if ($line["last_read"] != "" && $line["updated"] != "" &&
864 strtotime($line["last_read_noms"]) < strtotime($line["updated_noms"])) {
866 $update_pic = "<img id='FUPDPIC-$id' src=\"images/updated.png\"
871 $update_pic = "<img id='FUPDPIC-$id' src=\"images/blank_icon.gif\"
876 if ($line["last_read"] == "" &&
877 ($line["unread"] != "t" && $line["unread"] != "1")) {
879 $update_pic = "<img id='FUPDPIC-$id' src=\"images/updated.png\"
882 $update_pic = "<img id='FUPDPIC-$id' src=\"images/blank_icon.gif\"
886 if ($line["unread"] == "t" ||
$line["unread"] == "1") {
891 if ($line["marked"] == "t" ||
$line["marked"] == "1") {
892 $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_set.png\"
893 alt=\"Reset mark\" onclick='javascript:toggleMark($id, false)'>";
895 $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_unset.png\"
896 alt=\"Set mark\" onclick='javascript:toggleMark($id, true)'>";
899 $content_link = "<a id=\"FTITLE-$id\" href=\"javascript:view($id,$feed_id);\">" .
900 $line["title"] . "</a>";
902 print "<tr class='$class' id='RROW-$id'>";
903 // onclick=\"javascript:view($id,$feed_id)\">
905 print "<td valign='center' align='center'>$update_pic</td>";
906 print "<td valign='center' align='center'>$marked_pic</td>";
908 print "<td width='25%'>
909 <a href=\"javascript:view($id,$feed_id);\">".$line["updated"]."</a></td>";
911 if ($line["feed_title"]) {
912 print "<td width='50%'>$content_link</td>";
913 print "<td width='20%'>
914 <a href='javascript:viewfeed($feed_id)'>".$line["feed_title"]."</a></td>";
916 print "<td width='70%'>$content_link</td>";
925 print "<tr><td align='center'>No articles found.</td></tr>";
930 print "<script type=\"text/javascript\">
931 document.onkeydown = hotkey_handler;
932 update_label_counters('$feed');
936 print "</body></html>";
941 if ($op == "pref-rpc") {
943 $subop = $_GET["subop"];
945 if ($subop == "unread") {
946 $ids = split(",", $_GET["ids"]);
947 foreach ($ids as $id) {
948 db_query($link, "UPDATE ttrss_user_entries SET unread = true
949 WHERE feed_id = '$id' AND owner_uid = ".$_SESSION["uid"]);
952 print "Marked selected feeds as unread.";
955 if ($subop == "read") {
956 $ids = split(",", $_GET["ids"]);
957 foreach ($ids as $id) {
958 db_query($link, "UPDATE ttrss_user_entries
959 SET unread = false,last_read = NOW() WHERE
960 feed_id = '$id' AND owner_uid = ".$_SESSION["uid"]);
963 print "Marked selected feeds as read.";
969 if ($op == "pref-feeds") {
971 $subop = $_GET["subop"];
973 if ($subop == "editSave") {
974 $feed_title = db_escape_string($_GET["t"]);
975 $feed_link = db_escape_string($_GET["l"]);
976 $upd_intl = db_escape_string($_GET["ui"]);
977 $purge_intl = db_escape_string($_GET["pi"]);
978 $feed_id = db_escape_string($_GET["id"]);
979 $cat_id = db_escape_string($_GET["catid"]);
981 if (strtoupper($upd_intl) == "DEFAULT")
984 if (strtoupper($purge_intl) == "DEFAULT")
987 if (strtoupper($purge_intl) == "DISABLED")
991 $category_qpart = "cat_id = '$cat_id'";
993 $category_qpart = 'cat_id = NULL';
996 $result = db_query($link, "UPDATE ttrss_feeds SET
998 title = '$feed_title', feed_url = '$feed_link',
999 update_interval = '$upd_intl',
1000 purge_interval = '$purge_intl'
1001 WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]);
1005 if ($subop == "remove") {
1007 if (!WEB_DEMO_MODE
) {
1009 $ids = split(",", $_GET["ids"]);
1011 foreach ($ids as $id) {
1012 db_query($link, "DELETE FROM ttrss_feeds
1013 WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
1015 $icons_dir = ICONS_DIR
;
1017 if (file_exists($icons_dir . "/$id.ico")) {
1018 unlink($icons_dir . "/$id.ico");
1024 if ($subop == "add") {
1026 if (!WEB_DEMO_MODE
) {
1028 $feed_link = db_escape_string(trim($_GET["link"]));
1030 $result = db_query($link,
1031 "SELECT id FROM ttrss_feeds
1032 WHERE feed_url = '$feed_link' AND owner_uid = ".$_SESSION["uid"]);
1034 if (db_num_rows($result) == 0) {
1036 $result = db_query($link,
1037 "INSERT INTO ttrss_feeds (owner_uid,feed_url,title)
1038 VALUES ('".$_SESSION["uid"]."', '$feed_link', '')");
1040 $result = db_query($link,
1041 "SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_link'
1042 AND owner_uid = " . $_SESSION["uid"]);
1044 $feed_id = db_fetch_result($result, 0, "id");
1047 update_rss_feed($link, $feed_link, $feed_id);
1051 print "<div class=\"warning\">
1052 Feed <b>$feed_link</b> already exists in the database.
1058 if ($subop == "addCat") {
1060 if (!WEB_DEMO_MODE
) {
1062 $feed_cat = db_escape_string(trim($_GET["cat"]));
1064 $result = db_query($link,
1065 "SELECT id FROM ttrss_feed_categories
1066 WHERE title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]);
1068 if (db_num_rows($result) == 0) {
1070 $result = db_query($link,
1071 "INSERT INTO ttrss_feed_categories (owner_uid,title)
1072 VALUES ('".$_SESSION["uid"]."', '$feed_cat')");
1076 print "<div class=\"warning\">
1077 Category <b>$feed_cat</b> already exists in the database.
1085 if ($subop == "removeCats") {
1087 if (!WEB_DEMO_MODE
) {
1089 $ids = split(",", $_GET["ids"]);
1091 foreach ($ids as $id) {
1093 db_query($link, "BEGIN");
1095 $result = db_query($link,
1096 "SELECT count(id) as num_feeds FROM ttrss_feeds
1097 WHERE cat_id = '$id'");
1099 $num_feeds = db_fetch_result($result, 0, "num_feeds");
1101 if ($num_feeds == 0) {
1102 db_query($link, "DELETE FROM ttrss_feed_categories
1103 WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
1106 print "<div class=\"warning\">
1107 Unable to delete non empty feed categories.</div>";
1111 db_query($link, "COMMIT");
1116 // print "<h3>Edit Feeds</h3>";
1118 $result = db_query($link, "SELECT id,title,feed_url,last_error
1119 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
1121 if (db_num_rows($result) > 0) {
1123 print "<div class=\"warning\">";
1125 print "<b>Feeds with update errors:</b>";
1127 print "<ul class=\"nomarks\">";
1129 while ($line = db_fetch_assoc($result)) {
1130 print "<li>" . $line["title"] . " (" . $line["feed_url"] . "): " .
1131 $line["last_error"];
1139 print "<p><div class=\"prefGenericAddBox\">
1140 <input id=\"fadd_link\" size=\"40\"> <input
1141 type=\"submit\" class=\"button\"
1142 onclick=\"javascript:addFeed()\" value=\"Add feed\"></div>";
1144 $feeds_sort = db_escape_string($_GET["sort"]);
1146 if (!$feeds_sort ||
$feeds_sort == "undefined") {
1147 $feeds_sort = $_SESSION["pref_sort_feeds"];
1148 if (!$feeds_sort) $feeds_sort = "title";
1151 $_SESSION["pref_sort_feeds"] = $feeds_sort;
1153 $result = db_query($link, "SELECT
1154 id,title,feed_url,substring(last_updated,1,16) as last_updated,
1155 update_interval,purge_interval,
1156 (SELECT title FROM ttrss_feed_categories
1157 WHERE id = cat_id) AS category
1159 ttrss_feeds WHERE owner_uid = '".$_SESSION["uid"]."'
1160 ORDER by $feeds_sort,title");
1162 if (db_num_rows($result) != 0) {
1164 print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>";
1166 print "<p><table width=\"100%\" class=\"prefFeedList\" id=\"prefFeedList\">";
1167 print "<tr class=\"title\">
1168 <td width=\"3%\"> </td>
1169 <td width=\"3%\">Select</td>
1171 <a href=\"javascript:updateFeedList('title')\">Title</a></td>
1173 <a href=\"javascript:updateFeedList('feed_url')\">Link</a>
1176 if (get_pref($link, 'ENABLE_FEED_CATS')) {
1177 print "<td width=\"10%\">
1178 <a href=\"javascript:updateFeedList('category')\">Category</a></td>";
1183 <a href=\"javascript:updateFeedList('update_interval')\">Update Interval</a>
1186 <a href=\"javascript:updateFeedList('purge_interval')\">Purge Days</a>
1192 while ($line = db_fetch_assoc($result)) {
1194 $class = ($lnum %
2) ?
"even" : "odd";
1196 $feed_id = $line["id"];
1198 $edit_feed_id = $_GET["id"];
1200 if ($subop == "edit" && $feed_id != $edit_feed_id) {
1204 print "<tr class=\"$class\" id=\"FEEDR-$feed_id\">";
1206 $icon_file = ICONS_DIR
. "/$feed_id.ico";
1208 if (file_exists($icon_file) && filesize($icon_file) > 0) {
1209 $feed_icon = "<img width=\"16\" height=\"16\"
1210 src=\"" . ICONS_URL
. "/$feed_id.ico\">";
1212 $feed_icon = " ";
1214 print "<td align='center'>$feed_icon</td>";
1216 $edit_title = htmlspecialchars(db_unescape_string($line["title"]));
1217 $edit_link = htmlspecialchars(db_unescape_string($line["feed_url"]));
1218 $edit_cat = htmlspecialchars(db_unescape_string($line["category"]));
1220 if (!$edit_cat) $edit_cat = "Uncategorized";
1222 if (!$edit_feed_id ||
$subop != "edit") {
1224 print "<td><input onclick='toggleSelectRow(this);'
1225 type=\"checkbox\" id=\"FRCHK-".$line["id"]."\"></td>";
1227 $edit_title = truncate_string($edit_title, 40);
1228 $edit_link = truncate_string($edit_link, 60);
1230 print "<td><a href=\"javascript:editFeed($feed_id);\">" .
1231 $edit_title . "</a></td>";
1233 print "<td><a href=\"javascript:editFeed($feed_id);\">" .
1234 $edit_link . "</a></td>";
1236 if (get_pref($link, 'ENABLE_FEED_CATS')) {
1237 print "<td><a href=\"javascript:editFeed($feed_id);\">" .
1238 $edit_cat . "</a></td>";
1241 if ($line["update_interval"] == "0")
1242 $line["update_interval"] = "Default";
1244 print "<td><a href=\"javascript:editFeed($feed_id);\">" .
1245 $line["update_interval"] . "</a></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><a href=\"javascript:editFeed($feed_id);\">" .
1254 $line["purge_interval"] . "</a></td>";
1256 } else if ($feed_id != $edit_feed_id) {
1258 print "<td><input disabled=\"true\" type=\"checkbox\"
1259 id=\"FRCHK-".$line["id"]."\"></td>";
1261 $edit_title = truncate_string($edit_title, 40);
1262 $edit_link = truncate_string($edit_link, 60);
1264 print "<td>$edit_title</td>";
1265 print "<td>$edit_link</td>";
1267 if (get_pref($link, 'ENABLE_FEED_CATS')) {
1268 print "<td>$edit_cat</td>";
1271 if ($line["update_interval"] == "0")
1272 $line["update_interval"] = "Default";
1274 print "<td>" . $line["update_interval"] . "</td>";
1276 if ($line["purge_interval"] == "0")
1277 $line["purge_interval"] = "Default";
1279 if ($line["purge_interval"] < 0)
1280 $line["purge_interval"] = "Disabled";
1282 print "<td>" . $line["purge_interval"] . "</td>";
1286 print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>";
1288 print "<td><input id=\"iedit_title\" value=\"$edit_title\"></td>";
1289 print "<td><input id=\"iedit_link\" value=\"$edit_link\"></td>";
1291 if (get_pref($link, 'ENABLE_FEED_CATS')) {
1294 print "<select id=\"iedit_fcat\">";
1295 print "<option id=\"0\">Uncategorized</option>";
1297 $tmp_result = db_query($link, "SELECT id,title FROM ttrss_feed_categories
1298 WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
1300 if (db_num_rows($tmp_result) > 0) {
1301 print "<option disabled>--------</option>";
1304 while ($tmp_line = db_fetch_assoc($tmp_result)) {
1305 if ($tmp_line["id"] == $line["cat_id"]) {
1306 $is_selected = "selected";
1310 printf("<option $is_selected id='%d'>%s</option>",
1311 $tmp_line["id"], $tmp_line["title"]);
1314 print "</select></td>";
1319 print "<td><input id=\"iedit_updintl\"
1320 value=\"".$line["update_interval"]."\"></td>";
1321 print "<td><input id=\"iedit_purgintl\"
1322 value=\"".$line["purge_interval"]."\"></td>";
1326 /* if (!$line["last_updated"]) $line["last_updated"] = "Never";
1328 print "<td>" . $line["last_updated"] . "</td>"; */
1339 if ($subop == "edit") {
1340 print "Edit feed:
1341 <input type=\"submit\" class=\"button\"
1342 onclick=\"javascript:feedEditCancel()\" value=\"Cancel\">
1343 <input type=\"submit\" class=\"button\"
1344 onclick=\"javascript:feedEditSave()\" value=\"Save\">";
1349 <input type=\"submit\" class=\"button\"
1350 onclick=\"javascript:selectedFeedDetails()\" value=\"Details\">
1351 <input type=\"submit\" class=\"button\"
1352 onclick=\"javascript:editSelectedFeed()\" value=\"Edit\">
1353 <input type=\"submit\" class=\"button\"
1354 onclick=\"javascript:removeSelectedFeeds()\" value=\"Remove\">";
1356 if (get_pref($link, 'ENABLE_PREFS_CATCHUP_UNCATCHUP')) {
1358 <input type=\"submit\" class=\"button\"
1359 onclick=\"javascript:readSelectedFeeds()\" value=\"Mark as read\">
1360 <input type=\"submit\" class=\"button\"
1361 onclick=\"javascript:unreadSelectedFeeds()\"
1362 value=\"Mark as unread\"> ";
1366 All feeds: <input type=\"submit\"
1367 class=\"button\" onclick=\"gotoExportOpml()\"
1368 value=\"Export OPML\">";
1372 print "<p>No feeds defined.</p>";
1376 if (get_pref($link, 'ENABLE_FEED_CATS')) {
1378 print "<h3>Edit Categories</h3>";
1380 // print "<h3>Categories</h3>";
1382 print "<div class=\"prefGenericAddBox\">
1383 <input id=\"fadd_cat\" size=\"40\"> <input
1384 type=\"submit\" class=\"button\"
1385 onclick=\"javascript:addFeedCat()\" value=\"Add category\"></div>";
1387 $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories
1388 WHERE owner_uid = ".$_SESSION["uid"]."
1391 if (db_num_rows($result) != 0) {
1393 print "<p><table width=\"100%\" class=\"prefFeedCatList\" id=\"prefFeedCatList\">";
1394 print "<tr class=\"title\">
1395 <td width=\"10%\">Select</td><td width=\"80%\">Title</td>
1400 while ($line = db_fetch_assoc($result)) {
1402 $class = ($lnum %
2) ?
"even" : "odd";
1404 $cat_id = $line["id"];
1406 $edit_cat_id = $_GET["id"];
1408 if ($subop == "editCat" && $cat_id != $edit_cat_id) {
1412 print "<tr class=\"$class\" id=\"FCATR-$cat_id\">";
1414 $edit_title = htmlspecialchars(db_unescape_string($line["title"]));
1416 if (!$edit_cat_id ||
$subop != "editCat") {
1418 print "<td><input onclick='toggleSelectRow(this);'
1419 type=\"checkbox\" id=\"FCCHK-".$line["id"]."\"></td>";
1421 print "<td><a href=\"javascript:editFeedCat($cat_id);\">" .
1422 $edit_title . "</a></td>";
1424 } else if ($cat_id != $edit_cat_id) {
1426 print "<td><input disabled=\"true\" type=\"checkbox\"
1427 id=\"FRCHK-".$line["id"]."\"></td>";
1429 print "<td>$edit_title</td>";
1433 print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>";
1435 print "<td><input id=\"iedit_title\" value=\"$edit_title\"></td>";
1448 if ($subop == "editCat") {
1449 print "Edit category:
1450 <input type=\"submit\" class=\"button\"
1451 onclick=\"javascript:feedCatEditCancel()\" value=\"Cancel\">
1452 <input type=\"submit\" class=\"button\"
1453 onclick=\"javascript:feedCatEditSave()\" value=\"Save\">";
1458 <input type=\"submit\" class=\"button\"
1459 onclick=\"javascript:editSelectedFeedCat()\" value=\"Edit\">
1460 <input type=\"submit\" class=\"button\"
1461 onclick=\"javascript:removeSelectedFeedCats()\" value=\"Remove\">";
1466 print "<p>No feed categories defined.</p>";
1470 print "<h3>Import OPML</h3>
1471 <form enctype=\"multipart/form-data\" method=\"POST\" action=\"opml.php\">
1472 File: <input id=\"opml_file\" name=\"opml_file\" type=\"file\">
1473 <input class=\"button\" name=\"op\" onclick=\"return validateOpmlImport();\"
1474 type=\"submit\" value=\"Import\">
1479 if ($op == "pref-filters") {
1481 $subop = $_GET["subop"];
1483 if ($subop == "editSave") {
1485 $regexp = db_escape_string($_GET["r"]);
1486 $descr = db_escape_string($_GET["d"]);
1487 $match = db_escape_string($_GET["m"]);
1488 $filter_id = db_escape_string($_GET["id"]);
1489 $feed_id = db_escape_string($_GET["fid"]);
1494 $feed_id = sprintf("'%s'", db_escape_string($feed_id));
1497 $result = db_query($link, "UPDATE ttrss_filters SET
1498 reg_exp = '$regexp',
1499 description = '$descr',
1501 filter_type = (SELECT id FROM ttrss_filter_types WHERE
1502 description = '$match')
1503 WHERE id = '$filter_id'");
1506 if ($subop == "remove") {
1508 if (!WEB_DEMO_MODE
) {
1510 $ids = split(",", $_GET["ids"]);
1512 foreach ($ids as $id) {
1513 db_query($link, "DELETE FROM ttrss_filters WHERE id = '$id'");
1519 if ($subop == "add") {
1521 if (!WEB_DEMO_MODE
) {
1523 $regexp = db_escape_string(trim($_GET["regexp"]));
1524 $match = db_escape_string(trim($_GET["match"]));
1525 $feed_id = db_escape_string($_GET["fid"]);
1530 $feed_id = sprintf("'%s'", db_escape_string($feed_id));
1533 $result = db_query($link,
1534 "INSERT INTO ttrss_filters (reg_exp,filter_type,owner_uid,feed_id) VALUES
1535 ('$regexp', (SELECT id FROM ttrss_filter_types WHERE
1536 description = '$match'),'".$_SESSION["uid"]."', $feed_id)");
1540 $result = db_query($link, "SELECT description
1541 FROM ttrss_filter_types ORDER BY description");
1543 $filter_types = array();
1545 while ($line = db_fetch_assoc($result)) {
1546 array_push($filter_types, $line["description"]);
1549 print "<div class=\"prefGenericAddBox\">
1550 <input id=\"fadd_regexp\" size=\"40\"> ";
1552 print_select("fadd_match", "Title", $filter_types);
1554 print " <select id=\"fadd_feed\">";
1556 print "<option selected id=\"0\">All feeds</option>";
1558 $result = db_query($link, "SELECT id,title FROM ttrss_feeds
1559 WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
1561 if (db_num_rows($result) > 0) {
1562 print "<option disabled>--------</option>";
1565 while ($line = db_fetch_assoc($result)) {
1566 printf("<option id='%d'>%s</option>", $line["id"], $line["title"]);
1569 print "</select> ";
1571 print "<input type=\"submit\"
1572 class=\"button\" onclick=\"javascript:addFilter()\"
1573 value=\"Add filter\">";
1575 $result = db_query($link, "SELECT
1576 ttrss_filters.id AS id,reg_exp,
1577 ttrss_filters.description AS description,
1578 ttrss_filter_types.name AS filter_type_name,
1579 ttrss_filter_types.description AS filter_type_descr,
1581 (SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title
1583 ttrss_filters,ttrss_filter_types
1585 filter_type = ttrss_filter_types.id AND
1586 ttrss_filters.owner_uid = ".$_SESSION["uid"]."
1589 if (db_num_rows($result) != 0) {
1591 print "<p><table width=\"100%\" class=\"prefFilterList\" id=\"prefFilterList\">";
1593 print "<tr class=\"title\">
1594 <td width=\"5%\">Select</td><td width=\"30%\">Filter expression</td>
1595 <td width=\"30%\">Feed</td><td width=\"10%\">Match</td>
1596 <td width=\"30%\">Description</td></tr>";
1600 while ($line = db_fetch_assoc($result)) {
1602 $class = ($lnum %
2) ?
"even" : "odd";
1604 $filter_id = $line["id"];
1605 $edit_filter_id = $_GET["id"];
1607 if ($subop == "edit" && $filter_id != $edit_filter_id) {
1611 print "<tr class=\"$class\" id=\"FILRR-$filter_id\">";
1613 $line["regexp"] = htmlspecialchars($line["reg_exp"]);
1614 $line["description"] = htmlspecialchars($line["description"]);
1616 if (!$line["feed_title"]) $line["feed_title"] = "All feeds";
1618 if (!$edit_filter_id ||
$subop != "edit") {
1620 if (!$line["description"]) $line["description"] = "[No description]";
1622 print "<td><input onclick='toggleSelectRow(this);'
1623 type=\"checkbox\" id=\"FICHK-".$line["id"]."\"></td>";
1625 print "<td><a href=\"javascript:editFilter($filter_id);\">" .
1626 $line["reg_exp"] . "</td>";
1628 print "<td><a href=\"javascript:editFilter($filter_id);\">" .
1629 $line["feed_title"] . "</td>";
1631 print "<td><a href=\"javascript:editFilter($filter_id);\">" .
1632 $line["filter_type_descr"] . "</td>";
1634 print "<td><a href=\"javascript:editFilter($filter_id);\">" .
1635 $line["description"] . "</td>";
1637 } else if ($filter_id != $edit_filter_id) {
1639 if (!$line["description"]) $line["description"] = "[No description]";
1641 print "<td><input disabled=\"true\" type=\"checkbox\"
1642 id=\"FICHK-".$line["id"]."\"></td>";
1644 print "<td>".$line["reg_exp"]."</td>";
1645 print "<td>".$line["feed_title"]."</td>";
1646 print "<td>".$line["filter_type_descr"]."</td>";
1647 print "<td>".$line["description"]."</td>";
1651 print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>";
1653 print "<td><input id=\"iedit_regexp\" value=\"".$line["reg_exp"].
1658 print "<select id=\"iedit_feed\">";
1660 print "<option id=\"0\">All feeds</option>";
1662 if (db_num_rows($result) > 0) {
1663 print "<option disabled>--------</option>";
1666 $tmp_result = db_query($link, "SELECT id,title FROM ttrss_feeds
1667 WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
1669 while ($tmp_line = db_fetch_assoc($tmp_result)) {
1670 if ($tmp_line["id"] == $line["feed_id"]) {
1671 $is_selected = "selected";
1675 printf("<option $is_selected id='%d'>%s</option>",
1676 $tmp_line["id"], $tmp_line["title"]);
1679 print "</select></td>";
1682 print_select("iedit_match", $line["filter_type_descr"], $filter_types);
1685 print "<td><input id=\"iedit_descr\" value=\"".$line["description"].
1697 print "<tr><td colspan=\"4\" align=\"center\">No filters defined.</td></tr>";
1704 if ($subop == "edit") {
1706 <input type=\"submit\" class=\"button\"
1707 onclick=\"javascript:filterEditCancel()\" value=\"Cancel\">
1708 <input type=\"submit\" class=\"button\"
1709 onclick=\"javascript:filterEditSave()\" value=\"Save\">";
1715 <input type=\"submit\" class=\"button\"
1716 onclick=\"javascript:editSelectedFilter()\" value=\"Edit\">
1717 <input type=\"submit\" class=\"button\"
1718 onclick=\"javascript:removeSelectedFilters()\" value=\"Remove\">";
1723 print "<p>No filters defined.</p>";
1728 if ($op == "pref-labels") {
1730 $subop = $_GET["subop"];
1732 if ($subop == "test") {
1734 $expr = $_GET["expr"];
1735 $descr = $_GET["descr"];
1737 print "<div class='infoBoxContents'>";
1739 print "<h1>Label «$descr»</h1>";
1741 // print "<p><b>Expression</b>: $expr</p>";
1743 $result = db_query($link,
1744 "SELECT count(id) AS num_matches
1745 FROM ttrss_entries,ttrss_user_entries
1747 ttrss_user_entries.ref_id = ttrss_entries.id AND
1748 owner_uid = " . $_SESSION["uid"]);
1750 $num_matches = db_fetch_result($result, 0, "num_matches");;
1752 if ($num_matches > 0) {
1754 print "<p>Query returned <b>$num_matches</b> matches, first 5:</p>";
1756 $result = db_query($link,
1758 (SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title
1759 FROM ttrss_entries,ttrss_user_entries
1761 ttrss_user_entries.ref_id = ttrss_entries.id
1762 AND owner_uid = " . $_SESSION["uid"] . "
1763 ORDER BY date_entered DESC LIMIT 5");
1765 print "<ul class=\"nomarks\">";
1766 while ($line = db_fetch_assoc($result)) {
1767 print "<li>".$line["title"].
1768 " <span class=\"insensitive\">(".$line["feed_title"].")</span></li>";
1773 print "<p>Query didn't return any matches.</p>";
1778 print "<div align='center'>
1779 <input type='submit' class='button'
1780 onclick=\"closeInfoBox()\" value=\"Close this window\"></div>";
1784 if ($subop == "editSave") {
1786 $sql_exp = $_GET["s"];
1787 $descr = $_GET["d"];
1788 $label_id = db_escape_string($_GET["id"]);
1790 // print "$sql_exp : $descr : $label_id";
1792 $result = db_query($link, "UPDATE ttrss_labels SET
1793 sql_exp = '$sql_exp',
1794 description = '$descr'
1795 WHERE id = '$label_id'");
1798 if ($subop == "remove") {
1800 if (!WEB_DEMO_MODE
) {
1802 $ids = split(",", $_GET["ids"]);
1804 foreach ($ids as $id) {
1805 db_query($link, "DELETE FROM ttrss_labels WHERE id = '$id'");
1811 if ($subop == "add") {
1813 if (!WEB_DEMO_MODE
) {
1815 // no escaping is done here on purpose
1816 $exp = trim($_GET["exp"]);
1818 $result = db_query($link,
1819 "INSERT INTO ttrss_labels (sql_exp,description,owner_uid)
1820 VALUES ('$exp', '$exp', '".$_SESSION["uid"]."')");
1824 print "<div class=\"prefGenericAddBox\">
1825 <input size=\"40\" id=\"ladd_expr\"> ";
1827 print"<input type=\"submit\" class=\"button\"
1828 onclick=\"javascript:addLabel()\" value=\"Add label\"></div>";
1830 $result = db_query($link, "SELECT
1831 id,sql_exp,description
1835 owner_uid = ".$_SESSION["uid"]."
1836 ORDER by description");
1838 print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>";
1840 if (db_num_rows($result) != 0) {
1842 print "<p><table width=\"100%\" class=\"prefLabelList\" id=\"prefLabelList\">";
1844 print "<tr class=\"title\">
1845 <td width=\"5%\">Select</td><td width=\"40%\">SQL expression
1846 <a class=\"helpLink\" href=\"javascript:popupHelp(1)\">(?)</a>
1848 <td width=\"40%\">Caption</td></tr>";
1852 while ($line = db_fetch_assoc($result)) {
1854 $class = ($lnum %
2) ?
"even" : "odd";
1856 $label_id = $line["id"];
1857 $edit_label_id = $_GET["id"];
1859 if ($subop == "edit" && $label_id != $edit_label_id) {
1863 print "<tr class=\"$class\" id=\"LILRR-$label_id\">";
1865 $line["sql_exp"] = htmlspecialchars($line["sql_exp"]);
1866 $line["description"] = htmlspecialchars($line["description"]);
1868 if (!$edit_label_id ||
$subop != "edit") {
1870 if (!$line["description"]) $line["description"] = "[No caption]";
1872 print "<td><input onclick='toggleSelectRow(this);'
1873 type=\"checkbox\" id=\"LICHK-".$line["id"]."\"></td>";
1875 print "<td><a href=\"javascript:editLabel($label_id);\">" .
1876 $line["sql_exp"] . "</td>";
1878 print "<td><a href=\"javascript:editLabel($label_id);\">" .
1879 $line["description"] . "</td>";
1881 } else if ($label_id != $edit_label_id) {
1883 if (!$line["description"]) $line["description"] = "[No description]";
1885 print "<td><input disabled=\"true\" type=\"checkbox\"
1886 id=\"LICHK-".$line["id"]."\"></td>";
1888 print "<td>".$line["sql_exp"]."</td>";
1889 print "<td>".$line["description"]."</td>";
1893 print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>";
1895 print "<td><input id=\"iedit_expr\" value=\"".$line["sql_exp"].
1898 print "<td><input id=\"iedit_descr\" value=\"".$line["description"].
1910 print "<tr><td colspan=\"4\" align=\"center\">No labels defined.</td></tr>";
1917 if ($subop == "edit") {
1919 <input type=\"submit\" class=\"button\"
1920 onclick=\"javascript:labelTest()\" value=\"Test\">
1921 <input type=\"submit\" class=\"button\"
1922 onclick=\"javascript:labelEditCancel()\" value=\"Cancel\">
1923 <input type=\"submit\" class=\"button\"
1924 onclick=\"javascript:labelEditSave()\" value=\"Save\">";
1930 <input type=\"submit\" class=\"button\"
1931 onclick=\"javascript:editSelectedLabel()\" value=\"Edit\">
1932 <input type=\"submit\" class=\"button\"
1933 onclick=\"javascript:removeSelectedLabels()\" value=\"Remove\">";
1936 print "<p>No labels defined.</p>";
1940 if ($op == "error") {
1941 print "<div width=\"100%\" align='center'>";
1942 $msg = $_GET["msg"];
1947 if ($op == "help") {
1949 <title>Tiny Tiny RSS : Help</title>
1950 <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">
1951 <script type=\"text/javascript\" src=\"functions.js\"></script>
1952 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
1955 $tid = sprintf("%d", $_GET["tid"]);
1957 /* FIXME this badly needs real implementation */
1959 print "<div class='helpResponse'>";
1963 <h1
>Help
for SQL expressions
</h1
>
1965 <h2
>Description
</h2
>
1967 <p
>The
«
;SQL expression
»
; is added to WHERE clause of
1968 view feed query
. You can match on ttrss_entries table fields
1969 and even
use subselect to query additional information
. This
1970 functionality is considered to be advanced
and requires basic
1971 understanding of SQL
.</p
>
1975 <pre
>unread
= true</pre
>
1977 Matches all unread articles
1979 <pre
>title like
'%Linux%'</pre
>
1981 Matches all articles which mention Linux in the title
. You get the idea
.
1983 <p
>See the database schema included in the distribution package
for gruesome
1988 print "<div align='center'>
1989 <a class=\"helpLink\"
1990 href=\"javascript:window.close()\">(Close this window)</a></div>";
1994 print "</body></html>";
2000 $param = $_GET["param"];
2002 if ($id == "quickAddFeed") {
2003 print "Feed URL: <input
2004 onblur=\"javascript:enableHotkeys()\" onfocus=\"javascript:disableHotkeys()\"
2006 <input class=\"button\"
2007 type=\"submit\" onclick=\"javascript:qafAdd()\" value=\"Add feed\">
2008 <input class=\"button\"
2009 type=\"submit\" onclick=\"javascript:closeDlg()\"
2013 if ($id == "quickDelFeed") {
2015 $param = db_escape_string($param);
2017 $result = db_query($link, "SELECT title FROM ttrss_feeds WHERE id = '$param'");
2021 $f_title = db_fetch_result($result, 0, "title");
2023 print "Remove current feed ($f_title)?
2024 <input class=\"button\"
2025 type=\"submit\" onclick=\"javascript:qfdDelete($param)\" value=\"Remove\">
2026 <input class=\"button\"
2027 type=\"submit\" onclick=\"javascript:closeDlg()\"
2030 print "Error: Feed $param not found.
2031 <input class=\"button\"
2032 type=\"submit\" onclick=\"javascript:closeDlg()\"
2037 if ($id == "search") {
2039 print "<input id=\"searchbox\" class=\"extSearch\"
2040 onblur=\"javascript:enableHotkeys()\" onfocus=\"javascript:disableHotkeys()\"
2041 onchange=\"javascript:search()\">
2042 <select id=\"searchmodebox\">
2043 <option selected>All feeds</option>
2044 <option>This feed</option>
2046 <input type=\"submit\"
2047 class=\"button\" onclick=\"javascript:search()\" value=\"Search\">
2048 <input class=\"button\"
2049 type=\"submit\" onclick=\"javascript:closeDlg()\"
2056 // update feeds of all users, may be used anonymously
2057 if ($op == "globalUpdateFeeds") {
2059 $result = db_query($link, "SELECT id FROM ttrss_users");
2061 while ($line = db_fetch_assoc($result)) {
2062 $user_id = $line["id"];
2063 // print "<!-- updating feeds of uid $user_id -->";
2064 update_all_feeds($link, false, $user_id);
2068 <message msg=\"All feeds updated\"/>
2073 if ($op == "pref-prefs") {
2075 $subop = $_REQUEST["subop"];
2077 if ($subop == "Save configuration") {
2079 if (WEB_DEMO_MODE
) {
2080 header("Location: prefs.php");
2084 $_SESSION["prefs_op_result"] = "save-config";
2086 foreach (array_keys($_POST) as $pref_name) {
2088 $pref_name = db_escape_string($pref_name);
2089 $value = db_escape_string($_POST[$pref_name]);
2091 $result = db_query($link, "SELECT type_name
2092 FROM ttrss_prefs,ttrss_prefs_types
2093 WHERE pref_name = '$pref_name' AND type_id = ttrss_prefs_types.id");
2095 if (db_num_rows($result) > 0) {
2097 $type_name = db_fetch_result($result, 0, "type_name");
2099 // print "$pref_name : $type_name : $value<br>";
2101 if ($type_name == "bool") {
2102 if ($value == "1") {
2107 } else if ($type_name == "integer") {
2108 $value = sprintf("%d", $value);
2111 // print "$pref_name : $type_name : $value<br>";
2113 db_query($link, "UPDATE ttrss_user_prefs SET value = '$value'
2114 WHERE pref_name = '$pref_name' AND owner_uid = ".$_SESSION["uid"]);
2118 header("Location: prefs.php");
2122 } else if ($subop == "getHelp") {
2124 $pref_name = db_escape_string($_GET["pn"]);
2126 $result = db_query($link, "SELECT help_text FROM ttrss_prefs
2127 WHERE pref_name = '$pref_name'");
2129 if (db_num_rows($result) > 0) {
2130 $help_text = db_fetch_result($result, 0, "help_text");
2133 print "Unknown option: $pref_name";
2136 } else if ($subop == "Change password") {
2138 if (WEB_DEMO_MODE
) {
2139 header("Location: prefs.php");
2143 $old_pw = $_POST["OLD_PASSWORD"];
2144 $new_pw = $_POST["OLD_PASSWORD"];
2146 $old_pw_hash = 'SHA1:' . sha1($_POST["OLD_PASSWORD"]);
2147 $new_pw_hash = 'SHA1:' . sha1($_POST["NEW_PASSWORD"]);
2149 $active_uid = $_SESSION["uid"];
2151 if ($old_pw && $new_pw) {
2153 $login = db_escape_string($_SERVER['PHP_AUTH_USER']);
2155 $result = db_query($link, "SELECT id FROM ttrss_users WHERE
2156 id = '$active_uid' AND (pwd_hash = '$old_pw' OR
2157 pwd_hash = '$old_pw_hash')");
2159 if (db_num_rows($result) == 1) {
2160 db_query($link, "UPDATE ttrss_users SET pwd_hash = '$new_pw_hash'
2161 WHERE id = '$active_uid'");
2163 $_SESSION["pwd_change_result"] = "ok";
2165 $_SESSION["pwd_change_result"] = "failed";
2169 header("Location: prefs.php");
2171 } else if ($subop == "Reset to defaults") {
2173 if (WEB_DEMO_MODE
) {
2174 header("Location: prefs.php");
2178 $_SESSION["prefs_op_result"] = "reset-to-defaults";
2180 if (DB_TYPE
== "pgsql") {
2181 db_query($link,"UPDATE ttrss_user_prefs
2182 SET value = ttrss_prefs.def_value
2183 WHERE owner_uid = '".$_SESSION["uid"]."' AND
2184 ttrss_prefs.pref_name = ttrss_user_prefs.pref_name");
2186 db_query($link, "DELETE FROM ttrss_user_prefs
2187 WHERE owner_uid = ".$_SESSION["uid"]);
2188 initialize_user_prefs($link, $_SESSION["uid"]);
2191 header("Location: prefs.php");
2195 if (!SINGLE_USER_MODE
) {
2197 $result = db_query($link, "SELECT id FROM ttrss_users
2198 WHERE id = ".$_SESSION["uid"]." AND (pwd_hash = 'password' OR
2199 pwd_hash = 'SHA1:".sha1("password")."')");
2201 if (db_num_rows($result) != 0) {
2202 print "<div class=\"warning\">
2203 Your password is at default value, please change it.
2207 if ($_SESSION["pwd_change_result"] == "failed") {
2208 print "<div class=\"warning\">
2209 There was an error while changing your password.
2213 if ($_SESSION["pwd_change_result"] == "ok") {
2214 print "<div class=\"notice\">
2215 Password changed successfully.
2219 $_SESSION["pwd_change_result"] = "";
2221 if ($_SESSION["prefs_op_result"] == "reset-to-defaults") {
2222 print "<div class=\"notice\">
2223 Your configuration was reset to defaults.
2227 if ($_SESSION["prefs_op_result"] == "save-config") {
2228 print "<div class=\"notice\">
2229 Your configuration was saved successfully.
2233 $_SESSION["prefs_op_result"] = "";
2235 print "<form action=\"backend.php\" method=\"POST\">";
2237 print "<table width=\"100%\" class=\"prefPrefsList\">";
2238 print "<tr><td colspan='3'><h3>Authentication</h3></tr></td>";
2240 print "<tr><td width=\"40%\">Old password</td>";
2241 print "<td><input class=\"editbox\" type=\"password\"
2242 name=\"OLD_PASSWORD\"></td></tr>";
2244 print "<tr><td width=\"40%\">New password</td>";
2246 print "<td><input class=\"editbox\" type=\"password\"
2247 name=\"NEW_PASSWORD\"></td></tr>";
2251 print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">";
2253 print "<p><input class=\"button\" type=\"submit\"
2254 value=\"Change password\" name=\"subop\">";
2260 $result = db_query($link, "SELECT
2261 ttrss_user_prefs.pref_name,short_desc,help_text,value,type_name,
2262 section_name,def_value
2263 FROM ttrss_prefs,ttrss_prefs_types,ttrss_prefs_sections,ttrss_user_prefs
2264 WHERE type_id = ttrss_prefs_types.id AND
2265 section_id = ttrss_prefs_sections.id AND
2266 ttrss_user_prefs.pref_name = ttrss_prefs.pref_name AND
2267 owner_uid = ".$_SESSION["uid"]."
2268 ORDER BY section_id,short_desc");
2270 print "<form action=\"backend.php\" method=\"POST\">";
2274 $active_section = "";
2276 while ($line = db_fetch_assoc($result)) {
2278 if ($active_section != $line["section_name"]) {
2280 if ($active_section != "") {
2284 print "<p><table width=\"100%\" class=\"prefPrefsList\">";
2286 $active_section = $line["section_name"];
2288 print "<tr><td colspan=\"3\"><h3>$active_section</h3></td></tr>";
2289 // print "<tr class=\"title\">
2290 // <td width=\"25%\">Option</td><td>Value</td></tr>";
2295 // $class = ($lnum % 2) ? "even" : "odd";
2299 $type_name = $line["type_name"];
2300 $pref_name = $line["pref_name"];
2301 $value = $line["value"];
2302 $def_value = $line["def_value"];
2303 $help_text = $line["help_text"];
2305 print "<td width=\"40%\" id=\"$pref_name\">" . $line["short_desc"];
2307 if ($help_text) print "<div class=\"prefHelp\">$help_text</div>";
2313 if ($type_name == "bool") {
2314 // print_select($pref_name, $value, array("true", "false"));
2316 if ($value == "true") {
2322 print_radio($pref_name, $value, array("Yes", "No"));
2325 print "<input class=\"editbox\" name=\"$pref_name\" value=\"$value\">";
2337 print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">";
2339 print "<p><input class=\"button\" type=\"submit\"
2340 name=\"subop\" value=\"Save configuration\">";
2342 print " <input class=\"button\" type=\"submit\"
2343 name=\"subop\" value=\"Reset to defaults\"></p>";
2351 if ($op == "pref-users") {
2353 $subop = $_GET["subop"];
2355 if ($subop == "editSave") {
2357 if (!WEB_DEMO_MODE
) {
2359 $login = db_escape_string($_GET["l"]);
2360 $uid = db_escape_string($_GET["id"]);
2361 $access_level = sprintf("%d", $_GET["al"]);
2363 db_query($link, "UPDATE ttrss_users SET login = '$login', access_level = '$access_level' WHERE id = '$uid'");
2366 } else if ($subop == "remove") {
2368 if (!WEB_DEMO_MODE
&& $_SESSION["access_level"] >= 10) {
2370 $ids = split(",", $_GET["ids"]);
2372 foreach ($ids as $id) {
2373 db_query($link, "DELETE FROM ttrss_users WHERE id = '$id' AND id != " . $_SESSION["uid"]);
2377 } else if ($subop == "add") {
2379 if (!WEB_DEMO_MODE
&& $_SESSION["access_level"] >= 10) {
2381 $login = db_escape_string(trim($_GET["login"]));
2382 $tmp_user_pwd = make_password(8);
2383 $pwd_hash = 'SHA1:' . sha1($tmp_user_pwd);
2385 db_query($link, "INSERT INTO ttrss_users (login,pwd_hash,access_level)
2386 VALUES ('$login', '$pwd_hash', 0)");
2389 $result = db_query($link, "SELECT id FROM ttrss_users WHERE
2390 login = '$login' AND pwd_hash = '$pwd_hash'");
2392 if (db_num_rows($result) == 1) {
2394 $new_uid = db_fetch_result($result, 0, "id");
2396 print "<div class=\"notice\">Added user <b>".$_GET["login"].
2397 "</b> with password <b>$tmp_user_pwd</b>.</div>";
2399 initialize_user($link, $new_uid);
2403 print "<div class=\"warning\">Error while adding user <b>".
2404 $_GET["login"].".</b></div>";
2408 } else if ($subop == "resetPass") {
2410 if (!WEB_DEMO_MODE
&& $_SESSION["access_level"] >= 10) {
2412 $uid = db_escape_string($_GET["id"]);
2414 $result = db_query($link, "SELECT login FROM ttrss_users WHERE id = '$uid'");
2416 $login = db_fetch_result($result, 0, "login");
2417 $tmp_user_pwd = make_password(8);
2418 $pwd_hash = 'SHA1:' . sha1($tmp_user_pwd);
2420 db_query($link, "UPDATE ttrss_users SET pwd_hash = '$pwd_hash'
2421 WHERE id = '$uid'");
2423 print "<div class=\"notice\">Changed password of
2424 user <b>$login</b> to <b>$tmp_user_pwd</b>.</div>";
2429 print "<div class=\"prefGenericAddBox\">
2430 <input id=\"uadd_box\" size=\"40\"> ";
2432 print"<input type=\"submit\" class=\"button\"
2433 onclick=\"javascript:addUser()\" value=\"Add user\"></div>";
2435 $result = db_query($link, "SELECT
2436 id,login,access_level,
2437 SUBSTRING(last_login,1,16) as last_login
2442 print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>";
2444 print "<p><table width=\"100%\" class=\"prefUserList\" id=\"prefUserList\">";
2446 print "<tr class=\"title\">
2447 <td width=\"5%\">Select</td>
2448 <td width='30%'>Username</td>
2449 <td width='30%'>Access Level</td>
2450 <td width='30%'>Last login</td></tr>";
2454 while ($line = db_fetch_assoc($result)) {
2456 $class = ($lnum %
2) ?
"even" : "odd";
2459 $edit_uid = $_GET["id"];
2461 if ($uid == $_SESSION["uid"] ||
($subop == "edit" && $uid != $edit_uid)) {
2465 print "<tr class=\"$class\" id=\"UMRR-$uid\">";
2467 $line["login"] = htmlspecialchars($line["login"]);
2469 if ($uid == $_SESSION["uid"]) {
2471 print "<td><input disabled=\"true\" type=\"checkbox\"
2472 id=\"UMCHK-".$line["id"]."\"></td>";
2474 print "<td>".$line["login"]."</td>";
2475 print "<td>".$line["access_level"]."</td>";
2477 } else if (!$edit_uid ||
$subop != "edit") {
2479 print "<td><input onclick='toggleSelectRow(this);'
2480 type=\"checkbox\" id=\"UMCHK-$uid\"></td>";
2482 print "<td><a href=\"javascript:editUser($uid);\">" .
2483 $line["login"] . "</td>";
2485 print "<td><a href=\"javascript:editUser($uid);\">" .
2486 $line["access_level"] . "</td>";
2488 } else if ($uid != $edit_uid) {
2490 print "<td><input disabled=\"true\" type=\"checkbox\"
2491 id=\"UMCHK-".$line["id"]."\"></td>";
2493 print "<td>".$line["login"]."</td>";
2494 print "<td>".$line["access_level"]."</td>";
2498 print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>";
2500 print "<td><input id=\"iedit_ulogin\" value=\"".$line["login"].
2503 print "<td><input id=\"iedit_ulevel\" value=\"".$line["access_level"].
2508 print "<td>".$line["last_login"]."</td>";
2519 if ($subop == "edit") {
2521 <input type=\"submit\" class=\"button\"
2522 onclick=\"javascript:userEditCancel()\" value=\"Cancel\">
2523 <input type=\"submit\" class=\"button\"
2524 onclick=\"javascript:userEditSave()\" value=\"Save\">";
2530 <input type=\"submit\" class=\"button\"
2531 onclick=\"javascript:selectedUserDetails()\" value=\"User details\">
2532 <input type=\"submit\" class=\"button\"
2533 onclick=\"javascript:editSelectedUser()\" value=\"Edit\">
2534 <input type=\"submit\" class=\"button\"
2535 onclick=\"javascript:removeSelectedUsers()\" value=\"Remove\">
2536 <input type=\"submit\" class=\"button\"
2537 onclick=\"javascript:resetSelectedUserPass()\" value=\"Reset password\">";
2542 if ($op == "user-details") {
2544 if (WEB_DEMO_MODE ||
$_SESSION["access_level"] < 10) {
2548 /* print "<html><head>
2549 <title>Tiny Tiny RSS : User Details</title>
2550 <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">
2551 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
2554 $uid = sprintf("%d", $_GET["id"]);
2556 print "<div class='infoBoxContents'>";
2558 $result = db_query($link, "SELECT login,
2559 SUBSTRING(last_login,1,16) AS last_login,
2561 (SELECT COUNT(int_id) FROM ttrss_user_entries
2562 WHERE owner_uid = id) AS stored_articles
2564 WHERE id = '$uid'");
2566 if (db_num_rows($result) == 0) {
2567 print "<h1>User not found</h1>";
2571 print "<h1>User Details</h1>";
2573 print "<table width='100%'>";
2575 $login = db_fetch_result($result, 0, "login");
2576 $last_login = db_fetch_result($result, 0, "last_login");
2577 $access_level = db_fetch_result($result, 0, "access_level");
2578 $stored_articles = db_fetch_result($result, 0, "stored_articles");
2580 print "<tr><td>Username</td><td>$login</td></tr>";
2581 print "<tr><td>Access level</td><td>$access_level</td></tr>";
2582 print "<tr><td>Last logged in</td><td>$last_login</td></tr>";
2583 print "<tr><td>Stored articles</td><td>$stored_articles</td></tr>";
2585 $result = db_query($link, "SELECT COUNT(id) as num_feeds FROM ttrss_feeds
2586 WHERE owner_uid = '$uid'");
2588 $num_feeds = db_fetch_result($result, 0, "num_feeds");
2590 print "<tr><td>Subscribed feeds count</td><td>$num_feeds</td></tr>";
2592 /* $result = db_query($link, "SELECT
2593 SUM(LENGTH(content)+LENGTH(title)+LENGTH(link)+LENGTH(guid)) AS db_size
2594 FROM ttrss_user_entries,ttrss_entries
2595 WHERE owner_uid = '$uid' AND ref_id = id");
2597 $db_size = round(db_fetch_result($result, 0, "db_size") / 1024);
2599 print "<tr><td>Approx. used DB size</td><td>$db_size KBytes</td></tr>"; */
2603 print "<h1>Subscribed feeds</h1>";
2605 $result = db_query($link, "SELECT id,title,feed_url FROM ttrss_feeds
2606 WHERE owner_uid = '$uid' ORDER BY title");
2608 print "<ul class=\"nomarks\">";
2610 while ($line = db_fetch_assoc($result)) {
2612 $icon_file = ICONS_URL
."/".$line["id"].".ico";
2614 if (file_exists($icon_file) && filesize($icon_file) > 0) {
2615 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"$icon_file\">";
2617 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
2620 print "<li>$feed_icon <a href=\"".$line["feed_url"]."\">".$line["title"]."</a></li>";
2627 print "<div align='center'>
2628 <input type='submit' class='button'
2629 onclick=\"closeInfoBox()\" value=\"Close this window\"></div>";
2631 // print "</body></html>";
2635 if ($op == "feed-details") {
2637 $feed_id = $_GET["id"];
2639 $result = db_query($link,
2641 title,feed_url,last_updated,icon_url,site_url,
2642 (SELECT COUNT(int_id) FROM ttrss_user_entries
2643 WHERE feed_id = id) AS total,
2644 (SELECT COUNT(int_id) FROM ttrss_user_entries
2645 WHERE feed_id = id AND unread = true) AS unread,
2646 (SELECT COUNT(int_id) FROM ttrss_user_entries
2647 WHERE feed_id = id AND marked = true) AS marked
2649 WHERE id = '$feed_id' AND owner_uid = ".$_SESSION["uid"]);
2651 if (db_num_rows($result) == 0) return;
2653 $title = db_fetch_result($result, 0, "title");
2654 $last_updated = db_fetch_result($result, 0, "last_updated");
2655 $feed_url = db_fetch_result($result, 0, "feed_url");
2656 $icon_url = db_fetch_result($result, 0, "icon_url");
2657 $total = db_fetch_result($result, 0, "total");
2658 $unread = db_fetch_result($result, 0, "unread");
2659 $marked = db_fetch_result($result, 0, "marked");
2660 $site_url = db_fetch_result($result, 0, "site_url");
2662 $result = db_query($link, "SELECT COUNT(id) AS subscribed
2663 FROM ttrss_feeds WHERE feed_url = '$feed_url'");
2665 $subscribed = db_fetch_result($result, 0, "subscribed");
2667 print "<div class=\"infoBoxContents\">";
2669 $icon_file = ICONS_DIR
. "/$feed_id.ico";
2671 if (file_exists($icon_file) && filesize($icon_file) > 0) {
2672 $feed_icon = "<img width=\"16\" height=\"16\"
2673 src=\"" . ICONS_URL
. "/$feed_id.ico\">";
2678 print "<h1>$feed_icon $title</h1>";
2680 print "<table width='100%'>";
2683 print "<tr><td width='30%'>Link</td>
2684 <td><a href=\"$site_url\">$site_url</a>
2685 <a href=\"$feed_url\">(feed)</a></td>
2688 print "<tr><td width='30%'>Feed URL</td>
2689 <td><a href=\"$feed_url\">$feed_url</a></td></tr>";
2691 print "<tr><td>Last updated</td><td>$last_updated</td></tr>";
2692 print "<tr><td>Total articles</td><td>$total</td></tr>";
2693 print "<tr><td>Unread articles</td><td>$unread</td></tr>";
2694 print "<tr><td>Starred articles</td><td>$marked</td></tr>";
2695 print "<tr><td>Subscribed users</td><td>$subscribed</td></tr>";
2699 $result = db_query($link, "SELECT title,
2700 SUBSTRING(updated,1,16) AS updated,unread
2701 FROM ttrss_entries,ttrss_user_entries
2702 WHERE ref_id = id AND feed_id = '$feed_id'
2703 ORDER BY date_entered DESC LIMIT 5");
2705 if (db_num_rows($result) > 0) {
2707 print "<h1>Latest headlines</h1>";
2709 print "<ul class=\"nomarks\">";
2711 while ($line = db_fetch_assoc($result)) {
2712 if ($line["unread"] == "t" ||
$line["unread"] == "1") {
2713 $line["title"] = "<b>" . $line["title"] . "</b>";
2715 print "<li>" . $line["title"].
2716 " <span class=\"insensitive\">(" .$line["updated"].")</span></li>";
2723 print "<div align='center'>
2724 <input type='submit' class='button'
2725 onclick=\"closeInfoBox()\" value=\"Close this window\"></div>";
2732 <!-- <?
= sprintf("Backend execution time: %.4f seconds", getmicrotime() - $script_started) ?
> -->