Skip to content

Instantly share code, notes, and snippets.

@stevelacey
Created June 27, 2013 10:53
Show Gist options
  • Save stevelacey/5875606 to your computer and use it in GitHub Desktop.
Save stevelacey/5875606 to your computer and use it in GitHub Desktop.
Spamhaus checker
<?php
$linode = array('server-name' => '1.2.3.4');
$rackspace = array('server-name' => '1.2.3.4');
foreach (array('linode' => $linode, 'rackspace' => $rackspace) as $stack => $servers) {
foreach ($servers as $server => $ip) {
$data = file_get_contents(sprintf('http://www.spamhaus.org/query/ip/%s', $ip));
echo sprintf('%s (%s) - %s', $server, $stack, $ip), PHP_EOL;
if (!strpos($data, sprintf('%s is listed in the', $ip))) {
echo 'yay!';
} else {
echo 'boooo!';
}
echo PHP_EOL, '--', PHP_EOL;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment