]> git.wh0rd.org - tt-rss.git/blobdiff - update_feedbrowser.php
update_rss_feed: properly define
[tt-rss.git] / update_feedbrowser.php
old mode 100644 (file)
new mode 100755 (executable)
index 6074906..0031ff3
@@ -1,9 +1,9 @@
 #!/usr/bin/php
 <?php
-       // this script is probably run not from your httpd-user, so cache
-       // directory defined in config.php won't be accessible
-       define('MAGPIE_CACHE_DIR', '/var/tmp/magpie-ttrss-cache-cli');
-       define('SIMPLEPIE_CACHE_DIR',   '/var/tmp/simplepie-ttrss-cache-cli');
+       /* This script updates feedbrowser (e.g. Other Feeds tab) cache
+        * If you are using update daemon, it is NOT necessary to run
+        * this script, as updates are handled automatically. */
+
        define('DEFAULT_ERROR_LEVEL', E_ERROR | E_WARNING | E_PARSE);
        define('DISABLE_SESSIONS', true);
 
 
        init_connection($link);
 
-       $result = db_query($link, "SELECT feed_url,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 feed_url LIKE '%:%@%/%')) 
-                       GROUP BY feed_url ORDER BY subscribers DESC");
-
-       db_query($link, "BEGIN");
-
-       db_query($link, "DELETE FROM ttrss_feedbrowser_cache");
-
-       while ($line = db_fetch_assoc($result)) {
-               $subscribers = db_escape_string($line["subscribers"]);
-               $feed_url = db_escape_string($line["feed_url"]);
-
-               db_query($link, "INSERT INTO ttrss_feedbrowser_cache 
-                       (feed_url, subscribers) VALUES ('$feed_url', '$subscribers')");
-
-       }
+       $count = update_feedbrowser_cache($link);
 
-       db_query($link, "COMMIT");
+       print "Finished, $count feeds processed.\n";
 
        db_close($link);