PHP 返回 gethostbyname($lookup) 值
我使用下面的代码(简化版本)来确定我的 IP 是否在黑名单中。我需要修改它才能确定 IP 是否在白名单上。该函数将要求我查看返回的特定代码。
127.0.0.1
127.0.0.2
127.0.0.3
127.0.0.4
127.0.0.5
如何调整以在脚本运行时返回(代码)输出值?
$host = '222.22.222.222';
$rbl = 'hostkarma.junkemailfilter.com';
$rev = array_reverse(explode('.', $host));
$lookup = implode('.', $rev) . '.' . $rbl;
if ($lookup != gethostbyname($lookup)) {
echo "ip: $host is listed in $rbl\n";
} else {
echo "ip: $host NOT listed in $rbl\n";
}
编辑:抱歉,如果 IP 地址位于 $rlb 中输入的黑名单中,则上述脚本的功能将返回确认。但是,Hostkarma 返回一个代码,上面显示的 127.0 代码之一,因为每个代码表示不同的块状态。我需要获取代码。 “回显$lookup;”仅返回反向查找,如下所示:222.222.22.222.hostkarma.junkemailfilter.com
I am using the code below (simplified version) to determine if my IPs are on a blacklist. I need to modify it to be able to determine if an IP is on a Whitelist. The function will require me to see a specific code returned.
127.0.0.1
127.0.0.2
127.0.0.3
127.0.0.4
127.0.0.5
How can this be adjusted to return the (code) output value when the script runs?
$host = '222.22.222.222';
$rbl = 'hostkarma.junkemailfilter.com';
$rev = array_reverse(explode('.', $host));
$lookup = implode('.', $rev) . '.' . $rbl;
if ($lookup != gethostbyname($lookup)) {
echo "ip: $host is listed in $rbl\n";
} else {
echo "ip: $host NOT listed in $rbl\n";
}
EDIT: Sorry guys, The function of the script above will return confirmation if the IP address is on the blacklist entered in $rlb. However, Hostkarma returns a code, one of the 127.0 codes shown above as each code indicates a different block status. I need to get the code. "echo $lookup;" just returns the reverse lookup, like this: 222.222.22.222.hostkarma.junkemailfilter.com
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
127.xxx
代码应作为gethostbyname
返回的值提供给您。The
127.x.x.x
code should be given to you as the value returned bygethostbyname
.你是这个意思吗?
Do you mean this?