[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/extensions/SpamBlacklist/ -> EmailBlacklist.php (source)

   1  <?php
   2  
   3  /**
   4   * Email Blacklisting
   5   */
   6  class EmailBlacklist extends BaseBlacklist {
   7  
   8      /**
   9       * Returns the code for the blacklist implementation
  10       *
  11       * @return string
  12       */
  13  	protected function getBlacklistType() {
  14          return 'email';
  15      }
  16  
  17      /**
  18       * Checks a User object for a blacklisted email address
  19       *
  20       * @param User $user
  21       * @return bool True on valid email
  22       */
  23  	public function checkUser( User $user ) {
  24          $blacklists = $this->getBlacklists();
  25          $whitelists = $this->getWhitelists();
  26  
  27          // The email to check
  28          $email = $user->getEmail();
  29  
  30          if ( !count( $blacklists ) ) {
  31              // Nothing to check
  32              return true;
  33          }
  34  
  35          // Check for whitelisted email addresses
  36          if ( is_array( $whitelists ) ) {
  37              wfDebugLog( 'SpamBlacklist', "Excluding whitelisted email addresses from " . count( $whitelists ) .
  38                  " regexes: " . implode( ', ', $whitelists ) . "\n" );
  39              foreach ( $whitelists as $regex ) {
  40                  if ( preg_match( $regex, $email ) )  {
  41                      // Whitelisted email
  42                      return true;
  43                  }
  44              }
  45          }
  46  
  47  
  48          # Do the match
  49          wfDebugLog( 'SpamBlacklist', "Checking e-mail address against " . count( $blacklists ) .
  50              " regexes: " . implode( ', ', $blacklists ) . "\n" );
  51          foreach ( $blacklists as $regex ) {
  52              if ( preg_match( $regex, $email ) ) {
  53                  return false;
  54              }
  55          }
  56  
  57          return true;
  58      }
  59  }


Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1