Version 4.7.13
This commit is contained in:
1 parent
fd22d99e69
commit
7124a02564
954 files changed
+29277
-59308
No files matched your search
@@ -375,7 +375,6 @@ class _Profanity extends \IPS\Patterns\ActiveRecord implements \JsonSerializable
|
||||
bypass the system. */
|
||||
$content = preg_replace( "#<blockquote\s+?class=\"ipsQuote\"[^>]+?>#", "<blockquote>", $content );
|
||||
$content = preg_replace( "#<div\s+?class=\"ipsQuote_citation\"([^>]+?)?>(.+?)</div>#s", "", $content );
|
||||
|
||||
foreach( static::getProfanity() AS $profanity )
|
||||
{
|
||||
if ( $profanity->action == 'moderate' )
|
||||
@@ -437,6 +436,79 @@ class _Profanity extends \IPS\Patterns\ActiveRecord implements \JsonSerializable
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Profanity Blocks
|
||||
*
|
||||
* @param string $content The content to check
|
||||
* @return bool|string
|
||||
*/
|
||||
public static function checkProfanityBlocks( $content )
|
||||
{
|
||||
$looseProfanity = array();
|
||||
$exactProfanity = array();
|
||||
|
||||
/* Clean up profanity a little to remove citation details and inline data attributes.
|
||||
We don't want to remove <blockquotes> entirely as users can then hide profanity in a quote box to
|
||||
bypass the system. */
|
||||
$content = preg_replace( "#<blockquote\s+?class=\"ipsQuote\"[^>]+?>#", "<blockquote>", $content );
|
||||
$content = preg_replace( "#<div\s+?class=\"ipsQuote_citation\"([^>]+?)?>(.+?)</div>#s", "", $content );
|
||||
$blocked = [];
|
||||
foreach( static::getProfanity() AS $profanity )
|
||||
{
|
||||
if ( $profanity->action == 'block' )
|
||||
{
|
||||
if ( $profanity->m_exact )
|
||||
{
|
||||
$exactProfanity[] = $profanity->type;
|
||||
}
|
||||
else
|
||||
{
|
||||
$looseProfanity[] = $profanity->type;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Loose is easy - if any of the words are present, then mod queue */
|
||||
if ( \count( $looseProfanity ) )
|
||||
{
|
||||
foreach( $looseProfanity AS $word )
|
||||
{
|
||||
if ( mb_stristr( $content, $word ) )
|
||||
{
|
||||
return $word;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Still here? Check exact - this gets a bit more complicated. */
|
||||
if ( \count( $exactProfanity ) )
|
||||
{
|
||||
$words = array();
|
||||
foreach( $exactProfanity AS $word )
|
||||
{
|
||||
$words[] = preg_quote( $word, '/' );
|
||||
}
|
||||
|
||||
$split = preg_split( '/((?=<^|\b)(?:' . implode( '|', $words ) . ')(?=\b|$))/iu', $content, null, PREG_SPLIT_DELIM_CAPTURE );
|
||||
|
||||
if ( \is_array( $split ) )
|
||||
{
|
||||
foreach( $split AS $section )
|
||||
{
|
||||
if ( \in_array( mb_strtolower( $section ), array_map( 'mb_strtolower', $exactProfanity ) ) )
|
||||
{
|
||||
return $section;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Still here? All good */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check URL Filters
|
||||
*
|
||||
@@ -511,20 +583,6 @@ class _Profanity extends \IPS\Patterns\ActiveRecord implements \JsonSerializable
|
||||
break;
|
||||
}
|
||||
|
||||
/* IF we are moderating all URL's and it's not an attachment, return here. */
|
||||
if ( $good !== TRUE )
|
||||
{
|
||||
if ( \IPS\Settings::i()->url_filter_any_action == 'moderate' )
|
||||
{
|
||||
return $urlToCheck;
|
||||
}
|
||||
|
||||
if ( \IPS\Settings::i()->ipb_url_filter_option == 'none' )
|
||||
{
|
||||
return $good;
|
||||
}
|
||||
}
|
||||
|
||||
$url = preg_quote( $url, '/' );
|
||||
$url = str_replace( '\*', "(.*?)", $url );
|
||||
|
||||
@@ -552,6 +610,21 @@ class _Profanity extends \IPS\Patterns\ActiveRecord implements \JsonSerializable
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check the URL after we have cycled through the black/white list. */
|
||||
if ( $good !== TRUE )
|
||||
{
|
||||
/* If we are moderating links, only return if the URL was caught by a rule above. */
|
||||
if ( \IPS\Settings::i()->url_filter_any_action == 'moderate' AND ( \IPS\Settings::i()->ipb_url_filter_option == 'none' OR $good !== NULL ) )
|
||||
{
|
||||
return $urlToCheck;
|
||||
}
|
||||
|
||||
if ( \IPS\Settings::i()->ipb_url_filter_option == 'none' )
|
||||
{
|
||||
return $good;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user