}
require_once 'db-prefs.php';
- require_once 'errors.php';
require_once 'version.php';
- require_once 'lib/phpmailer/class.phpmailer.php';
- require_once 'lib/sphinxapi.php';
- require_once 'lib/tmhoauth/tmhOAuth.php';
-
- //define('MAGPIE_USER_AGENT_EXT', ' (Tiny Tiny RSS/' . VERSION . ')');
define('MAGPIE_OUTPUT_ENCODING', 'UTF-8');
define('SELF_USER_AGENT', 'Tiny Tiny RSS/' . VERSION . ' (http://tt-rss.org/)');
ini_set('user_agent', SELF_USER_AGENT);
- require_once "lib/simplepie/simplepie.inc";
- require_once "lib/magpierss/rss_fetch.inc";
- require_once 'lib/magpierss/rss_utils.inc';
- require_once 'lib/htmlpurifier/library/HTMLPurifier.auto.php';
require_once 'lib/pubsubhubbub/publisher.php';
- require_once 'lib/pubsubhubbub/subscriber.php';
-
- $config = HTMLPurifier_Config::createDefault();
-
- $allowed = "p,a[href],i,em,b,strong,code,pre,blockquote,br,img[src|alt|title],ul,ol,li,h1,h2,h3,h4,s,object[classid|type|id|name|width|height|codebase],param[name|value],table,tr,td";
-
- $config->set('HTML.SafeObject', true);
- @$config->set('HTML', 'Allowed', $allowed);
- $config->set('Output.FlashCompat', true);
- $config->set('Attr.EnableID', true);
- if (!defined('MOBILE_VERSION')) {
- @$config->set('Cache', 'SerializerPath', CACHE_DIR . "/htmlpurifier");
- } else {
- @$config->set('Cache', 'SerializerPath', "../" . CACHE_DIR . "/htmlpurifier");
- }
- $purifier = new HTMLPurifier($config);
+ $purifier = false;
$tz_offset = -1;
$utc_tz = new DateTimeZone('UTC');
}
} // function purge_feed
- /**
- * Purge old posts from old feeds. Not used anymore, purging is done after feed update.
- *
- * @param mixed $link A database connection
- * @param boolean $do_output Set to true to enable printed output, false by default.
- * @param integer $limit The maximal number of removed posts.
- * @access public
- * @return void
- */
- /* function global_purge_old_posts($link, $do_output = false, $limit = false) {
-
- $random_qpart = sql_random_function();
-
- if ($limit) {
- $limit_qpart = "LIMIT $limit";
- } else {
- $limit_qpart = "";
- }
-
- $result = db_query($link,
- "SELECT id,purge_interval,owner_uid FROM ttrss_feeds
- ORDER BY $random_qpart $limit_qpart");
-
- while ($line = db_fetch_assoc($result)) {
-
- $feed_id = $line["id"];
- $purge_interval = $line["purge_interval"];
- $owner_uid = $line["owner_uid"];
-
- if ($purge_interval == 0) {
-
- $tmp_result = db_query($link,
- "SELECT value FROM ttrss_user_prefs WHERE
- pref_name = 'PURGE_OLD_DAYS' AND owner_uid = '$owner_uid'");
-
- if (db_num_rows($tmp_result) != 0) {
- $purge_interval = db_fetch_result($tmp_result, 0, "value");
- }
- }
-
- if ($do_output) {
-// print "Feed $feed_id: purge interval = $purge_interval\n";
- }
-
- if ($purge_interval > 0 || FORCE_ARTICLE_PURGE) {
- purge_feed($link, $feed_id, $purge_interval, $do_output);
- }
- }
-
- purge_orphans($link, $do_output);
-
- } // function global_purge_old_posts */
-
function feed_purge_interval($link, $feed_id) {
$result = db_query($link, "SELECT purge_interval, owner_uid FROM ttrss_feeds
}
}
- function purge_old_posts($link) {
-
- $user_id = $_SESSION["uid"];
-
- $result = db_query($link, "SELECT id,purge_interval FROM ttrss_feeds
- WHERE owner_uid = '$user_id'");
-
- while ($line = db_fetch_assoc($result)) {
-
- $feed_id = $line["id"];
- $purge_interval = $line["purge_interval"];
-
- if ($purge_interval == 0) $purge_interval = get_pref($link, 'PURGE_OLD_DAYS');
-
- if ($purge_interval > 0) {
- purge_feed($link, $feed_id, $purge_interval);
- }
- }
-
- purge_orphans($link);
- }
-
function purge_orphans($link, $do_output = false) {
// purge orphaned posts in main content table
function update_rss_feed_real($link, $feed, $ignore_daemon = false, $no_cache = false,
$override_url = false) {
+ require_once "lib/simplepie/simplepie.inc";
+ require_once "lib/magpierss/rss_fetch.inc";
+ require_once 'lib/magpierss/rss_utils.inc';
+
global $memcache;
$debug_enabled = defined('DAEMON_EXTENDED_DEBUG') || $_REQUEST['xdebug'];
if ($feed_hub_url && function_exists('curl_init') &&
!ini_get("open_basedir")) {
+ require_once 'lib/pubsubhubbub/subscriber.php';
+
$callback_url = get_self_url_prefix() .
- "/backend.php?op=pubsub&id=$feed";
+ "/public.php?op=pubsub&id=$feed";
$s = new Subscriber($feed_hub_url, $callback_url);
if (!$entry_content) $entry_content = $item["content"]["encoded"];
if (!$entry_content) $entry_content = $item["content"];
+ if (is_array($entry_content)) $entry_content = $entry_content[0];
+
// Magpie bugs are getting ridiculous
if (trim($entry_content) == "Array") $entry_content = false;
if (PUBSUBHUBBUB_HUB && $published == 'true') {
$rss_link = get_self_url_prefix() .
- "/backend.php?op=rss&id=-2&key=" .
+ "/public.php?op=rss&id=-2&key=" .
get_feed_access_key($link, -2, false, $owner_uid);
$p = new Publisher(PUBSUBHUBBUB_HUB);
}
- function lookup_user_id($link, $user) {
-
- $result = db_query($link, "SELECT id FROM ttrss_users WHERE login = '$user'");
-
- if (db_num_rows($result) == 1) {
- return db_fetch_result($result, 0, "id");
- } else {
- return false;
- }
- }
-
-/* function http_authenticate_user($link) {
- if (!$_SERVER["PHP_AUTH_USER"]) {
-
- header('WWW-Authenticate: Basic realm="Tiny Tiny RSS RSSGen"');
- header('HTTP/1.0 401 Unauthorized');
- exit;
-
- } else {
- $auth_result = authenticate_user($link,
- $_SERVER["PHP_AUTH_USER"], $_SERVER["PHP_AUTH_PW"]);
-
- if (!$auth_result) {
- header('WWW-Authenticate: Basic realm="Tiny Tiny RSS RSSGen"');
- header('HTTP/1.0 401 Unauthorized');
- exit;
- }
- }
-
- return true;
- } */
-
function get_ssl_certificate_id() {
if ($_SERVER["REDIRECT_SSL_CLIENT_M_SERIAL"]) {
return sha1($_SERVER["REDIRECT_SSL_CLIENT_M_SERIAL"] .
}
}
- function get_script_urlpath() {
- return preg_replace('/\/[^\/]*$/', "", $_SERVER["REQUEST_URI"]);
- }
-
function validate_session($link) {
if (SINGLE_USER_MODE) return true;
# try to authenticate user if called from login form
if ($login_action == "do_login") {
- $login = $_POST["login"];
+ $login = db_escape_string($_POST["login"]);
$password = $_POST["password"];
$remember_me = $_POST["remember_me"];
}
}
- function smart_date($timestamp) {
- if (date("Y.m.d", $timestamp) == date("Y.m.d")) {
- return "Today";
- } else if (date("Y", $timestamp) == date("Y")) {
- return date("D m", $timestamp);
- } else {
- return date("Y/m/d", $timestamp);
- }
- }
-
- function sql_bool_to_string($s) {
- if ($s == "t" || $s == "1") {
- return "true";
- } else {
- return "false";
- }
- }
-
function sql_bool_to_bool($s) {
if ($s == "t" || $s == "1" || $s == "true") {
return true;
}
}
- function toggleEvenOdd($a) {
- if ($a == "even")
- return "odd";
- else
- return "even";
- }
-
// Session caching removed due to causing wrong redirects to upgrade
// script when get_schema_version() is called on an obsolete session
// created on a previous schema version.
}
function sanity_check($link) {
-
- global $ERRORS;
+ require_once 'errors.php';
$error_code = 0;
$schema_version = get_schema_version($link, true);
return $ret_arr;
}
- function getSubscribedFeeds($link) {
- $result = db_query($link, "SELECT COUNT(id) AS fn FROM
- ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"]);
-
- return db_fetch_result($result, 0, "fn");
- }
-
function getTagCounters($link) {
$ret_arr = array();
}
}
- function get_session_cookie_name() {
- return ((!defined('TTRSS_SESSION_NAME')) ? "ttrss_sid" : TTRSS_SESSION_NAME);
- }
-
function make_init_params($link) {
$params = array();
return $params;
}
- function print_runtime_info($link) {
- print "<runtime-info><![CDATA[";
- print json_encode(make_runtime_info($link));
- print "]]></runtime-info>";
- }
-
function make_runtime_info($link) {
$data = array();
label_cache,
tag_cache,
always_display_enclosures,
+ site_url,
note,
+ num_comments,
+ comments,
+ int_id,
unread,feed_id,marked,published,link,last_read,orig_feed_id,
".SUBSTRING_FOR_DATE."(last_read,1,19) as last_read_noms,
$vfeed_query_part
"unread," .
"feed_id," .
"orig_feed_id," .
+ "site_url," .
+ "always_display_enclosures, ".
"marked," .
+ "num_comments, " .
+ "comments, " .
"tag_cache," .
"label_cache," .
"link," .
$last_error = $qfh_ret[3];
$feed_self_url = get_self_url_prefix() .
- "/backend.php?op=rss&id=-2&key=" .
+ "/public.php?op=rss&id=-2&key=" .
get_feed_access_key($link, -2, false);
if (!$feed_site_url) $feed_site_url = get_self_url_prefix();
$res = trim($str); if (!$res) return '';
-// if (get_pref($link, "STRIP_UNSAFE_TAGS", $owner) || $force_strip_tags) {
+ // create global Purifier object if needed
+ if (!$purifier) {
+ require_once 'lib/htmlpurifier/library/HTMLPurifier.auto.php';
+
+ $config = HTMLPurifier_Config::createDefault();
+
+ $allowed = "p,a[href],i,em,b,strong,code,pre,blockquote,br,img[src|alt|title],ul,ol,li,h1,h2,h3,h4,s,object[classid|type|id|name|width|height|codebase],param[name|value],table,tr,td";
+
+ $config->set('HTML.SafeObject', true);
+ @$config->set('HTML', 'Allowed', $allowed);
+ $config->set('Output.FlashCompat', true);
+ $config->set('Attr.EnableID', true);
+ if (!defined('MOBILE_VERSION')) {
+ @$config->set('Cache', 'SerializerPath', CACHE_DIR . "/htmlpurifier");
+ } else {
+ @$config->set('Cache', 'SerializerPath', "../" . CACHE_DIR . "/htmlpurifier");
+ }
+
+ $purifier = new HTMLPurifier($config);
+ }
+
$res = $purifier->purify($res);
-// }
if (get_pref($link, "STRIP_IMAGES", $owner)) {
$res = preg_replace('/<img[^>]+>/is', '', $res);
*/
function send_headlines_digests($link, $limit = 100) {
+ require_once 'lib/phpmailer/class.phpmailer.php';
+
if (!DIGEST_ENABLE) return false;
$user_limit = DIGEST_EMAIL_LIMIT;
if (PUBSUBHUBBUB_HUB) {
$rss_link = get_self_url_prefix() .
- "/backend.php?op=rss&id=-2&key=" .
+ "/public.php?op=rss&id=-2&key=" .
get_feed_access_key($link, -2, false);
$p = new Publisher(PUBSUBHUBBUB_HUB);
}
$rss_link = htmlspecialchars(get_self_url_prefix() .
- "/backend.php?op=rss&id=$feed_id$cat_q$search_q");
+ "/public.php?op=rss&id=$feed_id$cat_q$search_q");
$reply .= "<option value=\"0\" disabled=\"1\">".__('Feed:')."</option>";
return $tags;
}
- function trim_value(&$value) {
- $value = trim($value);
- }
-
function trim_array($array) {
$tmp = $array;
- array_walk($tmp, 'trim_value');
+ array_walk($tmp, 'trim');
return $tmp;
}
$marked_pic = "<img id=\"FMPIC-$id\"
src=\"".theme_image($link, 'images/mark_set.png')."\"
class=\"markedPic\" alt=\"Unstar article\"
- onclick='javascript:tMark($id)'>";
+ onclick='javascript:toggleMark($id)'>";
} else {
$marked_pic = "<img id=\"FMPIC-$id\"
src=\"".theme_image($link, 'images/mark_unset.png')."\"
class=\"markedPic\" alt=\"Star article\"
- onclick='javascript:tMark($id)'>";
+ onclick='javascript:toggleMark($id)'>";
}
if ($line["published"] == "t" || $line["published"] == "1") {
$published_pic = "<img id=\"FPPIC-$id\" src=\"".theme_image($link,
'images/pub_set.png')."\"
class=\"markedPic\"
- alt=\"Unpublish article\" onclick='javascript:tPub($id)'>";
+ alt=\"Unpublish article\" onclick='javascript:togglePub($id)'>";
} else {
$published_pic = "<img id=\"FPPIC-$id\" src=\"".theme_image($link,
'images/pub_unset.png')."\"
class=\"markedPic\"
- alt=\"Publish article\" onclick='javascript:tPub($id)'>";
+ alt=\"Publish article\" onclick='javascript:togglePub($id)'>";
}
# $content_link = "<a target=\"_blank\" href=\"".$line["link"]."\">" .
}
}
- // FIXME: make this less of a hack
-
- $feed_site_url = false;
-
- if ($line["feed_id"]) {
- $tmp_result = db_query($link, "SELECT site_url FROM ttrss_feeds
- WHERE id = " . $line["feed_id"]);
-
- if (db_num_rows($tmp_result) == 1) {
- $feed_site_url = db_fetch_result($tmp_result, 0, "site_url");
- }
- }
+ $feed_site_url = $line["site_url"];
$article_content = sanitize_rss($link, $line["content_preview"],
false, false, $feed_site_url);
<a title=\"".__('Edit tags for this article')."\"
href=\"#\" onclick=\"editArticleTags($id, $feed_id, true)\">(+)</a>";
+ $num_comments = $line["num_comments"];
+ $entry_comments = "";
+
+ if ($num_comments > 0) {
+ if ($line["comments"]) {
+ $comments_url = $line["comments"];
+ } else {
+ $comments_url = $line["link"];
+ }
+ $entry_comments = "<a target='_blank' href=\"$comments_url\">$num_comments comments</a>";
+ } else {
+ if ($line["comments"] && $line["link"] != $line["comments"]) {
+ $entry_comments = "<a target='_blank' href=\"".$line["comments"]."\">comments</a>";
+ }
+ }
+
+ if ($entry_comments) $reply['content'] .= " ($entry_comments)";
+
$reply['content'] .= "<div style=\"float : right\">";
$reply['content'] .= "<img src=\"images/art-zoom.png\"
alt='Zoom' title='".__('Share on Twitter')."'>";
}
+ $reply['content'] .= "<img src=\"".theme_image($link, 'images/art-share.png')."\"
+ class='tagsPic' style=\"cursor : pointer\"
+ onclick=\"shareArticle(".$line['int_id'].")\"
+ alt='Zoom' title='".__('Share by URL')."'>";
+
$reply['content'] .= "<img src=\"images/digest_checkbox.png\"
style=\"cursor : pointer\" style=\"cursor : pointer\"
onclick=\"dismissArticle($id)\"
}
}
- function rounded_table_start($classname, $header = " ") {
- print "<table width='100%' class='$classname' cellspacing='0' cellpadding='0'>";
- print "<tr><td class='c1'> </td><td class='top'>$header</td><td class='c2'> </td></tr>";
- print "<tr><td class='left'> </td><td class='content'>";
- }
-
- function rounded_table_end($footer = " ") {
- print "</td><td class='right'> </td></tr>";
- print "<tr><td class='c4'> </td><td class='bottom'>$footer</td><td class='c3'> </td></tr>";
- print "</table>";
- }
-
function feed_has_icon($id) {
return is_file(ICONS_DIR . "/$id.ico") && filesize(ICONS_DIR . "/$id.ico") > 0;
}
}
- function ccache_zero($link, $feed_id, $owner_uid) {
+ /* function ccache_zero($link, $feed_id, $owner_uid) {
db_query($link, "UPDATE ttrss_counters_cache SET
value = 0, updated = NOW() WHERE
feed_id = '$feed_id' AND owner_uid = '$owner_uid'");
- }
+ } */
function ccache_zero_all($link, $owner_uid) {
db_query($link, "UPDATE ttrss_counters_cache SET
return $unread;
}
- function ccache_cleanup($link, $owner_uid) {
+ /* function ccache_cleanup($link, $owner_uid) {
if (DB_TYPE == "pgsql") {
db_query($link, "DELETE FROM ttrss_counters_cache AS c1 WHERE
c1.feed_id = c2.feed_id");
}
- }
+ } */
function label_find_id($link, $label, $owner_uid) {
$result = db_query($link,
return $result;
}
- function print_labels_headlines_dropdown($link, $feed_id) {
- print "<option value=\"addLabel()\">".__("Create label...")."</option>";
-
- $result = db_query($link, "SELECT id, caption FROM ttrss_labels2 WHERE
- owner_uid = '".$_SESSION["uid"]."' ORDER BY caption");
-
- while ($line = db_fetch_assoc($result)) {
-
- $label_id = $line["id"];
- $label_caption = $line["caption"];
- $id = $line["id"];
-
- if ($feed_id < -10 && $feed_id == -11-$label_id) {
- print "<option id=\"LHDL-$id\"
- value=\"selectionRemoveLabel($label_id)\">".
- __('Remove:') . " $label_caption</option>";
- } else {
- print "<option id=\"LHDL-$id\"
- value=\"selectionAssignLabel($label_id)\">".
- __('Assign:') . " $label_caption</option>";
- }
- }
- }
-
function format_tags_string($tags, $id) {
$tags_str = "";
}
}
- function make_url_from_parts($parts) {
- $url = $parts['scheme'] . '://' . $parts['host'];
-
- if ($parts['path']) $url .= $parts['path'];
- if ($parts['query']) $url .= '?' . $parts['query'];
-
- return $url;
- }
-
/**
* Fixes incomplete URLs by prepending "http://".
* Also replaces feed:// with http://, and
$is_updated = ($line["last_read"] == "" &&
($line["unread"] != "t" && $line["unread"] != "1"));
+ $tags = explode(",", $line["tag_cache"]);
+ $labels = json_decode($line["label_cache"], true);
+
+ //if (!$tags) $tags = get_article_tags($link, $line["id"]);
+ //if (!$labels) $labels = get_article_labels($link, $line["id"]);
+
$headline_row = array(
"id" => (int)$line["id"],
"unread" => sql_bool_to_bool($line["unread"]),
"title" => $line["title"],
"link" => $line["link"],
"feed_id" => $line["feed_id"],
- "tags" => get_article_tags($link, $line["id"]),
+ "tags" => $tags,
);
if ($include_attachments)
$headline_row["content"] = $line["content_preview"];
}
+ // unify label output to ease parsing
+ if ($labels["no-labels"] == 1) $labels = array();
+
+ $headline_row["labels"] = $labels;
+
array_push($headlines, $headline_row);
}
}
function sphinx_search($query, $offset = 0, $limit = 30) {
+ require_once 'lib/sphinxapi.php';
+
$sphinxClient = new SphinxClient();
$sphinxClient->SetServer('localhost', 9312);
function fetch_twitter_rss($link, $url, $owner_uid) {
+
+ require_once 'lib/tmhoauth/tmhOAuth.php';
+
$result = db_query($link, "SELECT twitter_oauth FROM ttrss_users
WHERE id = $owner_uid");
_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);
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 "<select style='width: 100%' name='profile'>";
+
+ print "<option value='0'>" . __("Default profile") . "</option>";
+
+ while ($line = db_fetch_assoc($result)) {
+ $id = $line["id"];
+ $title = $line["title"];
+
+ print "<option value='$id'>$title</option>";
+ }
+
+ print "</select>";
+
+ $_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'");
+
+ }
+ } 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
+
+ }
}
?>