- case "pref-pub-items":
- module_pref_pub_items($link);
- break; // pref-pub-items
-
- case "globalUpdateFeeds":
- // update feeds of all users, may be used anonymously
-
- print "<!--";
- // Update all feeds needing a update.
- update_daemon_common($link, 0, true, true);
- print " -->";
-
- // FIXME : old feed update way. To be removed.
- //$result = db_query($link, "SELECT id FROM ttrss_users");
-
- //while ($line = db_fetch_assoc($result)) {
- // $user_id = $line["id"];
- // print "<!-- updating feeds of uid $user_id -->";
- // update_all_feeds($link, false, $user_id);
- //}
-
- print "<rpc-reply>
- <message msg=\"All feeds updated\"/>
- </rpc-reply>";
- break; // globalUpdateFeeds
-
- case "user-details":
-
- if (WEB_DEMO_MODE || $_SESSION["access_level"] < 10) {
- return;
- }
-
- /*
- print "<html><head>
- <title>Tiny Tiny RSS : User Details</title>
- <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">
- <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
- </head><body>";
- */
-
- $uid = sprintf("%d", $_GET["id"]);
-
- print "<div id=\"infoBoxTitle\">User details</div>";
-
- print "<div class='infoBoxContents'>";
-
- $result = db_query($link, "SELECT login,
- ".SUBSTRING_FOR_DATE."(last_login,1,16) AS last_login,
- access_level,
- (SELECT COUNT(int_id) FROM ttrss_user_entries
- WHERE owner_uid = id) AS stored_articles,
- ".SUBSTRING_FOR_DATE."(created,1,16) AS created
- FROM ttrss_users
- WHERE id = '$uid'");
-
- if (db_num_rows($result) == 0) {
- print "<h1>User not found</h1>";
- return;
- }
-
- // print "<h1>User Details</h1>";
-
- $login = db_fetch_result($result, 0, "login");
-
- // print "<h1>$login</h1>";
-
- print "<table width='100%'>";
-
- $last_login = date(get_pref($link, 'LONG_DATE_FORMAT'),
- strtotime(db_fetch_result($result, 0, "last_login")));
-
- $created = date(get_pref($link, 'LONG_DATE_FORMAT'),
- strtotime(db_fetch_result($result, 0, "created")));
-
- $access_level = db_fetch_result($result, 0, "access_level");
- $stored_articles = db_fetch_result($result, 0, "stored_articles");
-
- // print "<tr><td>Username</td><td>$login</td></tr>";
- // print "<tr><td>Access level</td><td>$access_level</td></tr>";
- print "<tr><td>".__('Registered')."</td><td>$created</td></tr>";
- print "<tr><td>".__('Last logged in')."</td><td>$last_login</td></tr>";
- print "<tr><td>".__('Stored articles')."</td><td>$stored_articles</td></tr>";
-
- $result = db_query($link, "SELECT COUNT(id) as num_feeds FROM ttrss_feeds
- WHERE owner_uid = '$uid'");
-
- $num_feeds = db_fetch_result($result, 0, "num_feeds");
-
- print "<tr><td>".__('Subscribed feeds count')."</td><td>$num_feeds</td></tr>";
-
- /*
- $result = db_query($link, "SELECT
- SUM(LENGTH(content)+LENGTH(title)+LENGTH(link)+LENGTH(guid)) AS db_size
- FROM ttrss_user_entries,ttrss_entries
- WHERE owner_uid = '$uid' AND ref_id = id");
-
- $db_size = round(db_fetch_result($result, 0, "db_size") / 1024);
-
- print "<tr><td>Approx. used DB size</td><td>$db_size KBytes</td></tr>";
- */
-
- print "</table>";
-
- print "<h1>".__('Subscribed feeds')."</h1>";
-
- $result = db_query($link, "SELECT id,title,site_url FROM ttrss_feeds
- WHERE owner_uid = '$uid' ORDER BY title");
-
- print "<ul class=\"userFeedList\">";
-
- $row_class = "odd";
-
- while ($line = db_fetch_assoc($result)) {
-
- $icon_file = ICONS_URL."/".$line["id"].".ico";
-
- if (file_exists($icon_file) && filesize($icon_file) > 0) {
- $feed_icon = "<img class=\"tinyFeedIcon\" src=\"$icon_file\">";
- } else {
- $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
- }
-
- print "<li class=\"$row_class\">$feed_icon <a href=\"".$line["site_url"]."\">".$line["title"]."</a></li>";
-
- $row_class = toggleEvenOdd($row_class);
-
- }
-
- if (db_num_rows($result) < $num_feeds) {
- // FIXME - add link to show ALL subscribed feeds here somewhere
- print "<li><img
- class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\"> ...</li>";
- }
-
- print "</ul>";
-
- print "</div>";
-
- print "<div align='center'>
- <input type='submit' class='button'
- onclick=\"closeInfoBox()\" value=\"Close this window\"></div>";
-
- // print "</body></html>";
-
- break; // user-details
-
- case "pref-feed-browser":
- module_pref_feed_browser($link);
- break; // pref-feed-browser
-
- case "publish":
- $key = db_escape_string($_GET["key"]);
-
- $result = db_query($link, "SELECT login, owner_uid
- FROM ttrss_user_prefs, ttrss_users WHERE
- pref_name = '_PREFS_PUBLISH_KEY' AND
- value = '$key' AND
- ttrss_users.id = owner_uid");
-
- if (db_num_rows($result) == 1) {
- $owner = db_fetch_result($result, 0, "owner_uid");
- $login = db_fetch_result($result, 0, "login");
-
- generate_syndicated_feed($link, $owner, -2, false);
-
- } else {
- print "<error>User not found</error>";
- }
- break; // publish
-
- case "rss":
- $feed = db_escape_string($_GET["id"]);
- $user = db_escape_string($_GET["user"]);
- $pass = db_escape_string($_GET["pass"]);
- $is_cat = $_GET["is_cat"] != false;
-
- $search = db_escape_string($_GET["q"]);
- $match_on = db_escape_string($_GET["m"]);
- $search_mode = db_escape_string($_GET["smode"]);
-
- if (!$_SESSION["uid"] && $user && $pass) {
- authenticate_user($link, $user, $pass);
- }
-
- if ($_SESSION["uid"] ||
- http_authenticate_user($link)) {
-
- generate_syndicated_feed($link, 0, $feed, $is_cat,
- $search, $search_mode, $match_on);
- }
- break; // rss
-
- case "labelFromSearch":
- $search = db_escape_string($_GET["search"]);
- $search_mode = db_escape_string($_GET["smode"]);
- $match_on = db_escape_string($_GET["match"]);
- $is_cat = db_escape_string($_GET["is_cat"]);
- $title = db_escape_string($_GET["title"]);
- $feed = sprintf("%d", $_GET["feed"]);
-
- $label_qparts = array();
-
- $search_expr = getSearchSql($search, $match_on);
-
- if ($is_cat) {
- if ($feed != 0) {
- $search_expr .= " AND ttrss_feeds.cat_id = $feed ";
- } else {
- $search_expr .= " AND ttrss_feeds.cat_id IS NULL ";
- }
- } else {
- if ($search_mode == "all_feeds") {
- // NOOP
- } else if ($search_mode == "this_cat") {
-
- $tmp_result = db_query($link, "SELECT cat_id
- FROM ttrss_feeds WHERE id = '$feed'");
-
- $cat_id = db_fetch_result($tmp_result, 0, "cat_id");