#1343 Email hosts of members can be allowed or not.

Email hosts white list or black list can be managed through hostnames.

From
8fd5aeea2c
https://github.com/xpressengine/xe-core/issues/1343
This commit is contained in:
MinSoo Kim 2015-03-24 20:32:13 +09:00
parent 2260b30132
commit 7583bfd56f
12 changed files with 383 additions and 18 deletions

View file

@ -66,6 +66,8 @@ class memberModel extends member
if(!$config->identifier) $config->identifier = 'user_id';
if(!$config->emailhost_check) $config->emailhost_check = 'allowed';
if(!$config->max_error_count) $config->max_error_count = 10;
if(!$config->max_error_count_time) $config->max_error_count_time = 300;
@ -321,7 +323,7 @@ class memberModel extends member
$args = new stdClass();
$args->member_srl = $member_srl;
$output = executeQuery('member.getMemberInfoByMemberSrl', $args, $columnList);
if(!$output->data)
if(!$output->data)
{
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, new stdClass);
return;
@ -840,6 +842,20 @@ class memberModel extends member
return $output->data;
}
function getManagedEmailHosts()
{
static $output;
if(isset($output->data)) return $output->data;
$output = executeQueryArray('member.getManagedEmailHosts');
if(!$output->toBool())
{
$output->data = array();
return array();
}
return $output->data;
}
/**
* @brief Verify if ID is denied
*/
@ -867,6 +883,49 @@ class memberModel extends member
}
return false;
}
/**
* @brief Verify if email_host from email_address is denied
*/
function isDeniedEmailHost($email_address)
{
$email_address = trim($email_address);
$oMemberModel = &getModel('member');
$config = $oMemberModel->getMemberConfig();
$emailhost_check = $config->emailhost_check;
$managedHosts = $oMemberModel->getManagedEmailHosts();
if(count($managedHosts) < 1) return FALSE;
static $return;
if(!isset($return[$email_address]))
{
$email = explode('@',$email_address);
$email_hostname = $email[1];
if(!$email_hostname) return TRUE;
foreach($managedHosts as $managedHost)
{
if($managedHost->email_host && strtolower($managedHost->email_host) == strtolower($email_hostname))
{
$return[$email_address] = TRUE;
}
}
if(!$return[$email_address])
{
$return[$email_address] = FALSE;
}
}
if($emailhost_check == 'prohibited')
{
return $return[$email_address];
}
else
{
return (!$return[$email_address]);
}
}
/**
* @brief Get information of the profile image
*/
@ -1096,7 +1155,7 @@ class memberModel extends member
case 'low':
if($length < 4) return false;
break;
break;
}
return true;