Discuz iswhitelist函数 白名单相关操作
//白名单相关操作
function iswhitelist($host) {
global $_G;
static $iswhitelist = array();
if(isset($iswhitelist[$host])) {
return $iswhitelist[$host];
}
$hostlen = strlen($host);
$iswhitelist[$host] = false;
if(!$_G['cache']['domainwhitelist']) {
loadcache('domainwhitelist');
}
if(is_array($_G['cache']['domainwhitelist'])) foreach($_G['cache']['domainwhitelist'] as $val) {
$domainlen = strlen($val);
if($domainlen > $hostlen) {
continue;
}
if(substr($host, -$domainlen) == $val) {
$iswhitelist[$host] = true;
break;
}
}
if($iswhitelist[$host] == false) {
$iswhitelist[$host] = $host == $_SERVER['HTTP_HOST'];
}
return $iswhitelist[$host];
}
页:
[1]