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:")."

"; $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_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 "
".__("Feed")."
"; print "
"; /* Title */ print ""; /* Feed URL */ $feed_url = db_fetch_result($result, 0, "feed_url"); $feed_url = htmlspecialchars(db_fetch_result($result, 0, "feed_url")); print "
"; print __('URL:') . " "; print ""; /* Category */ if (get_pref($link, 'ENABLE_FEED_CATS')) { $cat_id = db_fetch_result($result, 0, "cat_id"); print "
"; print __('Place in 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, $disabled); } /* Link to */ print "
"; print __('Link to feed:') . " "; $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 "
"; print "
".__("Update")."
"; print "
"; /* Update Interval */ $update_interval = db_fetch_result($result, 0, "update_interval"); print_select_hash("update_interval", $update_interval, $update_intervals); /* Update method */ if (ALLOW_SELECT_UPDATE_METHOD) { $update_method = db_fetch_result($result, 0, "update_method"); print " " . __('using') . " "; print_select_hash("update_method", $update_method, $update_methods); } /* Purge intl */ print "
"; $purge_interval = db_fetch_result($result, 0, "purge_interval"); print __('Article purging:') . " "; print_select_hash("purge_interval", $purge_interval, $purge_intervals); print "
"; print "
".__("Authentication")."
"; print "
"; $auth_login = htmlspecialchars(db_fetch_result($result, 0, "auth_login")); print __('Login:') . " "; print ""; print " " . __("Password:") . " "; $auth_pass = htmlspecialchars(db_fetch_result($result, 0, "auth_pass")); print ""; print "
"; print "
".__("Options")."
"; print "
"; print "
"; print " "; $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 "
 "; $cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images")); if ($cache_images) { $checked = "checked"; } else { $checked = ""; } if (ENABLE_SIMPLEPIE && SIMPLEPIE_CACHE_IMAGES) { $disabled = ""; $label_class = ""; } else { $disabled = "disabled"; $label_class = "class='insensitive'"; } 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"])); $cache_images = checkbox_to_sql_bool( db_escape_string($_POST["cache_images"])); $update_method = (int) db_escape_string($_POST["update_method"]); 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'; } if (ENABLE_SIMPLEPIE && SIMPLEPIE_CACHE_IMAGES) { $cache_images_qpart = "cache_images = $cache_images,"; } else { $cache_images_qpart = ""; } $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, $cache_images_qpart include_in_digest = $include_in_digest, update_method = '$update_method' 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 == "clear") { $id = db_escape_string($_GET["id"]); clear_feed_articles($link, $id); } if ($subop == "rescore") { $ids = split(",", db_escape_string($_GET["ids"])); foreach ($ids as $id) { $filters = load_filters($link, $id, $_SESSION["uid"], 6); $result = db_query($link, "SELECT title, content, link, ref_id FROM ttrss_user_entries, ttrss_entries WHERE ref_id = id AND feed_id = '$id' AND owner_uid = " .$_SESSION['uid']." "); $scores = array(); while ($line = db_fetch_assoc($result)) { $article_filters = get_article_filters($filters, $line['title'], $line['content'], $line['link']); $new_score = calculate_article_score($article_filters); if (!$scores[$new_score]) $scores[$new_score] = array(); array_push($scores[$new_score], $line['ref_id']); } foreach (array_keys($scores) as $s) { if ($s > 1000) { db_query($link, "UPDATE ttrss_user_entries SET score = '$s', marked = true WHERE ref_id IN (" . join(',', $scores[$s]) . ")"); } else if ($s < -500) { db_query($link, "UPDATE ttrss_user_entries SET score = '$s', unread = false WHERE ref_id IN (" . join(',', $scores[$s]) . ")"); } else { db_query($link, "UPDATE ttrss_user_entries SET score = '$s' WHERE ref_id IN (" . join(',', $scores[$s]) . ")"); } } } print __("All done."); } if ($subop == "rescoreAll") { $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION['uid']); while ($feed_line = db_fetch_assoc($result)) { $id = $feed_line["id"]; $filters = load_filters($link, $id, $_SESSION["uid"], 6); $tmp_result = db_query($link, "SELECT title, content, link, ref_id FROM ttrss_user_entries, ttrss_entries WHERE ref_id = id AND feed_id = '$id' AND owner_uid = " .$_SESSION['uid']." "); $scores = array(); while ($line = db_fetch_assoc($tmp_result)) { $article_filters = get_article_filters($filters, $line['title'], $line['content'], $line['link']); $new_score = calculate_article_score($article_filters); if (!$scores[$new_score]) $scores[$new_score] = array(); array_push($scores[$new_score], $line['ref_id']); } foreach (array_keys($scores) as $s) { if ($s > 1000) { db_query($link, "UPDATE ttrss_user_entries SET score = '$s', marked = true WHERE ref_id IN (" . join(',', $scores[$s]) . ")"); } else { db_query($link, "UPDATE ttrss_user_entries SET score = '$s' WHERE ref_id IN (" . join(',', $scores[$s]) . ")"); } } } print __("All done."); } if ($subop == "add") { if (!WEB_DEMO_MODE) { $feed_url = db_escape_string(trim($_REQUEST["feed_url"])); $cat_id = db_escape_string($_REQUEST["cat_id"]); $p_from = db_escape_string($_REQUEST["from"]); /* only read authentication information from POST */ $auth_login = db_escape_string(trim($_POST["auth_login"])); $auth_pass = db_escape_string(trim($_POST["auth_pass"])); 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, $auth_login, $auth_pass)) { print_notice(T_sprintf("Subscribed to %s.", $feed_url)); } else { print_warning(T_sprintf("Already subscribed to %s.", $feed_url)); } if ($p_from != 'tt-rss') { $tt_uri = ($_SERVER['HTTPS'] != "on" ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . preg_replace('/backend\.php.*$/', 'tt-rss.php', $_SERVER["REQUEST_URI"]); $tp_uri = ($_SERVER['HTTPS'] != "on" ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . 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") { $action = $_REQUEST["action"]; if ($action == "save") { $cat_title = db_escape_string(trim($_REQUEST["value"])); $cat_id = db_escape_string($_GET["cid"]); $result = db_query($link, "UPDATE ttrss_feed_categories SET title = '$cat_title' WHERE id = '$cat_id' AND owner_uid = ".$_SESSION["uid"]); print $_REQUEST["value"]; return; } print "
".__('Category editor')."
"; print "
"; 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_warning(T_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 ""; $lnum = 0; while ($line = db_fetch_assoc($result)) { $class = ($lnum % 2) ? "even" : "odd"; $cat_id = $line["id"]; $this_row_id = "id=\"FCATR-$cat_id\""; print ""; $edit_title = htmlspecialchars($line["title"]); print ""; print ""; print ""; ++$lnum; } print "
" . $edit_title . "
"; print "
"; print "
"; } else { print "

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

"; } print "
"; print "
"; print " "; print "
"; print "
"; return; } if ($quiet) return; set_pref($link, "_PREFS_ACTIVE_TAB", "feedConfig"); $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 " "; } $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 = ""; } $show_last_article_info = false; $show_last_article_checked = ""; $show_last_article_qpart = ""; if ($_GET["slat"] == "true") { $show_last_article_info = true; $show_last_article_checked = "checked"; $show_last_article_qpart = ", (SELECT ".SUBSTRING_FOR_DATE."(MAX(updated),1,16) FROM ttrss_user_entries, ttrss_entries WHERE ref_id = ttrss_entries.id AND feed_id = F1.id) AS last_article"; } else if ($feeds_sort == "last_article") { $feeds_sort = "title"; } 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_FOR_DATE."(F1.last_updated,1,16) AS last_updated, F1.parent_feed, F1.update_interval, F1.last_error, F1.purge_interval, F1.cat_id, F2.title AS parent_title, C1.title AS category, F1.hidden, F1.include_in_digest $show_last_article_qpart 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 ""; if ($show_last_article_info) { 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($line["title"]); $edit_cat = htmlspecialchars($line["category"]); $hidden = sql_bool_to_bool($line["hidden"]); $last_error = $line["last_error"]; if (!$edit_cat) $edit_cat = __("Uncategorized"); $last_updated = $line["last_updated"]; if (!$last_updated) { $last_updated = "—"; } else 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 (!$last_article) { $last_article = "—"; } else 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 ""; if ($show_last_article_info) { 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 ""; $onclick = "onclick='editFeed($feed_id)' title='".__('Click to edit')."'"; if (get_pref($link, 'ENABLE_FEED_ICONS')) { print ""; } if ($hidden) { $edit_title = "$edit_title (Hidden)"; $last_updated = "$last_updated"; $last_article = "$last_article"; } if ($last_error) { $edit_title = "$edit_title"; $last_updated = "$last_updated"; $last_article = "$last_article"; } $parent_title = $line["parent_title"]; if ($parent_title) { $parent_title = "(linked to $parent_title)"; } print ""; if ($show_last_article_info) { print ""; } print ""; print ""; ++$lnum; } print "
". "
". "
". __('Select:')." ".__('All').", ".__('None')." "; if (!get_pref($link, 'ENABLE_FEED_CATS')) { print "
  ".__('Title')."".__('Last Article')."".__('Updated')."
$edit_cat
  ".__('Title')." ".__('Last Article')." ".__('Updated')."
$feed_icon" . "$edit_title $parent_title" . "" . "$last_article$last_updated
"; print "

"; print "

"; if (get_pref($link, 'ENABLE_FEED_CATS')) { print __('Selection:') . " "; print_feed_cat_select($link, "sfeed_set_fcat", "", "disabled"); print " "; } print "
"; print ""; } print "

".__('OPML')."

".__('File:')."  
"; print " "; print ""; print "

" . __("Firefox Integration") . "

"; print "

" . __('This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.'); print "

" . __('Click here to register this site as a feed reader.') . "

"; print "

".__("Published articles")."

"; if (!get_pref($link, "_PREFS_PUBLISH_KEY")) { set_pref($link, "_PREFS_PUBLISH_KEY", generate_publish_key()); } print "

".__('Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.')."

"; $url_path = article_publish_url($link); print "

Link to published articles feed.

"; print "

"; /* print " "; */ print "

"; } ?>