Add support for ignoring URLs when using word filters

This commit is contained in:
Benjamin Southall 2016-12-14 05:47:08 +09:00
parent d01bcf48d7
commit c9edbdc1c8

View File

@ -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;