本文整理汇总了PHP中wfUtils::getIPWhitelist方法的典型用法代码示例。如果您正苦于以下问题:PHP wfUtils::getIPWhitelist方法的具体用法?PHP wfUtils::getIPWhitelist怎么用?PHP wfUtils::getIPWhitelist使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wfUtils
的用法示例。
在下文中一共展示了wfUtils::getIPWhitelist方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isWhitelisted
/**
* @param string $IP Should be in dot or colon notation (127.0.0.1 or ::1)
* @return bool
*/
public function isWhitelisted($IP)
{
foreach (wfUtils::getIPWhitelist() as $subnet) {
if ($subnet instanceof wfUserIPRange) {
if ($subnet->isIPInRange($IP)) {
return true;
}
} elseif (wfUtils::subnetContainsIP($subnet, $IP)) {
return true;
}
}
return false;
}
示例2: getBlockedIPWhitelistWhereClause
/**
* Generate SQL from the whitelist. Uses the return format from wfUtils::getIPWhitelist
*
* @see wfUtils::getIPWhitelist
* @param array $whitelisted_ips
* @return string
*/
public function getBlockedIPWhitelistWhereClause($whitelisted_ips = null)
{
if ($whitelisted_ips === null) {
$whitelisted_ips = wfUtils::getIPWhitelist();
}
if (!is_array($whitelisted_ips)) {
return false;
}
$where = '';
foreach ($whitelisted_ips as $ip_range) {
if (!is_a($ip_range, 'wfUserIPRange')) {
$ip_range = wfUtils::CIDR2wfUserIPRange($ip_range);
}
$where .= $ip_range->toSQL('IP') . ' OR ';
}
if ($where) {
// remove the extra ' OR '
$where = substr($where, 0, -4);
}
return $where;
}
示例3: isWhitelisted
/**
* @param string $IP Should be in dot or colon notation (127.0.0.1 or ::1)
* @param bool $forcedWhitelistEntry If provided, returns whether or not the IP is on a forced whitelist.
* @return bool
*/
public function isWhitelisted($IP, &$forcedWhitelistEntry = null)
{
if ($forcedWhitelistEntry !== null) {
$forcedWhitelistEntry = false;
}
foreach (wfUtils::getIPWhitelist() as $subnet) {
if ($subnet instanceof wfUserIPRange) {
if ($subnet->isIPInRange($IP)) {
return true;
}
} elseif (wfUtils::subnetContainsIP($subnet, $IP)) {
if ($forcedWhitelistEntry !== null) {
$forcedWhitelistEntry = true;
}
return true;
}
}
return false;
}