Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4141637
EmailBlacklist.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
EmailBlacklist.php
View Options
<?php
namespace
MediaWiki\Extension\SpamBlacklist
;
use
LogicException
;
use
MediaWiki\Title\Title
;
use
MediaWiki\User\User
;
use
Wikimedia\AtEase\AtEase
;
/**
* Email Blacklisting
*/
class
EmailBlacklist
extends
BaseBlacklist
{
/**
* @inheritDoc
* @suppress PhanPluginNeverReturnMethod LSP/ISP violation
*/
public
function
filter
(
array
$links
,
?
Title
$title
,
User
$user
,
$preventLog
=
false
)
{
throw
new
LogicException
(
__CLASS__
.
' cannot be used to filter links.'
);
}
/**
* Returns the code for the blacklist implementation
*
* @return string
*/
protected
function
getBlacklistType
()
{
return
'email'
;
}
/**
* Checks a User object for a blacklisted email address
*
* @param User $user
* @return bool True on valid email
*/
public
function
checkUser
(
User
$user
)
{
$blacklists
=
$this
->
getBlacklists
();
$whitelists
=
$this
->
getWhitelists
();
// The email to check
$email
=
$user
->
getEmail
();
if
(
!
count
(
$blacklists
)
)
{
// Nothing to check
return
true
;
}
// Check for whitelisted email addresses
if
(
is_array
(
$whitelists
)
)
{
wfDebugLog
(
'SpamBlacklist'
,
"Excluding whitelisted email addresses from "
.
count
(
$whitelists
)
.
" regexes: "
.
implode
(
', '
,
$whitelists
)
.
"
\n
"
);
foreach
(
$whitelists
as
$regex
)
{
AtEase
::
suppressWarnings
();
$match
=
preg_match
(
$regex
,
$email
);
AtEase
::
restoreWarnings
();
if
(
$match
)
{
// Whitelisted email
return
true
;
}
}
}
# Do the match
wfDebugLog
(
'SpamBlacklist'
,
"Checking e-mail address against "
.
count
(
$blacklists
)
.
" regexes: "
.
implode
(
', '
,
$blacklists
)
.
"
\n
"
);
foreach
(
$blacklists
as
$regex
)
{
AtEase
::
suppressWarnings
();
$match
=
preg_match
(
$regex
,
$email
);
AtEase
::
restoreWarnings
();
if
(
$match
)
{
return
false
;
}
}
return
true
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Wed, Aug 19, 16:02 (4 w, 6 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
ea/b8/f12c952ccd1a03cd700eefa50ed9
Default Alt Text
EmailBlacklist.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment