+ $reply['content'] .= "
(".
$line["feed_title"].")
";
}
- } */
+ }
$reply['content'] .= "";
@@ -5294,18 +5417,7 @@
$reply['content'] .= "";
$reply['content'] .= "";
if ($line['note']) {
$reply['content'] .= format_article_note($id, $line['note']);
}
$reply['content'] .= "
";
- $reply['content'] .= "$article_content";
+ $reply['content'] .= "";
+ $reply['content'] .= $expand_cdm ? $article_content : '';
+ $reply['content'] .= "";
- $tmp_result = db_query($link, "SELECT always_display_enclosures FROM
+/* $tmp_result = db_query($link, "SELECT always_display_enclosures FROM
ttrss_feeds WHERE id = ".
(($line['feed_id'] == null) ? $line['orig_feed_id'] :
- $line['feed_id'])." AND owner_uid = ".$_SESSION["uid"]);
+ $line['feed_id'])." AND owner_uid = ".$_SESSION["uid"]);
$always_display_enclosures = sql_bool_to_bool(db_fetch_result($tmp_result,
- 0, "always_display_enclosures"));
+ 0, "always_display_enclosures")); */
+
+ $always_display_enclosures = sql_bool_to_bool($line["always_display_enclosures"]);
$reply['content'] .= format_article_enclosures($link, $id, $always_display_enclosures,
$article_content);
@@ -5415,7 +5538,11 @@
$reply['content'] .= "";
-# }
-
- #print "]]>";
+ if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H2", $timing_info);
return array($topmost_article_ids, $headlines_count, $feed, $disable_cache,
- $vgroup_last_feed, $reply['content'], $reply['toolbar']);
+ $vgroup_last_feed, $reply);
}
// from here: http://www.roscripts.com/Create_tag_cloud-71.html
@@ -5544,6 +5686,8 @@
$tags[$line["tag_name"]] = $line["count"];
}
+ if( count($tags) == 0 ){ return; }
+
ksort($tags);
$max_size = 32; // max font size in pixels
@@ -5599,22 +5743,9 @@
}
function get_self_url_prefix() {
-
- /* $url_path = "";
-
- if ($_SERVER['HTTPS'] != "on") {
- $url_path = "http://";
- } else {
- $url_path = "https://";
- }
-
- $url_path .= $_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
-
- return $url_path; */
-
return SELF_URL_PATH;
-
}
+
function opml_publish_url($link){
$url_path = get_self_url_prefix();
@@ -5722,9 +5853,9 @@
// Test if feed is currently being updated by another process.
if (DB_TYPE == "pgsql") {
- $updstart_thresh_qpart = "AND (ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < NOW() - INTERVAL '120 seconds')";
+ $updstart_thresh_qpart = "AND (ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < NOW() - INTERVAL '5 minutes')";
} else {
- $updstart_thresh_qpart = "AND (ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < DATE_SUB(NOW(), INTERVAL 120 SECOND))";
+ $updstart_thresh_qpart = "AND (ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < DATE_SUB(NOW(), INTERVAL 5 MINUTE))";
}
// Test if there is a limit to number of updated feeds
@@ -6110,6 +6241,38 @@
return $unread;
}
+ function ccache_cleanup($link, $owner_uid) {
+
+ if (DB_TYPE == "pgsql") {
+ db_query($link, "DELETE FROM ttrss_counters_cache AS c1 WHERE
+ (SELECT count(*) FROM ttrss_counters_cache AS c2
+ WHERE c1.feed_id = c2.feed_id AND c2.owner_uid = c1.owner_uid) > 1
+ AND owner_uid = '$owner_uid'");
+
+ db_query($link, "DELETE FROM ttrss_cat_counters_cache AS c1 WHERE
+ (SELECT count(*) FROM ttrss_cat_counters_cache AS c2
+ WHERE c1.feed_id = c2.feed_id AND c2.owner_uid = c1.owner_uid) > 1
+ AND owner_uid = '$owner_uid'");
+ } else {
+ db_query($link, "DELETE c1 FROM
+ ttrss_counters_cache AS c1,
+ ttrss_counters_cache AS c2
+ WHERE
+ c1.owner_uid = '$owner_uid' AND
+ c1.owner_uid = c2.owner_uid AND
+ c1.feed_id = c2.feed_id");
+
+ db_query($link, "DELETE c1 FROM
+ ttrss_cat_counters_cache AS c1,
+ ttrss_cat_counters_cache AS c2
+ WHERE
+ c1.owner_uid = '$owner_uid' AND
+ c1.owner_uid = c2.owner_uid AND
+ c1.feed_id = c2.feed_id");
+
+ }
+ }
+
function label_find_id($link, $label, $owner_uid) {
$result = db_query($link,
"SELECT id FROM ttrss_labels2 WHERE caption = '$label'
@@ -6353,12 +6516,6 @@
$num_tags = 0;
-/* if (get_user_theme($link) == "3pane") {
- $tag_limit = 3;
- } else {
- $tag_limit = 6;
- } */
-
$tag_limit = 6;
$formatted_tags = array();
@@ -6487,9 +6644,9 @@
db_query($link, "COMMIT");
-/* if (file_exists(ICONS_DIR . "/$id.ico")) {
+ if (file_exists(ICONS_DIR . "/$id.ico")) {
unlink(ICONS_DIR . "/$id.ico");
- } */
+ }
ccache_remove($link, $id, $owner_uid);
@@ -6749,7 +6906,7 @@
function api_get_headlines($link, $feed_id, $limit, $offset,
$filter, $is_cat, $show_excerpt, $show_content, $view_mode, $order,
- $include_attachments) {
+ $include_attachments, $since_id) {
/* do not rely on params below */
@@ -6759,7 +6916,7 @@
$qfh_ret = queryFeedHeadlines($link, $feed_id, $limit,
$view_mode, $is_cat, $search, $search_mode, $match_on,
- $order, $offset);
+ $order, $offset, 0, false, $since_id);
$result = $qfh_ret[0];
$feed_title = $qfh_ret[1];
@@ -7387,11 +7544,17 @@
_debug("Updating: " . $line['access_url'] . " ($id)");
- $fetch_url = $line['access_url'] . '/backend.php?op=fbexport';
+ $fetch_url = $line['access_url'] . '/public.php?op=fbexport';
$post_query = 'key=' . $line['access_key'];
$feeds = fetch_file_contents($fetch_url, false, false, false, $post_query);
+ // try doing it the old way
+ if (!$feeds) {
+ $fetch_url = $line['access_url'] . '/backend.php?op=fbexport';
+ $feeds = fetch_file_contents($fetch_url, false, false, false, $post_query);
+ }
+
if ($feeds) {
$feeds = json_decode($feeds, true);
@@ -7441,6 +7604,223 @@
last_status_out = '$status', last_connected = NOW() WHERE id = '$id'");
}
+ }
+
+ function handle_public_request($link, $op) {
+ switch ($op) {
+
+ case "getUnread":
+ $login = db_escape_string($_REQUEST["login"]);
+ $fresh = $_REQUEST["fresh"] == "1";
+
+ $result = db_query($link, "SELECT id FROM ttrss_users WHERE login = '$login'");
+
+ if (db_num_rows($result) == 1) {
+ $uid = db_fetch_result($result, 0, "id");
+
+ print getGlobalUnread($link, $uid);
+
+ if ($fresh) {
+ print ";";
+ print getFeedArticles($link, -3, false, true, $uid);
+ }
+
+ } else {
+ print "-1;User not found";
+ }
+
+ break; // getUnread
+
+ case "getProfiles":
+ $login = db_escape_string($_REQUEST["login"]);
+ $password = db_escape_string($_REQUEST["password"]);
+
+ if (authenticate_user($link, $login, $password)) {
+ $result = db_query($link, "SELECT * FROM ttrss_settings_profiles
+ WHERE owner_uid = " . $_SESSION["uid"] . " ORDER BY title");
+
+ print "";
+
+ $_SESSION = array();
+ }
+ break; // getprofiles
+
+ case "pubsub":
+ $mode = db_escape_string($_REQUEST['hub_mode']);
+ $feed_id = (int) db_escape_string($_REQUEST['id']);
+ $feed_url = db_escape_string($_REQUEST['hub_topic']);
+
+ if (!PUBSUBHUBBUB_ENABLED) {
+ header('HTTP/1.0 404 Not Found');
+ echo "404 Not found";
+ return;
+ }
+
+ // TODO: implement hub_verifytoken checking
+
+ $result = db_query($link, "SELECT feed_url FROM ttrss_feeds
+ WHERE id = '$feed_id'");
+
+ if (db_num_rows($result) != 0) {
+
+ $check_feed_url = db_fetch_result($result, 0, "feed_url");
+
+ if ($check_feed_url && ($check_feed_url == $feed_url || !$feed_url)) {
+ if ($mode == "subscribe") {
+ db_query($link, "UPDATE ttrss_feeds SET pubsub_state = 2
+ WHERE id = '$feed_id'");
+
+ print $_REQUEST['hub_challenge'];
+ return;
+
+ } else if ($mode == "unsubscribe") {
+
+ db_query($link, "UPDATE ttrss_feeds SET pubsub_state = 0
+ WHERE id = '$feed_id'");
+
+ print $_REQUEST['hub_challenge'];
+ return;
+
+ } else if (!$mode) {
+
+ // Received update ping, schedule feed update.
+ //update_rss_feed($link, $feed_id, true, true);
+
+ db_query($link, "UPDATE ttrss_feeds SET
+ last_update_started = '1970-01-01',
+ last_updated = '1970-01-01' WHERE id = '$feed_id' AND
+ owner_uid = ".$_SESSION["uid"]);
+
+ }
+ } else {
+ header('HTTP/1.0 404 Not Found');
+ echo "404 Not found";
+ }
+ } else {
+ header('HTTP/1.0 404 Not Found');
+ echo "404 Not found";
+ }
+
+ break; // pubsub
+
+ case "logout":
+ logout_user();
+ header("Location: tt-rss.php");
+ break; // logout
+
+ case "fbexport":
+
+ $access_key = db_escape_string($_POST["key"]);
+
+ // TODO: rate limit checking using last_connected
+ $result = db_query($link, "SELECT id FROM ttrss_linked_instances
+ WHERE access_key = '$access_key'");
+
+ if (db_num_rows($result) == 1) {
+
+ $instance_id = db_fetch_result($result, 0, "id");
+
+ $result = db_query($link, "SELECT feed_url, site_url, title, subscribers
+ FROM ttrss_feedbrowser_cache ORDER BY subscribers DESC LIMIT 100");
+
+ $feeds = array();
+
+ while ($line = db_fetch_assoc($result)) {
+ array_push($feeds, $line);
+ }
+
+ db_query($link, "UPDATE ttrss_linked_instances SET
+ last_status_in = 1 WHERE id = '$instance_id'");
+
+ print json_encode(array("feeds" => $feeds));
+ } else {
+ print json_encode(array("error" => array("code" => 6)));
+ }
+ break; // fbexport
+
+ case "share":
+ $uuid = db_escape_string($_REQUEST["key"]);
+
+ $result = db_query($link, "SELECT ref_id, owner_uid FROM ttrss_user_entries WHERE
+ uuid = '$uuid'");
+
+ if (db_num_rows($result) != 0) {
+ header("Content-Type: text/html");
+
+ $id = db_fetch_result($result, 0, "ref_id");
+ $owner_uid = db_fetch_result($result, 0, "owner_uid");
+
+ $_SESSION["uid"] = $owner_uid;
+ $article = format_article($link, $id, false, true);
+ $_SESSION["uid"] = "";
+
+ print_r($article['content']);
+
+ } else {
+ print "Article not found.";
+ }
+
+ break;
+
+ case "rss":
+ $feed = db_escape_string($_REQUEST["id"]);
+ $key = db_escape_string($_REQUEST["key"]);
+ $is_cat = $_REQUEST["is_cat"] != false;
+ $limit = (int)db_escape_string($_REQUEST["limit"]);
+
+ $search = db_escape_string($_REQUEST["q"]);
+ $match_on = db_escape_string($_REQUEST["m"]);
+ $search_mode = db_escape_string($_REQUEST["smode"]);
+ $view_mode = db_escape_string($_REQUEST["view-mode"]);
+
+ if (SINGLE_USER_MODE) {
+ authenticate_user($link, "admin", null);
+ }
+
+ $owner_id = false;
+
+ if ($key) {
+ $result = db_query($link, "SELECT owner_uid FROM
+ ttrss_access_keys WHERE access_key = '$key' AND feed_id = '$feed'");
+
+ if (db_num_rows($result) == 1)
+ $owner_id = db_fetch_result($result, 0, "owner_uid");
+ }
+
+ if ($owner_id) {
+ $_SESSION['uid'] = $owner_id;
+
+ generate_syndicated_feed($link, 0, $feed, $is_cat, $limit,
+ $search, $search_mode, $match_on, $view_mode);
+ } else {
+ header('HTTP/1.1 403 Forbidden');
+ }
+ break; // rss
+
+
+ case "globalUpdateFeeds":
+ // Update all feeds needing a update.
+ update_daemon_common($link, 0, true, true);
+ break; // globalUpdateFeeds
+
+
+ default:
+ header("Content-Type: text/plain");
+ print json_encode(array("error" => array("code" => 7)));
+ break; // fallback
+
+ }
}
?>