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