3

我有这个用 PHP 编写的函数

<?php
/***************************************************************************************
This is a simple PHP script to lookup for blacklisted IP against multiple DNSBLs at once.

You are free to use the script, modify it, and/or redistribute the files as you wish.

Homepage: http://dnsbllookup.com
****************************************************************************************/
function flush_buffers(){ 
    ob_end_flush(); 
    flush(); 
    ob_start(); 
} 

function dnsbllookup($ip)
{
    $dnsbl_lookup=array(
    "access.redhawk.org",
    "b.barracudacentral.org",
    "bl.csma.biz",
    "bl.emailbasura.org",
    "bl.spamcannibal.org",
    "bl.spamcop.net",
    "bl.technovision.dk",
    "blackholes.five-ten-sg.com",
    "blackholes.wirehub.net",
    "blacklist.sci.kun.nl",
    "block.dnsbl.sorbs.net",
    "blocked.hilli.dk",
    "bogons.cymru.com",
    "cart00ney.surriel.com",
    "cbl.abuseat.org",
    "dev.null.dk",
    "dialup.blacklist.jippg.org",
    "dialups.mail-abuse.org",
    "dialups.visi.com",
    "dnsbl.ahbl.org",
    "dnsbl.antispam.or.id",
    "dnsbl.cyberlogic.net",
    "dnsbl.kempt.net",
    "dnsbl.njabl.org",
    "dnsbl.sorbs.net",
    "dnsbl-1.uceprotect.net",
    "dnsbl-2.uceprotect.net",
    "dnsbl-3.uceprotect.net",
    "duinv.aupads.org",
    "dul.dnsbl.sorbs.net",
    "dul.ru",
    "escalations.dnsbl.sorbs.net",
    "hil.habeas.com",
    "http.dnsbl.sorbs.net",
    "intruders.docs.uu.se",
    "ips.backscatterer.org",
    "korea.services.net",
    "mail-abuse.blacklist.jippg.org",
    "misc.dnsbl.sorbs.net",
    "msgid.bl.gweep.ca",
    "new.dnsbl.sorbs.net",
    "no-more-funn.moensted.dk",
    "old.dnsbl.sorbs.net",
    "pbl.spamhaus.org",
    "proxy.bl.gweep.ca",
    "psbl.surriel.com",
    "pss.spambusters.org.ar",
    "rbl.schulte.org",
    "rbl.snark.net",
    "recent.dnsbl.sorbs.net",
    "relays.bl.gweep.ca",
    "relays.bl.kundenserver.de",
    "relays.mail-abuse.org",
    "relays.nether.net",
    "rsbl.aupads.org",
    "sbl.spamhaus.org",
    "smtp.dnsbl.sorbs.net",
    "socks.dnsbl.sorbs.net",
    "spam.dnsbl.sorbs.net",
    "spam.olsentech.net",
    "spamguard.leadmon.net",
    "spamsources.fabel.dk",
    "tor.ahbl.org",
    "web.dnsbl.sorbs.net",
    "whois.rfc-ignorant.org",
    "xbl.spamhaus.org",
    "zen.spamhaus.org",
    "zombie.dnsbl.sorbs.net",
    "bl.tiopan.com",
    "dnsbl.abuse.ch",
    "tor.dnsbl.sectoor.de",
    "ubl.unsubscore.com",
    "cblless.anti-spam.org.cn",
    "dnsbl.tornevall.org",
    "dnsbl.anticaptcha.net",
    "dnsbl.dronebl.org"
    ); // Add your preferred list of DNSBL's

    $AllCount = count($dnsbl_lookup);
    $BadCount = 0;
    if($ip)
    {
        $reverse_ip = implode(".", array_reverse(explode(".", $ip)));
        foreach($dnsbl_lookup as $host)
        {
            if(checkdnsrr($reverse_ip.".".$host.".", "A"))
            {
                echo "<span color='#339933'>Listed on ".$reverse_ip.'.'.$host."!</span><br/>";
                flush_buffers();
                $BadCount++;
            }
            else
            {
                echo "Not listed on ".$reverse_ip.'.'.$host."!<br/>";
                flush_buffers();
            }
        }
    }
    else
    {
        echo "Empty ip!<br/>";
        flush_buffers();
    }

    echo "This ip has ".$BadCount." bad listings of ".$AllCount."!<br/>";
    flush_buffers();

}

if(preg_match("/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\z/",@$_GET['ip']) == true)
{
    dnsbllookup($_GET['ip']);
}
?>

如果在某些黑名单中列出,它会检查 IP

http://127.0.0.1/check4_html.php?ip=123.123.123.123

Not listed on 123.123.123.123.access.redhawk.org!
Not listed on 123.123.123.123.b.barracudacentral.org!
Not listed on 123.123.123.123.bl.csma.biz!
Not listed on 123.123.123.123.bl.emailbasura.org!

bu 我有一个小问题,我想在每次检查时刷新输出,我该怎么做?

脚本运行时发生的第一件事,我等待 20 秒,然后弹出 20 次检查,然后每秒 1 次,这是为什么呢?

任何帮助,将不胜感激。

4

2 回答 2

1

这个概念对我有用:)

ini_set('output_buffering','on');
ini_set('zlib.output_compression', 0);
ini_set('implicit_flush',1);
ob_implicit_flush();

echo ("<html><head><head><body>");
for($i=0;$i<20;$i++) {
      echo $i;
      echo str_repeat(" ", 500);
      ob_flush();
      flush();
      sleep(1);
}
于 2012-10-15T21:18:58.320 回答
0

flush()似乎不是“输出缓冲”(ob)的一部分。使用ob_flush(). 如果您使用正确的功能ob_end(),也应该没有必要。ob_start():)

无效 ob_flush ( 无效 )

此函数将发送输出缓冲区的内容(如果有)。如果要进一步处理缓冲区的内容,则必须在 ob_flush() 之前调用 ob_get_contents(),因为在调用 ob_flush() 之后会丢弃缓冲区内容。

该函数不会像 ob_end_flush() 那样破坏输出缓冲区。

于 2012-10-15T17:50:04.427 回答