]> git.wh0rd.org - tt-rss.git/blobdiff - include/rssfuncs.php
do not include keyboard help files into index and prefs.php
[tt-rss.git] / include / rssfuncs.php
index 8846d985fb52cf571cd484cc40bebee2828565d8..7588428de958b14d1838c45e1c5cf54599bf840e 100644 (file)
@@ -1,4 +1,50 @@
 <?php
+       define('DAEMON_UPDATE_LOGIN_LIMIT', 30);
+       define('DAEMON_FEED_LIMIT', 100);
+       define('DAEMON_SLEEP_INTERVAL', 120);
+
+       function update_feedbrowser_cache($link) {
+
+               $result = db_query($link, "SELECT feed_url, site_url, title, 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 (private IS true OR auth_login != '' OR auth_pass != '' OR feed_url LIKE '%:%@%/%'))
+                               GROUP BY feed_url, site_url, title ORDER BY subscribers DESC LIMIT 1000");
+
+               db_query($link, "BEGIN");
+
+               db_query($link, "DELETE FROM ttrss_feedbrowser_cache");
+
+               $count = 0;
+
+               while ($line = db_fetch_assoc($result)) {
+                       $subscribers = db_escape_string($line["subscribers"]);
+                       $feed_url = db_escape_string($line["feed_url"]);
+                       $title = db_escape_string($line["title"]);
+                       $site_url = db_escape_string($line["site_url"]);
+
+                       $tmp_result = db_query($link, "SELECT subscribers FROM
+                               ttrss_feedbrowser_cache WHERE feed_url = '$feed_url'");
+
+                       if (db_num_rows($tmp_result) == 0) {
+
+                               db_query($link, "INSERT INTO ttrss_feedbrowser_cache
+                                       (feed_url, site_url, title, subscribers) VALUES ('$feed_url',
+                                               '$site_url', '$title', '$subscribers')");
+
+                               ++$count;
+
+                       }
+
+               }
+
+               db_query($link, "COMMIT");
+
+               return $count;
+
+       }
+
+
        /**
         * Update a feed batch.
         * Used by daemons to update n feeds by run.
@@ -15,7 +61,7 @@
                // Process all other feeds using last_updated and interval parameters
 
                // Test if the user has loggued in recently. If not, it does not update its feeds.
-               if (DAEMON_UPDATE_LOGIN_LIMIT > 0) {
+               if (!SINGLE_USER_MODE && DAEMON_UPDATE_LOGIN_LIMIT > 0) {
                        if (DB_TYPE == "pgsql") {
                                $login_thresh_qpart = "AND ttrss_users.last_login >= NOW() - INTERVAL '".DAEMON_UPDATE_LOGIN_LIMIT." days'";
                        } else {
                }
 
                // Send feed digests by email if needed.
-               if (DAEMON_SENDS_DIGESTS) send_headlines_digests($link);
+               send_headlines_digests($link);
 
        } // function update_daemon_common