X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=update.php;h=7bf6807ffb4b2145a59a32d3c92125e8d96f4b46;hb=7a866114e1236da92c0a35c9441903640a6bdf63;hp=51930beab03c50efefdbb359362c1f7d0d0290ce;hpb=6aff7845751e1671f436da6686209b414fdcfcc4;p=tt-rss.git diff --git a/update.php b/update.php index 51930bea..7bf6807f 100755 --- a/update.php +++ b/update.php @@ -1,7 +1,7 @@ #!/usr/bin/env php - Database Updater + Tiny Tiny RSS data update script. -

+

- + get_commands() as $command => $data) { + printf(" %-19s - %s\n", "$command", $data["description"]); + } + return; } @@ -73,11 +82,6 @@ "Maybe another update process is already running.\n"); } - // Create a database connection. - $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); - - init_connection($link); - if (in_array("-feeds", $op)) { // Update all feeds needing a update. update_daemon_common($link); @@ -92,7 +96,8 @@ $rc = cleanup_tags($link, 14, 50000); _debug("Cleaned $rc cached tags."); - get_linked_feeds($link); + global $pluginhost; + $pluginhost->run_hooks($pluginhost::HOOK_UPDATE_TASK, "hook_update_task", $op); } if (in_array("-feedbrowser", $op)) { @@ -129,7 +134,8 @@ _debug("Cleaned $rc cached tags."); - get_linked_feeds($link); + global $pluginhost; + $pluginhost->run_hooks($pluginhost::HOOK_UPDATE_TASK, "hook_update_task", $op); } } @@ -139,39 +145,6 @@ _debug("$rc tags deleted.\n"); } - if (in_array("-get-feeds", $op)) { - get_linked_feeds($link); - } - - if (in_array("-import",$op)) { - $username = $argv[count($argv) - 2]; - $filename = $argv[count($argv) - 1]; - - if (!$username) { - print "error: please specify username.\n"; - return; - } - - if (!is_file($filename)) { - print "error: input filename ($filename) doesn't exist.\n"; - return; - } - - _debug("importing $filename for user $username...\n"); - - $result = db_query($link, "SELECT id FROM ttrss_users WHERE login = '$username'"); - - if (db_num_rows($result) == 0) { - print "error: could not find user $username.\n"; - return; - } - - $owner_uid = db_fetch_result($result, 0, "id"); - - perform_data_import($link, $filename, $owner_uid); - - } - if (in_array("-indexes", $op)) { _debug("PLEASE BACKUP YOUR DATABASE BEFORE PROCEEDING!"); _debug("Type 'yes' to continue."); @@ -227,17 +200,6 @@ _debug("all done."); } - if (in_array("-update-self", $op)) { - _debug("Warning: self-updating is experimental. Use at your own risk."); - _debug("Please backup your tt-rss directory before continuing. Your database will not be modified."); - _debug("Type 'yes' to continue."); - - if (read_stdin() != 'yes') - exit; - - update_self($link, in_array("-force", $op)); - } - if (in_array("-convert-filters", $op)) { _debug("WARNING: this will remove all existing type2 filters."); _debug("Type 'yes' to continue."); @@ -254,38 +216,61 @@ while ($line = db_fetch_assoc($result)) { $owner_uid = $line["owner_uid"]; - $filter = array(); + // date filters are removed + if ($line["filter_type"] != 5) { + $filter = array(); - if (sql_bool_to_bool($line["cat_filter"])) { - $feed_id = "CAT:" . (int)$line["cat_id"]; - } else { - $feed_id = (int)$line["feed_id"]; - } + if (sql_bool_to_bool($line["cat_filter"])) { + $feed_id = "CAT:" . (int)$line["cat_id"]; + } else { + $feed_id = (int)$line["feed_id"]; + } - $filter["enabled"] = $line["enabled"] ? "on" : "off"; - $filter["rule"] = array( - json_encode(array( - "reg_exp" => $line["reg_exp"], - "feed_id" => $feed_id, - "filter_type" => $line["filter_type"]))); + $filter["enabled"] = $line["enabled"] ? "on" : "off"; + $filter["rule"] = array( + json_encode(array( + "reg_exp" => $line["reg_exp"], + "feed_id" => $feed_id, + "filter_type" => $line["filter_type"]))); - $filter["action"] = array( - json_encode(array( - "action_id" => $line["action_id"], - "action_param_label" => $line["action_param"], - "action_param" => $line["action_param"]))); + $filter["action"] = array( + json_encode(array( + "action_id" => $line["action_id"], + "action_param_label" => $line["action_param"], + "action_param" => $line["action_param"]))); - // Oh god it's full of hacks + // Oh god it's full of hacks - $_REQUEST = $filter; - $_SESSION["uid"] = $owner_uid; + $_REQUEST = $filter; + $_SESSION["uid"] = $owner_uid; - $filters = new Pref_Filters($link, $_REQUEST); - $filters->add(); + $filters = new Pref_Filters($link, $_REQUEST); + $filters->add(); + } } } + if (in_array("-force-update", $op)) { + _debug("marking all feeds as needing update..."); + + db_query($link, "UPDATE ttrss_feeds SET last_update_started = '1970-01-01', + last_updated = '1970-01-01'"); + } + + if (in_array("-list-plugins", $op)) { + $tmppluginhost = new PluginHost($link); + $tmppluginhost->load_all(); + foreach ($tmppluginhost->get_plugins() as $name => $plugin) { + $about = $plugin->_about(); + + printf("%-60s - v%.2f (by %s)\n%s\n\n", + $name, $about[0], $about[2], $about[1]); + } + } + + $pluginhost->run_commands($op); + db_close($link); if ($lock_handle != false) {