Created
April 22, 2012 18:12
-
-
Save EddieRingle/2465846 to your computer and use it in GitHub Desktop.
Spamhaus DBL example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Let's say the variable $input contains a user-submitted link */ | |
$parsed_url = parse_url($input); | |
if ($parsed_url != false) { | |
/* The domain should be found using the 'host' key */ | |
$domain = $parsed_url['host']; | |
/* Now check that domain against the DBL */ | |
$dbl_record = dns_get_record($domain); | |
/* If the resulting array is empty, the domain is clear for liftoff */ | |
if ($dbl_record != NULL && count($dbl_record) == 0) { | |
/* Do stuff with the good domain */ | |
} else { | |
/* Warn about a blocked domain */ | |
} | |
} |
$domain = $parsed_url['host'] . '.dbl.spamhaus.org';
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As-is, it does not work. However, after doing some research, I figured out that the
$domain
variable should be set like$revip.zen.spamhaus.org
where$revip
is the reverse IP address of what you're checking.For example:
The rest is basically true, but it's better to check the actual results:
The return codes are listed here: http://www.spamhaus.org/faq/section/DNSBL%2520Usage#202