+ _debug("all done.");
+ }
+
+ if (isset($options["convert-filters"])) {
+ _debug("WARNING: this will remove all existing type2 filters.");
+ _debug("Type 'yes' to continue.");
+
+ if (read_stdin() != 'yes')
+ exit;
+
+ _debug("converting filters...");
+
+ db_query( "DELETE FROM ttrss_filters2");
+
+ $result = db_query( "SELECT * FROM ttrss_filters ORDER BY id");
+
+ while ($line = db_fetch_assoc($result)) {
+ $owner_uid = $line["owner_uid"];
+
+ // 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"];
+ }
+
+ $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"])));