MediaWiki  1.34.0
EmailBlacklist.php
Go to the documentation of this file.
1 <?php
2 
13  public function filter( array $links, Title $title, $preventLog = false ) {
14  throw new LogicException( __CLASS__ . ' cannot be used to filter links.' );
15  }
16 
22  protected function getBlacklistType() {
23  return 'email';
24  }
25 
32  public function checkUser( User $user ) {
33  $blacklists = $this->getBlacklists();
34  $whitelists = $this->getWhitelists();
35 
36  // The email to check
37  $email = $user->getEmail();
38 
39  if ( !count( $blacklists ) ) {
40  // Nothing to check
41  return true;
42  }
43 
44  // Check for whitelisted email addresses
45  if ( is_array( $whitelists ) ) {
46  wfDebugLog( 'SpamBlacklist', "Excluding whitelisted email addresses from " .
47  count( $whitelists ) . " regexes: " . implode( ', ', $whitelists ) . "\n" );
48  foreach ( $whitelists as $regex ) {
49  if ( preg_match( $regex, $email ) ) {
50  // Whitelisted email
51  return true;
52  }
53  }
54  }
55 
56  # Do the match
57  wfDebugLog( 'SpamBlacklist', "Checking e-mail address against " . count( $blacklists ) .
58  " regexes: " . implode( ', ', $blacklists ) . "\n" );
59  foreach ( $blacklists as $regex ) {
60  if ( preg_match( $regex, $email ) ) {
61  return false;
62  }
63  }
64 
65  return true;
66  }
67 }
EmailBlacklist\filter
filter(array $links, Title $title, $preventLog=false)
Definition: EmailBlacklist.php:13
BaseBlacklist\getBlacklists
getBlacklists()
Fetch local and (possibly cached) remote blacklists.
Definition: BaseBlacklist.php:223
EmailBlacklist\getBlacklistType
getBlacklistType()
Returns the code for the blacklist implementation.
Definition: EmailBlacklist.php:22
wfDebugLog
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
Definition: GlobalFunctions.php:1007
User\getEmail
getEmail()
Get the user's e-mail address.
Definition: User.php:2801
EmailBlacklist\checkUser
checkUser(User $user)
Checks a User object for a blacklisted email address.
Definition: EmailBlacklist.php:32
BaseBlacklist
Base class for different kinds of blacklists.
Definition: BaseBlacklist.php:9
$title
$title
Definition: testCompression.php:34
EmailBlacklist
Email Blacklisting.
Definition: EmailBlacklist.php:6
Title
Represents a title within MediaWiki.
Definition: Title.php:42
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:51
BaseBlacklist\getWhitelists
getWhitelists()
Returns the (local) whitelist.
Definition: BaseBlacklist.php:257