Browse Source

for corp and edu sites, allow registration only to certain email addrs

pull/1/head
Mike Macgirvin 11 years ago
parent
commit
4c2fbc81a0
2 changed files with 36 additions and 0 deletions
  1. +30
    -0
      boot.php
  2. +6
    -0
      mod/register.php

+ 30
- 0
boot.php View File

@ -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)


+ 6
- 0
mod/register.php View 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.') ;


Loading…
Cancel
Save