3 function batch_edit_cbox($elem, $label = false) {
4 print "<input type=\"checkbox\" title=\"".__("Check to enable field")."\"
5 onchange=\"batchFeedsToggleField(this, '$elem', '$label')\">";
8 function module_pref_feeds($link) {
10 global $update_intervals;
11 global $purge_intervals;
12 global $update_methods;
14 $subop = $_REQUEST["subop"];
15 $quiet = $_REQUEST["quiet"];
16 $mode = $_REQUEST["mode"];
18 if ($subop == "removeicon") {
19 $feed_id = db_escape_string($_REQUEST["feed_id"]);
21 $result = db_query($link, "SELECT id FROM ttrss_feeds
22 WHERE id = '$feed_id' AND owner_uid = ". $_SESSION["uid"]);
24 if (db_num_rows($result) != 0) {
25 unlink(ICONS_DIR . "/$feed_id.ico");
31 if ($subop == "uploadicon") {
32 $icon_file = $_FILES['icon_file']['tmp_name'];
33 $feed_id = db_escape_string($_REQUEST["feed_id"]);
35 if (is_file($icon_file) && $feed_id) {
36 if (filesize($icon_file) < 20000) {
38 $result = db_query($link, "SELECT id FROM ttrss_feeds
39 WHERE id = '$feed_id' AND owner_uid = ". $_SESSION["uid"]);
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");
55 print "<script type=\"text/javascript\">";
56 print "parent.uploadIconHandler($rc);";
61 if ($subop == "editfeed") {
62 header("Content-Type: text/xml");
64 print "<dlg id=\"$subop\">";
65 print "<title>".__('Feed Editor')."</title>";
66 print "<content><![CDATA[";
68 $feed_id = db_escape_string($_REQUEST["id"]);
70 $result = db_query($link,
71 "SELECT * FROM ttrss_feeds WHERE id = '$feed_id' AND
72 owner_uid = " . $_SESSION["uid"]);
74 $title = htmlspecialchars(db_fetch_result($result,
77 $icon_file = ICONS_DIR . "/$feed_id.ico";
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\">";
86 print "<form id=\"edit_feed_form\" onsubmit=\"return false\">";
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\">";
92 print "<div class=\"dlgSec\">".__("Feed")."</div>";
93 print "<div class=\"dlgSecCont\">";
97 print "<input style=\"font-size : 16px\" size=\"40\" onkeypress=\"return filterCR(event, feedEditSave)\"
98 name=\"title\" value=\"$title\">";
102 $feed_url = db_fetch_result($result, 0, "feed_url");
103 $feed_url = htmlspecialchars(db_fetch_result($result,
108 print __('URL:') . " ";
109 print "<input size=\"40\" onkeypress=\"return filterCR(event, feedEditSave)\"
110 name=\"feed_url\" value=\"$feed_url\">";
114 if (get_pref($link, 'ENABLE_FEED_CATS')) {
116 $cat_id = db_fetch_result($result, 0, "cat_id");
120 print __('Place in category:') . " ";
122 print_feed_cat_select($link, "cat_id", $cat_id, $disabled);
127 print "<div class=\"dlgSec\">".__("Update")."</div>";
128 print "<div class=\"dlgSecCont\">";
130 /* Update Interval */
132 $update_interval = db_fetch_result($result, 0, "update_interval");
134 print_select_hash("update_interval", $update_interval, $update_intervals);
138 $update_method = db_fetch_result($result, 0, "update_method");
140 print " " . __('using') . " ";
141 print_select_hash("update_method", $update_method, $update_methods);
143 $purge_interval = db_fetch_result($result, 0, "purge_interval");
145 if (FORCE_ARTICLE_PURGE == 0) {
151 print __('Article purging:') . " ";
153 print_select_hash("purge_interval", $purge_interval, $purge_intervals);
156 print "<input type='hidden' name='purge_interval' value='$purge_interval'>";
161 print "<div class=\"dlgSec\">".__("Authentication")."</div>";
162 print "<div class=\"dlgSecCont\">";
164 $auth_login = htmlspecialchars(db_fetch_result($result, 0, "auth_login"));
168 print "<tr><td>" . __('Login:') . "</td><td>";
170 print "<input size=\"20\" onkeypress=\"return filterCR(event, feedEditSave)\"
171 name=\"auth_login\" value=\"$auth_login\">";
173 print "</tr><tr><td>" . __("Password:") . "</td><td>";
175 $auth_pass = htmlspecialchars(db_fetch_result($result, 0, "auth_pass"));
177 print "<input size=\"20\" type=\"password\" name=\"auth_pass\"
178 onkeypress=\"return filterCR(event, feedEditSave)\"
179 value=\"$auth_pass\">";
181 print "</td></tr></table>";
184 print "<div class=\"dlgSec\">".__("Options")."</div>";
185 print "<div class=\"dlgSecCont\">";
187 print "<div style=\"line-height : 100%\">";
189 $private = sql_bool_to_bool(db_fetch_result($result, 0, "private"));
192 $checked = "checked";
197 print "<input type=\"checkbox\" name=\"private\" id=\"private\"
198 $checked> <label for=\"private\">".__('Hide from Popular feeds')."</label>";
200 $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content"));
203 $checked = "checked";
208 print "<br/><input type=\"checkbox\" id=\"rtl_content\" name=\"rtl_content\"
209 $checked> <label for=\"rtl_content\">".__('Right-to-left content')."</label>";
211 $include_in_digest = sql_bool_to_bool(db_fetch_result($result, 0, "include_in_digest"));
213 if ($include_in_digest) {
214 $checked = "checked";
219 print "<br/><input type=\"checkbox\" id=\"include_in_digest\"
220 name=\"include_in_digest\"
221 $checked> <label for=\"include_in_digest\">".__('Include in e-mail digest')."</label>";
224 $always_display_enclosures = sql_bool_to_bool(db_fetch_result($result, 0, "always_display_enclosures"));
226 if ($always_display_enclosures) {
227 $checked = "checked";
232 print "<br/><input type=\"checkbox\" id=\"always_display_enclosures\"
233 name=\"always_display_enclosures\"
234 $checked> <label for=\"always_display_enclosures\">".__('Always display image attachments')."</label>";
237 $cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images"));
240 $checked = "checked";
245 if (SIMPLEPIE_CACHE_IMAGES) {
249 $disabled = "disabled";
250 $label_class = "class='insensitive'";
253 print "<br/><input type=\"checkbox\" id=\"cache_images\"
254 name=\"cache_images\" $disabled
255 $checked> <label $label_class for=\"cache_images\">".
256 __('Cache images locally')."</label>";
268 print "<div class=\"dlgSec\">".__("Icon")."</div>";
269 print "<div class=\"dlgSecCont\">";
271 print "<iframe name=\"icon_upload_iframe\"
272 style=\"width: 400px; height: 100px; display: none;\"></iframe>";
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>
289 $title = htmlspecialchars($title, ENT_QUOTES);
291 print "<div class='dlgButtons'>
292 <div style=\"float : left\">
293 <button onclick='return unsubscribeFeed($feed_id, \"$title\")'>".
294 __('Unsubscribe')."</button>
296 <button onclick=\"return feedEditSave()\">".__('Save')."</button>
297 <button onclick=\"return feedEditCancel()\">".__('Cancel')."</button>
300 print "]]></content></dlg>";
305 if ($subop == "editfeeds") {
307 $feed_ids = db_escape_string($_REQUEST["ids"]);
309 header("Content-Type: text/xml");
310 print "<dlg id=\"$subop\">";
311 print "<title>".__('Multiple Feed Editor')."</title>";
312 print "<content><![CDATA[";
314 print "<form id=\"batch_edit_feed_form\" onsubmit=\"return false\">";
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\">";
320 print "<div class=\"dlgSec\">".__("Feed")."</div>";
321 print "<div class=\"dlgSecCont\">";
325 print "<input disabled style=\"font-size : 16px\" size=\"35\" onkeypress=\"return filterCR(event, feedEditSave)\"
326 name=\"title\" value=\"$title\">";
328 batch_edit_cbox("title");
334 print __('URL:') . " ";
335 print "<input disabled size=\"40\" onkeypress=\"return filterCR(event, feedEditSave)\"
336 name=\"feed_url\" value=\"$feed_url\">";
338 batch_edit_cbox("feed_url");
342 if (get_pref($link, 'ENABLE_FEED_CATS')) {
346 print __('Place in category:') . " ";
348 print_feed_cat_select($link, "cat_id", $cat_id, "disabled");
350 batch_edit_cbox("cat_id");
356 print "<div class=\"dlgSec\">".__("Update")."</div>";
357 print "<div class=\"dlgSecCont\">";
359 /* Update Interval */
361 print_select_hash("update_interval", $update_interval, $update_intervals,
364 batch_edit_cbox("update_interval");
368 print " " . __('using') . " ";
369 print_select_hash("update_method", $update_method, $update_methods,
371 batch_edit_cbox("update_method");
375 if (FORCE_ARTICLE_PURGE != 0) {
379 print __('Article purging:') . " ";
381 print_select_hash("purge_interval", $purge_interval, $purge_intervals,
384 batch_edit_cbox("purge_interval");
388 print "<div class=\"dlgSec\">".__("Authentication")."</div>";
389 print "<div class=\"dlgSecCont\">";
391 print __('Login:') . " ";
392 print "<input disabled size=\"15\" onkeypress=\"return filterCR(event, feedEditSave)\"
393 name=\"auth_login\" value=\"$auth_login\">";
395 batch_edit_cbox("auth_login");
397 print " " . __("Password:") . " ";
399 print "<input disabled size=\"15\" type=\"password\" name=\"auth_pass\"
400 onkeypress=\"return filterCR(event, feedEditSave)\"
401 value=\"$auth_pass\">";
403 batch_edit_cbox("auth_pass");
406 print "<div class=\"dlgSec\">".__("Options")."</div>";
407 print "<div class=\"dlgSecCont\">";
409 print "<div style=\"line-height : 100%\">";
411 print "<input disabled type=\"checkbox\" name=\"private\" id=\"private\"
412 $checked> <label id=\"private_l\" class='insensitive' for=\"private\">".__('Hide from Popular feeds')."</label>";
414 print " "; batch_edit_cbox("private", "private_l");
416 print "<br/><input disabled type=\"checkbox\" id=\"rtl_content\" name=\"rtl_content\"
417 $checked> <label class='insensitive' id=\"rtl_content_l\" for=\"rtl_content\">".__('Right-to-left content')."</label>";
419 print " "; batch_edit_cbox("rtl_content", "rtl_content_l");
421 print "<br/><input disabled type=\"checkbox\" id=\"include_in_digest\"
422 name=\"include_in_digest\"
423 $checked> <label id=\"include_in_digest_l\" class='insensitive' for=\"include_in_digest\">".__('Include in e-mail digest')."</label>";
425 print " "; batch_edit_cbox("include_in_digest", "include_in_digest_l");
427 print "<br/><input disabled type=\"checkbox\" id=\"always_display_enclosures\"
428 name=\"always_display_enclosures\"
429 $checked> <label id=\"always_display_enclosures_l\" class='insensitive' for=\"always_display_enclosures\">".__('Always display image attachments')."</label>";
431 print " "; batch_edit_cbox("always_display_enclosures", "always_display_enclosures_l");
433 print "<br/><input disabled type=\"checkbox\" id=\"cache_images\"
434 name=\"cache_images\"
435 $checked> <label class='insensitive' id=\"cache_images_l\"
436 for=\"cache_images\">".
437 __('Cache images locally')."</label>";
440 if (SIMPLEPIE_CACHE_IMAGES) {
441 print " "; batch_edit_cbox("cache_images", "cache_images_l");
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')."\">
456 print "]]></content></dlg>";
461 if ($subop == "editSave" || $subop == "batchEditSave") {
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"]);
480 $always_display_enclosures = checkbox_to_sql_bool(
481 db_escape_string($_POST["always_display_enclosures"]));
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'";
488 $category_qpart = 'cat_id = NULL,';
489 $category_qpart_nocomma = 'cat_id = NULL';
492 $category_qpart = "";
493 $category_qpart_nocomma = "";
496 if (SIMPLEPIE_CACHE_IMAGES) {
497 $cache_images_qpart = "cache_images = $cache_images,";
499 $cache_images_qpart = "";
502 if ($subop == "editSave") {
504 $result = db_query($link, "UPDATE ttrss_feeds SET
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',
512 rtl_content = $rtl_content,
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"]);
519 } else if ($subop == "batchEditSave") {
520 $feed_data = array();
522 foreach (array_keys($_POST) as $k) {
523 if ($k != "op" && $k != "subop" && $k != "ids") {
524 $feed_data[$k] = $_POST[$k];
528 db_query($link, "BEGIN");
530 foreach (array_keys($feed_data) as $k) {
536 $qpart = "title = '$feed_title'";
540 $qpart = "feed_url = '$feed_link'";
543 case "update_interval":
544 $qpart = "update_interval = '$upd_intl'";
547 case "purge_interval":
548 $qpart = "purge_interval = '$purge_intl'";
552 $qpart = "auth_login = '$auth_login'";
556 $qpart = "auth_pass = '$auth_pass'";
560 $qpart = "private = '$private'";
563 case "include_in_digest":
564 $qpart = "include_in_digest = '$include_in_digest'";
567 case "always_display_enclosures":
568 $qpart = "always_display_enclosures = '$always_display_enclosures'";
572 $qpart = "cache_images = '$cache_images'";
576 $qpart = "rtl_content = '$rtl_content'";
579 case "update_method":
580 $qpart = "update_method = '$update_method'";
584 $qpart = $category_qpart_nocomma;
591 "UPDATE ttrss_feeds SET $qpart WHERE id IN ($feed_ids)
592 AND owner_uid = " . $_SESSION["uid"]);
597 db_query($link, "COMMIT");
602 if ($subop == "remove") {
604 $ids = split(",", db_escape_string($_REQUEST["ids"]));
606 foreach ($ids as $id) {
607 remove_feed($link, $id, $_SESSION["uid"]);
613 if ($subop == "clear") {
614 $id = db_escape_string($_REQUEST["id"]);
615 clear_feed_articles($link, $id);
618 if ($subop == "rescore") {
619 $ids = split(",", db_escape_string($_REQUEST["ids"]));
621 foreach ($ids as $id) {
623 $filters = load_filters($link, $id, $_SESSION["uid"], 6);
625 $result = db_query($link, "SELECT
626 title, content, link, ref_id, author,".
627 SUBSTRING_FOR_DATE."(updated, 1, 19) AS updated
629 ttrss_user_entries, ttrss_entries
630 WHERE ref_id = id AND feed_id = '$id' AND
631 owner_uid = " .$_SESSION['uid']."
636 while ($line = db_fetch_assoc($result)) {
638 $tags = get_article_tags($link, $line["ref_id"]);
640 $article_filters = get_article_filters($filters, $line['title'],
641 $line['content'], $line['link'], strtotime($line['updated']),
642 $line['author'], $tags);
644 $new_score = calculate_article_score($article_filters);
646 if (!$scores[$new_score]) $scores[$new_score] = array();
648 array_push($scores[$new_score], $line['ref_id']);
651 foreach (array_keys($scores) as $s) {
653 db_query($link, "UPDATE ttrss_user_entries SET score = '$s',
655 ref_id IN (" . join(',', $scores[$s]) . ")");
656 } else if ($s < -500) {
657 db_query($link, "UPDATE ttrss_user_entries SET score = '$s',
659 ref_id IN (" . join(',', $scores[$s]) . ")");
661 db_query($link, "UPDATE ttrss_user_entries SET score = '$s' WHERE
662 ref_id IN (" . join(',', $scores[$s]) . ")");
667 print __("All done.");
671 if ($subop == "rescoreAll") {
673 $result = db_query($link,
674 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION['uid']);
676 while ($feed_line = db_fetch_assoc($result)) {
678 $id = $feed_line["id"];
680 $filters = load_filters($link, $id, $_SESSION["uid"], 6);
682 $tmp_result = db_query($link, "SELECT
683 title, content, link, ref_id, author,".
684 SUBSTRING_FOR_DATE."(updated, 1, 19) AS updated
686 ttrss_user_entries, ttrss_entries
687 WHERE ref_id = id AND feed_id = '$id' AND
688 owner_uid = " .$_SESSION['uid']."
693 while ($line = db_fetch_assoc($tmp_result)) {
695 $tags = get_article_tags($link, $line["ref_id"]);
697 $article_filters = get_article_filters($filters, $line['title'],
698 $line['content'], $line['link'], strtotime($line['updated']),
699 $line['author'], $tags);
701 $new_score = calculate_article_score($article_filters);
703 if (!$scores[$new_score]) $scores[$new_score] = array();
705 array_push($scores[$new_score], $line['ref_id']);
708 foreach (array_keys($scores) as $s) {
710 db_query($link, "UPDATE ttrss_user_entries SET score = '$s',
712 ref_id IN (" . join(',', $scores[$s]) . ")");
714 db_query($link, "UPDATE ttrss_user_entries SET score = '$s' WHERE
715 ref_id IN (" . join(',', $scores[$s]) . ")");
720 print __("All done.");
724 if ($subop == "add") {
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"]);
730 /* only read authentication information from POST */
732 $auth_login = db_escape_string(trim($_POST["auth_login"]));
733 $auth_pass = db_escape_string(trim($_POST["auth_pass"]));
735 if ($p_from != 'tt-rss') {
738 <title>Tiny Tiny RSS</title>
739 <link rel=\"stylesheet\" type=\"text/css\" href=\"utility.css\">
742 <img class=\"floatingLogo\" src=\"images/ttrss_logo.png\"
743 alt=\"Tiny Tiny RSS\"/>
744 <h1>Subscribe to feed...</h1>";
747 $rc = subscribe_to_feed($link, $feed_url, $cat_id, $auth_login, $auth_pass);
751 print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url));
754 print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url));
757 print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
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"]);
765 $tp_uri = ($_SERVER['HTTPS'] != "on" ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . preg_replace('/backend\.php.*$/', 'prefs.php', $_SERVER["REQUEST_URI"]);
767 $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE
768 feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
770 $feed_id = db_fetch_result($result, 0, "id");
775 print "<form method=\"GET\" style='display: inline'
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")."\">
784 print "<form style='display: inline' method=\"GET\" action=\"$tt_uri\">
785 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
788 print "</body></html>";
793 if ($subop == "categorize") {
796 $ids = split(",", db_escape_string($_REQUEST["ids"]));
798 $cat_id = db_escape_string($_REQUEST["cat_id"]);
801 $cat_id_qpart = 'NULL';
803 $cat_id_qpart = "'$cat_id'";
806 db_query($link, "BEGIN");
808 foreach ($ids as $id) {
810 db_query($link, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
812 AND owner_uid = " . $_SESSION["uid"]);
816 db_query($link, "COMMIT");
820 if ($subop == "editCats") {
822 $action = $_REQUEST["action"];
824 if ($action == "save") {
826 $cat_title = db_escape_string(trim($_REQUEST["value"]));
827 $cat_id = db_escape_string($_REQUEST["cid"]);
829 db_query($link, "BEGIN");
831 $result = db_query($link, "SELECT title FROM ttrss_feed_categories
832 WHERE id = '$cat_id' AND owner_uid = ".$_SESSION["uid"]);
834 if (db_num_rows($result) == 1) {
836 $old_title = db_fetch_result($result, 0, "title");
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"]);
848 print $_REQUEST["value"];
851 db_query($link, "COMMIT");
857 header("Content-Type: text/xml");
858 print "<dlg id=\"$subop\">";
859 print "<title>".__('Category editor')."</title>";
860 print "<content><![CDATA[";
862 if ($action == "add") {
864 $feed_cat = db_escape_string(trim($_REQUEST["cat"]));
866 if (!add_feed_category($link, $feed_cat))
867 print_warning(T_sprintf("Category <b>$%s</b> already exists in the database.", $feed_cat));
871 if ($action == "remove") {
873 $ids = split(",", db_escape_string($_REQUEST["ids"]));
875 foreach ($ids as $id) {
876 remove_feed_category($link, $id, $_SESSION["uid"]);
881 <input id=\"fadd_cat\"
882 onkeypress=\"return filterCR(event, addFeedCat)\"
884 <button onclick=\"addFeedCat()\">".
885 __('Create category')."</button></div>";
887 $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories
888 WHERE owner_uid = ".$_SESSION["uid"]."
893 if (db_num_rows($result) != 0) {
895 print __('Select:')."
896 <a href=\"#\" onclick=\"selectTableRows('prefFeedCatList', 'all')\">".__('All')."</a>,
897 <a href=\"#\" onclick=\"selectTableRows('prefFeedCatList', 'none')\">".__('None')."</a>";
899 print "<div class=\"prefFeedCatHolder\">";
901 print "<form id=\"feed_cat_edit_form\" onsubmit=\"return false\">";
903 print "<table width=\"100%\" class=\"prefFeedCatList\"
904 cellspacing=\"0\" id=\"prefFeedCatList\">";
908 while ($line = db_fetch_assoc($result)) {
910 $class = ($lnum % 2) ? "even" : "odd";
912 $cat_id = $line["id"];
913 $this_row_id = "id=\"FCATR-$cat_id\"";
915 print "<tr class=\"$class\" $this_row_id>";
917 $edit_title = htmlspecialchars($line["title"]);
919 print "<td width='5%' align='center'><input
920 onclick='toggleSelectRow(this);'
921 type=\"checkbox\" id=\"FCCHK-$cat_id\"></td>";
923 print "<td><span id=\"FCATT-$cat_id\">" .
924 $edit_title . "</span></td>";
938 print "<p>".__('No feed categories defined.')."</p>";
941 print "<div class='dlgButtons'>
942 <div style='float : left'>
943 <button onclick=\"return removeSelectedFeedCats()\">".
944 __('Remove')."</button>
947 print "<button onclick=\"selectTab('feedConfig')\">".
948 __('Close this window')."</button></div>";
950 print "]]></content></dlg>";
958 print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">";
959 print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Feeds')."\">";
961 set_pref($link, "_PREFS_ACTIVE_TAB", "feedConfig");
963 $result = db_query($link, "SELECT COUNT(id) AS num_errors
964 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
966 $num_errors = db_fetch_result($result, 0, "num_errors");
968 if ($num_errors > 0) {
970 print format_notice("<a href=\"javascript:showFeedsWithErrors()\">".
971 __('Some feeds have update errors (click for details)')."</a>");
974 $feed_search = db_escape_string($_REQUEST["search"]);
976 if (array_key_exists("search", $_REQUEST)) {
977 $_SESSION["prefs_feed_search"] = $feed_search;
979 $feed_search = $_SESSION["prefs_feed_search"];
982 print "<div dojoType=\"dijit.Toolbar\">";
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>
994 print "<div dojoType=\"dijit.form.DropDownButton\">".
995 "<span>" . __('Select')."</span>";
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>";
1004 /* print "<div onclick=\"selectTableRows('prefFeedList', 'all')\">".__('All')."</div>,
1005 <div href=\"#\" onclick=\"selectTableRows('prefFeedList', 'none')\">".__('None')."</div>"; */
1009 print "<button dojoType=\"dijit.form.Button\" onclick=\"quickAddFeed()\">"
1010 .__('Subscribe to feed')."</button dojoType=\"dijit.form.Button\"> ";
1012 print "<button dojoType=\"dijit.form.Button\" onclick=\"editSelectedFeed()\">".
1013 __('Edit feeds')."</button dojoType=\"dijit.form.Button\"> ";
1015 if (get_pref($link, 'ENABLE_FEED_CATS')) {
1017 print "<button dojoType=\"dijit.form.Button\" onclick=\"editFeedCats()\">".
1018 __('Edit categories')."</button dojoType=\"dijit.form.Button\"> ";
1021 print "<button dojoType=\"dijit.form.Button\" onclick=\"removeSelectedFeeds()\">"
1022 .__('Unsubscribe')."</button dojoType=\"dijit.form.Button\"> ";
1024 if (defined('_ENABLE_FEED_DEBUGGING')) {
1026 print "<select id=\"feedActionChooser\" onchange=\"feedActionChange()\">
1027 <option value=\"facDefault\" selected>".__('More actions...')."</option>";
1029 if (FORCE_ARTICLE_PURGE == 0) {
1031 "<option value=\"facPurge\">".__('Manual purge')."</option>";
1035 <option value=\"facClear\">".__('Clear feed data')."</option>
1036 <option value=\"facRescore\">".__('Rescore articles')."</option>";
1042 print "</div>"; # toolbar
1044 print "<div id=\"feedlistLoading\">
1045 <img src='images/indicator_tiny.gif'>".
1046 __("Loading, please wait...")."</div>";
1048 print "<div dojoType=\"dojo.data.ItemFileWriteStore\" jsId=\"feedStore\"
1049 url=\"backend.php?op=feeds&root=1\">
1051 <div dojoType=\"lib.CheckBoxStoreModel\" jsId=\"feedModel\" store=\"feedStore\"
1052 query=\"{id:'root'}\" rootId=\"root\" rootLabel=\"Feeds\"
1053 childrenAttrs=\"items\" checkboxStrict=\"false\" checkboxAll=\"false\">
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);
1062 console.log('onClick: ' + id);
1064 if (id.match('FEED')) {
1065 editFeed(bare_id, event);
1069 <script type=\"dojo/method\" event=\"onLoad\" args=\"item\">
1070 Element.hide(\"feedlistLoading\");
1072 <script type=\"dojo/method\" event=\"checkItemAcceptance\" args=\"item, source, position\">
1073 var source_item = dijit.getEnclosingWidget(source);
1075 console.log(source_item);
1081 $feeds_sort = db_escape_string($_REQUEST["sort"]);
1083 if (!$feeds_sort || $feeds_sort == "undefined") {
1084 $feeds_sort = $_SESSION["pref_sort_feeds"];
1085 if (!$feeds_sort) $feeds_sort = "title";
1088 $_SESSION["pref_sort_feeds"] = $feeds_sort;
1092 $feed_search = split(" ", $feed_search);
1095 foreach ($feed_search as $token) {
1097 $token = trim($token);
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%'))");
1104 $search_qpart = "(" . join($tokens, " AND ") . ") AND ";
1110 $show_last_article_info = false;
1111 $show_last_article_checked = "";
1112 $show_last_article_qpart = "";
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";
1124 if (get_pref($link, 'ENABLE_FEED_CATS')) {
1125 $order_by_qpart = "category,$feeds_sort,title";
1127 $order_by_qpart = "$feeds_sort,title";
1130 $result = db_query($link, "SELECT
1134 ".SUBSTRING_FOR_DATE."(F1.last_updated,1,16) AS last_updated,
1139 C1.title AS category,
1140 F1.include_in_digest
1141 $show_last_article_qpart
1144 LEFT JOIN ttrss_feed_categories AS C1
1145 ON (F1.cat_id = C1.id)
1147 $search_qpart F1.owner_uid = '".$_SESSION["uid"]."'
1148 ORDER by $order_by_qpart");
1150 if (db_num_rows($result) != 0) {
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>".
1160 <a href=\"#\" onclick=\"selectTableRows('prefFeedList', 'all')\">".__('All')."</a>,
1161 <a href=\"#\" onclick=\"selectTableRows('prefFeedList', 'none')\">".__('None')."</a>
1164 if (!get_pref($link, 'ENABLE_FEED_CATS')) {
1165 print "<tr class=\"title\">
1166 <td width='5%' align='center'> </td>";
1168 print "<td width='3%'> </td>";
1170 print "<td width='60%'><a href=\"#\" onclick=\"updateFeedList('title')\">".__('Title')."</a></td>";
1172 if ($show_last_article_info) {
1173 print "<td width='20%' align='right'><a href=\"#\" onclick=\"updateFeedList('last_article')\">".__('Last Article')."</a></td>";
1176 print "<td width='20%' align='right'><a href=\"#\" onclick=\"updateFeedList('last_updated')\">".__('Updated')."</a></td>";
1183 while ($line = db_fetch_assoc($result)) {
1185 $feed_id = $line["id"];
1186 $cat_id = $line["cat_id"];
1188 $edit_title = htmlspecialchars($line["title"]);
1189 $edit_cat = htmlspecialchars($line["category"]);
1191 $last_error = $line["last_error"];
1193 if (!$edit_cat) $edit_cat = __("Uncategorized");
1195 $last_updated = $line["last_updated"];
1197 if (!$last_updated) {
1198 $last_updated = "—";
1200 $last_updated = make_local_datetime($link, $last_updated, false);
1203 $last_article = $line["last_article"];
1205 if (!$last_article) {
1206 $last_article = "—";
1208 $last_article = make_local_datetime($link, $last_article, false);
1211 if (get_pref($link, 'ENABLE_FEED_CATS') && $cur_cat_id != $cat_id) {
1214 print "<tr><td colspan=\"6\" class=\"feedEditCat\">$edit_cat</td></tr>";
1216 print "<tr class=\"title\">
1217 <td width='5%'> </td>";
1219 print "<td width='3%'> </td>";
1221 print "<td width='60%'><a href=\"#\" onclick=\"updateFeedList('title')\">".__('Title')."</a></td>";
1223 if ($show_last_article_info) {
1224 print "<td width='20%' align='right'>
1225 <a href=\"#\" onclick=\"updateFeedList('last_article')\">".__('Last Article')."</a></td>";
1228 print "<td width='20%' align='right'>
1229 <a href=\"#\" onclick=\"updateFeedList('last_updated')\">".__('Updated')."</a></td>";
1231 $cur_cat_id = $cat_id;
1234 $class = ($lnum % 2) ? "even" : "odd";
1235 $this_row_id = "id=\"FEEDR-$feed_id\"";
1237 print "<tr class=\"$class\" $this_row_id>";
1239 $icon_file = ICONS_DIR . "/$feed_id.ico";
1241 if (file_exists($icon_file) && filesize($icon_file) > 0) {
1242 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . "/$feed_id.ico\">";
1244 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
1247 print "<td class='feedSelect'><input
1248 onclick='toggleSelectRowById(this, \"FEEDR-".$line['id']."\");'
1249 type=\"checkbox\" id=\"FRCHK-".$line["id"]."\"></td>";
1251 $onclick = "onclick='editFeed($feed_id, event)' title='".__('Click to edit')."'";
1253 print "<td $onclick class='feedIcon'>$feed_icon</td>";
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>";
1261 print "<td $onclick>" . $edit_title . "</td>";
1263 if ($show_last_article_info) {
1264 print "<td align='right' $onclick>" .
1265 "$last_article</td>";
1268 print "<td $onclick align='right'>$last_updated</td>";
1283 if (!$feed_search) {
1284 print_warning(__("You don't have any subscribed feeds."));
1286 print_warning(__('No matching feeds found.'));
1292 print "</div>"; # feeds pane
1294 print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('OPML')."\">";
1296 print "<p>" . __("Using OPML you can export and import your feeds and Tiny Tiny RSS settings.");
1298 print "<div class=\"insensitive\">" . __("Note: Only main settings profile can be migrated using OPML.") . "</div>";
1302 print "<iframe name=\"upload_iframe\"
1303 style=\"width: 400px; height: 100px; display: none;\"></iframe>";
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\">
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>
1315 print "</div> ";
1317 print "<button onclick=\"gotoExportOpml()\">".__('Export OPML')."</button>";
1319 print "<p>".__('Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.');
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>";
1323 print "<button onclick=\"return displayDlg('pubOPMLUrl')\">".
1324 __('Display URL')."</button> ";
1327 print "</div>"; # pane
1329 if (true || strpos($_SERVER['HTTP_USER_AGENT'], "Firefox") !== false) {
1331 print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Firefox integration')."\">";
1333 print "<p>" . __('This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.') . "</p>";
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.') .
1345 print "</div>"; # pane
1348 print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Subscribing using bookmarklet')."\">";
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>";
1352 $bm_subscribe_url = str_replace('%s', '', add_feed_url());
1354 $confirm_str = __('Subscribe to %s in Tiny Tiny RSS?');
1356 $bm_url = htmlspecialchars("javascript:{if(confirm('$confirm_str'.replace('%s',window.location.href)))window.location.href='$bm_subscribe_url'+window.location.href}");
1358 print "<a href=\"$bm_url\" class='visibleLink'>" . __('Subscribe in Tiny Tiny RSS'). "</a>";
1360 print "</div>"; #pane
1362 print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Published articles and generated feeds')."\">";
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>";
1366 $rss_url = '-2::' . htmlspecialchars(get_self_url_prefix() .
1367 "/backend.php?op=rss&id=-2&view-mode=all_articles");;
1369 print "<button onclick=\"return displayDlg('generatedFeed', '$rss_url')\">".
1370 __('Display URL')."</button> ";
1372 print "<button onclick=\"return clearFeedAccessKeys()\">".
1373 __('Clear all generated URLs')."</button> ";
1375 print "</div>"; #pane
1376 print "</div>"; #container
1380 function print_feed_browser($link, $search, $limit, $mode = 1) {
1382 $owner_uid = $_SESSION["uid"];
1385 $search_qpart = "AND (UPPER(feed_url) LIKE UPPER('%$search%') OR
1386 UPPER(title) LIKE UPPER('%$search%'))";
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
1402 ttrss_archived_feeds
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");
1413 while ($line = db_fetch_assoc($result)) {
1417 $feed_url = $line["feed_url"];
1418 $subscribers = $line["subscribers"];
1420 $det_result = db_query($link, "SELECT site_url,title,id
1421 FROM ttrss_feeds WHERE feed_url = '$feed_url' LIMIT 1");
1423 $details = db_fetch_assoc($det_result);
1425 $icon_file = ICONS_DIR . "/" . $details["id"] . ".ico";
1427 if (file_exists($icon_file) && filesize($icon_file) > 0) {
1428 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL .
1429 "/".$details["id"].".ico\">";
1431 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
1434 $check_box = "<input onclick='toggleSelectListRow(this)'
1435 class='feedBrowseCB'
1436 type=\"checkbox\" id=\"FBCHK-" . $details["id"] . "\">";
1438 $class = ($feedctr % 2) ? "even" : "odd";
1440 $feed_url = htmlspecialchars($line["feed_url"]);
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>";
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>";
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 " <span class='subscribers'>($subscribers)</span>
1460 } else if ($mode == 2) {
1461 $feed_url = htmlspecialchars($line["feed_url"]);
1462 $site_url = htmlspecialchars($line["site_url"]);
1463 $title = htmlspecialchars($line["title"]);
1465 $icon_file = ICONS_DIR . "/" . $line["id"] . ".ico";
1467 if (file_exists($icon_file) && filesize($icon_file) > 0) {
1468 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL .
1469 "/".$line["id"].".ico\">";
1471 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
1474 $check_box = "<input onclick='toggleSelectListRow(this)' class='feedBrowseCB'
1475 type=\"checkbox\" id=\"FBCHK-" . $line["id"] . "\">";
1477 $class = ($feedctr % 2) ? "even" : "odd";
1479 if ($line['articles_archived'] > 0) {
1480 $archived = sprintf(__("%d archived articles"), $line['articles_archived']);
1481 $archived = " <span class='subscribers'>($archived)</span>";
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>";
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>";
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>";
1508 if ($feedctr == 0) {
1509 print "<li style=\"text-align : center\"><p>".__('No feeds found.')."</p></li>";