本文整理匯總了PHP中IPSMember::_banFiltersCache方法的典型用法代碼示例。如果您正苦於以下問題:PHP IPSMember::_banFiltersCache方法的具體用法?PHP IPSMember::_banFiltersCache怎麽用?PHP IPSMember::_banFiltersCache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類IPSMember
的用法示例。
在下文中一共展示了IPSMember::_banFiltersCache方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: isBanned
/**
* Check to see if a member is banned (or not)
*
* @access public
* @param string Type of ban check (ip/ipAddress, name, email)
* @param string String to check
* @return boolean TRUE (banned) - FALSE (not banned)
*/
public static function isBanned($type, $string)
{
/* Try and be helpful */
switch (strtolower($type)) {
case 'ip':
$type = 'ipAddress';
break;
case 'emailaddress':
$type = 'email';
break;
case 'username':
case 'displayname':
$type = 'name';
break;
}
if ($type == 'ipAddress') {
$banCache = ipsRegistry::cache()->getCache('banfilters');
} else {
if (!is_array(self::$_banFiltersCache)) {
self::$_banFiltersCache = array();
/* Load Ban Filters */
ipsRegistry::DB()->build(array('select' => '*', 'from' => 'banfilters'));
ipsRegistry::DB()->execute();
while ($r = ipsRegistry::DB()->fetch()) {
self::$_banFiltersCache[$r['ban_type']][] = $r['ban_content'];
}
}
$banCache = self::$_banFiltersCache[$type];
}
if (is_array($banCache) and count($banCache)) {
foreach ($banCache as $entry) {
$ip = str_replace('\\*', '.*', preg_quote(trim($entry), "/"));
if ($ip and preg_match("/^{$ip}\$/", $string)) {
return TRUE;
}
}
}
return FALSE;
}