diff options
author | Andrew Dolgov <[email protected]> | 2005-09-03 11:34:24 +0100 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2005-09-03 11:34:24 +0100 |
commit | e6155a06999fe488755b9fdffca6e232a2c5dddc (patch) | |
tree | 1ed5338b7d9f4d616319ba72bbf86fdbf0f2b779 /functions.php | |
parent | ea6774cf1d4bfc4fae156198dcffa709c8367785 (diff) |
check filters on feed update, update NEWS, TODO and schema
Diffstat (limited to 'functions.php')
-rw-r--r-- | functions.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/functions.php b/functions.php index 1337b30f8..ea2c2235d 100644 --- a/functions.php +++ b/functions.php @@ -111,6 +111,19 @@ pg_query("UPDATE ttrss_feeds SET icon_url = '$icon_url' WHERE id = '$feed'"); } + + $filters = array(); + + $result = pg_query("SELECT regexp, + (SELECT name FROM ttrss_filter_types + WHERE id = filter_type) as name + FROM ttrss_filters"); + + while ($line = pg_fetch_assoc($result)) { + if (!$filters[$line["name"]]) $filters[$line["name"]] = array(); + array_push($filters[$line["name"]], $line["regexp"]); + } + foreach ($rss->items as $item) { $entry_guid = $item["id"]; @@ -168,6 +181,12 @@ if (pg_num_rows($result) == 0) { + error_reporting(0); + if (is_filtered($entry_title, $entry_content, $filters)) { + continue; + } + error_reporting (E_ERROR | E_WARNING | E_PARSE); + //$entry_guid = pg_escape_string($entry_guid); $entry_content = pg_escape_string($entry_content); $entry_title = pg_escape_string($entry_title); @@ -290,4 +309,30 @@ print "</select>"; } + function is_filtered($title, $content, $filters) { + + if ($filters["title"]) { + foreach ($filters["title"] as $title_filter) { + if (preg_match("/$title_filter/i", $title)) + return true; + } + } + + if ($filters["content"]) { + foreach ($filters["content"] as $content_filter) { + if (preg_match("/$content_filter/i", $content)) + return true; + } + } + + if ($filters["both"]) { + foreach ($filters["both"] as $filter) { + if (preg_match("/$filter/i", $title) || preg_match("/$filter/i", $content)) + return true; + } + } + + return false; + } + ?> |