5 header("Content-Type: application/xml");
8 require_once "config.php";
10 require_once "functions.php";
11 require_once "magpierss/rss_fetch.inc";
13 $link = db_connect(DB_HOST
, DB_USER
, DB_PASS
, DB_NAME
);
15 if (DB_TYPE
== "pgsql") {
16 pg_query("set client_encoding = 'utf-8'");
19 $fetch = $_GET["fetch"];
21 function getLabelCounters($link) {
23 $result = db_query($link, "SELECT count(id) as count FROM ttrss_entries
24 WHERE marked = true AND unread = true");
26 $count = db_fetch_result($result, 0, "count");
28 print "<label id=\"-1\" counter=\"$count\"/>";
30 $result = db_query($link, "SELECT id,sql_exp,description FROM
31 ttrss_labels ORDER by description");
33 while ($line = db_fetch_assoc($result)) {
35 $id = -$line["id"] - 11;
39 $tmp_result = db_query($link, "SELECT count(id) as count FROM ttrss_entries
40 WHERE (" . $line["sql_exp"] . ") AND unread = true");
42 $count = db_fetch_result($tmp_result, 0, "count");
44 print "<feed id=\"$id\" counter=\"$count\"/>";
46 error_reporting (E_ERROR | E_WARNING | E_PARSE
);
51 function getFeedCounter($link, $id) {
53 $result = db_query($link, "SELECT
54 count(id) as count FROM ttrss_entries
55 WHERE feed_id = '$id' AND unread = true");
57 $count = db_fetch_result($result, 0, "count");
59 print "<feed id=\"$id\" counter=\"$count\"/>";
62 function getFeedCounters($link) {
64 $result = db_query($link, "SELECT id,
65 (SELECT count(id) FROM ttrss_entries WHERE feed_id = ttrss_feeds.id
66 AND unread = true) as count
69 while ($line = db_fetch_assoc($result)) {
72 $count = $line["count"];
74 print "<feed id=\"$id\" counter=\"$count\"/>";
78 function outputFeedList($link) {
81 <title>Tiny Tiny RSS : Feedlist</title>
82 <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">
83 <script type=\"text/javascript\" src=\"functions.js\"></script>
84 <script type=\"text/javascript\" src=\"feedlist.js\"></script>
85 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
88 print "<ul class=\"feedList\" id=\"feedList\">";
92 $result = db_query($link, "SELECT count(id) as num_starred
93 FROM ttrss_entries WHERE marked = true AND unread = true");
94 $num_starred = db_fetch_result($result, 0, "num_starred");
96 printFeedEntry(-1, "odd", "Starred articles", $num_starred, "images/mark_set.png");
100 $result = db_query($link, "SELECT id,sql_exp,description FROM
101 ttrss_labels ORDER by description");
103 if (db_num_rows($result) > 0) {
104 print "<li><hr></li>";
107 while ($line = db_fetch_assoc($result)) {
111 $tmp_result = db_query($link, "SELECT count(id) as count FROM ttrss_entries
112 WHERE (" . $line["sql_exp"] . ") AND unread = true");
114 $count = db_fetch_result($tmp_result, 0, "count");
122 error_reporting (E_ERROR | E_WARNING | E_PARSE
);
124 printFeedEntry(-$line["id"]-11,
125 $class, $line["description"], $count, "images/label.png");
130 print "<li><hr></li>";
132 $result = db_query($link, "SELECT *,
133 (SELECT count(id) FROM ttrss_entries
134 WHERE feed_id = ttrss_feeds.id) AS total,
135 (SELECT count(id) FROM ttrss_entries
136 WHERE feed_id = ttrss_feeds.id AND unread = true) as unread
137 FROM ttrss_feeds ORDER BY title");
139 $actid = $_GET["actid"];
147 while ($line = db_fetch_assoc($result)) {
149 $feed = $line["title"];
150 $feed_id = $line["id"];
152 $subop = $_GET["subop"];
154 $total = $line["total"];
155 $unread = $line["unread"];
157 // $class = ($lnum % 2) ? "even" : "odd";
161 if ($unread > 0) $class .= "Unread";
163 if ($actid == $feed_id) {
164 $class .= "Selected";
167 $total_unread +
= $unread;
169 printFeedEntry($feed_id, $class, $feed, $unread, "icons/$feed_id.ico");
176 print "<div class=\"invisible\" id=\"FEEDTU\">$total_unread</div>";
183 $subop = $_GET["subop"];
185 if ($subop == "getLabelCounters") {
188 getLabelCounters($link);
190 getFeedCounter($link, $aid);
192 print "</rpc-reply>";
195 if ($subop == "getFeedCounters") {
197 getFeedCounters($link);
198 print "</rpc-reply>";
201 if ($subop == "getAllCounters") {
203 getLabelCounters($link);
204 getFeedCounters($link);
205 print "</rpc-reply>";
209 if ($subop == "mark") {
210 $mark = $_GET["mark"];
211 $id = db_escape_string($_GET["id"]);
219 $result = db_query($link, "UPDATE ttrss_entries SET marked = $mark
223 if ($subop == "updateFeed") {
224 $feed_id = db_escape_string($_GET["feed"]);
226 $result = db_query($link,
227 "SELECT feed_url FROM ttrss_feeds WHERE id = '$feed_id'");
229 if (db_num_rows($result) > 0) {
230 $feed_url = db_fetch_result($result, 0, "feed_url");
231 // update_rss_feed($link, $feed_url, $feed_id);
234 print "DONE-$feed_id";
239 if ($subop == "forceUpdateAllFeeds" ||
$subop == "updateAllFeeds") {
240 update_all_feeds($link, true);
243 getLabelCounters($link);
244 getFeedCounters($link);
245 print "</rpc-reply>";
248 if ($subop == "catchupPage") {
250 $ids = split(",", $_GET["ids"]);
252 foreach ($ids as $id) {
254 db_query($link, "UPDATE ttrss_entries SET unread=false,last_read = NOW()
259 print "Marked active page as read.";
263 if ($op == "feeds") {
265 $subop = $_GET["subop"];
267 if ($subop == "catchupAll") {
268 db_query($link, "UPDATE ttrss_entries SET last_read = NOW(),unread = false");
271 outputFeedList($link);
278 $feed_id = $_GET["feed"];
280 $result = db_query($link, "UPDATE ttrss_entries SET unread = false,last_read = NOW() WHERE id = '$id'");
282 $addheader = $_GET["addheader"];
284 $result = db_query($link, "SELECT title,link,content,feed_id,comments,
285 (SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url
291 <title>Tiny Tiny RSS : Article $id</title>
292 <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">
293 <script type=\"text/javascript\" src=\"functions.js\"></script>
294 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
300 $line = db_fetch_assoc($result);
302 if ($line["icon_url"]) {
303 $feed_icon = "<img class=\"feedIcon\" src=\"" . $line["icon_url"] . "\">";
305 $feed_icon = " ";
308 if ($line["comments"] && $line["link"] != $line["comments"]) {
309 $entry_comments = "(<a href=\"".$line["comments"]."\">Comments</a>)";
311 $entry_comments = "";
314 print "<div class=\"postReply\">";
316 print "<div class=\"postHeader\"><table>";
318 print "<tr><td><b>Title:</b></td>
319 <td width='100%'>" . $line["title"] . "</td></tr>";
321 print "<tr><td><b>Link:</b></td>
323 <a href=\"" . $line["link"] . "\">".$line["link"]."</a>
324 $entry_comments</td></tr>";
326 print "</table></div>";
328 print "<div class=\"postIcon\">" . $feed_icon . "</div>";
329 print "<div class=\"postContent\">" . $line["content"] . "</div>";
333 print "<script type=\"text/javascript\">
334 update_label_counters($feed_id);
339 print "</body></html>";
343 if ($op == "viewfeed") {
345 $feed = $_GET["feed"];
346 $skip = $_GET["skip"];
347 $subop = $_GET["subop"];
348 $view_mode = $_GET["view"];
349 $addheader = $_GET["addheader"];
350 $limit = $_GET["limit"];
353 print "Error: no feed to display.";
357 if (!$skip) $skip = 0;
359 if ($subop == "undefined") $subop = "";
363 <title>Tiny Tiny RSS : Feed $feed</title>
364 <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">
365 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
366 <script type=\"text/javascript\" src=\"functions.js\"></script>
367 <script type=\"text/javascript\" src=\"viewfeed.js\"></script>
373 $result = db_query($link,
374 "SELECT *,SUBSTRING(last_updated,1,16) as last_updated_s
375 FROM ttrss_feeds WHERE id = '$feed'");
379 $line = db_fetch_assoc($result);
381 update_rss_feed($link, $line["feed_url"], $feed);
383 if ($subop == "MarkAllRead") {
385 db_query($link, "UPDATE ttrss_entries SET unread = false,last_read = NOW()
386 WHERE feed_id = '$feed'");
391 print "<table class=\"headlinesList\" id=\"headlinesList\" width=\"100%\">";
393 $search = $_GET["search"];
396 $search_query_part = "(upper(title) LIKE upper('%$search%')
397 OR content LIKE '%$search%') AND";
399 $search_query_part = "";
402 $view_query_part = "";
404 if ($view_mode == "Starred") {
405 $view_query_part = " marked = true AND ";
408 if ($view_mode == "Unread") {
409 $view_query_part = " unread = true AND ";
412 /* $result = db_query($link, "SELECT count(id) AS total_entries
413 FROM ttrss_entries WHERE
417 $total_entries = db_fetch_result($result, 0, "total_entries"); */
419 /* $result = db_query("SELECT count(id) AS unread_entries
420 FROM ttrss_entries WHERE
425 $unread_entries = db_fetch_result($result, 0, "unread_entries"); */
427 if ($limit && $limit != "All") {
428 $limit_query_part = "LIMIT " . $limit;
431 $vfeed_query_part = "";
434 $query_strategy_part = "feed_id = '$feed'";
435 } else if ($feed == -1) { // starred virtual feed
436 $query_strategy_part = "marked = true";
437 $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE
438 id = feed_id) as feed_title,";
439 } else if ($feed <= -10) { // labels
440 $label_id = -$feed - 11;
442 $tmp_result = db_query($link, "SELECT sql_exp FROM ttrss_labels
443 WHERE id = '$label_id'");
445 $query_strategy_part = db_fetch_result($tmp_result, 0, "sql_exp");
447 $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE
448 id = feed_id) as feed_title,";
450 $query_strategy_part = "id > 0"; // dumb
453 $order_by = "updated DESC";
455 // if ($feed < -10) {
456 // $order_by = "feed_id,updated DESC";
459 if ($feed < -10) error_reporting (0);
461 $result = db_query($link, "SELECT
462 id,title,updated,unread,feed_id,marked,link,last_read,
463 SUBSTRING(last_read,1,19) as last_read_noms,
465 SUBSTRING(updated,1,19) as updated_noms
471 $query_strategy_part ORDER BY $order_by
475 print "<tr><td colspan='4' align='center'>
476 Could not display feed (query failed). Please check match syntax or local configuration.</td></tr>";
482 error_reporting (E_ERROR | E_WARNING | E_PARSE
);
486 while ($line = db_fetch_assoc($result)) {
488 $class = ($lnum %
2) ?
"even" : "odd";
491 $feed_id = $line["feed_id"];
493 // printf("L %d (%s) > U %d (%s) = %d<br>",
494 // strtotime($line["last_read_noms"]), $line["last_read_noms"],
495 // strtotime($line["updated"]), $line["updated"],
496 // strtotime($line["last_read"]) >= strtotime($line["updated"]));
498 if ($line["last_read"] != "" && $line["updated"] != "" &&
499 strtotime($line["last_read_noms"]) < strtotime($line["updated_noms"])) {
501 $update_pic = "<img id='FUPDPIC-$id' src=\"images/updated.png\"
506 $update_pic = "<img id='FUPDPIC-$id' src=\"images/blank_icon.gif\"
511 if ($line["unread"] == "t" ||
$line["unread"] == "1") {
516 if ($line["marked"] == "t" ||
$line["marked"] == "1") {
517 $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_set.png\"
518 alt=\"Reset mark\" onclick='javascript:toggleMark($id, false)'>";
520 $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_unset.png\"
521 alt=\"Set mark\" onclick='javascript:toggleMark($id, true)'>";
524 $content_link = "<a id=\"FTITLE-$id\" href=\"javascript:view($id,$feed_id);\">" .
525 $line["title"] . "</a>";
527 print "<tr class='$class' id='RROW-$id'>";
528 // onclick=\"javascript:view($id,$feed_id)\">
530 print "<td valign='center' align='center'>$update_pic</td>";
531 print "<td valign='center' align='center'>$marked_pic</td>";
533 print "<td width='25%'>
534 <a href=\"javascript:view($id,$feed_id);\">".$line["updated"]."</a></td>";
536 if ($line["feed_title"]) {
537 print "<td width='50%'>$content_link</td>";
538 print "<td width='20%'>".$line["feed_title"]."</td>";
540 print "<td width='70%'>$content_link</td>";
549 print "<tr><td align='center'>No articles found.</td></tr>";
552 /* while ($lnum < HEADLINES_PER_PAGE) {
554 print "<tr><td> </td></tr>";
561 $result = db_query($link, "SELECT count(id) as unread FROM ttrss_entries
562 WHERE feed_id = '$feed' AND $query_strategy_part
565 $unread = db_fetch_result($result, 0, "unread");
567 } else if ($feed == -1) {
568 $result = db_query($link, "SELECT count(id) as unread FROM ttrss_entries
569 WHERE $query_strategy_part");
571 $unread = db_fetch_result($result, 0, "unread");
574 // print "[viewfeed] feed type not implemented<br>";
577 $result = db_query($link, "SELECT count(id) as unread FROM ttrss_entries
578 WHERE $query_strategy_part");
580 $unread = db_fetch_result($result, 0, "unread");
582 error_reporting (E_ERROR | E_WARNING | E_PARSE
);
585 if (!$unread) $unread = 0;
587 // update unread/total counters and status for active feed in the feedlist
588 // kludge, because iframe doesn't seem to support onload()
590 print "<script type=\"text/javascript\">
591 document.onkeydown = hotkey_handler;
593 var p_document = parent.frames['feeds-frame'].document;
595 var feedr = p_document.getElementById(\"FEEDR-\" + $feed);
596 var feedu = p_document.getElementById(\"FEEDU-\" + $feed);
599 feedu.innerHTML = \"$unread\";
602 var feedctr = p_document.getElementById(\"FEEDCTR-\" + $feed);
604 if ($unread > 0 && $feed >= 0 && !feedr.className.match(\"Unread\")) {
605 feedr.className = feedr.className + \"Unread\";
606 feedctr.className = '';
607 } else if ($unread <= 0) {
608 feedr.className = feedr.className.replace(\"Unread\", \"\");
609 feedctr.className = 'invisible';
612 update_label_counters($feed);
619 print "</body></html>";
624 if ($op == "pref-rpc") {
626 $subop = $_GET["subop"];
628 if ($subop == "unread") {
629 $ids = split(",", $_GET["ids"]);
630 foreach ($ids as $id) {
631 db_query($link, "UPDATE ttrss_entries SET unread = true WHERE feed_id = '$id'");
634 print "Marked selected feeds as read.";
637 if ($subop == "read") {
638 $ids = split(",", $_GET["ids"]);
639 foreach ($ids as $id) {
640 db_query($link, "UPDATE ttrss_entries
641 SET unread = false,last_read = NOW() WHERE feed_id = '$id'");
644 print "Marked selected feeds as unread.";
650 if ($op == "pref-feeds") {
652 $subop = $_GET["subop"];
654 if ($subop == "editSave") {
655 $feed_title = db_escape_string($_GET["t"]);
656 $feed_link = db_escape_string($_GET["l"]);
657 $feed_id = $_GET["id"];
659 $result = db_query($link, "UPDATE ttrss_feeds SET
660 title = '$feed_title', feed_url = '$feed_link' WHERE id = '$feed_id'");
664 if ($subop == "remove") {
666 if (!WEB_DEMO_MODE
) {
668 $ids = split(",", $_GET["ids"]);
670 foreach ($ids as $id) {
671 db_query($link, "DELETE FROM ttrss_feeds WHERE id = '$id'");
673 if (file_exists(ICONS_DIR
. "/$id.ico")) {
674 unlink(ICONS_DIR
. "/$id.ico");
680 if ($subop == "add") {
682 if (!WEB_DEMO_MODE
) {
684 $feed_link = db_escape_string($_GET["link"]);
686 $result = db_query($link,
687 "INSERT INTO ttrss_feeds (feed_url,title) VALUES ('$feed_link', '')");
689 $result = db_query($link,
690 "SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_link'");
692 $feed_id = db_fetch_result($result, 0, "id");
695 update_rss_feed($link, $feed_link, $feed_id);
700 print "<table class=\"prefAddFeed\"><tr>
701 <td><input id=\"fadd_link\"></td>
702 <td colspan=\"4\" align=\"right\">
703 <a class=\"button\" href=\"javascript:addFeed()\">Add feed</a></td></tr>
706 $result = db_query($link, "SELECT
707 id,title,feed_url,substring(last_updated,1,16) as last_updated
709 ttrss_feeds ORDER by title");
711 print "<p><table width=\"100%\" class=\"prefFeedList\" id=\"prefFeedList\">";
712 print "<tr class=\"title\">
713 <td> </td><td>Select</td><td width=\"40%\">Title</td>
714 <td width=\"40%\">Link</td><td>Last updated</td></tr>";
718 while ($line = db_fetch_assoc($result)) {
720 $class = ($lnum %
2) ?
"even" : "odd";
722 $feed_id = $line["id"];
724 $edit_feed_id = $_GET["id"];
726 if ($subop == "edit" && $feed_id != $edit_feed_id) {
730 print "<tr class=\"$class\" id=\"FEEDR-$feed_id\">";
732 $icon_file = ICONS_DIR
. "/$feed_id.ico";
734 if (file_exists($icon_file) && filesize($icon_file) > 0) {
735 $feed_icon = "<img width=\"16\" height=\"16\"
736 src=\"" . ICONS_URL
. "/$feed_id.ico\">";
738 $feed_icon = " ";
740 print "<td align='center'>$feed_icon</td>";
742 if (!$edit_feed_id ||
$subop != "edit") {
744 print "<td><input onclick='toggleSelectRow(this);'
745 type=\"checkbox\" id=\"FRCHK-".$line["id"]."\"></td>";
747 print "<td><a href=\"javascript:editFeed($feed_id);\">" .
748 $line["title"] . "</td>";
749 print "<td><a href=\"javascript:editFeed($feed_id);\">" .
750 $line["feed_url"] . "</td>";
753 } else if ($feed_id != $edit_feed_id) {
755 print "<td><input disabled=\"true\" type=\"checkbox\"
756 id=\"FRCHK-".$line["id"]."\"></td>";
758 print "<td>".$line["title"]."</td>";
759 print "<td>".$line["feed_url"]."</td>";
763 print "<td><input disabled=\"true\" type=\"checkbox\"></td>";
765 print "<td><input id=\"iedit_title\" value=\"".$line["title"]."\"></td>";
766 print "<td><input id=\"iedit_link\" value=\"".$line["feed_url"]."\"></td>";
770 if (!$line["last_updated"]) $line["last_updated"] = "Never";
772 print "<td>" . $line["last_updated"] . "</td>";
780 print "<tr><td colspan=\"5\" align=\"center\">No feeds defined.</td></tr>";
787 if ($subop == "edit") {
788 print "Edit feed:
789 <input type=\"submit\" class=\"button\"
790 onclick=\"javascript:feedEditCancel()\" value=\"Cancel\">
791 <input type=\"submit\" class=\"button\"
792 onclick=\"javascript:feedEditSave()\" value=\"Save\">";
797 <input type=\"submit\" class=\"button\"
798 onclick=\"javascript:editSelectedFeed()\" value=\"Edit\">
799 <input type=\"submit\" class=\"button\"
800 onclick=\"javascript:removeSelectedFeeds()\" value=\"Remove\">";
802 if (ENABLE_PREFS_CATCHUP_UNCATCHUP
) {
804 <input type=\"submit\" class=\"button\"
805 onclick=\"javascript:readSelectedFeeds()\" value=\"Mark as read\">
806 <input type=\"submit\" class=\"button\"
807 onclick=\"javascript:unreadSelectedFeeds()\" value=\"Mark as unread\"> ";
811 <input type=\"submit\"
812 class=\"button\" onclick=\"gotoExportOpml()\" value=\"Export OPML\">";
818 if ($op == "pref-filters") {
820 $subop = $_GET["subop"];
822 if ($subop == "editSave") {
824 $regexp = db_escape_string($_GET["r"]);
825 $descr = db_escape_string($_GET["d"]);
826 $match = db_escape_string($_GET["m"]);
827 $filter_id = db_escape_string($_GET["id"]);
829 $result = db_query($link, "UPDATE ttrss_filters SET
831 description = '$descr',
832 filter_type = (SELECT id FROM ttrss_filter_types WHERE
833 description = '$match')
834 WHERE id = '$filter_id'");
837 if ($subop == "remove") {
839 if (!WEB_DEMO_MODE
) {
841 $ids = split(",", $_GET["ids"]);
843 foreach ($ids as $id) {
844 db_query($link, "DELETE FROM ttrss_filters WHERE id = '$id'");
850 if ($subop == "add") {
852 if (!WEB_DEMO_MODE
) {
854 $regexp = db_escape_string($_GET["regexp"]);
855 $match = db_escape_string($_GET["match"]);
857 $result = db_query($link,
858 "INSERT INTO ttrss_filters (reg_exp,filter_type) VALUES
859 ('$regexp', (SELECT id FROM ttrss_filter_types WHERE
860 description = '$match'))");
864 $result = db_query($link, "SELECT description
865 FROM ttrss_filter_types ORDER BY description");
867 $filter_types = array();
869 while ($line = db_fetch_assoc($result)) {
870 array_push($filter_types, $line["description"]);
873 print "<table class=\"prefAddFeed\"><tr>
874 <td><input id=\"fadd_regexp\"></td>
876 print_select("fadd_match", "Title", $filter_types);
878 print"</td><td colspan=\"4\" align=\"right\">
879 <a class=\"button\" href=\"javascript:addFilter()\">Add filter</a></td></tr>
882 $result = db_query($link, "SELECT
883 id,reg_exp,description,
884 (SELECT name FROM ttrss_filter_types WHERE
885 id = filter_type) as filter_type_name,
886 (SELECT description FROM ttrss_filter_types
887 WHERE id = filter_type) as filter_type_descr
889 ttrss_filters ORDER by reg_exp");
891 print "<p><table width=\"100%\" class=\"prefFilterList\" id=\"prefFilterList\">";
893 print "<tr class=\"title\">
894 <td width=\"5%\">Select</td><td width=\"40%\">Filter expression</td>
895 <td width=\"40%\">Description</td><td width=\"10%\">Match</td></tr>";
899 while ($line = db_fetch_assoc($result)) {
901 $class = ($lnum %
2) ?
"even" : "odd";
903 $filter_id = $line["id"];
904 $edit_filter_id = $_GET["id"];
906 if ($subop == "edit" && $filter_id != $edit_filter_id) {
910 print "<tr class=\"$class\" id=\"FILRR-$filter_id\">";
912 $line["regexp"] = htmlspecialchars($line["reg_exp"]);
913 $line["description"] = htmlspecialchars($line["description"]);
915 if (!$edit_filter_id ||
$subop != "edit") {
917 if (!$line["description"]) $line["description"] = "[No description]";
919 print "<td><input onclick='toggleSelectRow(this);'
920 type=\"checkbox\" id=\"FICHK-".$line["id"]."\"></td>";
922 print "<td><a href=\"javascript:editFilter($filter_id);\">" .
923 $line["reg_exp"] . "</td>";
925 print "<td><a href=\"javascript:editFilter($filter_id);\">" .
926 $line["description"] . "</td>";
928 print "<td>".$line["filter_type_descr"]."</td>";
930 } else if ($filter_id != $edit_filter_id) {
932 if (!$line["description"]) $line["description"] = "[No description]";
934 print "<td><input disabled=\"true\" type=\"checkbox\"
935 id=\"FICHK-".$line["id"]."\"></td>";
937 print "<td>".$line["reg_exp"]."</td>";
938 print "<td>".$line["description"]."</td>";
939 print "<td>".$line["filter_type_descr"]."</td>";
943 print "<td><input disabled=\"true\" type=\"checkbox\"></td>";
945 print "<td><input id=\"iedit_regexp\" value=\"".$line["reg_exp"].
948 print "<td><input id=\"iedit_descr\" value=\"".$line["description"].
952 print_select("iedit_match", $line["filter_type_descr"], $filter_types);
964 print "<tr><td colspan=\"4\" align=\"center\">No filters defined.</td></tr>";
971 if ($subop == "edit") {
973 <input type=\"submit\" class=\"button\"
974 onclick=\"javascript:filterEditCancel()\" value=\"Cancel\">
975 <input type=\"submit\" class=\"button\"
976 onclick=\"javascript:filterEditSave()\" value=\"Save\">";
982 <input type=\"submit\" class=\"button\"
983 onclick=\"javascript:editSelectedFilter()\" value=\"Edit\">
984 <input type=\"submit\" class=\"button\"
985 onclick=\"javascript:removeSelectedFilters()\" value=\"Remove\">";
989 if ($op == "pref-labels") {
991 $subop = $_GET["subop"];
993 if ($subop == "editSave") {
995 $sql_exp = $_GET["s"];
997 $label_id = db_escape_string($_GET["id"]);
999 // print "$sql_exp : $descr : $label_id";
1001 $result = db_query($link, "UPDATE ttrss_labels SET
1002 sql_exp = '$sql_exp',
1003 description = '$descr'
1004 WHERE id = '$label_id'");
1007 if ($subop == "remove") {
1009 if (!WEB_DEMO_MODE
) {
1011 $ids = split(",", $_GET["ids"]);
1013 foreach ($ids as $id) {
1014 db_query($link, "DELETE FROM ttrss_labels WHERE id = '$id'");
1020 if ($subop == "add") {
1022 if (!WEB_DEMO_MODE
) {
1024 $exp = $_GET["exp"];
1026 $result = db_query($link,
1027 "INSERT INTO ttrss_labels (sql_exp,description)
1028 VALUES ('$exp', '$exp')");
1032 print "<table class=\"prefAddFeed\"><tr>
1033 <td><input id=\"ladd_expr\"></td>";
1035 print"<td colspan=\"4\" align=\"right\">
1036 <a class=\"button\" href=\"javascript:addLabel()\">Add label</a></td></tr>
1039 $result = db_query($link, "SELECT
1040 id,sql_exp,description
1042 ttrss_labels ORDER by description");
1044 print "<p><table width=\"100%\" class=\"prefLabelList\" id=\"prefLabelList\">";
1046 print "<tr class=\"title\">
1047 <td width=\"5%\">Select</td><td width=\"40%\">SQL expression</td>
1048 <td width=\"40%\">Caption</td></tr>";
1052 while ($line = db_fetch_assoc($result)) {
1054 $class = ($lnum %
2) ?
"even" : "odd";
1056 $label_id = $line["id"];
1057 $edit_label_id = $_GET["id"];
1059 if ($subop == "edit" && $label_id != $edit_label_id) {
1063 print "<tr class=\"$class\" id=\"LILRR-$label_id\">";
1065 $line["sql_exp"] = htmlspecialchars($line["sql_exp"]);
1066 $line["description"] = htmlspecialchars($line["description"]);
1068 if (!$edit_label_id ||
$subop != "edit") {
1070 if (!$line["description"]) $line["description"] = "[No caption]";
1072 print "<td><input onclick='toggleSelectRow(this);'
1073 type=\"checkbox\" id=\"LICHK-".$line["id"]."\"></td>";
1075 print "<td><a href=\"javascript:editLabel($label_id);\">" .
1076 $line["sql_exp"] . "</td>";
1078 print "<td><a href=\"javascript:editLabel($label_id);\">" .
1079 $line["description"] . "</td>";
1081 } else if ($label_id != $edit_label_id) {
1083 if (!$line["description"]) $line["description"] = "[No description]";
1085 print "<td><input disabled=\"true\" type=\"checkbox\"
1086 id=\"LICHK-".$line["id"]."\"></td>";
1088 print "<td>".$line["sql_exp"]."</td>";
1089 print "<td>".$line["description"]."</td>";
1093 print "<td><input disabled=\"true\" type=\"checkbox\"></td>";
1095 print "<td><input id=\"iedit_expr\" value=\"".$line["sql_exp"].
1098 print "<td><input id=\"iedit_descr\" value=\"".$line["description"].
1110 print "<tr><td colspan=\"4\" align=\"center\">No labels defined.</td></tr>";
1117 if ($subop == "edit") {
1119 <input type=\"submit\" class=\"button\"
1120 onclick=\"javascript:labelEditCancel()\" value=\"Cancel\">
1121 <input type=\"submit\" class=\"button\"
1122 onclick=\"javascript:labelEditSave()\" value=\"Save\">";
1128 <input type=\"submit\" class=\"button\"
1129 onclick=\"javascript:editSelectedLabel()\" value=\"Edit\">
1130 <input type=\"submit\" class=\"button\"
1131 onclick=\"javascript:removeSelectedLabels()\" value=\"Remove\">";
1135 if ($op == "error") {
1136 print "<div width=\"100%\" align='center'>";
1137 $msg = $_GET["msg"];