summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Southall <applemansigloo@gmail.com>2016-12-14 05:47:08 +0900
committerBenjamin Southall <applemansigloo@gmail.com>2016-12-14 05:47:08 +0900
commitc9edbdc1c86127b31b8f59c19c1904e41bcb3842 (patch)
tree9a96a9012656e12331b1f68eb0833bfdcb93e450
parentd01bcf48d75c721276f547a5c17d1476aa053c48 (diff)
Add support for ignoring URLs when using word filters
-rwxr-xr-xinc/functions.php56
1 files changed, 45 insertions, 11 deletions
diff --git a/inc/functions.php b/inc/functions.php
index 86efe789..ff7c129a 100755
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -1779,20 +1779,54 @@ function ReverseIPOctets($ip) {
}
function wordfilters(&$body) {
- global $config;
+ global $config;
+
+ foreach ($config['wordfilters'] as $filter) {
+ if (isset($filter[3]) && $filter[3]) {
+ $refilter = $filter[0];
+ if (strncmp($filter[0], "/", 1) !== 0)
+ {
+ $refilter = "/.*" . $filter[0] . "/";
+ }
+ $body = preg_replace_callback($refilter,
+ function($matches) use ($filter , $body) {
+ foreach ($matches as $match) {
+ if (preg_match("/(http|https|ftp):\/\//i", $match)) {
+ return $match;
+ } else {
+ if (isset($filter[2]) && $filter[2]) {
+ $refilter = $filter[0];
+ if (strncmp($filter[0], "/", 1) !== 0)
+ {
+ $refilter = "/.*" . $filter[0] . "/";
+ }
+ if (is_callable($filter[1]))
+ return preg_replace_callback($refilter, $filter[1], $match);
+ else
+ return preg_replace($refilter, $filter[1], $match);
+ } else {
+ return str_ireplace($filter[0], $filter[1], $match);
+ }
+
+ }
+ }
+ }
+ , $body);
+ } else {
+ if (isset($filter[2]) && $filter[2]) {
+ if (is_callable($filter[1]))
+ $body = preg_replace_callback($filter[0], $filter[1], $body);
+ else
+ $body = preg_replace($filter[0], $filter[1], $body);
+ } else {
+ $body = str_ireplace($filter[0], $filter[1], $body);
+ }
+ }
+ }
- foreach ($config['wordfilters'] as $filter) {
- if (isset($filter[2]) && $filter[2]) {
- if (is_callable($filter[1]))
- $body = preg_replace_callback($filter[0], $filter[1], $body);
- else
- $body = preg_replace($filter[0], $filter[1], $body);
- } else {
- $body = str_ireplace($filter[0], $filter[1], $body);
- }
- }
}
+
function quote($body, $quote=true) {
global $config;