-
- if (!$op) {
- print "<p class='warning'>".__("<b>Warning:</b> Please backup your database before proceeding.")."</p>";
-
- print "<p>" . T_sprintf("Your Tiny Tiny RSS database needs update to the latest version (<b>%d</b> to <b>%d</b>).", $version, $latest_version) . "</p>";
-
- /* print "<p>Available incremental updates:";
-
- foreach (array_keys($update_versions) as $v) {
- if ($v > $version) {
- print " <a href='$update_versions[$v]'>$v</a>";
- }
- } */
-
- print "</p>";
-
- print "<form method='POST'>
- <input type='hidden' name='op' value='do'>
- <input type='submit' onclick='return confirmOP()' value='".__("Perform updates")."'>
- </form>";
-
- } else if ($op == "do") {
-
- print "<p>".__("Performing updates...")."</p>";
-
- $num_updates = 0;
-
- foreach (array_keys($update_versions) as $v) {
- if ($v == $version + 1) {
- print "<p>".T_sprintf("Updating to version %d...", $v)."</p>";
- $fp = fopen($update_versions[$v], "r");
- if ($fp) {
- while (!feof($fp)) {
- $query = trim(getline($fp, ";"));
- if ($query != "") {
- print "<p class='query'>$query</p>";
- db_query($link, $query);
- }
- }
- }
- fclose($fp);
-
- print "<p>".__("Checking version... ");
-
- $result = db_query($link, "SELECT schema_version FROM ttrss_version");
- $version = db_fetch_result($result, 0, "schema_version");
-
- if ($version == $v) {
- print __("OK!");
- } else {
- print "<b>".__("ERROR!")."</b>";
- return;
- }
-
- $num_updates++;
- }
+
+ if ($op == "-daemon-loop") {
+ if (!make_stampfile('update_daemon.stamp')) {
+ die("error: unable to create stampfile\n");
+ }
+
+ // Call to the feed batch update function
+ // or regenerate feedbrowser cache
+
+ if (rand(0,100) > 30) {
+ update_daemon_common($link);
+ } else {
+ $count = update_feedbrowser_cache($link);
+ _debug("Feedbrowser updated, $count feeds processed.");
+
+ purge_orphans($link, true);
+
+ $rc = cleanup_tags($link, 14, 50000);
+
+ _debug("Cleaned $rc cached tags.");