blob: 9266b2e46e22d4efc2258a850bbd271a94b1d682 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
<?php
/**
* Email Blacklisting
*/
class EmailBlacklist extends BaseBlacklist {
/**
* 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 ) {
if ( preg_match( $regex, $email ) ) {
// Whitelisted email
return true;
}
}
}
# Do the match
wfDebugLog( 'SpamBlacklist', "Checking e-mail address against " . count( $blacklists ) .
" regexes: " . implode( ', ', $blacklists ) . "\n" );
foreach ( $blacklists as $regex ) {
if ( preg_match( $regex, $email ) ) {
return false;
}
}
return true;
}
}
|