]> projects.mako.cc - scuttle/blobdiff - services/userservice.php
increased description size to 1000 characters
[scuttle] / services / userservice.php
index a2709fbd10123715c3b86cf661d25f9ca90700d9..44374a076e09d8a8f053f30201046c27a4ae614b 100644 (file)
@@ -63,6 +63,15 @@ class UserService {
             return false;
     }
 
+    function _in_regex_array($value, $array) {
+      foreach ($array as $key => $pattern) {
+        if (preg_match($pattern, $value)) {
+          return TRUE;
+        }
+      }
+      return FALSE;
+    }
+
     function _randompassword() {
         $password = mt_rand(1, 99999999);
         $password = substr(md5($password), mt_rand(0, 19), mt_rand(6, 12));
@@ -325,6 +334,29 @@ class UserService {
             return false;
     }
 
+    function isBlockedEmail($email) {
+      // Check whitelist
+      $whitelist = $GLOBALS['email_whitelist'];
+      if (!is_null($whitelist) && is_array($whitelist)) {
+        if (!$this->_in_regex_array($email, $whitelist)) {
+          // Not in whitelist -> blocked
+          return TRUE;
+        }
+      }
+
+      // Check blacklist
+      $blacklist = $GLOBALS['email_blacklist'];
+      if (!is_null($blacklist) && is_array($blacklist)) {
+        if ($this->_in_regex_array($email, $blacklist)) {
+          // In blacklist -> blocked
+          return TRUE;
+        }
+      }
+
+      // Not blocked
+      return FALSE;
+    }
+
     function isReserved($username) {
         if (in_array($username, $GLOBALS['reservedusers'])) {
             return true;

Benjamin Mako Hill || Want to submit a patch?