$bv){ if(in_array($bk, $bv) || in_array('.' . $bk , $bv)){ $write_len += fwrite($fp, 'address=/' . $bk . '/' . "\n"); continue; } foreach($bv as $bvv){ $write_len += fwrite($fp, 'address=/' . $bvv . '/' . "\n"); } } foreach($arr_result as $rk => $rv){ if(array_key_exists($rk, $GLOBALS['arr_blacklist'])){//黑名单操作 continue; } if(empty($rk)){//遗漏的域名,不会写入到最终的配置里 // print_r($rv); continue; } //白名单机制,优先级低于黑名单,即某域名同时存在黑白名单中,那么它会在黑名单中生效 if(array_key_exists($rk, $GLOBALS['arr_whitelist'])){ continue; } if(!is_array($rv)){ if(array_key_exists($rv, $GLOBALS['arr_whitelist'])){//白名单机制 continue; } $write_len += fwrite($fp, 'address=/' . $rv . '/' . "\n"); continue; } $rv = array_unique($rv); if(in_array('.' . $rk, $rv) || in_array('www.' . $rk, $rv)){ $write_len += fwrite($fp, 'address=/' . $rk . '/' . "\n"); continue; } foreach($rv as $rvv){ if(array_key_exists($rvv, $GLOBALS['arr_whitelist'])){//白名单机制 continue; } $write_len += fwrite($fp, 'address=/' . $rvv . '/' . "\n"); } } fclose($fp); return $write_len; } }