From 186649709a15de3b36411ae250d28abb574b1c53 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 31 Jul 2006 12:35:50 +0100 Subject: add aggregated feed generator --- functions.php | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) (limited to 'functions.php') diff --git a/functions.php b/functions.php index 686cecfeb..e77f2d5a0 100644 --- a/functions.php +++ b/functions.php @@ -948,6 +948,28 @@ } } + 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 authenticate_user($link, $login, $password) { if (!SINGLE_USER_MODE) { @@ -1406,7 +1428,13 @@ function getCategoryUnread($link, $cat) { - $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE cat_id = '$cat' + if ($cat != 0) { + $cat_query = "cat_id = '$cat'"; + } else { + $cat_query = "cat_id IS NULL"; + } + + $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE $cat_query AND owner_uid = " . $_SESSION["uid"]); $cat_feeds = array(); @@ -1414,6 +1442,8 @@ array_push($cat_feeds, "feed_id = " . $line["id"]); } + if (count($cat_feeds) == 0) return 0; + $match_part = implode(" OR ", $cat_feeds); $result = db_query($link, "SELECT COUNT(int_id) AS unread @@ -2179,4 +2209,41 @@ } + function generate_syndicated_feed($link, $feed, $is_cat) { + + $qfh_ret = queryFeedHeadlines($link, $feed, + 30, false, $is_cat, false, false, false); + + $result = $qfh_ret[0]; + $feed_title = $qfh_ret[1]; + $feed_site_url = $qfh_ret[2]; + $last_error = $qfh_ret[3]; + + print " + + $feed_title + $feed_site_url + Tiny Tiny RSS v".VERSION.""; + + while ($line = db_fetch_assoc($result)) { + print ""; + print "" . htmlspecialchars($line["link"]) . ""; + + $rfc822_date = date('r', strtotime($line["updated"])); + + print "$rfc822_date"; + + print "" . + htmlspecialchars($line["title"]) . ""; + + print "" . + htmlspecialchars($line["content_preview"]) . ""; + + print ""; + } + + print ""; + + } + ?> -- cgit v1.2.3