Filter editor"; print "
"; print "
"; print ""; print ""; print ""; // print "
Note: filter will only apply to new articles.
"; $result = db_query($link, "SELECT id,description FROM ttrss_filter_types ORDER BY description"); $filter_types = array(); while ($line = db_fetch_assoc($result)) { //array_push($filter_types, $line["description"]); $filter_types[$line["id"]] = $line["description"]; } print ""; print ""; print ""; print ""; print ""; print ""; $param_disabled = ($action_id == 4) ? "" : "disabled"; print ""; if ($enabled) { $checked = "checked"; } else { $checked = ""; } print "
Match: "; print ""; print_select_hash("filter_type", $filter_type, $filter_types, "class=\"iedit\""); print "
Feed:"; print_feed_select($link, "feed_id", $feed_id); print "
Action:"; print "
Params:
Options: "; print "
"; print "
"; print "
"; print " "; print ""; print "
"; return; } if ($subop == "editSave") { $reg_exp = db_escape_string(trim($_GET["reg_exp"])); $filter_type = db_escape_string(trim($_GET["filter_type"])); $filter_id = db_escape_string($_GET["id"]); $feed_id = db_escape_string($_GET["feed_id"]); $action_id = db_escape_string($_GET["action_id"]); $action_param = db_escape_string($_GET["action_param"]); $enabled = checkbox_to_sql_bool(db_escape_string($_GET["enabled"])); if (!$feed_id) { $feed_id = 'NULL'; } else { $feed_id = sprintf("'%s'", db_escape_string($feed_id)); } $result = db_query($link, "UPDATE ttrss_filters SET reg_exp = '$reg_exp', feed_id = $feed_id, action_id = '$action_id', filter_type = '$filter_type', enabled = $enabled, action_param = '$action_param' WHERE id = '$filter_id' AND owner_uid = " . $_SESSION["uid"]); } if ($subop == "remove") { if (!WEB_DEMO_MODE) { $ids = split(",", db_escape_string($_GET["ids"])); foreach ($ids as $id) { db_query($link, "DELETE FROM ttrss_filters WHERE id = '$id' AND owner_uid = ". $_SESSION["uid"]); } } } if ($subop == "add") { if (!WEB_DEMO_MODE) { $regexp = db_escape_string(trim($_GET["reg_exp"])); $filter_type = db_escape_string(trim($_GET["filter_type"])); $feed_id = db_escape_string($_GET["feed_id"]); $action_id = db_escape_string($_GET["action_id"]); $action_param = db_escape_string($_GET["action_param"]); if (!$regexp) return; if (!$feed_id) { $feed_id = 'NULL'; } else { $feed_id = sprintf("'%s'", db_escape_string($feed_id)); } $result = db_query($link, "INSERT INTO ttrss_filters (reg_exp,filter_type,owner_uid,feed_id, action_id, action_param) VALUES ('$regexp', '$filter_type','".$_SESSION["uid"]."', $feed_id, '$action_id', '$action_param')"); } } if ($quiet) return; $sort = db_escape_string($_GET["sort"]); if (!$sort || $sort == "undefined") { $sort = "reg_exp"; } // print "
PLACEHOLDER
"; $result = db_query($link, "SELECT id,description FROM ttrss_filter_types ORDER BY description"); $filter_types = array(); while ($line = db_fetch_assoc($result)) { //array_push($filter_types, $line["description"]); $filter_types[$line["id"]] = $line["description"]; } print ""; $result = db_query($link, "SELECT ttrss_filters.id AS id,reg_exp, ttrss_filter_types.name AS filter_type_name, ttrss_filter_types.description AS filter_type_descr, enabled, feed_id, ttrss_filter_actions.description AS action_description, ttrss_feeds.title AS feed_title FROM ttrss_filter_types,ttrss_filter_actions,ttrss_filters LEFT JOIN ttrss_feeds ON (ttrss_filters.feed_id = ttrss_feeds.id) WHERE filter_type = ttrss_filter_types.id AND ttrss_filter_actions.id = action_id AND ttrss_filters.owner_uid = ".$_SESSION["uid"]." ORDER by $sort"); if (db_num_rows($result) != 0) { print "
"; print "

"; print ""; $lnum = 0; while ($line = db_fetch_assoc($result)) { $class = ($lnum % 2) ? "even" : "odd"; $filter_id = $line["id"]; $edit_filter_id = $_GET["id"]; $enabled = sql_bool_to_bool($line["enabled"]); if ($subop == "edit" && $filter_id != $edit_filter_id) { $class .= "Grayed"; $this_row_id = ""; } else { $this_row_id = "id=\"FILRR-$filter_id\""; } print ""; $line["reg_exp"] = htmlspecialchars(db_unescape_string($line["reg_exp"])); if (!$line["feed_title"]) $line["feed_title"] = "All feeds"; $line["feed_title"] = htmlspecialchars(db_unescape_string($line["feed_title"])); print ""; if (!$enabled) { $line["reg_exp"] = "" . $line["reg_exp"] . " (Disabled)"; $line["feed_title"] = "" . $line["feed_title"] . ""; $line["filter_type_descr"] = "" . $line["filter_type_descr"] . ""; $line["action_description"] = "" . $line["action_description"] . ""; } print ""; print ""; print ""; print ""; print ""; ++$lnum; } if ($lnum == 0) { print ""; } print "
Select: All, None "; print "
  Filter expression Feed Match Action
" . $line["reg_exp"] . "" . $line["feed_title"] . "" . $line["filter_type_descr"] . "" . $line["action_description"] . "
No filters defined.
"; print "

"; print "

"; print " Selection: "; print "

"; print "
First matching filter is used, filtering is performed when importing articles from the feed.
"; } else { print "

No filters defined.

"; } } ?>