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 == "massSubscribe") {
19 $ids = split(",", db_escape_string($_REQUEST["ids"]));
21 $subscribed = array();
23 foreach ($ids as $id) {
26 $result = db_query($link, "SELECT feed_url,title FROM ttrss_feeds
28 } else if ($mode == 2) {
29 $result = db_query($link, "SELECT * FROM ttrss_archived_feeds
30 WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
31 $orig_id = db_escape_string(db_fetch_result($result, 0, "id"));
32 $site_url = db_escape_string(db_fetch_result($result, 0, "site_url"));
35 $feed_url = db_escape_string(db_fetch_result($result, 0, "feed_url"));
36 $title = db_escape_string(db_fetch_result($result, 0, "title"));
38 $title_orig = db_fetch_result($result, 0, "title");
40 $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE
41 feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
43 if (db_num_rows($result) == 0) {
45 $result = db_query($link,
46 "INSERT INTO ttrss_feeds (owner_uid,feed_url,title,cat_id)
47 VALUES ('".$_SESSION["uid"]."', '$feed_url', '$title', NULL)");
48 } else if ($mode == 2) {
49 $result = db_query($link,
50 "INSERT INTO ttrss_feeds (id,owner_uid,feed_url,title,cat_id,site_url)
51 VALUES ('$orig_id','".$_SESSION["uid"]."', '$feed_url', '$title', NULL, '$site_url')");
53 array_push($subscribed, $title_orig);
57 if (count($subscribed) > 0) {
58 $msg = "<b>".__('Subscribed to feeds:')."</b>".
59 "<ul class=\"nomarks\">";
61 foreach ($subscribed as $title) {
62 $msg .= "<li>$title</li>";
66 print format_notice($msg);
70 if ($subop == "browse") {
72 print "<div id=\"infoBoxTitle\">".__('Feed Browser')."</div>";
74 print "<div class=\"infoBoxContents\">";
76 $browser_search = db_escape_string($_REQUEST["search"]);
78 //print "<p>".__("Showing top 25 registered feeds, sorted by popularity:")."</p>";
80 print "<form onsubmit='return false;' display='inline' name='feed_browser' id='feed_browser'>";
83 <div style='float : right'>
84 <img style='display : none'
85 id='feed_browser_spinner' src='images/indicator_white.gif'>
86 <input name=\"search\" size=\"20\" type=\"search\"
87 onchange=\"javascript:updateFeedBrowser()\" value=\"$browser_search\">
88 <button onclick=\"javascript:updateFeedBrowser()\">".__('Search')."</button>
91 print " <select name=\"mode\" onchange=\"updateFeedBrowser()\">
92 <option value='1'>" . __('Popular feeds') . "</option>
93 <option value='2'>" . __('Feed archive') . "</option>
98 print " <select name=\"limit\" onchange='updateFeedBrowser()'>";
100 foreach (array(25, 50, 100, 200) as $l) {
101 $issel = ($l == $limit) ?
"selected" : "";
102 print "<option $issel>$l</option>";
109 $owner_uid = $_SESSION["uid"];
111 print "<ul class='browseFeedList' id='browseFeedList'>";
112 print_feed_browser($link, $search, 25);
115 print "<div align='center'>
116 <button onclick=\"feedBrowserSubscribe()\">".__('Subscribe')."</button>
117 <button onclick=\"closeInfoBox()\" >".__('Cancel')."</button></div>";
123 if ($subop == "editfeed") {
124 $feed_id = db_escape_string($_REQUEST["id"]);
126 $result = db_query($link,
127 "SELECT * FROM ttrss_feeds WHERE id = '$feed_id' AND
128 owner_uid = " . $_SESSION["uid"]);
130 $title = htmlspecialchars(db_fetch_result($result,
133 $icon_file = ICONS_DIR
. "/$feed_id.ico";
135 if (file_exists($icon_file) && filesize($icon_file) > 0) {
136 $feed_icon = "<img width=\"16\" height=\"16\"
137 src=\"" . ICONS_URL
. "/$feed_id.ico\">";
142 print "<div id=\"infoBoxTitle\">".__('Feed Editor')."</div>";
144 print "<div class=\"infoBoxContents\">";
146 print "<form id=\"edit_feed_form\" onsubmit=\"return false\">";
148 print "<input type=\"hidden\" name=\"id\" value=\"$feed_id\">";
149 print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">";
150 print "<input type=\"hidden\" name=\"subop\" value=\"editSave\">";
152 print "<div class=\"dlgSec\">".__("Feed")."</div>";
153 print "<div class=\"dlgSecCont\">";
157 print "<input style=\"font-size : 16px\" size=\"40\" onkeypress=\"return filterCR(event, feedEditSave)\"
158 name=\"title\" value=\"$title\">";
162 $feed_url = db_fetch_result($result, 0, "feed_url");
163 $feed_url = htmlspecialchars(db_fetch_result($result,
168 print __('URL:') . " ";
169 print "<input size=\"40\" onkeypress=\"return filterCR(event, feedEditSave)\"
170 name=\"feed_url\" value=\"$feed_url\">";
174 if (get_pref($link, 'ENABLE_FEED_CATS')) {
176 $cat_id = db_fetch_result($result, 0, "cat_id");
180 print __('Place in category:') . " ";
182 $parent_feed = db_fetch_result($result, 0, "parent_feed");
184 if (sprintf("%d", $parent_feed) > 0) {
185 $disabled = "disabled";
190 print_feed_cat_select($link, "cat_id", $cat_id, $disabled);
197 print __('Link to feed:') . " ";
199 $tmp_result = db_query($link, "SELECT COUNT(id) AS count
200 FROM ttrss_feeds WHERE parent_feed = '$feed_id'");
202 $linked_count = db_fetch_result($tmp_result, 0, "count");
204 $parent_feed = db_fetch_result($result, 0, "parent_feed");
206 if ($linked_count > 0) {
207 $disabled = "disabled";
212 print "<select $disabled name=\"parent_feed\">";
214 print "<option value=\"0\">".__('Not linked')."</option>";
216 if (get_pref($link, 'ENABLE_FEED_CATS')) {
218 $cat_qpart = "AND cat_id = '$cat_id'";
220 $cat_qpart = "AND cat_id IS NULL";
224 $tmp_result = db_query($link, "SELECT id,title FROM ttrss_feeds
225 WHERE id != '$feed_id' AND owner_uid = ".$_SESSION["uid"]." AND
226 (SELECT COUNT(id) FROM ttrss_feeds AS T2 WHERE T2.id = ttrss_feeds.parent_feed) = 0
227 $cat_qpart ORDER BY title");
229 if (db_num_rows($tmp_result) > 0) {
230 print "<option disabled>--------</option>";
233 while ($tmp_line = db_fetch_assoc($tmp_result)) {
234 if ($tmp_line["id"] == $parent_feed) {
235 $is_selected = "selected";
240 $linked_title = truncate_string(htmlspecialchars($tmp_line["title"]), 40);
242 printf("<option $is_selected value='%d'>%s</option>",
243 $tmp_line["id"], $linked_title);
251 print "<div class=\"dlgSec\">".__("Update")."</div>";
252 print "<div class=\"dlgSecCont\">";
254 /* Update Interval */
256 $update_interval = db_fetch_result($result, 0, "update_interval");
258 print_select_hash("update_interval", $update_interval, $update_intervals);
262 if (ALLOW_SELECT_UPDATE_METHOD
) {
263 $update_method = db_fetch_result($result, 0, "update_method");
265 print " " . __('using') . " ";
266 print_select_hash("update_method", $update_method, $update_methods);
269 $purge_interval = db_fetch_result($result, 0, "purge_interval");
271 if (FORCE_ARTICLE_PURGE
== 0) {
277 print __('Article purging:') . " ";
279 print_select_hash("purge_interval", $purge_interval, $purge_intervals);
282 print "<input type='hidden' name='purge_interval' value='$purge_interval'>";
287 print "<div class=\"dlgSec\">".__("Authentication")."</div>";
288 print "<div class=\"dlgSecCont\">";
290 $auth_login = htmlspecialchars(db_fetch_result($result, 0, "auth_login"));
294 print "<tr><td>" . __('Login:') . "</td><td>";
296 print "<input size=\"20\" onkeypress=\"return filterCR(event, feedEditSave)\"
297 name=\"auth_login\" value=\"$auth_login\">";
299 print "</tr><tr><td>" . __("Password:") . "</td><td>";
301 $auth_pass = htmlspecialchars(db_fetch_result($result, 0, "auth_pass"));
303 print "<input size=\"20\" type=\"password\" name=\"auth_pass\"
304 onkeypress=\"return filterCR(event, feedEditSave)\"
305 value=\"$auth_pass\">";
307 print "</td></tr></table>";
310 print "<div class=\"dlgSec\">".__("Options")."</div>";
311 print "<div class=\"dlgSecCont\">";
313 print "<div style=\"line-height : 100%\">";
315 $private = sql_bool_to_bool(db_fetch_result($result, 0, "private"));
318 $checked = "checked";
323 print "<input type=\"checkbox\" name=\"private\" id=\"private\"
324 $checked> <label for=\"private\">".__('Hide from Popular feeds')."</label>";
326 $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content"));
329 $checked = "checked";
334 print "<br/><input type=\"checkbox\" id=\"rtl_content\" name=\"rtl_content\"
335 $checked> <label for=\"rtl_content\">".__('Right-to-left content')."</label>";
337 $include_in_digest = sql_bool_to_bool(db_fetch_result($result, 0, "include_in_digest"));
339 if ($include_in_digest) {
340 $checked = "checked";
345 print "<br/><input type=\"checkbox\" id=\"include_in_digest\"
346 name=\"include_in_digest\"
347 $checked> <label for=\"include_in_digest\">".__('Include in e-mail digest')."</label>";
350 $always_display_enclosures = sql_bool_to_bool(db_fetch_result($result, 0, "always_display_enclosures"));
352 if ($always_display_enclosures) {
353 $checked = "checked";
358 print "<br/><input type=\"checkbox\" id=\"always_display_enclosures\"
359 name=\"always_display_enclosures\"
360 $checked> <label for=\"always_display_enclosures\">".__('Always display image attachments')."</label>";
363 $cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images"));
366 $checked = "checked";
371 if (ENABLE_SIMPLEPIE
&& SIMPLEPIE_CACHE_IMAGES
) {
375 $disabled = "disabled";
376 $label_class = "class='insensitive'";
379 print "<br/><input type=\"checkbox\" id=\"cache_images\"
380 name=\"cache_images\" $disabled
381 $checked> <label $label_class for=\"cache_images\">".
382 __('Cache images locally')."</label>";
390 $title = htmlspecialchars($title, ENT_QUOTES
);
392 print "<div class='dlgButtons'>
393 <div style=\"float : left\">
394 <button onclick='return unsubscribeFeed($feed_id, \"$title\")'>".
395 __('Unsubscribe')."</button>
397 <button onclick=\"return feedEditSave()\">".__('Save')."</button>
398 <button onclick=\"return feedEditCancel()\">".__('Cancel')."</button>
404 if ($subop == "editfeeds") {
406 $feed_ids = db_escape_string($_REQUEST["ids"]);
408 print "<div id=\"infoBoxTitle\">".__('Multiple Feed Editor')."</div>";
410 print "<div class=\"infoBoxContents\">";
412 print "<form id=\"batch_edit_feed_form\" onsubmit=\"return false\">";
414 print "<input type=\"hidden\" name=\"ids\" value=\"$feed_ids\">";
415 print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">";
416 print "<input type=\"hidden\" name=\"subop\" value=\"batchEditSave\">";
418 print "<div class=\"dlgSec\">".__("Feed")."</div>";
419 print "<div class=\"dlgSecCont\">";
423 print "<input disabled style=\"font-size : 16px\" size=\"35\" onkeypress=\"return filterCR(event, feedEditSave)\"
424 name=\"title\" value=\"$title\">";
426 batch_edit_cbox("title");
432 print __('URL:') . " ";
433 print "<input disabled size=\"40\" onkeypress=\"return filterCR(event, feedEditSave)\"
434 name=\"feed_url\" value=\"$feed_url\">";
436 batch_edit_cbox("feed_url");
440 if (get_pref($link, 'ENABLE_FEED_CATS')) {
444 print __('Place in category:') . " ";
446 print_feed_cat_select($link, "cat_id", $cat_id, "disabled");
448 batch_edit_cbox("cat_id");
454 print "<div class=\"dlgSec\">".__("Update")."</div>";
455 print "<div class=\"dlgSecCont\">";
457 /* Update Interval */
459 print_select_hash("update_interval", $update_interval, $update_intervals,
462 batch_edit_cbox("update_interval");
466 if (ALLOW_SELECT_UPDATE_METHOD
) {
467 print " " . __('using') . " ";
468 print_select_hash("update_method", $update_method, $update_methods,
470 batch_edit_cbox("update_method");
475 if (FORCE_ARTICLE_PURGE
!= 0) {
479 print __('Article purging:') . " ";
481 print_select_hash("purge_interval", $purge_interval, $purge_intervals,
484 batch_edit_cbox("purge_interval");
488 print "<div class=\"dlgSec\">".__("Authentication")."</div>";
489 print "<div class=\"dlgSecCont\">";
491 print __('Login:') . " ";
492 print "<input disabled size=\"15\" onkeypress=\"return filterCR(event, feedEditSave)\"
493 name=\"auth_login\" value=\"$auth_login\">";
495 batch_edit_cbox("auth_login");
497 print " " . __("Password:") . " ";
499 print "<input disabled size=\"15\" type=\"password\" name=\"auth_pass\"
500 onkeypress=\"return filterCR(event, feedEditSave)\"
501 value=\"$auth_pass\">";
503 batch_edit_cbox("auth_pass");
506 print "<div class=\"dlgSec\">".__("Options")."</div>";
507 print "<div class=\"dlgSecCont\">";
509 print "<div style=\"line-height : 100%\">";
511 print "<input disabled type=\"checkbox\" name=\"private\" id=\"private\"
512 $checked> <label id=\"private_l\" class='insensitive' for=\"private\">".__('Hide from Popular feeds')."</label>";
514 print " "; batch_edit_cbox("private", "private_l");
516 print "<br/><input disabled type=\"checkbox\" id=\"rtl_content\" name=\"rtl_content\"
517 $checked> <label class='insensitive' id=\"rtl_content_l\" for=\"rtl_content\">".__('Right-to-left content')."</label>";
519 print " "; batch_edit_cbox("rtl_content", "rtl_content_l");
521 print "<br/><input disabled type=\"checkbox\" id=\"include_in_digest\"
522 name=\"include_in_digest\"
523 $checked> <label id=\"include_in_digest_l\" class='insensitive' for=\"include_in_digest\">".__('Include in e-mail digest')."</label>";
525 print " "; batch_edit_cbox("include_in_digest", "include_in_digest_l");
527 print "<br/><input disabled type=\"checkbox\" id=\"always_display_enclosures\"
528 name=\"always_display_enclosures\"
529 $checked> <label id=\"always_display_enclosures_l\" class='insensitive' for=\"always_display_enclosures\">".__('Always display image attachments')."</label>";
531 print " "; batch_edit_cbox("always_display_enclosures", "always_display_enclosures_l");
533 print "<br/><input disabled type=\"checkbox\" id=\"cache_images\"
534 name=\"cache_images\"
535 $checked> <label class='insensitive' id=\"cache_images_l\"
536 for=\"cache_images\">".
537 __('Cache images locally')."</label>";
540 if (ENABLE_SIMPLEPIE
&& SIMPLEPIE_CACHE_IMAGES
) {
541 print " "; batch_edit_cbox("cache_images", "cache_images_l");
549 print "<div class='dlgButtons'>
550 <input type=\"submit\" class=\"button\"
551 onclick=\"return feedsEditSave()\" value=\"".__('Save')."\">
552 <input type='submit' class='button'
553 onclick=\"return feedEditCancel()\" value=\"".__('Cancel')."\">
559 if ($subop == "editSave" ||
$subop == "batchEditSave") {
561 $feed_title = db_escape_string(trim($_POST["title"]));
562 $feed_link = db_escape_string(trim($_POST["feed_url"]));
563 $upd_intl = db_escape_string($_POST["update_interval"]);
564 $purge_intl = db_escape_string($_POST["purge_interval"]);
565 $feed_id = db_escape_string($_POST["id"]); /* editSave */
566 $feed_ids = db_escape_string($_POST["ids"]); /* batchEditSave */
567 $cat_id = db_escape_string($_POST["cat_id"]);
568 $auth_login = db_escape_string(trim($_POST["auth_login"]));
569 $auth_pass = db_escape_string(trim($_POST["auth_pass"]));
570 $parent_feed = db_escape_string($_POST["parent_feed"]);
571 $private = checkbox_to_sql_bool(db_escape_string($_POST["private"]));
572 $rtl_content = checkbox_to_sql_bool(db_escape_string($_POST["rtl_content"]));
573 $include_in_digest = checkbox_to_sql_bool(
574 db_escape_string($_POST["include_in_digest"]));
575 $cache_images = checkbox_to_sql_bool(
576 db_escape_string($_POST["cache_images"]));
577 $update_method = (int) db_escape_string($_POST["update_method"]);
579 $always_display_enclosures = checkbox_to_sql_bool(
580 db_escape_string($_POST["always_display_enclosures"]));
582 if (get_pref($link, 'ENABLE_FEED_CATS')) {
583 if ($cat_id && $cat_id != 0) {
584 $category_qpart = "cat_id = '$cat_id',";
585 $category_qpart_nocomma = "cat_id = '$cat_id'";
587 $category_qpart = 'cat_id = NULL,';
588 $category_qpart_nocomma = 'cat_id = NULL';
591 $category_qpart = "";
592 $category_qpart_nocomma = "";
595 if ($parent_feed && $parent_feed != 0) {
596 $parent_qpart = "parent_feed = '$parent_feed'";
598 $parent_qpart = 'parent_feed = NULL';
601 if (ENABLE_SIMPLEPIE
&& SIMPLEPIE_CACHE_IMAGES
) {
602 $cache_images_qpart = "cache_images = $cache_images,";
604 $cache_images_qpart = "";
607 if ($subop == "editSave") {
609 $result = db_query($link, "UPDATE ttrss_feeds SET
610 $category_qpart $parent_qpart,
611 title = '$feed_title', feed_url = '$feed_link',
612 update_interval = '$upd_intl',
613 purge_interval = '$purge_intl',
614 auth_login = '$auth_login',
615 auth_pass = '$auth_pass',
617 rtl_content = $rtl_content,
619 include_in_digest = $include_in_digest,
620 always_display_enclosures = $always_display_enclosures,
621 update_method = '$update_method'
622 WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]);
624 if (get_pref($link, 'ENABLE_FEED_CATS')) {
625 # update linked feed categories
626 $result = db_query($link, "UPDATE ttrss_feeds SET
627 $category_qpart_nocomma WHERE parent_feed = '$feed_id' AND
628 owner_uid = " . $_SESSION["uid"]);
630 } else if ($subop == "batchEditSave") {
631 $feed_data = array();
633 foreach (array_keys($_POST) as $k) {
634 if ($k != "op" && $k != "subop" && $k != "ids") {
635 $feed_data[$k] = $_POST[$k];
639 db_query($link, "BEGIN");
641 foreach (array_keys($feed_data) as $k) {
647 $qpart = "title = '$feed_title'";
651 $qpart = "feed_url = '$feed_link'";
654 case "update_interval":
655 $qpart = "update_interval = '$upd_intl'";
658 case "purge_interval":
659 $qpart = "purge_interval = '$purge_intl'";
663 $qpart = "auth_login = '$auth_login'";
667 $qpart = "auth_pass = '$auth_pass'";
671 $qpart = "private = '$private'";
674 case "include_in_digest":
675 $qpart = "include_in_digest = '$include_in_digest'";
678 case "always_display_enclosures":
679 $qpart = "always_display_enclosures = '$always_display_enclosures'";
683 $qpart = "cache_images = '$cache_images'";
687 $qpart = "rtl_content = '$rtl_content'";
690 case "update_method":
691 $qpart = "update_method = '$update_method'";
695 $qpart = $category_qpart_nocomma;
702 "UPDATE ttrss_feeds SET $qpart WHERE id IN ($feed_ids)
703 AND owner_uid = " . $_SESSION["uid"]);
708 db_query($link, "COMMIT");
713 if ($subop == "remove") {
715 $ids = split(",", db_escape_string($_REQUEST["ids"]));
717 foreach ($ids as $id) {
718 remove_feed($link, $id, $_SESSION["uid"]);
722 if ($subop == "clear") {
723 $id = db_escape_string($_REQUEST["id"]);
724 clear_feed_articles($link, $id);
727 if ($subop == "rescore") {
728 $ids = split(",", db_escape_string($_REQUEST["ids"]));
730 foreach ($ids as $id) {
732 $filters = load_filters($link, $id, $_SESSION["uid"], 6);
734 $result = db_query($link, "SELECT title, content, link, ref_id FROM
735 ttrss_user_entries, ttrss_entries
736 WHERE ref_id = id AND feed_id = '$id' AND
737 owner_uid = " .$_SESSION['uid']."
742 while ($line = db_fetch_assoc($result)) {
744 $article_filters = get_article_filters($filters, $line['title'],
745 $line['content'], $line['link']);
747 $new_score = calculate_article_score($article_filters);
749 if (!$scores[$new_score]) $scores[$new_score] = array();
751 array_push($scores[$new_score], $line['ref_id']);
754 foreach (array_keys($scores) as $s) {
756 db_query($link, "UPDATE ttrss_user_entries SET score = '$s',
758 ref_id IN (" . join(',', $scores[$s]) . ")");
759 } else if ($s < -500) {
760 db_query($link, "UPDATE ttrss_user_entries SET score = '$s',
762 ref_id IN (" . join(',', $scores[$s]) . ")");
764 db_query($link, "UPDATE ttrss_user_entries SET score = '$s' WHERE
765 ref_id IN (" . join(',', $scores[$s]) . ")");
770 print __("All done.");
774 if ($subop == "rescoreAll") {
776 $result = db_query($link,
777 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION['uid']);
779 while ($feed_line = db_fetch_assoc($result)) {
781 $id = $feed_line["id"];
783 $filters = load_filters($link, $id, $_SESSION["uid"], 6);
785 $tmp_result = db_query($link, "SELECT title, content, link, ref_id FROM
786 ttrss_user_entries, ttrss_entries
787 WHERE ref_id = id AND feed_id = '$id' AND
788 owner_uid = " .$_SESSION['uid']."
793 while ($line = db_fetch_assoc($tmp_result)) {
795 $article_filters = get_article_filters($filters, $line['title'],
796 $line['content'], $line['link']);
798 $new_score = calculate_article_score($article_filters);
800 if (!$scores[$new_score]) $scores[$new_score] = array();
802 array_push($scores[$new_score], $line['ref_id']);
805 foreach (array_keys($scores) as $s) {
807 db_query($link, "UPDATE ttrss_user_entries SET score = '$s',
809 ref_id IN (" . join(',', $scores[$s]) . ")");
811 db_query($link, "UPDATE ttrss_user_entries SET score = '$s' WHERE
812 ref_id IN (" . join(',', $scores[$s]) . ")");
817 print __("All done.");
821 if ($subop == "add") {
823 $feed_url = db_escape_string(trim($_REQUEST["feed_url"]));
824 $cat_id = db_escape_string($_REQUEST["cat_id"]);
825 $p_from = db_escape_string($_REQUEST["from"]);
827 /* only read authentication information from POST */
829 $auth_login = db_escape_string(trim($_POST["auth_login"]));
830 $auth_pass = db_escape_string(trim($_POST["auth_pass"]));
832 if ($p_from != 'tt-rss') {
835 <title>Tiny Tiny RSS</title>
836 <link rel=\"stylesheet\" type=\"text/css\" href=\"utility.css\">
839 <img class=\"floatingLogo\" src=\"images/ttrss_logo.png\"
840 alt=\"Tiny Tiny RSS\"/>
841 <h1>Subscribe to feed...</h1>";
844 $rc = subscribe_to_feed($link, $feed_url, $cat_id, $auth_login, $auth_pass);
848 print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url));
851 print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url));
854 print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
858 if ($p_from != 'tt-rss') {
859 $tt_uri = ($_SERVER['HTTPS'] != "on" ?
'http://' : 'https://') . $_SERVER['HTTP_HOST'] . preg_replace('/backend\.php.*$/', 'tt-rss.php', $_SERVER["REQUEST_URI"]);
862 $tp_uri = ($_SERVER['HTTPS'] != "on" ?
'http://' : 'https://') . $_SERVER['HTTP_HOST'] . preg_replace('/backend\.php.*$/', 'prefs.php', $_SERVER["REQUEST_URI"]);
864 $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE
865 feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
867 $feed_id = db_fetch_result($result, 0, "id");
872 print "<form method=\"GET\" style='display: inline'
874 <input type=\"hidden\" name=\"tab\" value=\"feedConfig\">
875 <input type=\"hidden\" name=\"subop\" value=\"editFeed\">
876 <input type=\"hidden\" name=\"subopparam\" value=\"$feed_id\">
877 <input type=\"submit\" value=\"".__("Edit subscription options")."\">
881 print "<form style='display: inline' method=\"GET\" action=\"$tt_uri\">
882 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
885 print "</body></html>";
890 if ($subop == "categorize") {
892 if (!WEB_DEMO_MODE
) {
894 $ids = split(",", db_escape_string($_REQUEST["ids"]));
896 $cat_id = db_escape_string($_REQUEST["cat_id"]);
899 $cat_id_qpart = 'NULL';
901 $cat_id_qpart = "'$cat_id'";
904 db_query($link, "BEGIN");
906 foreach ($ids as $id) {
908 db_query($link, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
909 WHERE id = '$id' AND parent_feed IS NULL
910 AND owner_uid = " . $_SESSION["uid"]);
912 # update linked feed categories
913 db_query($link, "UPDATE ttrss_feeds SET
914 cat_id = $cat_id_qpart WHERE parent_feed = '$id' AND
915 owner_uid = " . $_SESSION["uid"]);
919 db_query($link, "COMMIT");
924 if ($subop == "editCats") {
926 $action = $_REQUEST["action"];
928 if ($action == "save") {
930 $cat_title = db_escape_string(trim($_REQUEST["value"]));
931 $cat_id = db_escape_string($_REQUEST["cid"]);
933 db_query($link, "BEGIN");
935 $result = db_query($link, "SELECT title FROM ttrss_feed_categories
936 WHERE id = '$cat_id' AND owner_uid = ".$_SESSION["uid"]);
938 if (db_num_rows($result) == 1) {
940 $old_title = db_fetch_result($result, 0, "title");
942 if ($cat_title != "") {
943 $result = db_query($link, "UPDATE ttrss_feed_categories SET
944 title = '$cat_title' WHERE id = '$cat_id' AND
945 owner_uid = ".$_SESSION["uid"]);
952 print $_REQUEST["value"];
955 db_query($link, "COMMIT");
961 print "<div id=\"infoBoxTitle\">".__('Category editor')."</div>";
963 print "<div class=\"infoBoxContents\">";
966 if ($action == "add") {
968 if (!WEB_DEMO_MODE
) {
970 $feed_cat = db_escape_string(trim($_REQUEST["cat"]));
972 $result = db_query($link,
973 "SELECT id FROM ttrss_feed_categories
974 WHERE title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]);
976 if (db_num_rows($result) == 0) {
978 $result = db_query($link,
979 "INSERT INTO ttrss_feed_categories (owner_uid,title)
980 VALUES ('".$_SESSION["uid"]."', '$feed_cat')");
984 print_warning(T_sprintf("Category <b>$%s</b> already exists in the database.",
991 if ($action == "remove") {
993 $ids = split(",", db_escape_string($_REQUEST["ids"]));
995 foreach ($ids as $id) {
996 remove_feed_category($link, $id, $_SESSION["uid"]);
1000 print "<div class=\"prefGenericAddBox\">
1001 <input id=\"fadd_cat\"
1002 onkeypress=\"return filterCR(event, addFeedCat)\"
1004 <button onclick=\"javascript:addFeedCat()\">".
1005 __('Create category')."</button></div>";
1007 $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories
1008 WHERE owner_uid = ".$_SESSION["uid"]."
1013 if (db_num_rows($result) != 0) {
1015 print __('Select:')."
1016 <a href=\"javascript:selectPrefRows('fcat', true)\">".__('All')."</a>,
1017 <a href=\"javascript:selectPrefRows('fcat', false)\">".__('None')."</a>";
1019 print "<div class=\"prefFeedCatHolder\">";
1021 print "<form id=\"feed_cat_edit_form\" onsubmit=\"return false\">";
1023 print "<table width=\"100%\" class=\"prefFeedCatList\"
1024 cellspacing=\"0\" id=\"prefFeedCatList\">";
1028 while ($line = db_fetch_assoc($result)) {
1030 $class = ($lnum %
2) ?
"even" : "odd";
1032 $cat_id = $line["id"];
1033 $this_row_id = "id=\"FCATR-$cat_id\"";
1035 print "<tr class=\"$class\" $this_row_id>";
1037 $edit_title = htmlspecialchars($line["title"]);
1039 print "<td width='5%' align='center'><input
1040 onclick='toggleSelectPrefRow(this, \"fcat\");'
1041 type=\"checkbox\" id=\"FCCHK-$cat_id\"></td>";
1043 print "<td><span id=\"FCATT-$cat_id\">" .
1044 $edit_title . "</span></td>";
1058 print "<p>".__('No feed categories defined.')."</p>";
1061 print "<div class='dlgButtons'>
1062 <div style='float : left'>
1063 <button onclick=\"return removeSelectedFeedCats()\">".
1064 __('Remove')."</button>
1067 print "<button onclick=\"selectTab('feedConfig')\">".
1068 __('Close this window')."</button></div>";
1078 set_pref($link, "_PREFS_ACTIVE_TAB", "feedConfig");
1080 $result = db_query($link, "SELECT COUNT(id) AS num_errors
1081 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
1083 $num_errors = db_fetch_result($result, 0, "num_errors");
1085 if ($num_errors > 0) {
1087 print format_notice("<a href=\"javascript:showFeedsWithErrors()\">".
1088 __('Some feeds have update errors (click for details)')."</a>");
1091 $feed_search = db_escape_string($_REQUEST["search"]);
1093 if (array_key_exists("search", $_REQUEST)) {
1094 $_SESSION["prefs_feed_search"] = $feed_search;
1096 $feed_search = $_SESSION["prefs_feed_search"];
1099 print "<div style='float : right'>
1100 <input id=\"feed_search\" size=\"20\" type=\"search\"
1101 onfocus=\"javascript:disableHotkeys();\"
1102 onblur=\"javascript:enableHotkeys();\"
1103 onchange=\"javascript:updateFeedList()\" value=\"$feed_search\">
1104 <button onclick=\"javascript:updateFeedList()\">".
1105 __('Search')."</button>
1108 print "<button onclick=\"javascript:displayDlg('quickAddFeed')\">"
1109 .__('Subscribe to feed')."</button> ";
1111 print "<button onclick=\"javascript:editSelectedFeed()\">".
1112 __('Edit feeds')."</button> ";
1114 if (get_pref($link, 'ENABLE_FEED_CATS')) {
1116 print "<button onclick=\"javascript:editFeedCats()\">".
1117 __('Edit categories')."</button> ";
1120 print "<button onclick=\"javascript:removeSelectedFeeds()\">"
1121 .__('Unsubscribe')."</button> ";
1123 /* print "<select id=\"feedActionChooser\" onchange=\"feedActionChange()\">
1124 <option value=\"facDefault\" selected>".__('Other actions...')."</option>";
1126 if (FORCE_ARTICLE_PURGE == 0) {
1128 "<option value=\"facPurge\">".__('Manual purge')."</option>";
1132 <option value=\"facClear\">".__('Clear feed data')."</option>
1133 <option value=\"facRescore\">".__('Rescore articles')."</option>
1134 <option value=\"facUnsubscribe\">".__('Unsubscribe')."</option>";
1136 print "</select>"; */
1138 /* if (ENABLE_FEED_BROWSER && !SINGLE_USER_MODE) {
1139 print " <input type=\"submit\" class=\"button\"
1140 id=\"top25_feeds_btn\"
1141 onclick=\"javascript:browseFeeds()\" value=\"".__('More feeds')."\">";
1144 $feeds_sort = db_escape_string($_REQUEST["sort"]);
1146 if (!$feeds_sort ||
$feeds_sort == "undefined") {
1147 $feeds_sort = $_SESSION["pref_sort_feeds"];
1148 if (!$feeds_sort) $feeds_sort = "title";
1151 $_SESSION["pref_sort_feeds"] = $feeds_sort;
1155 $feed_search = split(" ", $feed_search);
1158 foreach ($feed_search as $token) {
1160 $token = trim($token);
1162 array_push($tokens, "(UPPER(F1.title) LIKE UPPER('%$token%') OR
1163 UPPER(C1.title) LIKE UPPER('%$token%') OR
1164 UPPER(F1.feed_url) LIKE UPPER('%$token%'))");
1167 $search_qpart = "(" . join($tokens, " AND ") . ") AND ";
1173 $show_last_article_info = false;
1174 $show_last_article_checked = "";
1175 $show_last_article_qpart = "";
1177 if ($_REQUEST["slat"] == "true") {
1178 $show_last_article_info = true;
1179 $show_last_article_checked = "checked";
1180 $show_last_article_qpart = ", (SELECT ".SUBSTRING_FOR_DATE
."(MAX(updated),1,16) FROM ttrss_user_entries,
1181 ttrss_entries WHERE ref_id = ttrss_entries.id
1182 AND feed_id = F1.id) AS last_article";
1183 } else if ($feeds_sort == "last_article") {
1184 $feeds_sort = "title";
1187 if (get_pref($link, 'ENABLE_FEED_CATS')) {
1188 $order_by_qpart = "category,$feeds_sort,title";
1190 $order_by_qpart = "$feeds_sort,title";
1193 $result = db_query($link, "SELECT
1197 ".SUBSTRING_FOR_DATE
."(F1.last_updated,1,16) AS last_updated,
1203 F2.title AS parent_title,
1204 C1.title AS category,
1205 F1.include_in_digest
1206 $show_last_article_qpart
1209 LEFT JOIN ttrss_feeds AS F2
1210 ON (F1.parent_feed = F2.id)
1211 LEFT JOIN ttrss_feed_categories AS C1
1212 ON (F1.cat_id = C1.id)
1214 $search_qpart F1.owner_uid = '".$_SESSION["uid"]."'
1215 ORDER by $order_by_qpart");
1217 if (db_num_rows($result) != 0) {
1219 // print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>";
1221 print "<p><table width=\"100%\" cellspacing=\"0\"
1222 class=\"prefFeedList\" id=\"prefFeedList\">";
1223 print "<tr><td class=\"selectPrompt\" colspan=\"8\">".
1224 "<div style='float : right'>".
1225 "<input id='show_last_article_times' type='checkbox' onchange='feedlistToggleSLAT()'
1226 $show_last_article_checked><label
1227 for='show_last_article_times'>".__('Show last article times')."</label></div>".
1229 <a href=\"javascript:selectPrefRows('feed', true)\">".__('All')."</a>,
1230 <a href=\"javascript:selectPrefRows('feed', false)\">".__('None')."</a>
1233 if (!get_pref($link, 'ENABLE_FEED_CATS')) {
1234 print "<tr class=\"title\">
1235 <td width='5%' align='center'> </td>";
1237 if (get_pref($link, 'ENABLE_FEED_ICONS')) {
1238 print "<td width='3%'> </td>";
1241 print "<td width='60%'><a href=\"javascript:updateFeedList('title')\">".__('Title')."</a></td>";
1243 if ($show_last_article_info) {
1244 print "<td width='20%' align='right'><a href=\"javascript:updateFeedList('last_article')\">".__('Last Article')."</a></td>";
1247 print "<td width='20%' align='right'><a href=\"javascript:updateFeedList('last_updated')\">".__('Updated')."</a></td>";
1254 while ($line = db_fetch_assoc($result)) {
1256 $feed_id = $line["id"];
1257 $cat_id = $line["cat_id"];
1259 $edit_title = htmlspecialchars($line["title"]);
1260 $edit_cat = htmlspecialchars($line["category"]);
1262 $last_error = $line["last_error"];
1264 if (!$edit_cat) $edit_cat = __("Uncategorized");
1266 $last_updated = $line["last_updated"];
1268 if (!$last_updated) {
1269 $last_updated = "—";
1270 } else if (get_pref($link, 'HEADLINES_SMART_DATE')) {
1271 $last_updated = smart_date_time(strtotime($last_updated));
1273 $short_date = get_pref($link, 'SHORT_DATE_FORMAT');
1274 $last_updated = date($short_date, strtotime($last_updated));
1277 $last_article = $line["last_article"];
1279 if (!$last_article) {
1280 $last_article = "—";
1281 } else if (get_pref($link, 'HEADLINES_SMART_DATE')) {
1282 $last_article = smart_date_time(strtotime($last_article));
1284 $short_date = get_pref($link, 'SHORT_DATE_FORMAT');
1285 $last_article = date($short_date, strtotime($last_article));
1288 if (get_pref($link, 'ENABLE_FEED_CATS') && $cur_cat_id != $cat_id) {
1291 print "<tr><td colspan=\"6\" class=\"feedEditCat\">$edit_cat</td></tr>";
1293 print "<tr class=\"title\">
1294 <td width='5%'> </td>";
1296 if (get_pref($link, 'ENABLE_FEED_ICONS')) {
1297 print "<td width='3%'> </td>";
1300 print "<td width='60%'><a href=\"javascript:updateFeedList('title')\">".__('Title')."</a></td>";
1302 if ($show_last_article_info) {
1303 print "<td width='20%' align='right'>
1304 <a href=\"javascript:updateFeedList('last_article')\">".__('Last Article')."</a></td>";
1307 print "<td width='20%' align='right'>
1308 <a href=\"javascript:updateFeedList('last_updated')\">".__('Updated')."</a></td>";
1310 $cur_cat_id = $cat_id;
1313 $class = ($lnum %
2) ?
"even" : "odd";
1314 $this_row_id = "id=\"FEEDR-$feed_id\"";
1316 print "<tr class=\"$class\" $this_row_id>";
1318 $icon_file = ICONS_DIR
. "/$feed_id.ico";
1320 if (file_exists($icon_file) && filesize($icon_file) > 0) {
1321 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL
. "/$feed_id.ico\">";
1323 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
1326 print "<td class='feedSelect'><input onclick='toggleSelectPrefRow(this, \"feed\");'
1327 type=\"checkbox\" id=\"FRCHK-".$line["id"]."\"></td>";
1329 $onclick = "onclick='editFeed($feed_id)' title='".__('Click to edit')."'";
1331 if (get_pref($link, 'ENABLE_FEED_ICONS')) {
1332 print "<td $onclick class='feedIcon'>$feed_icon</td>";
1336 $edit_title = "<span class=\"feed_error\">$edit_title</span>";
1337 $last_updated = "<span class=\"feed_error\">$last_updated</span>";
1338 $last_article = "<span class=\"feed_error\">$last_article</span>";
1341 $parent_title = $line["parent_title"];
1342 if ($parent_title) {
1343 $linked_to = sprintf(__("(linked to %s)"), $parent_title);
1344 $parent_title = "<span class='groupPrompt'>$linked_to</span>";
1347 print "<td $onclick>" . "$edit_title $parent_title" . "</td>";
1349 if ($show_last_article_info) {
1350 print "<td align='right' $onclick>" .
1351 "$last_article</td>";
1354 print "<td $onclick align='right'>$last_updated</td>";
1369 if (!$feed_search) {
1370 print_warning(__("You don't have any subscribed feeds."));
1372 print_warning(__('No matching feeds found.'));
1378 print "<h3>".__('OPML')."</h3>
1380 <div style='float : left'>
1381 <form enctype=\"multipart/form-data\" method=\"POST\" action=\"opml.php\">
1382 ".__('File:')." <input id=\"opml_file\" name=\"opml_file\" type=\"file\">
1383 <input type=\"hidden\" name=\"op\" value=\"Import\">
1384 <button onclick=\"return validateOpmlImport();\"
1385 type=\"submit\">".__('Import')."</button>
1390 print "<button onclick=\"gotoExportOpml()\">".
1391 __('Export OPML')."</button>";
1394 print "<h3>" . __("Firefox Integration") . "</h3>";
1396 print "<p>" . __('This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.') . "</p>";
1400 print "<button onclick='window.navigator.registerContentHandler(" .
1401 "\"application/vnd.mozilla.maybe.feed\", " .
1402 "\"" . add_feed_url() . "\", " . " \"Tiny Tiny RSS\")'>" .
1403 __('Click here to register this site as a feed reader.') .
1408 print "<h3>".__("Published articles")."</h3>";
1410 if (!get_pref($link, "_PREFS_PUBLISH_KEY")) {
1411 set_pref($link, "_PREFS_PUBLISH_KEY", generate_publish_key());
1414 print "<p>".__('Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.')."</p>";
1416 print "<button onclick=\"return displayDlg('pubUrl')\">".
1417 __('Display URL')."</button> ";
1422 function print_feed_browser($link, $search, $limit, $mode = 1) {
1424 $owner_uid = $_SESSION["uid"];
1427 $search_qpart = "AND (UPPER(feed_url) LIKE UPPER('%$search%') OR
1428 UPPER(title) LIKE UPPER('%$search%'))";
1434 $result = db_query($link, "SELECT feed_url, subscribers FROM
1435 ttrss_feedbrowser_cache WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
1436 WHERE tf.feed_url = ttrss_feedbrowser_cache.feed_url
1437 AND owner_uid = '$owner_uid') $search_qpart
1438 ORDER BY subscribers DESC LIMIT $limit");
1439 } else if ($mode == 2) {
1440 $result = db_query($link, "SELECT * FROM
1441 ttrss_archived_feeds WHERE
1442 (SELECT COUNT(*) FROM ttrss_feeds
1443 WHERE ttrss_feeds.feed_url = ttrss_archived_feeds.feed_url AND
1444 owner_uid = '$owner_uid') = 0 AND
1445 owner_uid = '$owner_uid' $search_qpart
1446 ORDER BY id DESC LIMIT $limit");
1451 while ($line = db_fetch_assoc($result)) {
1455 $feed_url = $line["feed_url"];
1456 $subscribers = $line["subscribers"];
1458 $det_result = db_query($link, "SELECT site_url,title,id
1459 FROM ttrss_feeds WHERE feed_url = '$feed_url' LIMIT 1");
1461 $details = db_fetch_assoc($det_result);
1463 $icon_file = ICONS_DIR
. "/" . $details["id"] . ".ico";
1465 if (file_exists($icon_file) && filesize($icon_file) > 0) {
1466 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL
.
1467 "/".$details["id"].".ico\">";
1469 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
1472 $check_box = "<input onclick='toggleSelectListRow(this)' class='feedBrowseCB'
1473 type=\"checkbox\" id=\"FBCHK-" . $details["id"] . "\">";
1475 $class = ($feedctr %
2) ?
"even" : "odd";
1477 if ($details["site_url"]) {
1478 $site_url = "<a target=\"_blank\" href=\"".$details["site_url"]."\">
1479 <img style='border-width : 0px' src='images/www.png' alt='www'></a>";
1484 print "<li class='$class' id=\"FBROW-".$details["id"]."\">$check_box".
1485 "$feed_icon " . $details["title"] .
1486 " <span class='subscribers'>($subscribers)</span>
1490 } else if ($mode == 2) {
1491 $feed_url = $line["feed_url"];
1493 $icon_file = ICONS_DIR
. "/" . $line["id"] . ".ico";
1495 if (file_exists($icon_file) && filesize($icon_file) > 0) {
1496 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL
.
1497 "/".$line["id"].".ico\">";
1499 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
1502 $check_box = "<input onclick='toggleSelectListRow(this)' class='feedBrowseCB'
1503 type=\"checkbox\" id=\"FBCHK-" . $line["id"] . "\">";
1505 $class = ($feedctr %
2) ?
"even" : "odd";
1507 if ($line["site_url"]) {
1508 $site_url = "<a target=\"_blank\" href=\"".$line["site_url"]."\">
1509 <img style='border-width : 0px' src='images/www.png' alt='www'></a>";
1514 print "<li class='$class' id=\"FBROW-".$line["id"]."\">$check_box".
1515 "$feed_icon " . $line["title"] . $site_url . "</li>";
1523 if ($feedctr == 0) {
1524 print "<li style=\"text-align : center\"><p>".__('No feeds found.')."</p></li>";