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