]> git.wh0rd.org - tt-rss.git/blob - modules/pref-feeds.php
add option to force display attachments in feeds (implementation)
[tt-rss.git] / modules / pref-feeds.php
1 <?php
2
3 function batch_edit_cbox($elem, $label = false) {
4 print "<input type=\"checkbox\" title=\"".__("Check to enable field")."\"
5 onchange=\"batchFeedsToggleField(this, '$elem', '$label')\">";
6 }
7
8 function module_pref_feeds($link) {
9
10 global $update_intervals;
11 global $purge_intervals;
12 global $update_methods;
13
14 $subop = $_REQUEST["subop"];
15 $quiet = $_REQUEST["quiet"];
16
17 if ($subop == "massSubscribe") {
18 $ids = split(",", db_escape_string($_GET["ids"]));
19
20 $subscribed = array();
21
22 foreach ($ids as $id) {
23 $result = db_query($link, "SELECT feed_url,title FROM ttrss_feeds
24 WHERE id = '$id'");
25
26 $feed_url = db_escape_string(db_fetch_result($result, 0, "feed_url"));
27 $title = db_escape_string(db_fetch_result($result, 0, "title"));
28
29 $title_orig = db_fetch_result($result, 0, "title");
30
31 $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE
32 feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
33
34 if (db_num_rows($result) == 0) {
35 $result = db_query($link,
36 "INSERT INTO ttrss_feeds (owner_uid,feed_url,title,cat_id)
37 VALUES ('".$_SESSION["uid"]."', '$feed_url', '$title', NULL)");
38
39 array_push($subscribed, $title_orig);
40 }
41 }
42
43 if (count($subscribed) > 0) {
44 $msg = "<b>".__('Subscribed to feeds:')."</b>".
45 "<ul class=\"nomarks\">";
46
47 foreach ($subscribed as $title) {
48 $msg .= "<li>$title</li>";
49 }
50 $msg .= "</ul>";
51
52 print format_notice($msg);
53 }
54 }
55
56 if ($subop == "browse") {
57
58 if (!ENABLE_FEED_BROWSER) {
59 print __("Feed browser is administratively disabled.");
60 return;
61 }
62
63 print "<div id=\"infoBoxTitle\">".__('Feed Browser')."</div>";
64
65 print "<div class=\"infoBoxContents\">";
66
67 $browser_search = db_escape_string($_GET["search"]);
68
69 //print "<p>".__("Showing top 25 registered feeds, sorted by popularity:")."</p>";
70
71 print "
72 <div style='float : right'>
73 <input id=\"feed_browser_search\" size=\"20\" type=\"search\"
74 onfocus=\"javascript:disableHotkeys();\"
75 onblur=\"javascript:enableHotkeys();\"
76 onchange=\"javascript:updateFeedBrowser()\" value=\"$browser_search\">
77 <input type=\"submit\" class=\"button\"
78 onclick=\"javascript:updateFeedBrowser()\" value=\"".__('Search')."\">
79 </div>";
80
81 print __('Top')." <select id=\"feed_browser_limit\">";
82
83 foreach (array(25, 50, 100, 200) as $l) {
84 $issel = ($l == $limit) ? "selected" : "";
85 print "<option $issel>$l</option>";
86 }
87
88 print "</select>
89 <input type=\"submit\" class=\"button\"
90 onclick=\"updateFeedBrowser()\" value=\"".__('Show')."\">";
91
92 print "<p>";
93
94 $owner_uid = $_SESSION["uid"];
95
96 print "<ul class='browseFeedList' id='browseFeedList'>";
97 $subscribe_btn_disabled = print_feed_browser($link, $search, 25) == 0 ? "disabled" : "";
98 print "</ul>";
99
100 print "<div align='center'>
101 <input type=\"submit\" class=\"button\" id=\"feed_browser_subscribe\"
102 $subscribe_btn_disabled
103 onclick=\"feedBrowserSubscribe()\" value=\"".__('Subscribe')."\">
104 <input type='submit' class='button'
105 onclick=\"closeInfoBox()\" value=\"".__('Cancel')."\"></div>";
106
107 print "</div>";
108 return;
109 }
110
111 if ($subop == "editfeed") {
112 $feed_id = db_escape_string($_REQUEST["id"]);
113
114 $result = db_query($link,
115 "SELECT * FROM ttrss_feeds WHERE id = '$feed_id' AND
116 owner_uid = " . $_SESSION["uid"]);
117
118 $title = htmlspecialchars(db_fetch_result($result,
119 0, "title"));
120
121 $icon_file = ICONS_DIR . "/$feed_id.ico";
122
123 if (file_exists($icon_file) && filesize($icon_file) > 0) {
124 $feed_icon = "<img width=\"16\" height=\"16\"
125 src=\"" . ICONS_URL . "/$feed_id.ico\">";
126 } else {
127 $feed_icon = "";
128 }
129
130 print "<div id=\"infoBoxTitle\">".__('Feed Editor')."</div>";
131
132 print "<div class=\"infoBoxContents\">";
133
134 print "<form id=\"edit_feed_form\" onsubmit=\"return false\">";
135
136 print "<input type=\"hidden\" name=\"id\" value=\"$feed_id\">";
137 print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">";
138 print "<input type=\"hidden\" name=\"subop\" value=\"editSave\">";
139
140 print "<div class=\"dlgSec\">".__("Feed")."</div>";
141 print "<div class=\"dlgSecCont\">";
142
143 /* Title */
144
145 print "<input style=\"font-size : 16px\" size=\"40\" onkeypress=\"return filterCR(event, feedEditSave)\"
146 name=\"title\" value=\"$title\">";
147
148 /* Feed URL */
149
150 $feed_url = db_fetch_result($result, 0, "feed_url");
151 $feed_url = htmlspecialchars(db_fetch_result($result,
152 0, "feed_url"));
153
154 print "<br/>";
155
156 print __('URL:') . " ";
157 print "<input size=\"40\" onkeypress=\"return filterCR(event, feedEditSave)\"
158 name=\"feed_url\" value=\"$feed_url\">";
159
160 /* Category */
161
162 if (get_pref($link, 'ENABLE_FEED_CATS')) {
163
164 $cat_id = db_fetch_result($result, 0, "cat_id");
165
166 print "<br/>";
167
168 print __('Place in category:') . " ";
169
170 $parent_feed = db_fetch_result($result, 0, "parent_feed");
171
172 if (sprintf("%d", $parent_feed) > 0) {
173 $disabled = "disabled";
174 } else {
175 $disabled = "";
176 }
177
178 print_feed_cat_select($link, "cat_id", $cat_id, $disabled);
179 }
180
181 /* Link to */
182
183 print "<br/>";
184
185 print __('Link to feed:') . " ";
186
187 $tmp_result = db_query($link, "SELECT COUNT(id) AS count
188 FROM ttrss_feeds WHERE parent_feed = '$feed_id'");
189
190 $linked_count = db_fetch_result($tmp_result, 0, "count");
191
192 $parent_feed = db_fetch_result($result, 0, "parent_feed");
193
194 if ($linked_count > 0) {
195 $disabled = "disabled";
196 } else {
197 $disabled = "";
198 }
199
200 print "<select $disabled name=\"parent_feed\">";
201
202 print "<option value=\"0\">".__('Not linked')."</option>";
203
204 if (get_pref($link, 'ENABLE_FEED_CATS')) {
205 if ($cat_id) {
206 $cat_qpart = "AND cat_id = '$cat_id'";
207 } else {
208 $cat_qpart = "AND cat_id IS NULL";
209 }
210 }
211
212 $tmp_result = db_query($link, "SELECT id,title FROM ttrss_feeds
213 WHERE id != '$feed_id' AND owner_uid = ".$_SESSION["uid"]." AND
214 (SELECT COUNT(id) FROM ttrss_feeds AS T2 WHERE T2.id = ttrss_feeds.parent_feed) = 0
215 $cat_qpart ORDER BY title");
216
217 if (db_num_rows($tmp_result) > 0) {
218 print "<option disabled>--------</option>";
219 }
220
221 while ($tmp_line = db_fetch_assoc($tmp_result)) {
222 if ($tmp_line["id"] == $parent_feed) {
223 $is_selected = "selected";
224 } else {
225 $is_selected = "";
226 }
227 printf("<option $is_selected value='%d'>%s</option>",
228 $tmp_line["id"], $tmp_line["title"]);
229 }
230
231 print "</select>";
232
233
234 print "</div>";
235
236 print "<div class=\"dlgSec\">".__("Update")."</div>";
237 print "<div class=\"dlgSecCont\">";
238
239 /* Update Interval */
240
241 $update_interval = db_fetch_result($result, 0, "update_interval");
242
243 print_select_hash("update_interval", $update_interval, $update_intervals);
244
245 /* Update method */
246
247 if (ALLOW_SELECT_UPDATE_METHOD) {
248 $update_method = db_fetch_result($result, 0, "update_method");
249
250 print " " . __('using') . " ";
251 print_select_hash("update_method", $update_method, $update_methods);
252 }
253
254 $purge_interval = db_fetch_result($result, 0, "purge_interval");
255
256 if (FORCE_ARTICLE_PURGE == 0) {
257
258 /* Purge intl */
259
260 print "<br/>";
261
262 print __('Article purging:') . " ";
263
264 print_select_hash("purge_interval", $purge_interval, $purge_intervals);
265
266 } else {
267 print "<input type='hidden' name='purge_interval' value='$purge_interval'>";
268
269 }
270
271 print "</div>";
272 print "<div class=\"dlgSec\">".__("Authentication")."</div>";
273 print "<div class=\"dlgSecCont\">";
274
275 $auth_login = htmlspecialchars(db_fetch_result($result, 0, "auth_login"));
276
277 print "<table>";
278
279 print "<tr><td>" . __('Login:') . "</td><td>";
280
281 print "<input size=\"20\" onkeypress=\"return filterCR(event, feedEditSave)\"
282 name=\"auth_login\" value=\"$auth_login\">";
283
284 print "</tr><tr><td>" . __("Password:") . "</td><td>";
285
286 $auth_pass = htmlspecialchars(db_fetch_result($result, 0, "auth_pass"));
287
288 print "<input size=\"20\" type=\"password\" name=\"auth_pass\"
289 onkeypress=\"return filterCR(event, feedEditSave)\"
290 value=\"$auth_pass\">";
291
292 print "</td></tr></table>";
293
294 print "</div>";
295 print "<div class=\"dlgSec\">".__("Options")."</div>";
296 print "<div class=\"dlgSecCont\">";
297
298 print "<div style=\"line-height : 100%\">";
299
300 $private = sql_bool_to_bool(db_fetch_result($result, 0, "private"));
301
302 if ($private) {
303 $checked = "checked";
304 } else {
305 $checked = "";
306 }
307
308 print "<input type=\"checkbox\" name=\"private\" id=\"private\"
309 $checked>&nbsp;<label for=\"private\">".__('Hide from "Other Feeds"')."</label>";
310
311 $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content"));
312
313 if ($rtl_content) {
314 $checked = "checked";
315 } else {
316 $checked = "";
317 }
318
319 print "<br/><input type=\"checkbox\" id=\"rtl_content\" name=\"rtl_content\"
320 $checked>&nbsp;<label for=\"rtl_content\">".__('Right-to-left content')."</label>";
321
322 $hidden = sql_bool_to_bool(db_fetch_result($result, 0, "hidden"));
323
324 if ($hidden) {
325 $checked = "checked";
326 } else {
327 $checked = "";
328 }
329
330 print "<br/><input type=\"checkbox\" id=\"hidden\" name=\"hidden\"
331 $checked>&nbsp;<label for=\"hidden\">".__('Hide from my feed list')."</label>";
332
333 $include_in_digest = sql_bool_to_bool(db_fetch_result($result, 0, "include_in_digest"));
334
335 if ($include_in_digest) {
336 $checked = "checked";
337 } else {
338 $checked = "";
339 }
340
341 print "<br/><input type=\"checkbox\" id=\"include_in_digest\"
342 name=\"include_in_digest\"
343 $checked>&nbsp;<label for=\"include_in_digest\">".__('Include in e-mail digest')."</label>";
344
345
346 $always_display_enclosures = sql_bool_to_bool(db_fetch_result($result, 0, "always_display_enclosures"));
347
348 if ($always_display_enclosures) {
349 $checked = "checked";
350 } else {
351 $checked = "";
352 }
353
354 print "<br/><input type=\"checkbox\" id=\"always_display_enclosures\"
355 name=\"always_display_enclosures\"
356 $checked>&nbsp;<label for=\"always_display_enclosures\">".__('Always display image attachments')."</label>";
357
358
359 $cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images"));
360
361 if ($cache_images) {
362 $checked = "checked";
363 } else {
364 $checked = "";
365 }
366
367 if (ENABLE_SIMPLEPIE && SIMPLEPIE_CACHE_IMAGES) {
368 $disabled = "";
369 $label_class = "";
370 } else {
371 $disabled = "disabled";
372 $label_class = "class='insensitive'";
373 }
374
375 print "<br/><input type=\"checkbox\" id=\"cache_images\"
376 name=\"cache_images\" $disabled
377 $checked>&nbsp;<label $label_class for=\"cache_images\">".
378 __('Cache images locally')."</label>";
379
380
381 print "</div>";
382 print "</div>";
383
384 print "</form>";
385
386 $title = htmlspecialchars($title, ENT_QUOTES);
387
388 print "<div class='dlgButtons'>
389 <div style=\"float : left\">
390 <input type='submit' class='button'
391 onclick='return unsubscribeFeed($feed_id, \"$title\")' value=\"".__('Unsubscribe')."\">
392 </div>
393 <input type=\"submit\" class=\"button\"
394 onclick=\"return feedEditSave()\" value=\"".__('Save')."\">
395 <input type='submit' class='button'
396 onclick=\"return feedEditCancel()\" value=\"".__('Cancel')."\">
397 </div>";
398
399 return;
400 }
401
402 if ($subop == "editfeeds") {
403
404 $feed_ids = db_escape_string($_REQUEST["ids"]);
405
406 print "<div id=\"infoBoxTitle\">".__('Multiple Feed Editor')."</div>";
407
408 print "<div class=\"infoBoxContents\">";
409
410 print "<form id=\"batch_edit_feed_form\" onsubmit=\"return false\">";
411
412 print "<input type=\"hidden\" name=\"ids\" value=\"$feed_ids\">";
413 print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">";
414 print "<input type=\"hidden\" name=\"subop\" value=\"batchEditSave\">";
415
416 print "<div class=\"dlgSec\">".__("Feed")."</div>";
417 print "<div class=\"dlgSecCont\">";
418
419 /* Title */
420
421 print "<input disabled style=\"font-size : 16px\" size=\"35\" onkeypress=\"return filterCR(event, feedEditSave)\"
422 name=\"title\" value=\"$title\">";
423
424 batch_edit_cbox("title");
425
426 /* Feed URL */
427
428 print "<br/>";
429
430 print __('URL:') . " ";
431 print "<input disabled size=\"40\" onkeypress=\"return filterCR(event, feedEditSave)\"
432 name=\"feed_url\" value=\"$feed_url\">";
433
434 batch_edit_cbox("feed_url");
435
436 /* Category */
437
438 if (get_pref($link, 'ENABLE_FEED_CATS')) {
439
440 print "<br/>";
441
442 print __('Place in category:') . " ";
443
444 print_feed_cat_select($link, "cat_id", $cat_id, "disabled");
445
446 batch_edit_cbox("cat_id");
447
448 }
449
450 print "</div>";
451
452 print "<div class=\"dlgSec\">".__("Update")."</div>";
453 print "<div class=\"dlgSecCont\">";
454
455 /* Update Interval */
456
457 print_select_hash("update_interval", $update_interval, $update_intervals,
458 "disabled");
459
460 batch_edit_cbox("update_interval");
461
462 /* Update method */
463
464 if (ALLOW_SELECT_UPDATE_METHOD) {
465 print " " . __('using') . " ";
466 print_select_hash("update_method", $update_method, $update_methods,
467 "disabled");
468 batch_edit_cbox("update_method");
469 }
470
471 /* Purge intl */
472
473 if (FORCE_ARTICLE_PURGE != 0) {
474
475 print "<br/>";
476
477 print __('Article purging:') . " ";
478
479 print_select_hash("purge_interval", $purge_interval, $purge_intervals,
480 "disabled");
481
482 batch_edit_cbox("purge_interval");
483 }
484
485 print "</div>";
486 print "<div class=\"dlgSec\">".__("Authentication")."</div>";
487 print "<div class=\"dlgSecCont\">";
488
489 print __('Login:') . " ";
490 print "<input disabled size=\"15\" onkeypress=\"return filterCR(event, feedEditSave)\"
491 name=\"auth_login\" value=\"$auth_login\">";
492
493 batch_edit_cbox("auth_login");
494
495 print " " . __("Password:") . " ";
496
497 print "<input disabled size=\"15\" type=\"password\" name=\"auth_pass\"
498 onkeypress=\"return filterCR(event, feedEditSave)\"
499 value=\"$auth_pass\">";
500
501 batch_edit_cbox("auth_pass");
502
503 print "</div>";
504 print "<div class=\"dlgSec\">".__("Options")."</div>";
505 print "<div class=\"dlgSecCont\">";
506
507 print "<div style=\"line-height : 100%\">";
508
509 print "<input disabled type=\"checkbox\" name=\"private\" id=\"private\"
510 $checked>&nbsp;<label id=\"private_l\" class='insensitive' for=\"private\">".__('Hide from "Other Feeds"')."</label>";
511
512 print "&nbsp;"; batch_edit_cbox("private", "private_l");
513
514 print "<br/><input disabled type=\"checkbox\" id=\"rtl_content\" name=\"rtl_content\"
515 $checked>&nbsp;<label class='insensitive' id=\"rtl_content_l\" for=\"rtl_content\">".__('Right-to-left content')."</label>";
516
517 print "&nbsp;"; batch_edit_cbox("rtl_content", "rtl_content_l");
518
519 print "<br/><input disabled type=\"checkbox\" id=\"hidden\" name=\"hidden\"
520 $checked>&nbsp;<label class='insensitive' id=\"hidden_l\" for=\"hidden\">".__('Hide from my feed list')."</label>";
521
522 print "&nbsp;"; batch_edit_cbox("hidden", "hidden_l");
523
524 print "<br/><input disabled type=\"checkbox\" id=\"include_in_digest\"
525 name=\"include_in_digest\"
526 $checked>&nbsp;<label id=\"include_in_digest_l\" class='insensitive' for=\"include_in_digest\">".__('Include in e-mail digest')."</label>";
527
528 print "&nbsp;"; batch_edit_cbox("include_in_digest", "include_in_digest_l");
529
530 print "<br/><input disabled type=\"checkbox\" id=\"cache_images\"
531 name=\"cache_images\"
532 $checked>&nbsp;<label class='insensitive' id=\"cache_images_l\"
533 for=\"cache_images\">".
534 __('Cache images locally')."</label>";
535
536
537 if (ENABLE_SIMPLEPIE && SIMPLEPIE_CACHE_IMAGES) {
538 print "&nbsp;"; batch_edit_cbox("cache_images", "cache_images_l");
539 }
540
541 print "</div>";
542 print "</div>";
543
544 print "</form>";
545
546 print "<div class='dlgButtons'>
547 <input type=\"submit\" class=\"button\"
548 onclick=\"return feedsEditSave()\" value=\"".__('Save')."\">
549 <input type='submit' class='button'
550 onclick=\"return feedEditCancel()\" value=\"".__('Cancel')."\">
551 </div>";
552
553 return;
554 }
555
556 if ($subop == "editSave" || $subop == "batchEditSave") {
557
558 $feed_title = db_escape_string(trim($_POST["title"]));
559 $feed_link = db_escape_string(trim($_POST["feed_url"]));
560 $upd_intl = db_escape_string($_POST["update_interval"]);
561 $purge_intl = db_escape_string($_POST["purge_interval"]);
562 $feed_id = db_escape_string($_POST["id"]); /* editSave */
563 $feed_ids = db_escape_string($_POST["ids"]); /* batchEditSave */
564 $cat_id = db_escape_string($_POST["cat_id"]);
565 $auth_login = db_escape_string(trim($_POST["auth_login"]));
566 $auth_pass = db_escape_string(trim($_POST["auth_pass"]));
567 $parent_feed = db_escape_string($_POST["parent_feed"]);
568 $private = checkbox_to_sql_bool(db_escape_string($_POST["private"]));
569 $rtl_content = checkbox_to_sql_bool(db_escape_string($_POST["rtl_content"]));
570 $hidden = checkbox_to_sql_bool(db_escape_string($_POST["hidden"]));
571 $include_in_digest = checkbox_to_sql_bool(
572 db_escape_string($_POST["include_in_digest"]));
573 $cache_images = checkbox_to_sql_bool(
574 db_escape_string($_POST["cache_images"]));
575 $update_method = (int) db_escape_string($_POST["update_method"]);
576
577 $always_display_enclosures = checkbox_to_sql_bool(
578 db_escape_string($_POST["always_display_enclosures"]));
579
580 if (get_pref($link, 'ENABLE_FEED_CATS')) {
581 if ($cat_id && $cat_id != 0) {
582 $category_qpart = "cat_id = '$cat_id',";
583 $category_qpart_nocomma = "cat_id = '$cat_id'";
584 } else {
585 $category_qpart = 'cat_id = NULL,';
586 $category_qpart_nocomma = 'cat_id = NULL';
587 }
588 } else {
589 $category_qpart = "";
590 $category_qpart_nocomma = "";
591 }
592
593 if ($parent_feed && $parent_feed != 0) {
594 $parent_qpart = "parent_feed = '$parent_feed'";
595 } else {
596 $parent_qpart = 'parent_feed = NULL';
597 }
598
599 if (ENABLE_SIMPLEPIE && SIMPLEPIE_CACHE_IMAGES) {
600 $cache_images_qpart = "cache_images = $cache_images,";
601 } else {
602 $cache_images_qpart = "";
603 }
604
605 if ($subop == "editSave") {
606
607 $result = db_query($link, "UPDATE ttrss_feeds SET
608 $category_qpart $parent_qpart,
609 title = '$feed_title', feed_url = '$feed_link',
610 update_interval = '$upd_intl',
611 purge_interval = '$purge_intl',
612 auth_login = '$auth_login',
613 auth_pass = '$auth_pass',
614 private = $private,
615 rtl_content = $rtl_content,
616 hidden = $hidden,
617 $cache_images_qpart
618 include_in_digest = $include_in_digest,
619 always_display_enclosures = $always_display_enclosures,
620 update_method = '$update_method'
621 WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]);
622
623 if (get_pref($link, 'ENABLE_FEED_CATS')) {
624 # update linked feed categories
625 $result = db_query($link, "UPDATE ttrss_feeds SET
626 $category_qpart_nocomma WHERE parent_feed = '$feed_id' AND
627 owner_uid = " . $_SESSION["uid"]);
628 }
629 } else if ($subop == "batchEditSave") {
630 $feed_data = array();
631
632 foreach (array_keys($_POST) as $k) {
633 if ($k != "op" && $k != "subop" && $k != "ids") {
634 $feed_data[$k] = $_POST[$k];
635 }
636 }
637
638 db_query($link, "BEGIN");
639
640 foreach (array_keys($feed_data) as $k) {
641
642 $qpart = "";
643
644 switch ($k) {
645 case "title":
646 $qpart = "title = '$feed_title'";
647 break;
648
649 case "feed_url":
650 $qpart = "feed_url = '$feed_link'";
651 break;
652
653 case "update_interval":
654 $qpart = "update_interval = '$upd_intl'";
655 break;
656
657 case "purge_interval":
658 $qpart = "purge_interval = '$purge_intl'";
659 break;
660
661 case "auth_login":
662 $qpart = "auth_login = '$auth_login'";
663 break;
664
665 case "auth_pass":
666 $qpart = "auth_pass = '$auth_pass'";
667 break;
668
669 case "private":
670 $qpart = "private = '$private'";
671 break;
672
673 case "hidden":
674 $qpart = "hidden = '$hidden'";
675 break;
676
677 case "include_in_digest":
678 $qpart = "include_in_digest = '$include_in_digest'";
679 break;
680
681 case "cache_images":
682 $qpart = "cache_images = '$cache_images'";
683 break;
684
685 case "rtl_content":
686 $qpart = "rtl_content = '$rtl_content'";
687 break;
688
689 case "update_method":
690 $qpart = "update_method = '$update_method'";
691 break;
692
693 case "cat_id":
694 $qpart = $category_qpart_nocomma;
695 break;
696
697 }
698
699 if ($qpart) {
700 db_query($link,
701 "UPDATE ttrss_feeds SET $qpart WHERE id IN ($feed_ids)
702 AND owner_uid = " . $_SESSION["uid"]);
703 print "<br/>";
704 }
705 }
706
707 db_query($link, "COMMIT");
708 }
709
710 }
711
712 if ($subop == "remove") {
713
714 $ids = split(",", db_escape_string($_GET["ids"]));
715
716 foreach ($ids as $id) {
717
718 if ($id > 0) {
719
720 db_query($link, "DELETE FROM ttrss_feeds
721 WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
722
723 $icons_dir = ICONS_DIR;
724
725 if (file_exists($icons_dir . "/$id.ico")) {
726 unlink($icons_dir . "/$id.ico");
727 }
728
729 ccache_remove($link, $id, $_SESSION["uid"]);
730
731 } else {
732 label_remove($link, -11-$id, $_SESSION["uid"]);
733 ccache_remove($link, -11-$id, $_SESSION["uid"]);
734 }
735 }
736 }
737
738 if ($subop == "clear") {
739 $id = db_escape_string($_GET["id"]);
740 clear_feed_articles($link, $id);
741 }
742
743 if ($subop == "rescore") {
744 $ids = split(",", db_escape_string($_GET["ids"]));
745
746 foreach ($ids as $id) {
747
748 $filters = load_filters($link, $id, $_SESSION["uid"], 6);
749
750 $result = db_query($link, "SELECT title, content, link, ref_id FROM
751 ttrss_user_entries, ttrss_entries
752 WHERE ref_id = id AND feed_id = '$id' AND
753 owner_uid = " .$_SESSION['uid']."
754 ");
755
756 $scores = array();
757
758 while ($line = db_fetch_assoc($result)) {
759
760 $article_filters = get_article_filters($filters, $line['title'],
761 $line['content'], $line['link']);
762
763 $new_score = calculate_article_score($article_filters);
764
765 if (!$scores[$new_score]) $scores[$new_score] = array();
766
767 array_push($scores[$new_score], $line['ref_id']);
768 }
769
770 foreach (array_keys($scores) as $s) {
771 if ($s > 1000) {
772 db_query($link, "UPDATE ttrss_user_entries SET score = '$s',
773 marked = true WHERE
774 ref_id IN (" . join(',', $scores[$s]) . ")");
775 } else if ($s < -500) {
776 db_query($link, "UPDATE ttrss_user_entries SET score = '$s',
777 unread = false WHERE
778 ref_id IN (" . join(',', $scores[$s]) . ")");
779 } else {
780 db_query($link, "UPDATE ttrss_user_entries SET score = '$s' WHERE
781 ref_id IN (" . join(',', $scores[$s]) . ")");
782 }
783 }
784 }
785
786 print __("All done.");
787
788 }
789
790 if ($subop == "rescoreAll") {
791
792 $result = db_query($link,
793 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION['uid']);
794
795 while ($feed_line = db_fetch_assoc($result)) {
796
797 $id = $feed_line["id"];
798
799 $filters = load_filters($link, $id, $_SESSION["uid"], 6);
800
801 $tmp_result = db_query($link, "SELECT title, content, link, ref_id FROM
802 ttrss_user_entries, ttrss_entries
803 WHERE ref_id = id AND feed_id = '$id' AND
804 owner_uid = " .$_SESSION['uid']."
805 ");
806
807 $scores = array();
808
809 while ($line = db_fetch_assoc($tmp_result)) {
810
811 $article_filters = get_article_filters($filters, $line['title'],
812 $line['content'], $line['link']);
813
814 $new_score = calculate_article_score($article_filters);
815
816 if (!$scores[$new_score]) $scores[$new_score] = array();
817
818 array_push($scores[$new_score], $line['ref_id']);
819 }
820
821 foreach (array_keys($scores) as $s) {
822 if ($s > 1000) {
823 db_query($link, "UPDATE ttrss_user_entries SET score = '$s',
824 marked = true WHERE
825 ref_id IN (" . join(',', $scores[$s]) . ")");
826 } else {
827 db_query($link, "UPDATE ttrss_user_entries SET score = '$s' WHERE
828 ref_id IN (" . join(',', $scores[$s]) . ")");
829 }
830 }
831 }
832
833 print __("All done.");
834
835 }
836
837 if ($subop == "add") {
838
839 if (!WEB_DEMO_MODE) {
840
841 $feed_url = db_escape_string(trim($_REQUEST["feed_url"]));
842 $cat_id = db_escape_string($_REQUEST["cat_id"]);
843 $p_from = db_escape_string($_REQUEST["from"]);
844
845 /* only read authentication information from POST */
846
847 $auth_login = db_escape_string(trim($_POST["auth_login"]));
848 $auth_pass = db_escape_string(trim($_POST["auth_pass"]));
849
850 if ($p_from != 'tt-rss') {
851 print "<html>
852 <head>
853 <title>Tiny Tiny RSS</title>
854 <link rel=\"stylesheet\" type=\"text/css\" href=\"utility.css\">
855 </head>
856 <body>
857 <img class=\"floatingLogo\" src=\"images/ttrss_logo.png\"
858 alt=\"Tiny Tiny RSS\"/>
859 <h1>Subscribe to feed...</h1>";
860 }
861
862 if (subscribe_to_feed($link, $feed_url, $cat_id, $auth_login, $auth_pass)) {
863 print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url));
864 } else {
865 print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
866 }
867
868 if ($p_from != 'tt-rss') {
869 $tt_uri = ($_SERVER['HTTPS'] != "on" ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . preg_replace('/backend\.php.*$/', 'tt-rss.php', $_SERVER["REQUEST_URI"]);
870
871
872 $tp_uri = ($_SERVER['HTTPS'] != "on" ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . preg_replace('/backend\.php.*$/', 'prefs.php', $_SERVER["REQUEST_URI"]);
873
874 $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE
875 feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
876
877 $feed_id = db_fetch_result($result, 0, "id");
878
879 print "<p>";
880
881 if ($feed_id) {
882 print "<form method=\"GET\" style='display: inline'
883 action=\"$tp_uri\">
884 <input type=\"hidden\" name=\"tab\" value=\"feedConfig\">
885 <input type=\"hidden\" name=\"subop\" value=\"editFeed\">
886 <input type=\"hidden\" name=\"subopparam\" value=\"$feed_id\">
887 <input type=\"submit\" value=\"".__("Edit subscription options")."\">
888 </form>";
889 }
890
891 print "<form style='display: inline' method=\"GET\" action=\"$tt_uri\">
892 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
893 </form></p>";
894
895 print "</body></html>";
896 return;
897 }
898
899 }
900 }
901
902 if ($subop == "categorize") {
903
904 if (!WEB_DEMO_MODE) {
905
906 $ids = split(",", db_escape_string($_GET["ids"]));
907
908 $cat_id = db_escape_string($_GET["cat_id"]);
909
910 if ($cat_id == 0) {
911 $cat_id_qpart = 'NULL';
912 } else {
913 $cat_id_qpart = "'$cat_id'";
914 }
915
916 db_query($link, "BEGIN");
917
918 foreach ($ids as $id) {
919
920 db_query($link, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
921 WHERE id = '$id' AND parent_feed IS NULL
922 AND owner_uid = " . $_SESSION["uid"]);
923
924 # update linked feed categories
925 db_query($link, "UPDATE ttrss_feeds SET
926 cat_id = $cat_id_qpart WHERE parent_feed = '$id' AND
927 owner_uid = " . $_SESSION["uid"]);
928
929 }
930
931 db_query($link, "COMMIT");
932 }
933
934 }
935
936 if ($subop == "editCats") {
937
938 $action = $_REQUEST["action"];
939
940 if ($action == "save") {
941
942 $cat_title = db_escape_string(trim($_REQUEST["value"]));
943 $cat_id = db_escape_string($_GET["cid"]);
944
945 db_query($link, "BEGIN");
946
947 $result = db_query($link, "SELECT title FROM ttrss_feed_categories
948 WHERE id = '$cat_id' AND owner_uid = ".$_SESSION["uid"]);
949
950 if (db_num_rows($result) == 1) {
951
952 $old_title = db_fetch_result($result, 0, "title");
953
954 if ($cat_title != "") {
955 $result = db_query($link, "UPDATE ttrss_feed_categories SET
956 title = '$cat_title' WHERE id = '$cat_id' AND
957 owner_uid = ".$_SESSION["uid"]);
958
959 print $cat_title;
960 } else {
961 print $old_title;
962 }
963 } else {
964 print $_REQUEST["value"];
965 }
966
967 db_query($link, "COMMIT");
968
969 return;
970
971 }
972
973 print "<div id=\"infoBoxTitle\">".__('Category editor')."</div>";
974
975 print "<div class=\"infoBoxContents\">";
976
977
978 if ($action == "add") {
979
980 if (!WEB_DEMO_MODE) {
981
982 $feed_cat = db_escape_string(trim($_GET["cat"]));
983
984 $result = db_query($link,
985 "SELECT id FROM ttrss_feed_categories
986 WHERE title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]);
987
988 if (db_num_rows($result) == 0) {
989
990 $result = db_query($link,
991 "INSERT INTO ttrss_feed_categories (owner_uid,title)
992 VALUES ('".$_SESSION["uid"]."', '$feed_cat')");
993
994 } else {
995
996 print_warning(T_sprintf("Category <b>$%s</b> already exists in the database.",
997 $feed_cat));
998 }
999
1000 }
1001 }
1002
1003 if ($action == "remove") {
1004
1005 if (!WEB_DEMO_MODE) {
1006
1007 $ids = split(",", db_escape_string($_GET["ids"]));
1008
1009 foreach ($ids as $id) {
1010
1011 db_query($link, "BEGIN");
1012
1013 $result = db_query($link,
1014 "SELECT count(id) as num_feeds FROM ttrss_feeds
1015 WHERE cat_id = '$id'");
1016
1017 $num_feeds = db_fetch_result($result, 0, "num_feeds");
1018
1019 if ($num_feeds == 0) {
1020 db_query($link, "DELETE FROM ttrss_feed_categories
1021 WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
1022
1023 ccache_remove($link, $id, $_SESSION["uid"], true);
1024
1025 } else {
1026
1027 print format_warning(__("Unable to delete non empty feed categories."));
1028
1029 }
1030
1031 db_query($link, "COMMIT");
1032 }
1033 }
1034 }
1035
1036 print "<div class=\"prefGenericAddBox\">
1037 <input id=\"fadd_cat\"
1038 onkeypress=\"return filterCR(event, addFeedCat)\"
1039 onkeyup=\"toggleSubmitNotEmpty(this, 'catadd_submit_btn')\"
1040 onchange=\"toggleSubmitNotEmpty(this, 'catadd_submit_btn')\"
1041 size=\"40\">&nbsp;
1042 <input
1043 type=\"submit\" class=\"button\" disabled=\"true\" id=\"catadd_submit_btn\"
1044 onclick=\"javascript:addFeedCat()\" value=\"".__('Create category')."\"></div>";
1045
1046 $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories
1047 WHERE owner_uid = ".$_SESSION["uid"]."
1048 ORDER BY title");
1049
1050 print "<p>";
1051
1052 if (db_num_rows($result) != 0) {
1053
1054 print "<table width=\"100%\" class=\"prefFeedCatList\"
1055 cellspacing=\"0\">";
1056
1057 print "<tr><td class=\"selectPrompt\" colspan=\"8\">
1058 ".__('Select:')."
1059 <a href=\"javascript:selectPrefRows('fcat', true)\">".__('All')."</a>,
1060 <a href=\"javascript:selectPrefRows('fcat', false)\">".__('None')."</a>
1061 </td></tr>";
1062
1063 print "</table>";
1064
1065 print "<div class=\"prefFeedCatHolder\">";
1066
1067 print "<form id=\"feed_cat_edit_form\" onsubmit=\"return false\">";
1068
1069 print "<table width=\"100%\" class=\"prefFeedCatList\"
1070 cellspacing=\"0\" id=\"prefFeedCatList\">";
1071
1072 $lnum = 0;
1073
1074 while ($line = db_fetch_assoc($result)) {
1075
1076 $class = ($lnum % 2) ? "even" : "odd";
1077
1078 $cat_id = $line["id"];
1079 $this_row_id = "id=\"FCATR-$cat_id\"";
1080
1081 print "<tr class=\"$class\" $this_row_id>";
1082
1083 $edit_title = htmlspecialchars($line["title"]);
1084
1085 print "<td width='5%' align='center'><input
1086 onclick='toggleSelectPrefRow(this, \"fcat\");'
1087 type=\"checkbox\" id=\"FCCHK-$cat_id\"></td>";
1088
1089 print "<td><span id=\"FCATT-$cat_id\">" .
1090 $edit_title . "</span></td>";
1091
1092 print "</tr>";
1093
1094 ++$lnum;
1095 }
1096
1097 print "</table>";
1098
1099 print "</form>";
1100
1101 print "</div>";
1102
1103 } else {
1104 print "<p>".__('No feed categories defined.')."</p>";
1105 }
1106
1107 print "<div style='float : right'>
1108 <input type='submit' class='button'
1109 onclick=\"selectTab('feedConfig')\" value=\"".__('Close this window')."\"></div>";
1110
1111 print "<div id=\"catOpToolbar\">";
1112
1113 print "
1114 <input type=\"submit\" class=\"button\" disabled=\"true\"
1115 onclick=\"return removeSelectedFeedCats()\" value=\"".__('Remove')."\">";
1116
1117 print "</div>";
1118
1119 print "</div>";
1120
1121 return;
1122
1123 }
1124
1125 if ($quiet) return;
1126
1127 set_pref($link, "_PREFS_ACTIVE_TAB", "feedConfig");
1128
1129 $result = db_query($link, "SELECT COUNT(id) AS num_errors
1130 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
1131
1132 $num_errors = db_fetch_result($result, 0, "num_errors");
1133
1134 if ($num_errors > 0) {
1135
1136 print format_notice("<a href=\"javascript:showFeedsWithErrors()\">".
1137 __('Some feeds have update errors (click for details)')."</a>");
1138 }
1139
1140 $feed_search = db_escape_string($_GET["search"]);
1141
1142 if (array_key_exists("search", $_GET)) {
1143 $_SESSION["prefs_feed_search"] = $feed_search;
1144 } else {
1145 $feed_search = $_SESSION["prefs_feed_search"];
1146 }
1147
1148 print "<div class=\"feedEditSearch\">
1149 <input id=\"feed_search\" size=\"20\" type=\"search\"
1150 onfocus=\"javascript:disableHotkeys();\"
1151 onblur=\"javascript:enableHotkeys();\"
1152 onchange=\"javascript:updateFeedList()\" value=\"$feed_search\">
1153 <input type=\"submit\" class=\"button\"
1154 onclick=\"javascript:updateFeedList()\" value=\"".__('Search')."\">
1155 </div>";
1156
1157 print "<input onclick=\"javascript:displayDlg('quickAddFeed')\"
1158 type=\"submit\" id=\"subscribe_to_feed_btn\"
1159 class=\"button\" value=\"".__('Subscribe to feed')."\">";
1160
1161 if (ENABLE_FEED_BROWSER && !SINGLE_USER_MODE) {
1162 print " <input type=\"submit\" class=\"button\"
1163 id=\"top25_feeds_btn\"
1164 onclick=\"javascript:browseFeeds()\" value=\"".__('More Feeds')."\">";
1165 }
1166
1167 $feeds_sort = db_escape_string($_GET["sort"]);
1168
1169 if (!$feeds_sort || $feeds_sort == "undefined") {
1170 $feeds_sort = $_SESSION["pref_sort_feeds"];
1171 if (!$feeds_sort) $feeds_sort = "title";
1172 }
1173
1174 $_SESSION["pref_sort_feeds"] = $feeds_sort;
1175
1176 if ($feed_search) {
1177 $search_qpart = "(UPPER(F1.title) LIKE UPPER('%$feed_search%') OR
1178 UPPER(C1.title) LIKE UPPER('%$feed_search%') OR
1179 UPPER(F1.feed_url) LIKE UPPER('%$feed_search%')) AND";
1180 } else {
1181 $search_qpart = "";
1182 }
1183
1184 $show_last_article_info = false;
1185 $show_last_article_checked = "";
1186 $show_last_article_qpart = "";
1187
1188 if ($_GET["slat"] == "true") {
1189 $show_last_article_info = true;
1190 $show_last_article_checked = "checked";
1191 $show_last_article_qpart = ", (SELECT ".SUBSTRING_FOR_DATE."(MAX(updated),1,16) FROM ttrss_user_entries,
1192 ttrss_entries WHERE ref_id = ttrss_entries.id
1193 AND feed_id = F1.id) AS last_article";
1194 } else if ($feeds_sort == "last_article") {
1195 $feeds_sort = "title";
1196 }
1197
1198 if (get_pref($link, 'ENABLE_FEED_CATS')) {
1199 $order_by_qpart = "category,$feeds_sort,title";
1200 } else {
1201 $order_by_qpart = "$feeds_sort,title";
1202 }
1203
1204 $result = db_query($link, "SELECT
1205 F1.id,
1206 F1.title,
1207 F1.feed_url,
1208 ".SUBSTRING_FOR_DATE."(F1.last_updated,1,16) AS last_updated,
1209 F1.parent_feed,
1210 F1.update_interval,
1211 F1.last_error,
1212 F1.purge_interval,
1213 F1.cat_id,
1214 F2.title AS parent_title,
1215 C1.title AS category,
1216 F1.hidden,
1217 F1.include_in_digest
1218 $show_last_article_qpart
1219 FROM
1220 ttrss_feeds AS F1
1221 LEFT JOIN ttrss_feeds AS F2
1222 ON (F1.parent_feed = F2.id)
1223 LEFT JOIN ttrss_feed_categories AS C1
1224 ON (F1.cat_id = C1.id)
1225 WHERE
1226 $search_qpart F1.owner_uid = '".$_SESSION["uid"]."'
1227 ORDER by $order_by_qpart");
1228
1229 if (db_num_rows($result) != 0) {
1230
1231 // print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>";
1232
1233 print "<p><table width=\"100%\" cellspacing=\"0\"
1234 class=\"prefFeedList\" id=\"prefFeedList\">";
1235 print "<tr><td class=\"selectPrompt\" colspan=\"8\">".
1236 "<div style='float : right'>".
1237 "<input id='show_last_article_times' type='checkbox' onchange='feedlistToggleSLAT()'
1238 $show_last_article_checked><label
1239 for='show_last_article_times'>".__('Show last article times')."</label></div>".
1240 __('Select:')."
1241 <a href=\"javascript:selectPrefRows('feed', true)\">".__('All')."</a>,
1242 <a href=\"javascript:selectPrefRows('feed', false)\">".__('None')."</a>
1243 </td</tr>";
1244
1245 if (!get_pref($link, 'ENABLE_FEED_CATS')) {
1246 print "<tr class=\"title\">
1247 <td width='5%' align='center'>&nbsp;</td>";
1248
1249 if (get_pref($link, 'ENABLE_FEED_ICONS')) {
1250 print "<td width='3%'>&nbsp;</td>";
1251 }
1252
1253 print "<td width='60%'><a href=\"javascript:updateFeedList('title')\">".__('Title')."</a></td>";
1254
1255 if ($show_last_article_info) {
1256 print "<td width='20%' align='right'><a href=\"javascript:updateFeedList('last_article')\">".__('Last&nbsp;Article')."</a></td>";
1257 }
1258
1259 print "<td width='20%' align='right'><a href=\"javascript:updateFeedList('last_updated')\">".__('Updated')."</a></td>";
1260 }
1261
1262 $lnum = 0;
1263
1264 $cur_cat_id = -1;
1265
1266 while ($line = db_fetch_assoc($result)) {
1267
1268 $feed_id = $line["id"];
1269 $cat_id = $line["cat_id"];
1270
1271 $edit_title = htmlspecialchars($line["title"]);
1272 $edit_cat = htmlspecialchars($line["category"]);
1273
1274 $hidden = sql_bool_to_bool($line["hidden"]);
1275
1276 $last_error = $line["last_error"];
1277
1278 if (!$edit_cat) $edit_cat = __("Uncategorized");
1279
1280 $last_updated = $line["last_updated"];
1281
1282 if (!$last_updated) {
1283 $last_updated = "&mdash;";
1284 } else if (get_pref($link, 'HEADLINES_SMART_DATE')) {
1285 $last_updated = smart_date_time(strtotime($last_updated));
1286 } else {
1287 $short_date = get_pref($link, 'SHORT_DATE_FORMAT');
1288 $last_updated = date($short_date, strtotime($last_updated));
1289 }
1290
1291 $last_article = $line["last_article"];
1292
1293 if (!$last_article) {
1294 $last_article = "&mdash;";
1295 } else if (get_pref($link, 'HEADLINES_SMART_DATE')) {
1296 $last_article = smart_date_time(strtotime($last_article));
1297 } else {
1298 $short_date = get_pref($link, 'SHORT_DATE_FORMAT');
1299 $last_article = date($short_date, strtotime($last_article));
1300 }
1301
1302 if (get_pref($link, 'ENABLE_FEED_CATS') && $cur_cat_id != $cat_id) {
1303 $lnum = 0;
1304
1305 print "<tr><td colspan=\"6\" class=\"feedEditCat\">$edit_cat</td></tr>";
1306
1307 print "<tr class=\"title\">
1308 <td width='5%'>&nbsp;</td>";
1309
1310 if (get_pref($link, 'ENABLE_FEED_ICONS')) {
1311 print "<td width='3%'>&nbsp;</td>";
1312 }
1313
1314 print "<td width='60%'><a href=\"javascript:updateFeedList('title')\">".__('Title')."</a></td>";
1315
1316 if ($show_last_article_info) {
1317 print "<td width='20%' align='right'>
1318 <a href=\"javascript:updateFeedList('last_article')\">".__('Last&nbsp;Article')."</a></td>";
1319 }
1320
1321 print "<td width='20%' align='right'>
1322 <a href=\"javascript:updateFeedList('last_updated')\">".__('Updated')."</a></td>";
1323
1324 $cur_cat_id = $cat_id;
1325 }
1326
1327 $class = ($lnum % 2) ? "even" : "odd";
1328 $this_row_id = "id=\"FEEDR-$feed_id\"";
1329
1330 print "<tr class=\"$class\" $this_row_id>";
1331
1332 $icon_file = ICONS_DIR . "/$feed_id.ico";
1333
1334 if (file_exists($icon_file) && filesize($icon_file) > 0) {
1335 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . "/$feed_id.ico\">";
1336 } else {
1337 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
1338 }
1339
1340 print "<td class='feedSelect'><input onclick='toggleSelectPrefRow(this, \"feed\");'
1341 type=\"checkbox\" id=\"FRCHK-".$line["id"]."\"></td>";
1342
1343 $onclick = "onclick='editFeed($feed_id)' title='".__('Click to edit')."'";
1344
1345 if (get_pref($link, 'ENABLE_FEED_ICONS')) {
1346 print "<td $onclick class='feedIcon'>$feed_icon</td>";
1347 }
1348
1349 if ($hidden) {
1350 $edit_title = "<span class=\"insensitive\">$edit_title ".
1351 __('(Hidden)')."</span>";
1352 $last_updated = "<span class=\"insensitive\">$last_updated</span>";
1353 $last_article = "<span class=\"insensitive\">$last_article</span>";
1354 }
1355
1356 if ($last_error) {
1357 $edit_title = "<span class=\"feed_error\">$edit_title</span>";
1358 $last_updated = "<span class=\"feed_error\">$last_updated</span>";
1359 $last_article = "<span class=\"feed_error\">$last_article</span>";
1360 }
1361
1362 $parent_title = $line["parent_title"];
1363 if ($parent_title) {
1364 $linked_to = sprintf(__("(linked to %s)"), $parent_title);
1365 $parent_title = "<span class='groupPrompt'>$linked_to</span>";
1366 }
1367
1368 print "<td $onclick>" . "$edit_title $parent_title" . "</td>";
1369
1370 if ($show_last_article_info) {
1371 print "<td align='right' $onclick>" .
1372 "$last_article</td>";
1373 }
1374
1375 print "<td $onclick align='right'>$last_updated</td>";
1376
1377 print "</tr>";
1378
1379 ++$lnum;
1380 }
1381
1382 print "</table>";
1383
1384 print "<p>";
1385
1386 print "<div id=\"feedOpToolbar\">";
1387
1388 if (get_pref($link, 'ENABLE_FEED_CATS')) {
1389
1390 print __('Selection:') . " ";
1391
1392 print_feed_cat_select($link, "sfeed_set_fcat", "", "disabled");
1393
1394 print " <input type=\"submit\" class=\"button\" disabled=\"true\"
1395 onclick=\"javascript:categorizeSelectedFeeds()\" value=\"".
1396 __('Recategorize')."\">";
1397 }
1398
1399 print "</div>";
1400
1401 print "<select id=\"feedActionChooser\" onchange=\"feedActionChange()\">
1402 <option value=\"facDefault\" selected>".__('Actions...')."</option>
1403 <optgroup label=\"".__('Selection:')."\">
1404 <option value=\"facEdit\">".__('Edit')."</option>";
1405
1406 if (FORCE_ARTICLE_PURGE == 0) {
1407 print
1408 "<option value=\"facPurge\">".__('Manual purge')."</option>";
1409 }
1410
1411 print "
1412 <option value=\"facClear\">".__('Clear feed data')."</option>
1413 <option value=\"facRescore\">".__('Rescore articles')."</option>
1414 <option value=\"facUnsubscribe\">".__('Unsubscribe')."</option>";
1415
1416 print "</optgroup>";
1417
1418 if (get_pref($link, 'ENABLE_FEED_CATS')) {
1419
1420 print "<optgroup label=\"".__('Other:')."\">
1421 <option value=\"facEditCats\">".__('Edit categories')."
1422 </option>
1423 </optgroup>";
1424
1425 }
1426
1427 print "</select>";
1428 } else {
1429
1430 print "<p>";
1431
1432 if (!$feed_search) {
1433 print_warning(__("You don't have any subscribed feeds."));
1434 } else {
1435 print_warning(__('No matching feeds found.'));
1436 }
1437 print "</p>";
1438
1439 }
1440
1441 print "<h3>".__('OPML')."</h3>
1442
1443 <div style='float : left'>
1444 <form enctype=\"multipart/form-data\" method=\"POST\" action=\"opml.php\">
1445 ".__('File:')." <input id=\"opml_file\" name=\"opml_file\" type=\"file\">&nbsp;
1446 <input type=\"hidden\" name=\"op\" value=\"Import\">
1447 <input class=\"button\" onclick=\"return validateOpmlImport();\"
1448 type=\"submit\" value=\"".__('Import')."\">
1449 </form></div>";
1450
1451 print "&nbsp;";
1452
1453 print "<input type=\"submit\"
1454 class=\"button\" onclick=\"gotoExportOpml()\"
1455 value=\"".__('Export OPML')."\">";
1456
1457
1458 print "<h3>" . __("Firefox Integration") . "</h3>";
1459
1460 print "<p>" . __('This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.');
1461 print "</p><p> <a class='visibleLinkB' href='javascript:window.navigator.registerContentHandler(" .
1462 "\"application/vnd.mozilla.maybe.feed\", " .
1463 "\"" . add_feed_url() . "\", " . " \"Tiny Tiny RSS\")'>" .
1464 __('Click here to register this site as a feed reader.') . "</a></p>";
1465
1466
1467 print "<h3>".__("Published articles")."</h3>";
1468
1469 if (!get_pref($link, "_PREFS_PUBLISH_KEY")) {
1470 set_pref($link, "_PREFS_PUBLISH_KEY", generate_publish_key());
1471 }
1472
1473 print "<p>".__('Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.')."</p>";
1474
1475 $url_path = article_publish_url($link);
1476
1477 print "<p><a class=\"visibleLinkB\" id=\"pubGenAddress\" target=\"_blank\" href=\"$url_path\">".__("Link to published articles feed.")."</a></p>";
1478
1479 print "<p><input type=\"submit\" onclick=\"return pubRegenKey()\" class=\"button\"
1480 value=\"".__('Generate another link')."\">";
1481 /* print " <input type=\"submit\" onclick=\"return pubToClipboard()\" class=\"button\"
1482 value=\"".__('Copy link to clipboard')."\">"; */
1483 print "</p>";
1484
1485 }
1486
1487 function print_feed_browser($link, $search, $limit) {
1488
1489 $owner_uid = $_SESSION["uid"];
1490
1491 if ($search) {
1492 $search_qpart = "AND (UPPER(feed_url) LIKE UPPER('%$search%') OR
1493 UPPER(title) LIKE UPPER('%$search%'))";
1494 } else {
1495 $search_qpart = "";
1496 }
1497
1498 $result = db_query($link, "SELECT feed_url, subscribers FROM
1499 ttrss_feedbrowser_cache WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
1500 WHERE tf.feed_url = ttrss_feedbrowser_cache.feed_url
1501 AND owner_uid = '$owner_uid') $search_qpart
1502 ORDER BY subscribers DESC LIMIT $limit");
1503
1504 $feedctr = 0;
1505
1506 while ($line = db_fetch_assoc($result)) {
1507 $feed_url = $line["feed_url"];
1508 $subscribers = $line["subscribers"];
1509
1510 $det_result = db_query($link, "SELECT site_url,title,id
1511 FROM ttrss_feeds WHERE feed_url = '$feed_url' LIMIT 1");
1512
1513 $details = db_fetch_assoc($det_result);
1514
1515 $icon_file = ICONS_DIR . "/" . $details["id"] . ".ico";
1516
1517 if (file_exists($icon_file) && filesize($icon_file) > 0) {
1518 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL .
1519 "/".$details["id"].".ico\">";
1520 } else {
1521 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
1522 }
1523
1524 $check_box = "<input onclick='toggleSelectListRow(this)' class='feedBrowseCB'
1525 type=\"checkbox\" id=\"FBCHK-" . $details["id"] . "\">";
1526
1527 $class = ($feedctr % 2) ? "even" : "odd";
1528
1529 if ($details["site_url"]) {
1530 $site_url = "<a target=\"_blank\" href=\"".$details["site_url"]."\">
1531 <img style='border-width : 0px' src='images/www.png' alt='www'></a>";
1532 } else {
1533 $site_url = "";
1534 }
1535
1536 print "<li class='$class' id=\"FBROW-".$details["id"]."\">$check_box".
1537 "$feed_icon " . $details["title"] .
1538 "&nbsp;<span class='subscribers'>($subscribers)</span>
1539 $site_url
1540 </li>";
1541
1542 ++$feedctr;
1543 }
1544
1545 if ($feedctr == 0) {
1546 print "<li style=\"text-align : center\"><p>".__('No feeds found.')."</p></li>";
1547 }
1548
1549 return $feedctr;
1550
1551 }
1552 ?>