0) { $msg = "".__('Subscribed to feeds:')."". ""; print format_notice($msg); } } if ($subop == "browse") { if (!ENABLE_FEED_BROWSER) { print __("Feed browser is administratively disabled."); return; } print "
".__('Other feeds: Top 25')."
"; print "
"; print "

".__("Showing top 25 registered feeds, sorted by popularity:")."

"; # $result = db_query($link, "SELECT feed_url,count(id) AS subscribers # FROM ttrss_feeds # WHERE auth_login = '' AND auth_pass = '' AND private = false # GROUP BY feed_url ORDER BY subscribers DESC LIMIT 25"); $owner_uid = $_SESSION["uid"]; $result = db_query($link, "SELECT feed_url,COUNT(id) AS subscribers FROM ttrss_feeds WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf WHERE tf.feed_url = ttrss_feeds.feed_url AND owner_uid = '$owner_uid') GROUP BY feed_url ORDER BY subscribers DESC LIMIT 25"); print ""; print "
"; print "
"; return; } if ($subop == "editfeed") { $feed_id = db_escape_string($_REQUEST["id"]); $result = db_query($link, "SELECT * FROM ttrss_feeds WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); $title = htmlspecialchars(db_unescape_string(db_fetch_result($result, 0, "title"))); $icon_file = ICONS_DIR . "/$feed_id.ico"; if (file_exists($icon_file) && filesize($icon_file) > 0) { $feed_icon = ""; } else { $feed_icon = ""; } print "
".__('Feed editor')."
"; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; $feed_url = db_fetch_result($result, 0, "feed_url"); $feed_url = htmlspecialchars(db_unescape_string(db_fetch_result($result, 0, "feed_url"))); print ""; print ""; if (get_pref($link, 'ENABLE_FEED_CATS')) { $cat_id = db_fetch_result($result, 0, "cat_id"); print ""; print ""; print ""; } $update_interval = db_fetch_result($result, 0, "update_interval"); print ""; print ""; print ""; $purge_interval = db_fetch_result($result, 0, "purge_interval"); print ""; print ""; $auth_login = escape_for_form(db_fetch_result($result, 0, "auth_login")); print ""; print ""; $auth_pass = escape_for_form(db_fetch_result($result, 0, "auth_pass")); print ""; print ""; $private = sql_bool_to_bool(db_fetch_result($result, 0, "private")); if ($private) { $checked = "checked"; } else { $checked = ""; } print ""; print ""; print "
".__('Title:')."
".__('Feed URL:')."
".__('Category:').""; $parent_feed = db_fetch_result($result, 0, "parent_feed"); if (sprintf("%d", $parent_feed) > 0) { $disabled = "disabled"; } else { $disabled = ""; } print_feed_cat_select($link, "cat_id", $cat_id, "class=\"iedit\" $disabled"); print "
".__('Update Interval:').""; print_select_hash("update_interval", $update_interval, $update_intervals, "class=\"iedit\""); print "
".__('Link to:').""; $tmp_result = db_query($link, "SELECT COUNT(id) AS count FROM ttrss_feeds WHERE parent_feed = '$feed_id'"); $linked_count = db_fetch_result($tmp_result, 0, "count"); $parent_feed = db_fetch_result($result, 0, "parent_feed"); if ($linked_count > 0) { $disabled = "disabled"; } else { $disabled = ""; } print ""; print "
".__('Article purging:').""; print_select_hash("purge_interval", $purge_interval, $purge_intervals, "class=\"iedit\""); print "
".__('Login:')."
".__('Password:')."
".__('Options:').""; $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content")); if ($rtl_content) { $checked = "checked"; } else { $checked = ""; } print "
"; $hidden = sql_bool_to_bool(db_fetch_result($result, 0, "hidden")); if ($hidden) { $checked = "checked"; } else { $checked = ""; } print "
"; $include_in_digest = sql_bool_to_bool(db_fetch_result($result, 0, "include_in_digest")); if ($include_in_digest) { $checked = "checked"; } else { $checked = ""; } print "
"; print "
"; print "
"; print "
"; print "
"; return; } if ($subop == "editSave") { $feed_title = db_escape_string(trim($_POST["title"])); $feed_link = db_escape_string(trim($_POST["feed_url"])); $upd_intl = db_escape_string($_POST["update_interval"]); $purge_intl = db_escape_string($_POST["purge_interval"]); $feed_id = db_escape_string($_POST["id"]); $cat_id = db_escape_string($_POST["cat_id"]); $auth_login = db_escape_string(trim($_POST["auth_login"])); $auth_pass = db_escape_string(trim($_POST["auth_pass"])); $parent_feed = db_escape_string($_POST["parent_feed"]); $private = checkbox_to_sql_bool(db_escape_string($_POST["private"])); $rtl_content = checkbox_to_sql_bool(db_escape_string($_POST["rtl_content"])); $hidden = checkbox_to_sql_bool(db_escape_string($_POST["hidden"])); $include_in_digest = checkbox_to_sql_bool( db_escape_string($_POST["include_in_digest"])); if (get_pref($link, 'ENABLE_FEED_CATS')) { if ($cat_id && $cat_id != 0) { $category_qpart = "cat_id = '$cat_id',"; $category_qpart_nocomma = "cat_id = '$cat_id'"; } else { $category_qpart = 'cat_id = NULL,'; $category_qpart_nocomma = 'cat_id = NULL'; } } else { $category_qpart = ""; $category_qpart_nocomma = ""; } if ($parent_feed && $parent_feed != 0) { $parent_qpart = "parent_feed = '$parent_feed'"; } else { $parent_qpart = 'parent_feed = NULL'; } $result = db_query($link, "UPDATE ttrss_feeds SET $category_qpart $parent_qpart, title = '$feed_title', feed_url = '$feed_link', update_interval = '$upd_intl', purge_interval = '$purge_intl', auth_login = '$auth_login', auth_pass = '$auth_pass', private = $private, rtl_content = $rtl_content, hidden = $hidden, include_in_digest = $include_in_digest WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); if (get_pref($link, 'ENABLE_FEED_CATS')) { # update linked feed categories $result = db_query($link, "UPDATE ttrss_feeds SET $category_qpart_nocomma WHERE parent_feed = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); } } if ($subop == "remove") { if (!WEB_DEMO_MODE) { $ids = split(",", db_escape_string($_GET["ids"])); foreach ($ids as $id) { if ($id > 0) { db_query($link, "DELETE FROM ttrss_feeds WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]); $icons_dir = ICONS_DIR; if (file_exists($icons_dir . "/$id.ico")) { unlink($icons_dir . "/$id.ico"); } } else if ($id < -10) { $label_id = -$id - 11; db_query($link, "DELETE FROM ttrss_labels WHERE id = '$label_id' AND owner_uid = " . $_SESSION["uid"]); } } } } if ($subop == "add") { if (!WEB_DEMO_MODE) { $feed_url = db_escape_string(trim($_GET["feed_url"])); $cat_id = db_escape_string($_GET["cat_id"]); $p_from = db_escape_string($_GET["from"]); if ($p_from != 'tt-rss') { print " Tiny Tiny RSS - Subscribe to feed... \"Tiny

Subscribe to feed...

"; } if (subscribe_to_feed($link, $feed_url, $cat_id)) { print format_notice(sprintf(__("Subscribed to %s."), $feed_url)); } else { print format_warning(sprintf(__("Already subscribed to %s."), $feed_url)); } if ($p_from != 'tt-rss') { $tt_uri = 'http://' . $_SERVER['SERVER_NAME'] . preg_replace('/backend\.php.*$/', 'tt-rss.php', $_SERVER["REQUEST_URI"]); $tp_uri = 'http://' . $_SERVER['SERVER_NAME'] . preg_replace('/backend\.php.*$/', 'prefs.php', $_SERVER["REQUEST_URI"]); print "

Return to Tiny Tiny RSS |"; $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]); $feed_id = db_fetch_result($result, 0, "id"); if ($feed_id) { print " Edit subscription options | "; } print "Close this window.

"; print "
"; return; } } } if ($subop == "categorize") { if (!WEB_DEMO_MODE) { $ids = split(",", db_escape_string($_GET["ids"])); $cat_id = db_escape_string($_GET["cat_id"]); if ($cat_id == 0) { $cat_id_qpart = 'NULL'; } else { $cat_id_qpart = "'$cat_id'"; } db_query($link, "BEGIN"); foreach ($ids as $id) { db_query($link, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart WHERE id = '$id' AND parent_feed IS NULL AND owner_uid = " . $_SESSION["uid"]); # update linked feed categories db_query($link, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart WHERE parent_feed = '$id' AND owner_uid = " . $_SESSION["uid"]); } db_query($link, "COMMIT"); } } if ($subop == "editCats") { print "
".__('Category editor')."
"; print "
"; $action = $_REQUEST["action"]; if ($action == "save") { $cat_title = db_escape_string(trim($_GET["title"])); $cat_id = db_escape_string($_GET["id"]); $result = db_query($link, "UPDATE ttrss_feed_categories SET title = '$cat_title' WHERE id = '$cat_id' AND owner_uid = ".$_SESSION["uid"]); } if ($action == "add") { if (!WEB_DEMO_MODE) { $feed_cat = db_escape_string(trim($_GET["cat"])); $result = db_query($link, "SELECT id FROM ttrss_feed_categories WHERE title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]); if (db_num_rows($result) == 0) { $result = db_query($link, "INSERT INTO ttrss_feed_categories (owner_uid,title) VALUES ('".$_SESSION["uid"]."', '$feed_cat')"); } else { print format_warning(sprintf(__("Category $%s already exists in the database."), $feed_cat)); } } } if ($action == "remove") { if (!WEB_DEMO_MODE) { $ids = split(",", db_escape_string($_GET["ids"])); foreach ($ids as $id) { db_query($link, "BEGIN"); $result = db_query($link, "SELECT count(id) as num_feeds FROM ttrss_feeds WHERE cat_id = '$id'"); $num_feeds = db_fetch_result($result, 0, "num_feeds"); if ($num_feeds == 0) { db_query($link, "DELETE FROM ttrss_feed_categories WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]); } else { print format_warning(__("Unable to delete non empty feed categories.")); } db_query($link, "COMMIT"); } } } print "
 
"; $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title"); print "

"; if (db_num_rows($result) != 0) { print ""; print ""; print "
Select: All, None
"; print "

"; print "
"; print ""; /* print ""; */ $lnum = 0; while ($line = db_fetch_assoc($result)) { $class = ($lnum % 2) ? "even" : "odd"; $cat_id = $line["id"]; $edit_cat_id = $_GET["id"]; if ($action == "edit" && $cat_id == $edit_cat_id) { $class .= "Selected"; $this_row_id = ""; } else if ($action == "edit" && $cat_id != $edit_cat_id) { $class .= "Grayed"; $this_row_id = ""; } else { $this_row_id = "id=\"FCATR-$cat_id\""; } print ""; $edit_title = htmlspecialchars(db_unescape_string($line["title"])); if (!$edit_cat_id || $action != "edit") { print ""; print ""; } else if ($cat_id != $edit_cat_id) { print ""; print ""; } else { print ""; print ""; } print ""; ++$lnum; } print "
 Title
" . $edit_title . "$edit_title"; print ""; print ""; print ""; print ""; print "
"; print "
"; print "
"; } else { print "

".__('No feed categories defined.')."

"; } print "
"; print "
"; if ($action == "edit") { print " "; } else { print " "; } print "
"; print "
"; return; } if ($quiet) return; $result = db_query($link, "SELECT COUNT(id) AS num_errors FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]); $num_errors = db_fetch_result($result, 0, "num_errors"); if ($num_errors > 0) { print format_notice("". __('Some feeds have update errors (click for details)').""); } $feed_search = db_escape_string($_GET["search"]); if (array_key_exists("search", $_GET)) { $_SESSION["prefs_feed_search"] = $feed_search; } else { $feed_search = $_SESSION["prefs_feed_search"]; } print "
"; print "
"; if (ENABLE_FEED_BROWSER && !SINGLE_USER_MODE) { print " "; } print "
"; $feeds_sort = db_escape_string($_GET["sort"]); if (!$feeds_sort || $feeds_sort == "undefined") { $feeds_sort = $_SESSION["pref_sort_feeds"]; if (!$feeds_sort) $feeds_sort = "title"; } $_SESSION["pref_sort_feeds"] = $feeds_sort; if ($feed_search) { $search_qpart = "(UPPER(F1.title) LIKE UPPER('%$feed_search%') OR UPPER(F1.feed_url) LIKE UPPER('%$feed_search%')) AND"; } else { $search_qpart = ""; } if (get_pref($link, 'ENABLE_FEED_CATS')) { $order_by_qpart = "category,$feeds_sort,title"; } else { $order_by_qpart = "$feeds_sort,title"; } $result = db_query($link, "SELECT F1.id, F1.title, F1.feed_url, substring(F1.last_updated,1,16) AS last_updated, F1.parent_feed, F1.update_interval, F1.purge_interval, F1.cat_id, F2.title AS parent_title, C1.title AS category, F1.hidden, F1.include_in_digest, (SELECT SUBSTRING(MAX(updated),1,16) FROM ttrss_user_entries, ttrss_entries WHERE ref_id = ttrss_entries.id AND feed_id = F1.id) AS last_article FROM ttrss_feeds AS F1 LEFT JOIN ttrss_feeds AS F2 ON (F1.parent_feed = F2.id) LEFT JOIN ttrss_feed_categories AS C1 ON (F1.cat_id = C1.id) WHERE $search_qpart F1.owner_uid = '".$_SESSION["uid"]."' ORDER by $order_by_qpart"); if (db_num_rows($result) != 0) { // print "
PLACEHOLDER
"; print "

"; print ""; if (get_pref($link, 'ENABLE_FEED_ICONS')) { print ""; } print " "; } $lnum = 0; $cur_cat_id = -1; while ($line = db_fetch_assoc($result)) { $feed_id = $line["id"]; $cat_id = $line["cat_id"]; $edit_title = htmlspecialchars(db_unescape_string($line["title"])); $edit_link = htmlspecialchars(db_unescape_string($line["feed_url"])); $edit_cat = htmlspecialchars(db_unescape_string($line["category"])); $hidden = sql_bool_to_bool($line["hidden"]); if (!$edit_cat) $edit_cat = "Uncategorized"; $last_updated = $line["last_updated"]; if (get_pref($link, 'HEADLINES_SMART_DATE')) { $last_updated = smart_date_time(strtotime($last_updated)); } else { $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); $last_updated = date($short_date, strtotime($last_updated)); } $last_article = $line["last_article"]; if (get_pref($link, 'HEADLINES_SMART_DATE')) { $last_article = smart_date_time(strtotime($last_article)); } else { $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); $last_article = date($short_date, strtotime($last_article)); } if (get_pref($link, 'ENABLE_FEED_CATS') && $cur_cat_id != $cat_id) { $lnum = 0; print ""; print ""; if (get_pref($link, 'ENABLE_FEED_ICONS')) { print ""; } print ""; $cur_cat_id = $cat_id; } $class = ($lnum % 2) ? "even" : "odd"; $this_row_id = "id=\"FEEDR-$feed_id\""; print ""; $icon_file = ICONS_DIR . "/$feed_id.ico"; if (file_exists($icon_file) && filesize($icon_file) > 0) { $feed_icon = ""; } else { $feed_icon = ""; } print ""; if (get_pref($link, 'ENABLE_FEED_ICONS')) { print ""; } $edit_title = truncate_string($edit_title, 40); $edit_link = truncate_string($edit_link, 60); if ($hidden) { $edit_title = "$edit_title (Hidden)"; $edit_link = "$edit_link"; $last_updated = "$last_updated"; $last_article = "$last_article"; } $parent_title = $line["parent_title"]; if ($parent_title) { $parent_title = "(linked to $parent_title)"; } print ""; print ""; print ""; print ""; print ""; ++$lnum; } print "
Select: All, None "; if (!get_pref($link, 'ENABLE_FEED_CATS')) { print "
  Title Feed Last Article Updated
$edit_cat
  Title Feed Last Article Updated
$feed_icon" . "$edit_title $parent_title" . "" . $edit_link . "" . "$last_article" . "$last_updated
"; print "

"; if ($subop == "edit") { print "Edit feed:  "; } else { print " Selection:  "; if (get_pref($link, 'ENABLE_FEED_CATS')) { print " | "; print_feed_cat_select($link, "sfeed_set_fcat", "", "disabled"); print " "; } print ""; if (get_pref($link, 'ENABLE_FEED_CATS')) { print " "; # print " | "; } } } else { // print "

No feeds defined.

"; } print "

OPML

File:  
"; print "  or  "; print ""; } ?>