public static function MoAuthUtilities::check_white_IPs in Google Authenticator / 2 Factor Authentication - 2FA 7
Return value
bool
2 calls to MoAuthUtilities::check_white_IPs()
File
- classes/
Utilities.php, line 408 - This file is part of miniOrange 2FA module.
Class
- MoAuthUtilities
- @file This file is part of miniOrange 2FA module.
Code
public static function check_white_IPs() {
$enable_whitelisted_IP = variable_get('mo_auth_two_factor_invoke_2fa_depending_upon_IP', FALSE);
if ($enable_whitelisted_IP == FALSE) {
return FALSE;
}
$current_IP_address = self::get_client_ip();
$whitelisted_IP = variable_get('mo_auth_two_factor_whitelist_IP', '');
if (is_null($whitelisted_IP) || empty($whitelisted_IP)) {
return FALSE;
}
$whitelisted_IP_array = explode(";", $whitelisted_IP);
$mo_ip_found = FALSE;
foreach ($whitelisted_IP_array as $key => $value) {
if (stristr($value, '-')) {
/** Search in range of IP address **/
list($lower, $upper) = explode('-', $value, 2);
$lower_range = ip2long($lower);
$upper_range = ip2long($upper);
$current_IP = ip2long($current_IP_address);
if ($lower_range !== FALSE && $upper_range !== FALSE && $current_IP !== FALSE && ($current_IP >= $lower_range && $current_IP <= $upper_range)) {
$mo_ip_found = TRUE;
break;
}
}
else {
/** Compare with single IP address **/
if ($current_IP_address == $value) {
$mo_ip_found = TRUE;
break;
}
}
}
return $mo_ip_found;
}