]> git.mxchange.org Git - friendica.git/commitdiff
for corp and edu sites, allow registration only to certain email addrs
authorMike Macgirvin <mike@macgirvin.com>
Thu, 23 Sep 2010 22:36:21 +0000 (15:36 -0700)
committerMike Macgirvin <mike@macgirvin.com>
Thu, 23 Sep 2010 22:36:21 +0000 (15:36 -0700)
boot.php
mod/register.php

index 05ec444620aaaf77262bba9f9c03a549da82cad1..83828a0df58e7ccfc3fa6e5f6b88dbc29dcb3c33 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -848,6 +848,36 @@ function allowed_url($url) {
        return $found;
 }}
 
+if(! function_exists('allowed_email')) {
+function allowed_email($email) {
+
+
+       $domain = strtolower(substr($email,strpos($email,'@') + 1));
+       if(! $domain)
+               return false;
+
+       $str_allowed = get_config('system','allowed_email');
+       if(! $str_allowed)
+               return true;
+
+       $found = false;
+
+       $fnmatch = function_exists('fnmatch');
+       $allowed = explode(',',$str_allowed);
+
+       if(count($allowed)) {
+               foreach($allowed as $a) {
+                       $pat = strtolower(trim($a));
+                       if(($fnmatch && fnmatch($pat,$host)) || ($pat == $host)) {
+                               $found = true; 
+                               break;
+                       }
+               }
+       }
+       return $found;
+}}
+
+
 if(! function_exists('format_like')) {
 function format_like($cnt,$arr,$type,$id) {
        if($cnt == 1)
index e65ba7c9b36aed9410664fc9e387a933ad1b52fc..b15ca4fb2b4ff3cdf923744e8c4025dde330d265 100644 (file)
@@ -65,6 +65,12 @@ function register_post(&$a) {
                dbesc($email)
        );
 
+       if(!eregi('[A-Za-z0-9._%-]+@[A-Za-z0-9._%-]+\.[A-Za-z]{2,6}',$email))
+                       $err .= t(' Not valid email.');
+
+       if(! allowed_email($email))
+                       $err .= t(' Your email domain is not among those allowed on this site.');
+
        if($r !== false && count($r))
                $err .= t(' Your email address is already registered on this system.') ;