Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -11,7 +11,7 @@
|
||||
namespace IPS\core;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -221,16 +221,14 @@ class _Profanity extends \IPS\Patterns\ActiveRecord implements \JsonSerializable
|
||||
|
||||
if ( array_key_exists( 'action', $values ) )
|
||||
{
|
||||
if ( in_array( $values['action'], static::$actionTypes ) )
|
||||
if ( \in_array( $values['action'], static::$actionTypes ) )
|
||||
{
|
||||
$obj->action = $values['action'];
|
||||
}
|
||||
}
|
||||
|
||||
$obj->save();
|
||||
|
||||
unset( \IPS\Data\Store::i()->profanityFilters );
|
||||
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
@@ -242,29 +240,29 @@ class _Profanity extends \IPS\Patterns\ActiveRecord implements \JsonSerializable
|
||||
public static function getProfanity()
|
||||
{
|
||||
$return = array();
|
||||
if ( isset( \IPS\Data\Store::i()->profanityFilters ) )
|
||||
{
|
||||
foreach( \IPS\Data\Store::i()->profanityFilters AS $id => $row )
|
||||
{
|
||||
$return[ $id ] = static::constructFromData( $row );
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
$toCache = array();
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_profanity_filters' ) AS $row )
|
||||
foreach( static::getStore() AS $id => $row )
|
||||
{
|
||||
$toCache[ $row['wid'] ] = $row;
|
||||
|
||||
$return[ $row['wid'] ] = static::constructFromData( $row );
|
||||
$return[ $id ] = static::constructFromData( $row );
|
||||
}
|
||||
|
||||
\IPS\Data\Store::i()->profanityFilters = $toCache;
|
||||
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all profanity filters
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getStore()
|
||||
{
|
||||
if ( !isset( \IPS\Data\Store::i()->profanityFilters ) )
|
||||
{
|
||||
\IPS\Data\Store::i()->profanityFilters = iterator_to_array( \IPS\Db::i()->select( '*', static::$databaseTable )->setKeyField( 'wid' ) );
|
||||
}
|
||||
|
||||
return \IPS\Data\Store::i()->profanityFilters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the content should be hidden by profanity or url filters
|
||||
@@ -310,7 +308,7 @@ class _Profanity extends \IPS\Patterns\ActiveRecord implements \JsonSerializable
|
||||
}
|
||||
|
||||
/* Loose is easy - if any of the words are present, then mod queue */
|
||||
if ( count( $looseProfanity ) )
|
||||
if ( \count( $looseProfanity ) )
|
||||
{
|
||||
foreach( $looseProfanity AS $word )
|
||||
{
|
||||
@@ -323,7 +321,7 @@ class _Profanity extends \IPS\Patterns\ActiveRecord implements \JsonSerializable
|
||||
}
|
||||
|
||||
/* Still here? Check exact - this gets a bit more complicated. */
|
||||
if ( count( $exactProfanity ) )
|
||||
if ( \count( $exactProfanity ) )
|
||||
{
|
||||
$words = array();
|
||||
foreach( $exactProfanity AS $word )
|
||||
@@ -333,11 +331,11 @@ class _Profanity extends \IPS\Patterns\ActiveRecord implements \JsonSerializable
|
||||
|
||||
$split = preg_split( '/((?=<^|\b)(?:' . implode( '|', $words ) . ')(?=\b|$))/iu', $content, null, PREG_SPLIT_DELIM_CAPTURE );
|
||||
|
||||
if ( is_array( $split ) )
|
||||
if ( \is_array( $split ) )
|
||||
{
|
||||
foreach( $split AS $section )
|
||||
{
|
||||
if ( in_array( $section, $exactProfanity ) )
|
||||
if ( \in_array( $section, $exactProfanity ) )
|
||||
{
|
||||
return TRUE;
|
||||
break;
|
||||
@@ -365,7 +363,7 @@ class _Profanity extends \IPS\Patterns\ActiveRecord implements \JsonSerializable
|
||||
}
|
||||
|
||||
/* If we are using a black or white list, but not moderating, do that. */
|
||||
if ( in_array( \IPS\Settings::i()->ipb_url_filter_option, array( 'black', 'white' ) ) AND \IPS\Settings::i()->url_filter_action == 'block' )
|
||||
if ( \in_array( \IPS\Settings::i()->ipb_url_filter_option, array( 'black', 'white' ) ) AND \IPS\Settings::i()->url_filter_action == 'block' )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -380,6 +378,10 @@ class _Profanity extends \IPS\Patterns\ActiveRecord implements \JsonSerializable
|
||||
|
||||
if ( $urls )
|
||||
{
|
||||
/* We are only checking the content to see if it should be filtered, not using it later. We need to fix embeds, otherwise they won't trigger post moderation
|
||||
even if they should */
|
||||
$content = str_replace( '<___base_url___>', rtrim( \IPS\Settings::i()->base_url, '/' ), $content );
|
||||
|
||||
try
|
||||
{
|
||||
/* Load the content so we can look for URL's */
|
||||
@@ -390,17 +392,24 @@ class _Profanity extends \IPS\Patterns\ActiveRecord implements \JsonSerializable
|
||||
$selector = new \DOMXPath($dom);
|
||||
$tags = $selector->query('//img | //a | //iframe');
|
||||
$good = NULL;
|
||||
|
||||
foreach( $tags AS $tag )
|
||||
{
|
||||
if ( ( $tag->hasAttribute( 'href' ) and !$tag->hasAttribute( 'data-mentionid' ) ) OR ( $tag->hasAttribute( 'src' ) AND !$tag->hasAttribute( 'data-emoticon' ) ) )
|
||||
if ( ( $tag->hasAttribute( 'href' ) and !$tag->hasAttribute( 'data-mentionid' ) ) OR ( ( $tag->hasAttribute( 'src' ) OR $tag->hasAttribute( 'data-embed-src' ) ) AND !$tag->hasAttribute( 'data-emoticon' ) ) )
|
||||
{
|
||||
if ( \IPS\Settings::i()->ipb_url_filter_option == 'none' )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
$urlToCheck = $tag->hasAttribute( 'href' ) ? $tag->getAttribute( 'href' ) : $tag->getAttribute( 'src' );
|
||||
|
||||
$urlToCheck = $tag->hasAttribute( 'href' ) ? $tag->getAttribute( 'href' ) : ( $tag->hasAttribute( 'src' ) ? $tag->getAttribute( 'src' ) : $tag->getAttribute( 'data-embed-src' ) );
|
||||
|
||||
/* If this is an embed routed through our internal embed handler, we need to retrieve the actual URL that was embedded */
|
||||
if( mb_strpos( $urlToCheck, 'controller=embed' ) !== FALSE AND mb_strpos( $urlToCheck, 'url=' ) !== FALSE )
|
||||
{
|
||||
$urlToCheck = \IPS\Http\Url::external( $urlToCheck )->queryString['url'];
|
||||
}
|
||||
|
||||
foreach( $urls AS $url )
|
||||
{
|
||||
/* Make sure we're not doing something weird like storing a blank URL */
|
||||
@@ -461,17 +470,11 @@ class _Profanity extends \IPS\Patterns\ActiveRecord implements \JsonSerializable
|
||||
}
|
||||
|
||||
/**
|
||||
* [ActiveRecord] Delete Record
|
||||
*
|
||||
* @return void
|
||||
* @brief [ActiveRecord] Caches
|
||||
* @note Defined cache keys will be cleared automatically as needed
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
parent::delete();
|
||||
protected $caches = array( 'profanityFilters' );
|
||||
|
||||
unset( \IPS\Data\Store::i()->profanityFilters );
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON Serialize
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user