Version 4.7.6

This commit is contained in:
Neo committed 2025-12-19 16:05:19 -08:00
1 parent 8ba7d43898
commit 7b7404e741
1085 files changed
+30590 -7837

No files matched your search

@@ -313,23 +313,49 @@ class _Profanity extends \IPS\Patterns\ActiveRecord implements \JsonSerializable
*
* @param string $content The content to check
* @param \IPS\Member|NULL $member The author of the content
* @param array|NULL $filtersMatched What matched, passed by reference
* @return bool
*/
public static function hiddenByFilters( $content, $member=NULL )
public static function hiddenByFilters( $content, $member=NULL, array &$filtersMatched = array() )
{
$return = static::_checkProfanityFilters( $content, $member );
if ( $return == FALSE )
if ( \is_string( $return ) )
{
$return = static::_checkUrlFilters( $content );
}
if ( $return == FALSE )
{
$return = static::_checkEmailFilters( $content );
$filtersMatched = array(
'type' => 'profanity',
'match' => $return
);
return TRUE;
}
return $return;
$return = static::_checkUrlFilters( $content );
if ( \is_string( $return ) )
{
$filtersMatched = array(
'type' => 'url',
'match' => $return
);
return TRUE;
}
$return = static::_checkEmailFilters( $content );
if ( \is_string( $return ) )
{
/* Add to approval queue table */
$filtersMatched = array(
'type' => 'email',
'match' => $return
);
return TRUE;
}
return FALSE;
}
/**
@@ -337,12 +363,19 @@ class _Profanity extends \IPS\Patterns\ActiveRecord implements \JsonSerializable
*
* @param string $content The content to check
* @param \IPS\Member|NULL $member The author of the content
* @return bool
* @return bool|string
*/
protected static function _checkProfanityFilters( $content, $member=NULL )
{
$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 );
foreach( static::getProfanity() AS $profanity )
{
if ( $profanity->action == 'moderate' )
@@ -370,7 +403,7 @@ class _Profanity extends \IPS\Patterns\ActiveRecord implements \JsonSerializable
{
if ( mb_stristr( $content, $word ) )
{
return TRUE;
return $word;
break;
}
}
@@ -393,7 +426,7 @@ class _Profanity extends \IPS\Patterns\ActiveRecord implements \JsonSerializable
{
if ( \in_array( mb_strtolower( $section ), array_map( 'mb_strtolower', $exactProfanity ) ) )
{
return TRUE;
return $word;
break;
}
}
@@ -408,7 +441,7 @@ class _Profanity extends \IPS\Patterns\ActiveRecord implements \JsonSerializable
* Check URL Filters
*
* @param string $content The content to check
* @return bool
* @return bool|string
*/
protected static function _checkUrlFilters( $content )
{
@@ -455,7 +488,7 @@ class _Profanity extends \IPS\Patterns\ActiveRecord implements \JsonSerializable
{
if ( \IPS\Settings::i()->ipb_url_filter_option == 'none' )
{
return TRUE;
return $tag->hasAttribute( 'href' );
}
$urlToCheck = $tag->hasAttribute( 'href' ) ? $tag->getAttribute( 'href' ) : ( $tag->hasAttribute( 'src' ) ? $tag->getAttribute( 'src' ) : $tag->getAttribute( 'data-embed-src' ) );
@@ -481,7 +514,7 @@ class _Profanity extends \IPS\Patterns\ActiveRecord implements \JsonSerializable
/* IF we are moderating all URL's and it's not an attachment, return here. */
if ( $good !== TRUE AND \IPS\Settings::i()->ipb_url_filter_option == 'none' )
{
return TRUE;
return $good;
}
$url = preg_quote( $url, '/' );
@@ -492,7 +525,7 @@ class _Profanity extends \IPS\Patterns\ActiveRecord implements \JsonSerializable
{
if ( preg_match( '/' . $url . '/i', $urlToCheck ) )
{
return TRUE;
return $urlToCheck;
}
}
/* If it's a whitelist, check that */
@@ -501,7 +534,7 @@ class _Profanity extends \IPS\Patterns\ActiveRecord implements \JsonSerializable
/* @note http:// is hard-coded here as we're simply validating that the URL is on the same domain, so the protocol doesn't matter for the base_url replacement */
if ( !preg_match( '/' . $url . '/i', str_replace( '<___base_url___>', 'http://' . parse_url( \IPS\Settings::i()->base_url, PHP_URL_HOST ), $urlToCheck ), $matches ) )
{
$good = FALSE;
$good = $urlToCheck;
}
else
{
@@ -514,9 +547,9 @@ class _Profanity extends \IPS\Patterns\ActiveRecord implements \JsonSerializable
}
}
if ( $good === FALSE AND \IPS\Settings::i()->ipb_url_filter_option == 'white' )
if ( $good !== TRUE AND \IPS\Settings::i()->ipb_url_filter_option == 'white' )
{
return TRUE;
return $good;
}
}
catch( \Exception $e ) {}
@@ -530,7 +563,7 @@ class _Profanity extends \IPS\Patterns\ActiveRecord implements \JsonSerializable
* Check Email Filters
*
* @param string $content The content to check
* @return bool
* @return bool|string
*/
protected static function _checkEmailFilters( $content )
{
@@ -578,7 +611,7 @@ class _Profanity extends \IPS\Patterns\ActiveRecord implements \JsonSerializable
if( preg_match( '/' . \IPS\Text\Parser::EMAIL_REGEX . '/u', $content, $matches ) )
{
return TRUE;
return $matches[0];
}
}