";
- $actions_result = db_query($this->link, "SELECT * FROM ttrss_filters2_actions
+ $actions_result = $this->dbh->query("SELECT * FROM ttrss_filters2_actions
WHERE filter_id = '$filter_id' ORDER BY id");
- while ($line = db_fetch_assoc($actions_result)) {
+ while ($line = $this->dbh->fetch_assoc($actions_result)) {
$line["action_param_label"] = $line["action_param"];
unset($line["filter_id"]);
@@ -323,6 +380,15 @@ class Pref_Filters extends Handler_Protected {
print "
";
+ if ($inverse) {
+ $checked = "checked=\"1\"";
+ } else {
+ $checked = "";
+ }
+
+ print "
+ ";
+
print "";
print "";
@@ -351,21 +417,22 @@ class Pref_Filters extends Handler_Protected {
if (strpos($feed_id, "CAT:") === 0) {
$feed_id = (int) substr($feed_id, 4);
- $feed = getCategoryTitle($this->link, $feed_id);
+ $feed = getCategoryTitle($feed_id);
} else {
$feed_id = (int) $feed_id;
if ($rule["feed_id"])
- $feed = getFeedTitle($this->link, (int)$rule["feed_id"]);
+ $feed = getFeedTitle((int)$rule["feed_id"]);
else
$feed = __("All feeds");
}
- $result = db_query($this->link, "SELECT description FROM ttrss_filter_types
+ $result = $this->dbh->query("SELECT description FROM ttrss_filter_types
WHERE id = ".(int)$rule["filter_type"]);
- $match_on = db_fetch_result($result, 0, "description");
+ $filter_type = $this->dbh->fetch_result($result, 0, "description");
- return T_sprintf("%s on %s in %s", $rule["reg_exp"], $match_on, $feed);
+ return T_sprintf("%s on %s in %s %s", strip_tags($rule["reg_exp"]),
+ $filter_type, $feed, isset($rule["inverse"]) ? __("(inverse)") : "");
}
function printRuleName() {
@@ -373,10 +440,10 @@ class Pref_Filters extends Handler_Protected {
}
private function getActionName($action) {
- $result = db_query($this->link, "SELECT description FROM
+ $result = $this->dbh->query("SELECT description FROM
ttrss_filter_actions WHERE id = " .(int)$action["action_id"]);
- $title = __(db_fetch_result($result, 0, "description"));
+ $title = __($this->dbh->fetch_result($result, 0, "description"));
if ($action["action_id"] == 4 || $action["action_id"] == 6 ||
$action["action_id"] == 7)
@@ -396,12 +463,16 @@ class Pref_Filters extends Handler_Protected {
# print_r($_REQUEST);
- $filter_id = db_escape_string($_REQUEST["id"]);
- $enabled = checkbox_to_sql_bool(db_escape_string($_REQUEST["enabled"]));
- $match_any_rule = checkbox_to_sql_bool(db_escape_string($_REQUEST["match_any_rule"]));
+ $filter_id = $this->dbh->escape_string($_REQUEST["id"]);
+ $enabled = checkbox_to_sql_bool($this->dbh->escape_string($_REQUEST["enabled"]));
+ $match_any_rule = checkbox_to_sql_bool($this->dbh->escape_string($_REQUEST["match_any_rule"]));
+ $inverse = checkbox_to_sql_bool($this->dbh->escape_string($_REQUEST["inverse"]));
+ $title = $this->dbh->escape_string($_REQUEST["title"]);
- $result = db_query($this->link, "UPDATE ttrss_filters2 SET enabled = $enabled,
- match_any_rule = $match_any_rule
+ $result = $this->dbh->query("UPDATE ttrss_filters2 SET enabled = $enabled,
+ match_any_rule = $match_any_rule,
+ inverse = $inverse,
+ title = '$title'
WHERE id = '$filter_id'
AND owner_uid = ". $_SESSION["uid"]);
@@ -411,17 +482,17 @@ class Pref_Filters extends Handler_Protected {
function remove() {
- $ids = split(",", db_escape_string($_REQUEST["ids"]));
+ $ids = explode(",", $this->dbh->escape_string($_REQUEST["ids"]));
foreach ($ids as $id) {
- db_query($this->link, "DELETE FROM ttrss_filters2 WHERE id = '$id' AND owner_uid = ". $_SESSION["uid"]);
+ $this->dbh->query("DELETE FROM ttrss_filters2 WHERE id = '$id' AND owner_uid = ". $_SESSION["uid"]);
}
}
private function saveRulesAndActions($filter_id) {
- db_query($this->link, "DELETE FROM ttrss_filters2_rules WHERE filter_id = '$filter_id'");
- db_query($this->link, "DELETE FROM ttrss_filters2_actions WHERE filter_id = '$filter_id'");
+ $this->dbh->query("DELETE FROM ttrss_filters2_rules WHERE filter_id = '$filter_id'");
+ $this->dbh->query("DELETE FROM ttrss_filters2_actions WHERE filter_id = '$filter_id'");
if ($filter_id) {
/* create rules */
@@ -450,9 +521,11 @@ class Pref_Filters extends Handler_Protected {
foreach ($rules as $rule) {
if ($rule) {
- $reg_exp = strip_tags(db_escape_string(trim($rule["reg_exp"])));
- $filter_type = (int) db_escape_string(trim($rule["filter_type"]));
- $feed_id = db_escape_string(trim($rule["feed_id"]));
+ $reg_exp = strip_tags($this->dbh->escape_string(trim($rule["reg_exp"])));
+ $inverse = isset($rule["inverse"]) ? "true" : "false";
+
+ $filter_type = (int) $this->dbh->escape_string(trim($rule["filter_type"]));
+ $feed_id = $this->dbh->escape_string(trim($rule["feed_id"]));
if (strpos($feed_id, "CAT:") === 0) {
@@ -470,19 +543,19 @@ class Pref_Filters extends Handler_Protected {
}
$query = "INSERT INTO ttrss_filters2_rules
- (filter_id, reg_exp,filter_type,feed_id,cat_id,cat_filter) VALUES
- ('$filter_id', '$reg_exp', '$filter_type', $feed_id, $cat_id, $cat_filter)";
+ (filter_id, reg_exp,filter_type,feed_id,cat_id,cat_filter,inverse) VALUES
+ ('$filter_id', '$reg_exp', '$filter_type', $feed_id, $cat_id, $cat_filter, $inverse)";
- db_query($this->link, $query);
+ $this->dbh->query($query);
}
}
foreach ($actions as $action) {
if ($action) {
- $action_id = (int) db_escape_string($action["action_id"]);
- $action_param = db_escape_string($action["action_param"]);
- $action_param_label = db_escape_string($action["action_param_label"]);
+ $action_id = (int) $this->dbh->escape_string($action["action_id"]);
+ $action_param = $this->dbh->escape_string($action["action_param"]);
+ $action_param_label = $this->dbh->escape_string($action["action_param_label"]);
if ($action_id == 7) {
$action_param = $action_param_label;
@@ -496,7 +569,7 @@ class Pref_Filters extends Handler_Protected {
(filter_id, action_id, action_param) VALUES
('$filter_id', '$action_id', '$action_param')";
- db_query($this->link, $query);
+ $this->dbh->query($query);
}
}
}
@@ -513,34 +586,35 @@ class Pref_Filters extends Handler_Protected {
$enabled = checkbox_to_sql_bool($_REQUEST["enabled"]);
$match_any_rule = checkbox_to_sql_bool($_REQUEST["match_any_rule"]);
+ $title = $this->dbh->escape_string($_REQUEST["title"]);
- db_query($this->link, "BEGIN");
+ $this->dbh->query("BEGIN");
/* create base filter */
- $result = db_query($this->link, "INSERT INTO ttrss_filters2
- (owner_uid, match_any_rule, enabled) VALUES
- (".$_SESSION["uid"].",$match_any_rule,$enabled)");
+ $result = $this->dbh->query("INSERT INTO ttrss_filters2
+ (owner_uid, match_any_rule, enabled, title) VALUES
+ (".$_SESSION["uid"].",$match_any_rule,$enabled, '$title')");
- $result = db_query($this->link, "SELECT MAX(id) AS id FROM ttrss_filters2
+ $result = $this->dbh->query("SELECT MAX(id) AS id FROM ttrss_filters2
WHERE owner_uid = ".$_SESSION["uid"]);
- $filter_id = db_fetch_result($result, 0, "id");
+ $filter_id = $this->dbh->fetch_result($result, 0, "id");
$this->saveRulesAndActions($filter_id);
- db_query($this->link, "COMMIT");
+ $this->dbh->query("COMMIT");
}
function index() {
- $sort = db_escape_string($_REQUEST["sort"]);
+ $sort = $this->dbh->escape_string($_REQUEST["sort"]);
if (!$sort || $sort == "undefined") {
$sort = "reg_exp";
}
- $filter_search = db_escape_string($_REQUEST["search"]);
+ $filter_search = $this->dbh->escape_string($_REQUEST["search"]);
if (array_key_exists("search", $_REQUEST)) {
$_SESSION["prefs_filter_search"] = $filter_search;
@@ -552,7 +626,7 @@ class Pref_Filters extends Handler_Protected {
print "