summaryrefslogtreecommitdiff
path: root/extensions/SpamBlacklist/EmailBlacklist.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2013-08-12 09:28:15 +0200
committerPierre Schmitz <pierre@archlinux.de>2013-08-12 09:28:15 +0200
commit08aa4418c30cfc18ccc69a0f0f9cb9e17be6c196 (patch)
tree577a29fb579188d16003a209ce2a2e9c5b0aa2bd /extensions/SpamBlacklist/EmailBlacklist.php
parentcacc939b34e315b85e2d72997811eb6677996cc1 (diff)
Update to MediaWiki 1.21.1
Diffstat (limited to 'extensions/SpamBlacklist/EmailBlacklist.php')
-rw-r--r--extensions/SpamBlacklist/EmailBlacklist.php59
1 files changed, 59 insertions, 0 deletions
diff --git a/extensions/SpamBlacklist/EmailBlacklist.php b/extensions/SpamBlacklist/EmailBlacklist.php
new file mode 100644
index 00000000..9266b2e4
--- /dev/null
+++ b/extensions/SpamBlacklist/EmailBlacklist.php
@@ -0,0 +1,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;
+ }
+}