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"];
17 if ($subop == "massSubscribe") {
18 $ids = split(",", db_escape_string($_GET["ids"]));
20 $subscribed = array();
22 foreach ($ids as $id) {
23 $result = db_query($link, "SELECT feed_url,title FROM ttrss_feeds
26 $feed_url = db_escape_string(db_fetch_result($result, 0, "feed_url"));
27 $title = db_escape_string(db_fetch_result($result, 0, "title"));
29 $title_orig = db_fetch_result($result, 0, "title");
31 $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE
32 feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
34 if (db_num_rows($result) == 0) {
35 $result = db_query($link,
36 "INSERT INTO ttrss_feeds (owner_uid,feed_url,title,cat_id)
37 VALUES ('".$_SESSION["uid"]."', '$feed_url', '$title', NULL)");
39 array_push($subscribed, $title_orig);
43 if (count($subscribed) > 0) {
44 $msg = "<b>".__('Subscribed to feeds:')."</b>".
45 "<ul class=\"nomarks\">";
47 foreach ($subscribed as $title) {
48 $msg .= "<li>$title</li>";
52 print format_notice($msg);
56 if ($subop == "browse") {
58 if (!ENABLE_FEED_BROWSER
) {
59 print __("Feed browser is administratively disabled.");
63 print "<div id=\"infoBoxTitle\">".__('Feed Browser')."</div>";
65 print "<div class=\"infoBoxContents\">";
67 $browser_search = db_escape_string($_GET["search"]);
69 //print "<p>".__("Showing top 25 registered feeds, sorted by popularity:")."</p>";
72 <div style='float : right'>
73 <input id=\"feed_browser_search\" size=\"20\" type=\"search\"
74 onfocus=\"javascript:disableHotkeys();\"
75 onblur=\"javascript:enableHotkeys();\"
76 onchange=\"javascript:updateFeedBrowser()\" value=\"$browser_search\">
77 <input type=\"submit\" class=\"button\"
78 onclick=\"javascript:updateFeedBrowser()\" value=\"".__('Search')."\">
81 print __('Top')." <select id=\"feed_browser_limit\">";
83 foreach (array(25, 50, 100, 200) as $l) {
84 $issel = ($l == $limit) ?
"selected" : "";
85 print "<option $issel>$l</option>";
89 <input type=\"submit\" class=\"button\"
90 onclick=\"updateFeedBrowser()\" value=\"".__('Show')."\">";
94 $owner_uid = $_SESSION["uid"];
96 print "<ul class='browseFeedList' id='browseFeedList'>";
97 $subscribe_btn_disabled = print_feed_browser($link, $search, 25) == 0 ?
"disabled" : "";
100 print "<div align='center'>
101 <input type=\"submit\" class=\"button\" id=\"feed_browser_subscribe\"
102 $subscribe_btn_disabled
103 onclick=\"feedBrowserSubscribe()\" value=\"".__('Subscribe')."\">
104 <input type='submit' class='button'
105 onclick=\"closeInfoBox()\" value=\"".__('Cancel')."\"></div>";
111 if ($subop == "editfeed") {
112 $feed_id = db_escape_string($_REQUEST["id"]);
114 $result = db_query($link,
115 "SELECT * FROM ttrss_feeds WHERE id = '$feed_id' AND
116 owner_uid = " . $_SESSION["uid"]);
118 $title = htmlspecialchars(db_fetch_result($result,
121 $icon_file = ICONS_DIR
. "/$feed_id.ico";
123 if (file_exists($icon_file) && filesize($icon_file) > 0) {
124 $feed_icon = "<img width=\"16\" height=\"16\"
125 src=\"" . ICONS_URL
. "/$feed_id.ico\">";
130 print "<div id=\"infoBoxTitle\">".__('Feed Editor')."</div>";
132 print "<div class=\"infoBoxContents\">";
134 print "<form id=\"edit_feed_form\" onsubmit=\"return false\">";
136 print "<input type=\"hidden\" name=\"id\" value=\"$feed_id\">";
137 print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">";
138 print "<input type=\"hidden\" name=\"subop\" value=\"editSave\">";
140 print "<div class=\"dlgSec\">".__("Feed")."</div>";
141 print "<div class=\"dlgSecCont\">";
145 print "<input style=\"font-size : 16px\" size=\"40\" onkeypress=\"return filterCR(event, feedEditSave)\"
146 name=\"title\" value=\"$title\">";
150 $feed_url = db_fetch_result($result, 0, "feed_url");
151 $feed_url = htmlspecialchars(db_fetch_result($result,
156 print __('URL:') . " ";
157 print "<input size=\"40\" onkeypress=\"return filterCR(event, feedEditSave)\"
158 name=\"feed_url\" value=\"$feed_url\">";
162 if (get_pref($link, 'ENABLE_FEED_CATS')) {
164 $cat_id = db_fetch_result($result, 0, "cat_id");
168 print __('Place in category:') . " ";
170 $parent_feed = db_fetch_result($result, 0, "parent_feed");
172 if (sprintf("%d", $parent_feed) > 0) {
173 $disabled = "disabled";
178 print_feed_cat_select($link, "cat_id", $cat_id, $disabled);
185 print __('Link to feed:') . " ";
187 $tmp_result = db_query($link, "SELECT COUNT(id) AS count
188 FROM ttrss_feeds WHERE parent_feed = '$feed_id'");
190 $linked_count = db_fetch_result($tmp_result, 0, "count");
192 $parent_feed = db_fetch_result($result, 0, "parent_feed");
194 if ($linked_count > 0) {
195 $disabled = "disabled";
200 print "<select $disabled name=\"parent_feed\">";
202 print "<option value=\"0\">".__('Not linked')."</option>";
204 if (get_pref($link, 'ENABLE_FEED_CATS')) {
206 $cat_qpart = "AND cat_id = '$cat_id'";
208 $cat_qpart = "AND cat_id IS NULL";
212 $tmp_result = db_query($link, "SELECT id,title FROM ttrss_feeds
213 WHERE id != '$feed_id' AND owner_uid = ".$_SESSION["uid"]." AND
214 (SELECT COUNT(id) FROM ttrss_feeds AS T2 WHERE T2.id = ttrss_feeds.parent_feed) = 0
215 $cat_qpart ORDER BY title");
217 if (db_num_rows($tmp_result) > 0) {
218 print "<option disabled>--------</option>";
221 while ($tmp_line = db_fetch_assoc($tmp_result)) {
222 if ($tmp_line["id"] == $parent_feed) {
223 $is_selected = "selected";
228 $title = truncate_string(htmlspecialchars($tmp_line["title"]), 40);
230 printf("<option $is_selected value='%d'>%s</option>",
231 $tmp_line["id"], $title);
239 print "<div class=\"dlgSec\">".__("Update")."</div>";
240 print "<div class=\"dlgSecCont\">";
242 /* Update Interval */
244 $update_interval = db_fetch_result($result, 0, "update_interval");
246 print_select_hash("update_interval", $update_interval, $update_intervals);
250 if (ALLOW_SELECT_UPDATE_METHOD
) {
251 $update_method = db_fetch_result($result, 0, "update_method");
253 print " " . __('using') . " ";
254 print_select_hash("update_method", $update_method, $update_methods);
257 $purge_interval = db_fetch_result($result, 0, "purge_interval");
259 if (FORCE_ARTICLE_PURGE
== 0) {
265 print __('Article purging:') . " ";
267 print_select_hash("purge_interval", $purge_interval, $purge_intervals);
270 print "<input type='hidden' name='purge_interval' value='$purge_interval'>";
275 print "<div class=\"dlgSec\">".__("Authentication")."</div>";
276 print "<div class=\"dlgSecCont\">";
278 $auth_login = htmlspecialchars(db_fetch_result($result, 0, "auth_login"));
282 print "<tr><td>" . __('Login:') . "</td><td>";
284 print "<input size=\"20\" onkeypress=\"return filterCR(event, feedEditSave)\"
285 name=\"auth_login\" value=\"$auth_login\">";
287 print "</tr><tr><td>" . __("Password:") . "</td><td>";
289 $auth_pass = htmlspecialchars(db_fetch_result($result, 0, "auth_pass"));
291 print "<input size=\"20\" type=\"password\" name=\"auth_pass\"
292 onkeypress=\"return filterCR(event, feedEditSave)\"
293 value=\"$auth_pass\">";
295 print "</td></tr></table>";
298 print "<div class=\"dlgSec\">".__("Options")."</div>";
299 print "<div class=\"dlgSecCont\">";
301 print "<div style=\"line-height : 100%\">";
303 $private = sql_bool_to_bool(db_fetch_result($result, 0, "private"));
306 $checked = "checked";
311 print "<input type=\"checkbox\" name=\"private\" id=\"private\"
312 $checked> <label for=\"private\">".__('Hide from "Other Feeds"')."</label>";
314 $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content"));
317 $checked = "checked";
322 print "<br/><input type=\"checkbox\" id=\"rtl_content\" name=\"rtl_content\"
323 $checked> <label for=\"rtl_content\">".__('Right-to-left content')."</label>";
325 $hidden = sql_bool_to_bool(db_fetch_result($result, 0, "hidden"));
328 $checked = "checked";
333 print "<br/><input type=\"checkbox\" id=\"hidden\" name=\"hidden\"
334 $checked> <label for=\"hidden\">".__('Hide from my feed list')."</label>";
336 $include_in_digest = sql_bool_to_bool(db_fetch_result($result, 0, "include_in_digest"));
338 if ($include_in_digest) {
339 $checked = "checked";
344 print "<br/><input type=\"checkbox\" id=\"include_in_digest\"
345 name=\"include_in_digest\"
346 $checked> <label for=\"include_in_digest\">".__('Include in e-mail digest')."</label>";
349 $always_display_enclosures = sql_bool_to_bool(db_fetch_result($result, 0, "always_display_enclosures"));
351 if ($always_display_enclosures) {
352 $checked = "checked";
357 print "<br/><input type=\"checkbox\" id=\"always_display_enclosures\"
358 name=\"always_display_enclosures\"
359 $checked> <label for=\"always_display_enclosures\">".__('Always display image attachments')."</label>";
362 $cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images"));
365 $checked = "checked";
370 if (ENABLE_SIMPLEPIE
&& SIMPLEPIE_CACHE_IMAGES
) {
374 $disabled = "disabled";
375 $label_class = "class='insensitive'";
378 print "<br/><input type=\"checkbox\" id=\"cache_images\"
379 name=\"cache_images\" $disabled
380 $checked> <label $label_class for=\"cache_images\">".
381 __('Cache images locally')."</label>";
389 $title = htmlspecialchars($title, ENT_QUOTES
);
391 print "<div class='dlgButtons'>
392 <div style=\"float : left\">
393 <input type='submit' class='button'
394 onclick='return unsubscribeFeed($feed_id, \"$title\")' value=\"".__('Unsubscribe')."\">
396 <input type=\"submit\" class=\"button\"
397 onclick=\"return feedEditSave()\" value=\"".__('Save')."\">
398 <input type='submit' class='button'
399 onclick=\"return feedEditCancel()\" value=\"".__('Cancel')."\">
405 if ($subop == "editfeeds") {
407 $feed_ids = db_escape_string($_REQUEST["ids"]);
409 print "<div id=\"infoBoxTitle\">".__('Multiple Feed Editor')."</div>";
411 print "<div class=\"infoBoxContents\">";
413 print "<form id=\"batch_edit_feed_form\" onsubmit=\"return false\">";
415 print "<input type=\"hidden\" name=\"ids\" value=\"$feed_ids\">";
416 print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">";
417 print "<input type=\"hidden\" name=\"subop\" value=\"batchEditSave\">";
419 print "<div class=\"dlgSec\">".__("Feed")."</div>";
420 print "<div class=\"dlgSecCont\">";
424 print "<input disabled style=\"font-size : 16px\" size=\"35\" onkeypress=\"return filterCR(event, feedEditSave)\"
425 name=\"title\" value=\"$title\">";
427 batch_edit_cbox("title");
433 print __('URL:') . " ";
434 print "<input disabled size=\"40\" onkeypress=\"return filterCR(event, feedEditSave)\"
435 name=\"feed_url\" value=\"$feed_url\">";
437 batch_edit_cbox("feed_url");
441 if (get_pref($link, 'ENABLE_FEED_CATS')) {
445 print __('Place in category:') . " ";
447 print_feed_cat_select($link, "cat_id", $cat_id, "disabled");
449 batch_edit_cbox("cat_id");
455 print "<div class=\"dlgSec\">".__("Update")."</div>";
456 print "<div class=\"dlgSecCont\">";
458 /* Update Interval */
460 print_select_hash("update_interval", $update_interval, $update_intervals,
463 batch_edit_cbox("update_interval");
467 if (ALLOW_SELECT_UPDATE_METHOD
) {
468 print " " . __('using') . " ";
469 print_select_hash("update_method", $update_method, $update_methods,
471 batch_edit_cbox("update_method");
476 if (FORCE_ARTICLE_PURGE
!= 0) {
480 print __('Article purging:') . " ";
482 print_select_hash("purge_interval", $purge_interval, $purge_intervals,
485 batch_edit_cbox("purge_interval");
489 print "<div class=\"dlgSec\">".__("Authentication")."</div>";
490 print "<div class=\"dlgSecCont\">";
492 print __('Login:') . " ";
493 print "<input disabled size=\"15\" onkeypress=\"return filterCR(event, feedEditSave)\"
494 name=\"auth_login\" value=\"$auth_login\">";
496 batch_edit_cbox("auth_login");
498 print " " . __("Password:") . " ";
500 print "<input disabled size=\"15\" type=\"password\" name=\"auth_pass\"
501 onkeypress=\"return filterCR(event, feedEditSave)\"
502 value=\"$auth_pass\">";
504 batch_edit_cbox("auth_pass");
507 print "<div class=\"dlgSec\">".__("Options")."</div>";
508 print "<div class=\"dlgSecCont\">";
510 print "<div style=\"line-height : 100%\">";
512 print "<input disabled type=\"checkbox\" name=\"private\" id=\"private\"
513 $checked> <label id=\"private_l\" class='insensitive' for=\"private\">".__('Hide from "Other Feeds"')."</label>";
515 print " "; batch_edit_cbox("private", "private_l");
517 print "<br/><input disabled type=\"checkbox\" id=\"rtl_content\" name=\"rtl_content\"
518 $checked> <label class='insensitive' id=\"rtl_content_l\" for=\"rtl_content\">".__('Right-to-left content')."</label>";
520 print " "; batch_edit_cbox("rtl_content", "rtl_content_l");
522 print "<br/><input disabled type=\"checkbox\" id=\"hidden\" name=\"hidden\"
523 $checked> <label class='insensitive' id=\"hidden_l\" for=\"hidden\">".__('Hide from my feed list')."</label>";
525 print " "; batch_edit_cbox("hidden", "hidden_l");
527 print "<br/><input disabled type=\"checkbox\" id=\"include_in_digest\"
528 name=\"include_in_digest\"
529 $checked> <label id=\"include_in_digest_l\" class='insensitive' for=\"include_in_digest\">".__('Include in e-mail digest')."</label>";
531 print " "; batch_edit_cbox("include_in_digest", "include_in_digest_l");
533 print "<br/><input disabled type=\"checkbox\" id=\"always_display_enclosures\"
534 name=\"always_display_enclosures\"
535 $checked> <label id=\"always_display_enclosures_l\" class='insensitive' for=\"always_display_enclosures\">".__('Always display image attachments')."</label>";
537 print " "; batch_edit_cbox("always_display_enclosures", "always_display_enclosures_l");
539 print "<br/><input disabled type=\"checkbox\" id=\"cache_images\"
540 name=\"cache_images\"
541 $checked> <label class='insensitive' id=\"cache_images_l\"
542 for=\"cache_images\">".
543 __('Cache images locally')."</label>";
546 if (ENABLE_SIMPLEPIE
&& SIMPLEPIE_CACHE_IMAGES
) {
547 print " "; batch_edit_cbox("cache_images", "cache_images_l");
555 print "<div class='dlgButtons'>
556 <input type=\"submit\" class=\"button\"
557 onclick=\"return feedsEditSave()\" value=\"".__('Save')."\">
558 <input type='submit' class='button'
559 onclick=\"return feedEditCancel()\" value=\"".__('Cancel')."\">
565 if ($subop == "editSave" ||
$subop == "batchEditSave") {
567 $feed_title = db_escape_string(trim($_POST["title"]));
568 $feed_link = db_escape_string(trim($_POST["feed_url"]));
569 $upd_intl = db_escape_string($_POST["update_interval"]);
570 $purge_intl = db_escape_string($_POST["purge_interval"]);
571 $feed_id = db_escape_string($_POST["id"]); /* editSave */
572 $feed_ids = db_escape_string($_POST["ids"]); /* batchEditSave */
573 $cat_id = db_escape_string($_POST["cat_id"]);
574 $auth_login = db_escape_string(trim($_POST["auth_login"]));
575 $auth_pass = db_escape_string(trim($_POST["auth_pass"]));
576 $parent_feed = db_escape_string($_POST["parent_feed"]);
577 $private = checkbox_to_sql_bool(db_escape_string($_POST["private"]));
578 $rtl_content = checkbox_to_sql_bool(db_escape_string($_POST["rtl_content"]));
579 $hidden = checkbox_to_sql_bool(db_escape_string($_POST["hidden"]));
580 $include_in_digest = checkbox_to_sql_bool(
581 db_escape_string($_POST["include_in_digest"]));
582 $cache_images = checkbox_to_sql_bool(
583 db_escape_string($_POST["cache_images"]));
584 $update_method = (int) db_escape_string($_POST["update_method"]);
586 $always_display_enclosures = checkbox_to_sql_bool(
587 db_escape_string($_POST["always_display_enclosures"]));
589 if (get_pref($link, 'ENABLE_FEED_CATS')) {
590 if ($cat_id && $cat_id != 0) {
591 $category_qpart = "cat_id = '$cat_id',";
592 $category_qpart_nocomma = "cat_id = '$cat_id'";
594 $category_qpart = 'cat_id = NULL,';
595 $category_qpart_nocomma = 'cat_id = NULL';
598 $category_qpart = "";
599 $category_qpart_nocomma = "";
602 if ($parent_feed && $parent_feed != 0) {
603 $parent_qpart = "parent_feed = '$parent_feed'";
605 $parent_qpart = 'parent_feed = NULL';
608 if (ENABLE_SIMPLEPIE
&& SIMPLEPIE_CACHE_IMAGES
) {
609 $cache_images_qpart = "cache_images = $cache_images,";
611 $cache_images_qpart = "";
614 if ($subop == "editSave") {
616 $result = db_query($link, "UPDATE ttrss_feeds SET
617 $category_qpart $parent_qpart,
618 title = '$feed_title', feed_url = '$feed_link',
619 update_interval = '$upd_intl',
620 purge_interval = '$purge_intl',
621 auth_login = '$auth_login',
622 auth_pass = '$auth_pass',
624 rtl_content = $rtl_content,
627 include_in_digest = $include_in_digest,
628 always_display_enclosures = $always_display_enclosures,
629 update_method = '$update_method'
630 WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]);
632 if (get_pref($link, 'ENABLE_FEED_CATS')) {
633 # update linked feed categories
634 $result = db_query($link, "UPDATE ttrss_feeds SET
635 $category_qpart_nocomma WHERE parent_feed = '$feed_id' AND
636 owner_uid = " . $_SESSION["uid"]);
638 } else if ($subop == "batchEditSave") {
639 $feed_data = array();
641 foreach (array_keys($_POST) as $k) {
642 if ($k != "op" && $k != "subop" && $k != "ids") {
643 $feed_data[$k] = $_POST[$k];
647 db_query($link, "BEGIN");
649 foreach (array_keys($feed_data) as $k) {
655 $qpart = "title = '$feed_title'";
659 $qpart = "feed_url = '$feed_link'";
662 case "update_interval":
663 $qpart = "update_interval = '$upd_intl'";
666 case "purge_interval":
667 $qpart = "purge_interval = '$purge_intl'";
671 $qpart = "auth_login = '$auth_login'";
675 $qpart = "auth_pass = '$auth_pass'";
679 $qpart = "private = '$private'";
683 $qpart = "hidden = '$hidden'";
686 case "include_in_digest":
687 $qpart = "include_in_digest = '$include_in_digest'";
690 case "always_display_enclosures":
691 $qpart = "always_display_enclosures = '$always_display_enclosures'";
695 $qpart = "cache_images = '$cache_images'";
699 $qpart = "rtl_content = '$rtl_content'";
702 case "update_method":
703 $qpart = "update_method = '$update_method'";
707 $qpart = $category_qpart_nocomma;
714 "UPDATE ttrss_feeds SET $qpart WHERE id IN ($feed_ids)
715 AND owner_uid = " . $_SESSION["uid"]);
720 db_query($link, "COMMIT");
725 if ($subop == "remove") {
727 $ids = split(",", db_escape_string($_GET["ids"]));
729 foreach ($ids as $id) {
733 db_query($link, "DELETE FROM ttrss_feeds
734 WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
736 $icons_dir = ICONS_DIR
;
738 if (file_exists($icons_dir . "/$id.ico")) {
739 unlink($icons_dir . "/$id.ico");
742 ccache_remove($link, $id, $_SESSION["uid"]);
745 label_remove($link, -11-$id, $_SESSION["uid"]);
746 ccache_remove($link, -11-$id, $_SESSION["uid"]);
751 if ($subop == "clear") {
752 $id = db_escape_string($_GET["id"]);
753 clear_feed_articles($link, $id);
756 if ($subop == "rescore") {
757 $ids = split(",", db_escape_string($_GET["ids"]));
759 foreach ($ids as $id) {
761 $filters = load_filters($link, $id, $_SESSION["uid"], 6);
763 $result = db_query($link, "SELECT title, content, link, ref_id FROM
764 ttrss_user_entries, ttrss_entries
765 WHERE ref_id = id AND feed_id = '$id' AND
766 owner_uid = " .$_SESSION['uid']."
771 while ($line = db_fetch_assoc($result)) {
773 $article_filters = get_article_filters($filters, $line['title'],
774 $line['content'], $line['link']);
776 $new_score = calculate_article_score($article_filters);
778 if (!$scores[$new_score]) $scores[$new_score] = array();
780 array_push($scores[$new_score], $line['ref_id']);
783 foreach (array_keys($scores) as $s) {
785 db_query($link, "UPDATE ttrss_user_entries SET score = '$s',
787 ref_id IN (" . join(',', $scores[$s]) . ")");
788 } else if ($s < -500) {
789 db_query($link, "UPDATE ttrss_user_entries SET score = '$s',
791 ref_id IN (" . join(',', $scores[$s]) . ")");
793 db_query($link, "UPDATE ttrss_user_entries SET score = '$s' WHERE
794 ref_id IN (" . join(',', $scores[$s]) . ")");
799 print __("All done.");
803 if ($subop == "rescoreAll") {
805 $result = db_query($link,
806 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION['uid']);
808 while ($feed_line = db_fetch_assoc($result)) {
810 $id = $feed_line["id"];
812 $filters = load_filters($link, $id, $_SESSION["uid"], 6);
814 $tmp_result = db_query($link, "SELECT title, content, link, ref_id FROM
815 ttrss_user_entries, ttrss_entries
816 WHERE ref_id = id AND feed_id = '$id' AND
817 owner_uid = " .$_SESSION['uid']."
822 while ($line = db_fetch_assoc($tmp_result)) {
824 $article_filters = get_article_filters($filters, $line['title'],
825 $line['content'], $line['link']);
827 $new_score = calculate_article_score($article_filters);
829 if (!$scores[$new_score]) $scores[$new_score] = array();
831 array_push($scores[$new_score], $line['ref_id']);
834 foreach (array_keys($scores) as $s) {
836 db_query($link, "UPDATE ttrss_user_entries SET score = '$s',
838 ref_id IN (" . join(',', $scores[$s]) . ")");
840 db_query($link, "UPDATE ttrss_user_entries SET score = '$s' WHERE
841 ref_id IN (" . join(',', $scores[$s]) . ")");
846 print __("All done.");
850 if ($subop == "add") {
852 if (!WEB_DEMO_MODE
) {
854 $feed_url = db_escape_string(trim($_REQUEST["feed_url"]));
855 $cat_id = db_escape_string($_REQUEST["cat_id"]);
856 $p_from = db_escape_string($_REQUEST["from"]);
858 /* only read authentication information from POST */
860 $auth_login = db_escape_string(trim($_POST["auth_login"]));
861 $auth_pass = db_escape_string(trim($_POST["auth_pass"]));
863 if ($p_from != 'tt-rss') {
866 <title>Tiny Tiny RSS</title>
867 <link rel=\"stylesheet\" type=\"text/css\" href=\"utility.css\">
870 <img class=\"floatingLogo\" src=\"images/ttrss_logo.png\"
871 alt=\"Tiny Tiny RSS\"/>
872 <h1>Subscribe to feed...</h1>";
875 if (subscribe_to_feed($link, $feed_url, $cat_id, $auth_login, $auth_pass)) {
876 print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url));
878 print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
881 if ($p_from != 'tt-rss') {
882 $tt_uri = ($_SERVER['HTTPS'] != "on" ?
'http://' : 'https://') . $_SERVER['HTTP_HOST'] . preg_replace('/backend\.php.*$/', 'tt-rss.php', $_SERVER["REQUEST_URI"]);
885 $tp_uri = ($_SERVER['HTTPS'] != "on" ?
'http://' : 'https://') . $_SERVER['HTTP_HOST'] . preg_replace('/backend\.php.*$/', 'prefs.php', $_SERVER["REQUEST_URI"]);
887 $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE
888 feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
890 $feed_id = db_fetch_result($result, 0, "id");
895 print "<form method=\"GET\" style='display: inline'
897 <input type=\"hidden\" name=\"tab\" value=\"feedConfig\">
898 <input type=\"hidden\" name=\"subop\" value=\"editFeed\">
899 <input type=\"hidden\" name=\"subopparam\" value=\"$feed_id\">
900 <input type=\"submit\" value=\"".__("Edit subscription options")."\">
904 print "<form style='display: inline' method=\"GET\" action=\"$tt_uri\">
905 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
908 print "</body></html>";
915 if ($subop == "categorize") {
917 if (!WEB_DEMO_MODE
) {
919 $ids = split(",", db_escape_string($_GET["ids"]));
921 $cat_id = db_escape_string($_GET["cat_id"]);
924 $cat_id_qpart = 'NULL';
926 $cat_id_qpart = "'$cat_id'";
929 db_query($link, "BEGIN");
931 foreach ($ids as $id) {
933 db_query($link, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
934 WHERE id = '$id' AND parent_feed IS NULL
935 AND owner_uid = " . $_SESSION["uid"]);
937 # update linked feed categories
938 db_query($link, "UPDATE ttrss_feeds SET
939 cat_id = $cat_id_qpart WHERE parent_feed = '$id' AND
940 owner_uid = " . $_SESSION["uid"]);
944 db_query($link, "COMMIT");
949 if ($subop == "editCats") {
951 $action = $_REQUEST["action"];
953 if ($action == "save") {
955 $cat_title = db_escape_string(trim($_REQUEST["value"]));
956 $cat_id = db_escape_string($_GET["cid"]);
958 db_query($link, "BEGIN");
960 $result = db_query($link, "SELECT title FROM ttrss_feed_categories
961 WHERE id = '$cat_id' AND owner_uid = ".$_SESSION["uid"]);
963 if (db_num_rows($result) == 1) {
965 $old_title = db_fetch_result($result, 0, "title");
967 if ($cat_title != "") {
968 $result = db_query($link, "UPDATE ttrss_feed_categories SET
969 title = '$cat_title' WHERE id = '$cat_id' AND
970 owner_uid = ".$_SESSION["uid"]);
977 print $_REQUEST["value"];
980 db_query($link, "COMMIT");
986 print "<div id=\"infoBoxTitle\">".__('Category editor')."</div>";
988 print "<div class=\"infoBoxContents\">";
991 if ($action == "add") {
993 if (!WEB_DEMO_MODE
) {
995 $feed_cat = db_escape_string(trim($_GET["cat"]));
997 $result = db_query($link,
998 "SELECT id FROM ttrss_feed_categories
999 WHERE title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]);
1001 if (db_num_rows($result) == 0) {
1003 $result = db_query($link,
1004 "INSERT INTO ttrss_feed_categories (owner_uid,title)
1005 VALUES ('".$_SESSION["uid"]."', '$feed_cat')");
1009 print_warning(T_sprintf("Category <b>$%s</b> already exists in the database.",
1016 if ($action == "remove") {
1018 if (!WEB_DEMO_MODE
) {
1020 $ids = split(",", db_escape_string($_GET["ids"]));
1022 foreach ($ids as $id) {
1024 db_query($link, "BEGIN");
1026 $result = db_query($link,
1027 "SELECT count(id) as num_feeds FROM ttrss_feeds
1028 WHERE cat_id = '$id'");
1030 $num_feeds = db_fetch_result($result, 0, "num_feeds");
1032 if ($num_feeds == 0) {
1033 db_query($link, "DELETE FROM ttrss_feed_categories
1034 WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
1036 ccache_remove($link, $id, $_SESSION["uid"], true);
1040 print format_warning(__("Unable to delete non empty feed categories."));
1044 db_query($link, "COMMIT");
1049 print "<div class=\"prefGenericAddBox\">
1050 <input id=\"fadd_cat\"
1051 onkeypress=\"return filterCR(event, addFeedCat)\"
1052 onkeyup=\"toggleSubmitNotEmpty(this, 'catadd_submit_btn')\"
1053 onchange=\"toggleSubmitNotEmpty(this, 'catadd_submit_btn')\"
1056 type=\"submit\" class=\"button\" disabled=\"true\" id=\"catadd_submit_btn\"
1057 onclick=\"javascript:addFeedCat()\" value=\"".__('Create category')."\"></div>";
1059 $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories
1060 WHERE owner_uid = ".$_SESSION["uid"]."
1065 if (db_num_rows($result) != 0) {
1067 print "<table width=\"100%\" class=\"prefFeedCatList\"
1068 cellspacing=\"0\">";
1070 print "<tr><td class=\"selectPrompt\" colspan=\"8\">
1072 <a href=\"javascript:selectPrefRows('fcat', true)\">".__('All')."</a>,
1073 <a href=\"javascript:selectPrefRows('fcat', false)\">".__('None')."</a>
1078 print "<div class=\"prefFeedCatHolder\">";
1080 print "<form id=\"feed_cat_edit_form\" onsubmit=\"return false\">";
1082 print "<table width=\"100%\" class=\"prefFeedCatList\"
1083 cellspacing=\"0\" id=\"prefFeedCatList\">";
1087 while ($line = db_fetch_assoc($result)) {
1089 $class = ($lnum %
2) ?
"even" : "odd";
1091 $cat_id = $line["id"];
1092 $this_row_id = "id=\"FCATR-$cat_id\"";
1094 print "<tr class=\"$class\" $this_row_id>";
1096 $edit_title = htmlspecialchars($line["title"]);
1098 print "<td width='5%' align='center'><input
1099 onclick='toggleSelectPrefRow(this, \"fcat\");'
1100 type=\"checkbox\" id=\"FCCHK-$cat_id\"></td>";
1102 print "<td><span id=\"FCATT-$cat_id\">" .
1103 $edit_title . "</span></td>";
1117 print "<p>".__('No feed categories defined.')."</p>";
1120 print "<div style='float : right'>
1121 <input type='submit' class='button'
1122 onclick=\"selectTab('feedConfig')\" value=\"".__('Close this window')."\"></div>";
1124 print "<div id=\"catOpToolbar\">";
1127 <input type=\"submit\" class=\"button\" disabled=\"true\"
1128 onclick=\"return removeSelectedFeedCats()\" value=\"".__('Remove')."\">";
1140 set_pref($link, "_PREFS_ACTIVE_TAB", "feedConfig");
1142 $result = db_query($link, "SELECT COUNT(id) AS num_errors
1143 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
1145 $num_errors = db_fetch_result($result, 0, "num_errors");
1147 if ($num_errors > 0) {
1149 print format_notice("<a href=\"javascript:showFeedsWithErrors()\">".
1150 __('Some feeds have update errors (click for details)')."</a>");
1153 $feed_search = db_escape_string($_GET["search"]);
1155 if (array_key_exists("search", $_GET)) {
1156 $_SESSION["prefs_feed_search"] = $feed_search;
1158 $feed_search = $_SESSION["prefs_feed_search"];
1161 print "<div class=\"feedEditSearch\">
1162 <input id=\"feed_search\" size=\"20\" type=\"search\"
1163 onfocus=\"javascript:disableHotkeys();\"
1164 onblur=\"javascript:enableHotkeys();\"
1165 onchange=\"javascript:updateFeedList()\" value=\"$feed_search\">
1166 <input type=\"submit\" class=\"button\"
1167 onclick=\"javascript:updateFeedList()\" value=\"".__('Search')."\">
1170 print "<input onclick=\"javascript:displayDlg('quickAddFeed')\"
1171 type=\"submit\" id=\"subscribe_to_feed_btn\"
1172 class=\"button\" value=\"".__('Subscribe to feed')."\">";
1174 if (ENABLE_FEED_BROWSER
&& !SINGLE_USER_MODE
) {
1175 print " <input type=\"submit\" class=\"button\"
1176 id=\"top25_feeds_btn\"
1177 onclick=\"javascript:browseFeeds()\" value=\"".__('More Feeds')."\">";
1180 $feeds_sort = db_escape_string($_GET["sort"]);
1182 if (!$feeds_sort ||
$feeds_sort == "undefined") {
1183 $feeds_sort = $_SESSION["pref_sort_feeds"];
1184 if (!$feeds_sort) $feeds_sort = "title";
1187 $_SESSION["pref_sort_feeds"] = $feeds_sort;
1191 $feed_search = split(" ", $feed_search);
1194 foreach ($feed_search as $token) {
1196 $token = trim($token);
1198 array_push($tokens, "(UPPER(F1.title) LIKE UPPER('%$token%') OR
1199 UPPER(C1.title) LIKE UPPER('%$token%') OR
1200 UPPER(F1.feed_url) LIKE UPPER('%$token%'))");
1203 $search_qpart = "(" . join($tokens, " AND ") . ") AND ";
1209 $show_last_article_info = false;
1210 $show_last_article_checked = "";
1211 $show_last_article_qpart = "";
1213 if ($_GET["slat"] == "true") {
1214 $show_last_article_info = true;
1215 $show_last_article_checked = "checked";
1216 $show_last_article_qpart = ", (SELECT ".SUBSTRING_FOR_DATE
."(MAX(updated),1,16) FROM ttrss_user_entries,
1217 ttrss_entries WHERE ref_id = ttrss_entries.id
1218 AND feed_id = F1.id) AS last_article";
1219 } else if ($feeds_sort == "last_article") {
1220 $feeds_sort = "title";
1223 if (get_pref($link, 'ENABLE_FEED_CATS')) {
1224 $order_by_qpart = "category,$feeds_sort,title";
1226 $order_by_qpart = "$feeds_sort,title";
1229 $result = db_query($link, "SELECT
1233 ".SUBSTRING_FOR_DATE
."(F1.last_updated,1,16) AS last_updated,
1239 F2.title AS parent_title,
1240 C1.title AS category,
1242 F1.include_in_digest
1243 $show_last_article_qpart
1246 LEFT JOIN ttrss_feeds AS F2
1247 ON (F1.parent_feed = F2.id)
1248 LEFT JOIN ttrss_feed_categories AS C1
1249 ON (F1.cat_id = C1.id)
1251 $search_qpart F1.owner_uid = '".$_SESSION["uid"]."'
1252 ORDER by $order_by_qpart");
1254 if (db_num_rows($result) != 0) {
1256 // print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>";
1258 print "<p><table width=\"100%\" cellspacing=\"0\"
1259 class=\"prefFeedList\" id=\"prefFeedList\">";
1260 print "<tr><td class=\"selectPrompt\" colspan=\"8\">".
1261 "<div style='float : right'>".
1262 "<input id='show_last_article_times' type='checkbox' onchange='feedlistToggleSLAT()'
1263 $show_last_article_checked><label
1264 for='show_last_article_times'>".__('Show last article times')."</label></div>".
1266 <a href=\"javascript:selectPrefRows('feed', true)\">".__('All')."</a>,
1267 <a href=\"javascript:selectPrefRows('feed', false)\">".__('None')."</a>
1270 if (!get_pref($link, 'ENABLE_FEED_CATS')) {
1271 print "<tr class=\"title\">
1272 <td width='5%' align='center'> </td>";
1274 if (get_pref($link, 'ENABLE_FEED_ICONS')) {
1275 print "<td width='3%'> </td>";
1278 print "<td width='60%'><a href=\"javascript:updateFeedList('title')\">".__('Title')."</a></td>";
1280 if ($show_last_article_info) {
1281 print "<td width='20%' align='right'><a href=\"javascript:updateFeedList('last_article')\">".__('Last Article')."</a></td>";
1284 print "<td width='20%' align='right'><a href=\"javascript:updateFeedList('last_updated')\">".__('Updated')."</a></td>";
1291 while ($line = db_fetch_assoc($result)) {
1293 $feed_id = $line["id"];
1294 $cat_id = $line["cat_id"];
1296 $edit_title = htmlspecialchars($line["title"]);
1297 $edit_cat = htmlspecialchars($line["category"]);
1299 $hidden = sql_bool_to_bool($line["hidden"]);
1301 $last_error = $line["last_error"];
1303 if (!$edit_cat) $edit_cat = __("Uncategorized");
1305 $last_updated = $line["last_updated"];
1307 if (!$last_updated) {
1308 $last_updated = "—";
1309 } else if (get_pref($link, 'HEADLINES_SMART_DATE')) {
1310 $last_updated = smart_date_time(strtotime($last_updated));
1312 $short_date = get_pref($link, 'SHORT_DATE_FORMAT');
1313 $last_updated = date($short_date, strtotime($last_updated));
1316 $last_article = $line["last_article"];
1318 if (!$last_article) {
1319 $last_article = "—";
1320 } else if (get_pref($link, 'HEADLINES_SMART_DATE')) {
1321 $last_article = smart_date_time(strtotime($last_article));
1323 $short_date = get_pref($link, 'SHORT_DATE_FORMAT');
1324 $last_article = date($short_date, strtotime($last_article));
1327 if (get_pref($link, 'ENABLE_FEED_CATS') && $cur_cat_id != $cat_id) {
1330 print "<tr><td colspan=\"6\" class=\"feedEditCat\">$edit_cat</td></tr>";
1332 print "<tr class=\"title\">
1333 <td width='5%'> </td>";
1335 if (get_pref($link, 'ENABLE_FEED_ICONS')) {
1336 print "<td width='3%'> </td>";
1339 print "<td width='60%'><a href=\"javascript:updateFeedList('title')\">".__('Title')."</a></td>";
1341 if ($show_last_article_info) {
1342 print "<td width='20%' align='right'>
1343 <a href=\"javascript:updateFeedList('last_article')\">".__('Last Article')."</a></td>";
1346 print "<td width='20%' align='right'>
1347 <a href=\"javascript:updateFeedList('last_updated')\">".__('Updated')."</a></td>";
1349 $cur_cat_id = $cat_id;
1352 $class = ($lnum %
2) ?
"even" : "odd";
1353 $this_row_id = "id=\"FEEDR-$feed_id\"";
1355 print "<tr class=\"$class\" $this_row_id>";
1357 $icon_file = ICONS_DIR
. "/$feed_id.ico";
1359 if (file_exists($icon_file) && filesize($icon_file) > 0) {
1360 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL
. "/$feed_id.ico\">";
1362 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
1365 print "<td class='feedSelect'><input onclick='toggleSelectPrefRow(this, \"feed\");'
1366 type=\"checkbox\" id=\"FRCHK-".$line["id"]."\"></td>";
1368 $onclick = "onclick='editFeed($feed_id)' title='".__('Click to edit')."'";
1370 if (get_pref($link, 'ENABLE_FEED_ICONS')) {
1371 print "<td $onclick class='feedIcon'>$feed_icon</td>";
1375 $edit_title = "<span class=\"insensitive\">$edit_title ".
1376 __('(Hidden)')."</span>";
1377 $last_updated = "<span class=\"insensitive\">$last_updated</span>";
1378 $last_article = "<span class=\"insensitive\">$last_article</span>";
1382 $edit_title = "<span class=\"feed_error\">$edit_title</span>";
1383 $last_updated = "<span class=\"feed_error\">$last_updated</span>";
1384 $last_article = "<span class=\"feed_error\">$last_article</span>";
1387 $parent_title = $line["parent_title"];
1388 if ($parent_title) {
1389 $linked_to = sprintf(__("(linked to %s)"), $parent_title);
1390 $parent_title = "<span class='groupPrompt'>$linked_to</span>";
1393 print "<td $onclick>" . "$edit_title $parent_title" . "</td>";
1395 if ($show_last_article_info) {
1396 print "<td align='right' $onclick>" .
1397 "$last_article</td>";
1400 print "<td $onclick align='right'>$last_updated</td>";
1411 print "<div id=\"feedOpToolbar\">";
1413 if (get_pref($link, 'ENABLE_FEED_CATS')) {
1415 print __('Selection:') . " ";
1417 print_feed_cat_select($link, "sfeed_set_fcat", "", "disabled");
1419 print " <input type=\"submit\" class=\"button\" disabled=\"true\"
1420 onclick=\"javascript:categorizeSelectedFeeds()\" value=\"".
1421 __('Recategorize')."\">";
1426 print "<select id=\"feedActionChooser\" onchange=\"feedActionChange()\">
1427 <option value=\"facDefault\" selected>".__('Actions...')."</option>
1428 <optgroup label=\"".__('Selection:')."\">
1429 <option value=\"facEdit\">".__('Edit')."</option>";
1431 if (FORCE_ARTICLE_PURGE
== 0) {
1433 "<option value=\"facPurge\">".__('Manual purge')."</option>";
1437 <option value=\"facClear\">".__('Clear feed data')."</option>
1438 <option value=\"facRescore\">".__('Rescore articles')."</option>
1439 <option value=\"facUnsubscribe\">".__('Unsubscribe')."</option>";
1441 print "</optgroup>";
1443 if (get_pref($link, 'ENABLE_FEED_CATS')) {
1445 print "<optgroup label=\"".__('Other:')."\">
1446 <option value=\"facEditCats\">".__('Edit categories')."
1457 if (!$feed_search) {
1458 print_warning(__("You don't have any subscribed feeds."));
1460 print_warning(__('No matching feeds found.'));
1466 print "<h3>".__('OPML')."</h3>
1468 <div style='float : left'>
1469 <form enctype=\"multipart/form-data\" method=\"POST\" action=\"opml.php\">
1470 ".__('File:')." <input id=\"opml_file\" name=\"opml_file\" type=\"file\">
1471 <input type=\"hidden\" name=\"op\" value=\"Import\">
1472 <input class=\"button\" onclick=\"return validateOpmlImport();\"
1473 type=\"submit\" value=\"".__('Import')."\">
1478 print "<input type=\"submit\"
1479 class=\"button\" onclick=\"gotoExportOpml()\"
1480 value=\"".__('Export OPML')."\">";
1483 print "<h3>" . __("Firefox Integration") . "</h3>";
1485 print "<p>" . __('This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.');
1486 print "</p><p> <a class='visibleLinkB' href='javascript:window.navigator.registerContentHandler(" .
1487 "\"application/vnd.mozilla.maybe.feed\", " .
1488 "\"" . add_feed_url() . "\", " . " \"Tiny Tiny RSS\")'>" .
1489 __('Click here to register this site as a feed reader.') . "</a></p>";
1492 print "<h3>".__("Published articles")."</h3>";
1494 if (!get_pref($link, "_PREFS_PUBLISH_KEY")) {
1495 set_pref($link, "_PREFS_PUBLISH_KEY", generate_publish_key());
1498 print "<p>".__('Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.')."</p>";
1500 $url_path = article_publish_url($link);
1502 print "<p><a class=\"visibleLinkB\" id=\"pubGenAddress\" target=\"_blank\" href=\"$url_path\">".__("Link to published articles feed.")."</a></p>";
1504 print "<p><input type=\"submit\" onclick=\"return pubRegenKey()\" class=\"button\"
1505 value=\"".__('Generate another link')."\">";
1506 /* print " <input type=\"submit\" onclick=\"return pubToClipboard()\" class=\"button\"
1507 value=\"".__('Copy link to clipboard')."\">"; */
1512 function print_feed_browser($link, $search, $limit) {
1514 $owner_uid = $_SESSION["uid"];
1517 $search_qpart = "AND (UPPER(feed_url) LIKE UPPER('%$search%') OR
1518 UPPER(title) LIKE UPPER('%$search%'))";
1523 $result = db_query($link, "SELECT feed_url, subscribers FROM
1524 ttrss_feedbrowser_cache WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
1525 WHERE tf.feed_url = ttrss_feedbrowser_cache.feed_url
1526 AND owner_uid = '$owner_uid') $search_qpart
1527 ORDER BY subscribers DESC LIMIT $limit");
1531 while ($line = db_fetch_assoc($result)) {
1532 $feed_url = $line["feed_url"];
1533 $subscribers = $line["subscribers"];
1535 $det_result = db_query($link, "SELECT site_url,title,id
1536 FROM ttrss_feeds WHERE feed_url = '$feed_url' LIMIT 1");
1538 $details = db_fetch_assoc($det_result);
1540 $icon_file = ICONS_DIR
. "/" . $details["id"] . ".ico";
1542 if (file_exists($icon_file) && filesize($icon_file) > 0) {
1543 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL
.
1544 "/".$details["id"].".ico\">";
1546 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
1549 $check_box = "<input onclick='toggleSelectListRow(this)' class='feedBrowseCB'
1550 type=\"checkbox\" id=\"FBCHK-" . $details["id"] . "\">";
1552 $class = ($feedctr %
2) ?
"even" : "odd";
1554 if ($details["site_url"]) {
1555 $site_url = "<a target=\"_blank\" href=\"".$details["site_url"]."\">
1556 <img style='border-width : 0px' src='images/www.png' alt='www'></a>";
1561 print "<li class='$class' id=\"FBROW-".$details["id"]."\">$check_box".
1562 "$feed_icon " . $details["title"] .
1563 " <span class='subscribers'>($subscribers)</span>
1570 if ($feedctr == 0) {
1571 print "<li style=\"text-align : center\"><p>".__('No feeds found.')."</p></li>";