MediaWiki  1.30.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 }
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:244
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:204
captcha-old.count
count
Definition: captcha-old.py:249
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:1140
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:932
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:6
EmailBlacklist
Email Blacklisting.
Definition: EmailBlacklist.php:6
Title
Represents a title within MediaWiki.
Definition: Title.php:39
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
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:236
array
the array() calling protocol came about after MediaWiki 1.4rc1.