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