]> git.wh0rd.org - tt-rss.git/blob - backend.php
inputify buttons, store view modes in session cookies, disable headline toolbar initially
[tt-rss.git] / backend.php
1 <?
2 // header("Content-Type: application/xml");
3
4 require_once "config.php";
5 require_once "functions.php";
6 require_once "magpierss/rss_fetch.inc";
7
8 error_reporting(0);
9
10 $link = pg_connect(DB_CONN);
11
12 error_reporting (E_ERROR | E_WARNING | E_PARSE);
13
14 if (!$link) {
15 print "Could not connect to database. Please check local configuration.";
16 return;
17 }
18
19 pg_query("set client_encoding = 'utf-8'");
20
21 $op = $_GET["op"];
22 $fetch = $_GET["fetch"];
23
24 function outputFeedList($link) {
25
26 $result = pg_query($link, "SELECT *,
27 (SELECT count(id) FROM ttrss_entries
28 WHERE feed_id = ttrss_feeds.id) AS total,
29 (SELECT count(id) FROM ttrss_entries
30 WHERE feed_id = ttrss_feeds.id AND unread = true) as unread
31 FROM ttrss_feeds ORDER BY title");
32
33 print "<table width=\"100%\" class=\"feeds\" id=\"feedsList\">";
34
35 $lnum = 0;
36
37 $total_unread = 0;
38
39 while ($line = pg_fetch_assoc($result)) {
40
41 $feed = $line["title"];
42 $feed_id = $line["id"];
43
44 $subop = $_GET["subop"];
45
46 $total = $line["total"];
47 $unread = $line["unread"];
48
49 $class = ($lnum % 2) ? "even" : "odd";
50
51 if ($unread > 0) $class .= "Unread";
52
53 $total_unread += $unread;
54
55 print "<tr class=\"$class\" id=\"FEEDR-$feed_id\">";
56
57 $icon_file = ICONS_DIR . "/$feed_id.ico";
58
59 if ($subop != "piggie") {
60
61 if (file_exists($icon_file) && filesize($icon_file) > 0) {
62 $feed_icon = "<img width=\"16\" height=\"16\"
63 src=\"" . ICONS_URL . "/$feed_id.ico\">";
64 } else {
65 $feed_icon = "&nbsp;";
66 }
67 } else {
68 $feed_icon = "<img width=\"16\" height=\"16\"
69 src=\"http://madoka.spb.ru/stuff/fox/tiny_piggie.png\">";
70 }
71
72 $feed = "<a href=\"javascript:viewfeed($feed_id, 0);\">$feed</a>";
73 if (ENABLE_FEED_ICONS) {
74 print "<td>$feed_icon</td>";
75 }
76 print "<td id=\"FEEDN-$feed_id\">$feed</td>";
77 print "<td>";
78 print "<span id=\"FEEDU-$feed_id\">$unread</span>&nbsp;/&nbsp;";
79 print "<span id=\"FEEDT-$feed_id\">$total</span>";
80 print "</td>";
81
82 print "</tr>";
83 ++$lnum;
84 }
85
86 // print "<tr><td class=\"footer\" colspan=\"3\">
87 // <a href=\"javascript:update_feed_list(false,true)\">Update all feeds</a></td></tr>";
88
89 // print "<tr><td class=\"footer\" colspan=\"2\">&nbsp;";
90 // print "</td></tr>";
91
92 print "</table>";
93
94 print "<div class=\"invisible\" id=\"FEEDTU\">$total_unread</div>";
95
96 /*
97 print "<p align=\"center\">All feeds:
98 <a class=\"button\"
99 href=\"javascript:scheduleFeedUpdate(true)\">Update</a>";
100
101 print "&nbsp;<a class=\"button\"
102 href=\"javascript:catchupAllFeeds()\">Mark as read</a></p>";
103
104 print "<div class=\"invisible\" id=\"FEEDTU\">$total_unread</div>";
105 */
106
107
108 }
109
110
111 if ($op == "rpc") {
112
113 $subop = $_GET["subop"];
114
115 if ($subop == "mark") {
116 $mark = $_GET["mark"];
117 $id = pg_escape_string($_GET["id"]);
118
119 if ($mark == "1") {
120 $mark = "true";
121 } else {
122 $mark = "false";
123 }
124
125 $result = pg_query("UPDATE ttrss_entries SET marked = $mark
126 WHERE id = '$id'");
127 }
128
129 if ($subop == "updateFeed") {
130 $feed_id = pg_escape_string($_GET["feed"]);
131
132 $result = pg_query($link,
133 "SELECT feed_url FROM ttrss_feeds WHERE id = '$feed_id'");
134
135 if (pg_num_rows($result) > 0) {
136 $feed_url = pg_fetch_result($result, 0, "feed_url");
137 // update_rss_feed($link, $feed_url, $feed_id);
138 }
139
140 print "DONE-$feed_id";
141
142 return;
143 }
144
145 if ($subop == "forceUpdateAllFeeds") {
146 update_all_feeds($link, true);
147 outputFeedList($link);
148 }
149
150 if ($subop == "updateAllFeeds") {
151 update_all_feeds($link, false);
152 outputFeedList($link);
153 }
154
155 if ($subop == "catchupPage") {
156
157 $ids = split(",", $_GET["ids"]);
158
159 foreach ($ids as $id) {
160
161 pg_query("UPDATE ttrss_entries SET unread=false,last_read = NOW()
162 WHERE id = '$id'");
163
164 }
165
166 print "Marked active page as read.";
167 }
168
169 }
170
171 if ($op == "feeds") {
172
173 $subop = $_GET["subop"];
174
175 if ($subop == "catchupAll") {
176 pg_query("UPDATE ttrss_entries SET last_read = NOW(),unread = false");
177 }
178
179 outputFeedList($link);
180
181 }
182
183 if ($op == "view") {
184
185 $id = $_GET["id"];
186
187 $result = pg_query("UPDATE ttrss_entries SET unread = false,last_read = NOW() WHERE id = '$id'");
188
189 $addheader = $_GET["addheader"];
190
191 $result = pg_query("SELECT title,link,content,feed_id,comments,
192 (SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url
193 FROM ttrss_entries
194 WHERE id = '$id'");
195
196 if ($addheader) {
197 print "<html><head>
198 <title>Tiny Tiny RSS : Article $id</title>
199 <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">
200 <script type=\"text/javascript\" src=\"functions.js\"></script>
201 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
202 </head><body>";
203 }
204
205 if ($result) {
206
207 $line = pg_fetch_assoc($result);
208
209 if ($line["icon_url"]) {
210 $feed_icon = "<img class=\"feedIcon\" src=\"" . $line["icon_url"] . "\">";
211 } else {
212 $feed_icon = "&nbsp;";
213 }
214
215 print "<table class=\"postTable\" width=\"100%\" cellspacing=\"0\"
216 cellpadding=\"0\">";
217
218 print "<tr class=\"titleTop\"><td align=\"right\"><b>Title:</b></td>
219 <td width=\"100%\">".$line["title"]."</td>
220 <td>&nbsp;</td></tr>";
221
222 if ($line["comments"] && $line["comments"] != $line["link"]) {
223 $comments_prompt = "(<a href=\"".$line["comments"]."\">Comments</a>)";
224 }
225
226 print "<tr class=\"titleBottom\"><td align=\"right\"><b>Link:</b></td>
227 <td><a href=\"".$line["link"]."\">".$line["link"]."</a> $comments_prompt</td>
228 <td>&nbsp;</td></tr>";
229 print "<tr><td valign=\"top\" class=\"post\"
230 colspan=\"2\" width=\"100%\">" . $line["content"] . "</td>
231 <td valign=\"top\">$feed_icon</td>
232 </tr>";
233 print "</table>";
234
235 }
236
237 if ($addheader) {
238 print "</body></html>";
239 }
240 }
241
242 if ($op == "viewfeed") {
243
244 $feed = $_GET["feed"];
245 $skip = $_GET["skip"];
246 $subop = $_GET["subop"];
247 $view_mode = $_GET["view"];
248 $addheader = $_GET["addheader"];
249 $limit = $_GET["limit"];
250
251 if (!$skip) $skip = 0;
252
253 if ($subop == "undefined") $subop = "";
254
255 if ($addheader) {
256 print "<html><head>
257 <title>Tiny Tiny RSS : Feed $feed</title>
258 <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">
259 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
260 <script type=\"text/javascript\" src=\"functions.js\"></script>
261 <script type=\"text/javascript\" src=\"viewfeed.js\"></script>
262 </head><body>";
263 }
264
265 // FIXME: check for null value here
266
267 $result = pg_query("SELECT *,SUBSTRING(last_updated,1,16) as last_updated,
268 EXTRACT(EPOCH FROM NOW()) - EXTRACT(EPOCH FROM last_updated) as update_timeout
269 FROM ttrss_feeds WHERE id = '$feed'");
270
271 if ($result) {
272
273 $line = pg_fetch_assoc($result);
274
275 if ($subop == "ForceUpdate" ||
276 (!$subop && $line["update_timeout"] > MIN_UPDATE_TIME)) {
277
278 update_rss_feed($link, $line["feed_url"], $feed);
279
280 } else {
281
282 if ($subop == "MarkAllRead") {
283
284 pg_query("UPDATE ttrss_entries SET unread = false,last_read = NOW()
285 WHERE feed_id = '$feed'");
286 }
287 }
288 }
289
290 print "<table class=\"headlinesList\" id=\"headlinesList\" width=\"100%\">";
291
292 $feed_last_updated = "Updated: " . $line["last_updated"];
293
294 $search = $_GET["search"];
295
296 if ($search) {
297 $search_query_part = "(upper(title) LIKE upper('%$search%')
298 OR content LIKE '%$search%') AND";
299 } else {
300 $search_query_part = "";
301 }
302
303 $view_query_part = "";
304
305 if ($view_mode == "Starred") {
306 $view_query_part = " marked = true AND ";
307 }
308
309 if ($view_mode == "Unread") {
310 $view_query_part = " unread = true AND ";
311 }
312
313 $result = pg_query("SELECT count(id) AS total_entries
314 FROM ttrss_entries WHERE
315 $search_query_part
316 feed_id = '$feed'");
317
318 $total_entries = pg_fetch_result($result, 0, "total_entries");
319
320 $result = pg_query("SELECT count(id) AS unread_entries
321 FROM ttrss_entries WHERE
322 $search_query_part
323 unread = true AND
324 feed_id = '$feed'");
325
326 $unread_entries = pg_fetch_result($result, 0, "unread_entries");
327
328 /* if ($limit < $unread_entries)
329 $limit = $unread_entries;
330
331 if ($limit != "All") {
332 $limit_query_part = "LIMIT " . $limit;
333 } */
334
335 $result = pg_query("SELECT
336 id,title,updated,unread,feed_id,marked,link,
337 EXTRACT(EPOCH FROM last_read) AS last_read_ts,
338 EXTRACT(EPOCH FROM updated) AS updated_ts
339 FROM
340 ttrss_entries
341 WHERE
342 $search_query_part
343 $view_query_part
344 feed_id = '$feed' ORDER BY updated DESC
345 $limit_query_part");
346
347 $lnum = 0;
348
349 $num_unread = 0;
350
351 while ($line = pg_fetch_assoc($result)) {
352
353 $class = ($lnum % 2) ? "even" : "odd";
354
355 if ($line["last_read_ts"] < $line["updated_ts"] && $line["unread"] == "f") {
356 $update_pic = "<img src=\"images/updated.png\" alt=\"Updated\">";
357 ++$num_unread;
358 } else {
359 $update_pic = "&nbsp;";
360 }
361
362 if ($line["unread"] == "t") {
363 $class .= "Unread";
364 ++$num_unread;
365 }
366
367 $id = $line["id"];
368 $feed_id = $line["feed_id"];
369
370 if ($line["marked"] == "t") {
371 $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_set.png\"
372 alt=\"Reset mark\" onclick='javascript:toggleMark($id, false)'>";
373 } else {
374 $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_unset.png\"
375 alt=\"Set mark\" onclick='javascript:toggleMark($id, true)'>";
376 }
377
378 $content_link = "<a id=\"FTITLE-$id\" href=\"javascript:view($id,$feed_id);\">" .
379 $line["title"] . "</a>";
380
381 print "<tr class='$class' id='RROW-$id'";
382 // onclick=\"javascript:view($id,$feed_id)\">
383
384 print "<td id='FUPDPIC-$id' valign='center'
385 class='headlineUpdateMark'>$update_pic</td>";
386
387 print "<td valign='center'
388 class='headlineUpdateMark'>$marked_pic</td>";
389
390 print "<td class='headlineUpdated'>
391 <a href=\"javascript:view($id,$feed_id);\">".$line["updated"]."</a></td>";
392 print "<td class='headlineTitle'>$content_link</td>";
393
394 print "<td class=\"invisible\" id=\"FLINK-$id\">".$line["link"]."</td>";
395
396 print "</tr>";
397
398 ++$lnum;
399 }
400
401 if ($lnum == 0) {
402 print "<tr><td align='center'>No entries found.</td></tr>";
403 }
404
405 while ($lnum < HEADLINES_PER_PAGE) {
406 ++$lnum;
407 print "<tr><td>&nbsp;</td></tr>";
408 }
409
410 print "</table>";
411
412 $result = pg_query("SELECT id, (SELECT count(id) FROM ttrss_entries
413 WHERE feed_id = ttrss_feeds.id) AS total,
414 (SELECT count(id) FROM ttrss_entries
415 WHERE feed_id = ttrss_feeds.id AND unread = true) as unread
416 FROM ttrss_feeds WHERE id = '$feed'");
417
418 $total = pg_fetch_result($result, 0, "total");
419 $unread = pg_fetch_result($result, 0, "unread");
420
421 // update unread/total counters and status for active feed in the feedlist
422 // kludge, because iframe doesn't seem to support onload()
423
424 print "<script type=\"text/javascript\">
425 document.onkeydown = hotkey_handler;
426
427 var feedr = parent.document.getElementById(\"FEEDR-\" + $feed);
428 var feedt = parent.document.getElementById(\"FEEDT-\" + $feed);
429 var feedu = parent.document.getElementById(\"FEEDU-\" + $feed);
430
431 feedt.innerHTML = \"$total\";
432 feedu.innerHTML = \"$unread\";
433
434 if ($unread > 0 && !feedr.className.match(\"Unread\")) {
435 feedr.className = feedr.className + \"Unread\";
436 } else if ($unread <= 0) {
437 feedr.className = feedr.className.replace(\"Unread\", \"\");
438 }
439
440 //p_notify('');
441 </script>";
442
443 if ($addheader) {
444 print "</body></html>";
445 }
446
447 }
448
449 if ($op == "pref-rpc") {
450
451 $subop = $_GET["subop"];
452
453 if ($subop == "unread") {
454 $ids = split(",", $_GET["ids"]);
455 foreach ($ids as $id) {
456 pg_query("UPDATE ttrss_entries SET unread = true WHERE feed_id = '$id'");
457 }
458
459 print "Marked selected feeds as read.";
460 }
461
462 if ($subop == "read") {
463 $ids = split(",", $_GET["ids"]);
464 foreach ($ids as $id) {
465 pg_query("UPDATE ttrss_entries
466 SET unread = false,last_read = NOW() WHERE feed_id = '$id'");
467 }
468
469 print "Marked selected feeds as unread.";
470
471 }
472
473 }
474
475 if ($op == "pref-feeds") {
476
477 $subop = $_GET["subop"];
478
479 if ($subop == "editSave") {
480 $feed_title = pg_escape_string($_GET["t"]);
481 $feed_link = pg_escape_string($_GET["l"]);
482 $feed_id = $_GET["id"];
483
484 $result = pg_query("UPDATE ttrss_feeds SET
485 title = '$feed_title', feed_url = '$feed_link' WHERE id = '$feed_id'");
486
487 }
488
489 if ($subop == "remove") {
490
491 if (!WEB_DEMO_MODE) {
492
493 $ids = split(",", $_GET["ids"]);
494
495 foreach ($ids as $id) {
496 pg_query("BEGIN");
497 pg_query("DELETE FROM ttrss_entries WHERE feed_id = '$id'");
498 pg_query("DELETE FROM ttrss_feeds WHERE id = '$id'");
499 pg_query("COMMIT");
500
501 if (file_exists(ICONS_DIR . "/$id.ico")) {
502 unlink(ICONS_DIR . "/$id.ico");
503 }
504 }
505 }
506 }
507
508 if ($subop == "add") {
509
510 if (!WEB_DEMO_MODE) {
511
512 $feed_link = pg_escape_string($_GET["link"]);
513
514 $result = pg_query(
515 "INSERT INTO ttrss_feeds (feed_url,title) VALUES ('$feed_link', '')");
516
517 $result = pg_query(
518 "SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_link'");
519
520 $feed_id = pg_fetch_result($result, 0, "id");
521
522 if ($feed_id) {
523 update_rss_feed($link, $feed_link, $feed_id);
524 }
525 }
526 }
527
528 print "<table class=\"prefAddFeed\"><tr>
529 <td><input id=\"fadd_link\"></td>
530 <td colspan=\"4\" align=\"right\">
531 <a class=\"button\" href=\"javascript:addFeed()\">Add feed</a></td></tr>
532 </table>";
533
534 $result = pg_query("SELECT
535 id,title,feed_url,substring(last_updated,1,16) as last_updated
536 FROM
537 ttrss_feeds ORDER by title");
538
539 print "<p><table width=\"100%\" class=\"prefFeedList\" id=\"prefFeedList\">";
540 print "<tr class=\"title\">
541 <td>&nbsp;</td><td>Select</td><td width=\"40%\">Title</td>
542 <td width=\"40%\">Link</td><td>Last updated</td></tr>";
543
544 $lnum = 0;
545
546 while ($line = pg_fetch_assoc($result)) {
547
548 $class = ($lnum % 2) ? "even" : "odd";
549
550 $feed_id = $line["id"];
551
552 $edit_feed_id = $_GET["id"];
553
554 if ($subop == "edit" && $feed_id != $edit_feed_id) {
555 $class .= "Grayed";
556 }
557
558 print "<tr class=\"$class\" id=\"FEEDR-$feed_id\">";
559
560 $icon_file = ICONS_DIR . "/$feed_id.ico";
561
562 if (file_exists($icon_file) && filesize($icon_file) > 0) {
563 $feed_icon = "<img width=\"16\" height=\"16\"
564 src=\"" . ICONS_URL . "/$feed_id.ico\">";
565 } else {
566 $feed_icon = "&nbsp;";
567 }
568 print "<td align='center'>$feed_icon</td>";
569
570 if (!$edit_feed_id || $subop != "edit") {
571
572 print "<td><input onclick='toggleSelectRow(this);'
573 type=\"checkbox\" id=\"FRCHK-".$line["id"]."\"></td>";
574
575 print "<td><a href=\"javascript:editFeed($feed_id);\">" .
576 $line["title"] . "</td>";
577 print "<td><a href=\"javascript:editFeed($feed_id);\">" .
578 $line["feed_url"] . "</td>";
579
580
581 } else if ($feed_id != $edit_feed_id) {
582
583 print "<td><input disabled=\"true\" type=\"checkbox\"
584 id=\"FRCHK-".$line["id"]."\"></td>";
585
586 print "<td>".$line["title"]."</td>";
587 print "<td>".$line["feed_url"]."</td>";
588
589 } else {
590
591 print "<td><input disabled=\"true\" type=\"checkbox\"></td>";
592
593 print "<td><input id=\"iedit_title\" value=\"".$line["title"]."\"></td>";
594 print "<td><input id=\"iedit_link\" value=\"".$line["feed_url"]."\"></td>";
595
596 }
597
598 if (!$line["last_updated"]) $line["last_updated"] = "Never";
599
600 print "<td>" . $line["last_updated"] . "</td>";
601
602 print "</tr>";
603
604 ++$lnum;
605 }
606
607 if ($lnum == 0) {
608 print "<tr><td colspan=\"5\" align=\"center\">No feeds defined.</td></tr>";
609 }
610
611 print "</table>";
612
613 print "<p>";
614
615 if ($subop == "edit") {
616 print "Edit feed:&nbsp;
617 <a class=\"button\" href=\"javascript:feedEditCancel()\">Cancel</a>&nbsp;
618 <a class=\"button\" href=\"javascript:feedEditSave()\">Save</a>";
619 } else {
620
621 print "
622 Selection:&nbsp;
623 <a class=\"button\"
624 href=\"javascript:editSelectedFeed()\">Edit</a>&nbsp;
625 <a class=\"buttonWarn\"
626 href=\"javascript:removeSelectedFeeds()\">Remove</a>&nbsp;";
627 if (ENABLE_PREFS_CATCHUP_UNCATCHUP) {
628 print "
629 <a class=\"button\"
630 href=\"javascript:readSelectedFeeds()\">Mark as read</a>&nbsp;
631 <a class=\"button\"
632 href=\"javascript:unreadSelectedFeeds()\">Mark as unread</a>&nbsp;";
633 }
634 print "
635 All feeds:&nbsp;
636 <a class=\"button\" href=\"opml.php?op=Export\">Export OPML</a>";
637
638 }
639
640 }
641
642 if ($op == "pref-filters") {
643
644 $subop = $_GET["subop"];
645
646 if ($subop == "editSave") {
647
648 $regexp = pg_escape_string($_GET["r"]);
649 $descr = pg_escape_string($_GET["d"]);
650 $match = pg_escape_string($_GET["m"]);
651 $filter_id = pg_escape_string($_GET["id"]);
652
653 $result = pg_query("UPDATE ttrss_filters SET
654 regexp = '$regexp',
655 description = '$descr',
656 filter_type = (SELECT id FROM ttrss_filter_types WHERE
657 description = '$match')
658 WHERE id = '$filter_id'");
659 }
660
661 if ($subop == "remove") {
662
663 if (!WEB_DEMO_MODE) {
664
665 $ids = split(",", $_GET["ids"]);
666
667 foreach ($ids as $id) {
668 pg_query("DELETE FROM ttrss_filters WHERE id = '$id'");
669
670 }
671 }
672 }
673
674 if ($subop == "add") {
675
676 if (!WEB_DEMO_MODE) {
677
678 $regexp = pg_escape_string($_GET["regexp"]);
679 $match = pg_escape_string($_GET["match"]);
680
681 $result = pg_query(
682 "INSERT INTO ttrss_filters (regexp,filter_type) VALUES
683 ('$regexp', (SELECT id FROM ttrss_filter_types WHERE
684 description = '$match'))");
685 }
686 }
687
688 $result = pg_query("SELECT description
689 FROM ttrss_filter_types ORDER BY description");
690
691 $filter_types = array();
692
693 while ($line = pg_fetch_assoc($result)) {
694 array_push($filter_types, $line["description"]);
695 }
696
697 print "<table class=\"prefAddFeed\"><tr>
698 <td><input id=\"fadd_regexp\"></td>
699 <td>";
700 print_select("fadd_match", "Title", $filter_types);
701
702 print"</td><td colspan=\"4\" align=\"right\">
703 <a class=\"button\" href=\"javascript:addFilter()\">Add filter</a></td></tr>
704 </table>";
705
706 $result = pg_query("SELECT
707 id,regexp,description,
708 (SELECT name FROM ttrss_filter_types WHERE
709 id = filter_type) as filter_type_name,
710 (SELECT description FROM ttrss_filter_types
711 WHERE id = filter_type) as filter_type_descr
712 FROM
713 ttrss_filters ORDER by regexp");
714
715 print "<p><table width=\"100%\" class=\"prefFilterList\" id=\"prefFilterList\">";
716
717 print "<tr class=\"title\">
718 <td width=\"5%\">Select</td><td width=\"40%\">Filter expression</td>
719 <td width=\"40%\">Description</td><td width=\"10%\">Match</td></tr>";
720
721 $lnum = 0;
722
723 while ($line = pg_fetch_assoc($result)) {
724
725 $class = ($lnum % 2) ? "even" : "odd";
726
727 $filter_id = $line["id"];
728 $edit_filter_id = $_GET["id"];
729
730 if ($subop == "edit" && $filter_id != $edit_filter_id) {
731 $class .= "Grayed";
732 }
733
734 print "<tr class=\"$class\" id=\"FILRR-$filter_id\">";
735
736 $line["regexp"] = htmlspecialchars($line["regexp"]);
737 $line["description"] = htmlspecialchars($line["description"]);
738
739 if (!$edit_filter_id || $subop != "edit") {
740
741 if (!$line["description"]) $line["description"] = "[No description]";
742
743 print "<td><input onclick='toggleSelectRow(this);'
744 type=\"checkbox\" id=\"FICHK-".$line["id"]."\"></td>";
745
746 print "<td><a href=\"javascript:editFilter($filter_id);\">" .
747 $line["regexp"] . "</td>";
748
749 print "<td><a href=\"javascript:editFilter($filter_id);\">" .
750 $line["description"] . "</td>";
751
752 print "<td>".$line["filter_type_descr"]."</td>";
753
754 } else if ($filter_id != $edit_filter_id) {
755
756 if (!$line["description"]) $line["description"] = "[No description]";
757
758 print "<td><input disabled=\"true\" type=\"checkbox\"
759 id=\"FICHK-".$line["id"]."\"></td>";
760
761 print "<td>".$line["regexp"]."</td>";
762 print "<td>".$line["description"]."</td>";
763 print "<td>".$line["filter_type_descr"]."</td>";
764
765 } else {
766
767 print "<td><input disabled=\"true\" type=\"checkbox\"></td>";
768
769 print "<td><input id=\"iedit_regexp\" value=\"".$line["regexp"].
770 "\"></td>";
771
772 print "<td><input id=\"iedit_descr\" value=\"".$line["description"].
773 "\"></td>";
774
775 print "<td>";
776 print_select("iedit_match", $line["filter_type_descr"], $filter_types);
777 print "</td>";
778
779 }
780
781
782 print "</tr>";
783
784 ++$lnum;
785 }
786
787 if ($lnum == 0) {
788 print "<tr><td colspan=\"4\" align=\"center\">No filters defined.</td></tr>";
789 }
790
791 print "</table>";
792
793 print "<p>";
794
795 if ($subop == "edit") {
796 print "Edit feed:&nbsp;
797 <a class=\"button\" href=\"javascript:filterEditCancel()\">Cancel</a>&nbsp;
798 <a class=\"button\" href=\"javascript:filterEditSave()\">Save</a>";
799
800 } else {
801
802 print "
803 Selection:&nbsp;
804 <a class=\"button\"
805 href=\"javascript:editSelectedFilter()\">Edit</a>&nbsp;
806 <a class=\"buttonWarn\"
807 href=\"javascript:removeSelectedFilters()\">Remove</a>&nbsp;";
808 }
809 }
810
811 pg_close($link);
812 ?>