[PHP] Controllare se un IP in blacklist

Nel tutorial di oggi vi mostreremo come creare una funzione PHP che controlla se un IP in blacklist o meno.

< ?php 
function blacklist($ip){ 
    $listed = true; 
    $dnsbl_lookup = array( 
    ); // Add your preferred list of DNSBL's 
    $lookups = count($dnsbl_lookup); 
    $total = 0; 
        $reverse_ip = implode(".", array_reverse(explode(".", $ip))); 
        foreach($dnsbl_lookup as $host){ 
            if(checkdnsrr($reverse_ip.".".$host.".", "A")){ 
    $percent = ($total / $lookups) * 100; 
    if($percent >= 50){ 
        return true; 
        return false; 
    die("Your on the blacklist!"); 
// Continue with page

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>