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