Last active
November 10, 2019 03:21
-
-
Save dalslandan200/192cddeeaf7cdb20661855be7fb00460 to your computer and use it in GitHub Desktop.
E-Mail Whitelisting working correctly for SMF 2.0.15 (partial file)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Check email providers | |
if (!empty($modSettings['enable_restrict_EmailProvider'])) | |
{ | |
// Whitelisted email providers | |
if (!empty($modSettings['accepted_provider'])) | |
{ | |
$accepted_provider = explode(",", $modSettings['accepted_provider']); | |
// Iterate each whitelisted domain, and do housecleaning. | |
foreach ($accepted_provider as $key => $value) | |
{ | |
// If there is whitespace, remove it. | |
$accepted_provider[$key] = trim($accepted_provider[$key]); | |
// Remove empty elements in the array | |
if (empty($accepted_provider[$key])) | |
unset($accepted_provider[$key]); | |
} | |
} | |
else | |
$accepted_provider = array(); | |
// Variable used to indicate whether email was whitelisted | |
$whitelist_pass = false; | |
// Iterate each whitelisted email provider | |
foreach($accepted_provider as $provider) | |
{ | |
// Search for ($provider) in ($email) | |
$strpos_result = strpos($email, $provider); | |
// strpos have returned a value (we have a match) | |
if($strpos_result !== FALSE) | |
{ | |
// Verify that (user) email domain matches the entire whitelisted domain. | |
if(empty($email[$strpos_result + strlen($provider)])) { | |
$whitelist_pass = true; | |
} | |
} | |
} | |
// Check if email was whitelisted | |
if(!empty($accepted_provider) && !$whitelist_pass) | |
fatal_error($txt['restricted'], false); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Check email providers | |
if (!empty($modSettings['enable_restrict_EmailProvider'])) | |
{ | |
// Use a better variable name for user email | |
$email = $regOptions['email']; | |
// Whitelisted email providers | |
if (!empty($modSettings['accepted_provider'])) | |
{ | |
$accepted_provider = explode(",", $modSettings['accepted_provider']); | |
// Iterate each whitelisted domain, and do housecleaning. | |
foreach ($accepted_provider as $key => $value) | |
{ | |
// If there is whitespace, remove it. | |
$accepted_provider[$key] = trim($accepted_provider[$key]); | |
// Remove empty elements in the array | |
if (empty($accepted_provider[$key])) | |
unset($accepted_provider[$key]); | |
} | |
} | |
else | |
$accepted_provider = array(); | |
// Variable used to indicate whether email was whitelisted | |
$whitelist_pass = false; | |
// Iterate each whitelisted email provider | |
foreach($accepted_provider as $provider) | |
{ | |
// Search for ($provider) in ($email) | |
$strpos_result = strpos($email, $provider); | |
// strpos have returned a value (we have a match) | |
if($strpos_result !== FALSE) | |
{ | |
// Verify that (user) email domain matches the entire whitelisted domain. | |
if(empty($email[$strpos_result + strlen($provider)])) { | |
$whitelist_pass = true; | |
} | |
} | |
} | |
// Check if email was whitelisted | |
if(!empty($accepted_provider) && !$whitelist_pass) | |
$reg_errors[] = array('lang', 'restricted'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment