我遇到的问题是,如果我在本地 wampserver 上运行我的这个脚本,那么如果它已经被列入黑名单,但如果我在我的服务器等上运行,它会显示正确的结果...... /usr/bin/php path-to-phpscript。 php 然后它显示这个 ip 在所有不正确的 bls 名称中都被列入黑名单。
<?php
$bls = array("b.barracudacentral.org",
"bl.score.senderscore.com",
"pbl.spamhaus.org",
"sbl.spamhaus.org",
"xbl.spamhaus.org",
"zen.spamhaus.org",
"dbl.spamhaus.org",
"sbl-xbl.spamhaus.org",
);
$ip = '62.213.183.192';
if ( isset($ip)) {
if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) || false === filter_var($ip, FILTER_VALIDATE_URL)) {
if (false === filter_var($ip, FILTER_VALIDATE_URL )) {
$iptosplit = gethostbyname($ip);
}
else {
$iptosplit = $ip;
}
$splitip = explode (".", $iptosplit);
$iptolookup = "$splitip[3].$splitip[2].$splitip[1].$splitip[0]";
$counter=1;
$blList = array();
foreach ( $bls as $rbl ) {
//echo "<tr>";
$rbllookup = $iptolookup.".".$rbl;
$lookup = gethostbyname($rbllookup);
if ( $lookup != $rbllookup || $lookup == $ip) {
$qtxtresult = dns_get_record("$rbllookup", DNS_TXT);
if ( ! isset($qtxtresult[0]['txt']) ) {
$qtxtresult[0]['txt'] = "";
}
$blList[$counter]=$ip.' is listed in ('.$rbl.')';
echo '...........Listed in -'.$rbl.'<br />';
}
echo str_repeat(" ", 24), "\n";
$counter++;
}
}
}
?>