Projecthoneypot DNS Blacklist Blocker

I made this PHP script to help project parts of my site that I wanted to block spam bots to access. This is now protecting all my sites and pages (including this one).
the code is simple you just need to include it at the top of all the pages you want to project.

The code for the check is below and is free to anyone that wishes to use it. The version I use has a bit more than below including an exclusion list for anyone that has a blacklisted dynamic IP as well as stats of what has been blocked. My Stats are at http://www.aj-services.com/dnsbl/list.php this shows the power of the script and how many known spammers it is blocking.

<?php
// Script by Anthony Parkes (www.aj-services.com)
// this is a very basic script that can be added to any page that you
// might not want spam bots to see. For Example feedback forms or contact
// pages. I have added this to the top of index.php in wordpress and it
// protects the site well.
// To Install: Copy the file to your webserver and place the following line at the top of all
// the php files you wish to protect.
// include("/path/to/checkip.php");
////// SETTINGS /////////
$accesskey = ""; // this is your projecthoneypot.org http:bl key
$maxlastseen = "14";  // Only block ips that have been seen on the honeypot project in the last xx days (value can be 1-99)
////////////////////////////
if ($tocheck == "") {
$tocheck = $_SERVER['REMOTE_ADDR'];
}
$check = $accesskey . "." . implode( '.', array_reverse( explode( '.', $tocheck ) ) ) . '.dnsbl.httpbl.org';
$results = gethostbyname($check);
list($r_a, $r_b, $r_c, $r_d) = explode(".", $results);
if ($r_a == "127") {
//is listed
$lastseen = $r_b;
$threat = $r_c;
if ($r_d == "0") { $type = "Search Engine"; }
if ($r_d == "1") { $type = "Suspicious"; }
if ($r_d == "2") { $type = "Harvester"; }
if ($r_d == "3") { $type = "Suspicious & Harvester"; }
if ($r_d == "4") { $type = "Comment Spammer"; }
if ($r_d == "5") { $type = "Suspicious & Comment Spammer"; }
if ($r_d == "6") { $type = "Harvester & Comment Spammer"; }
if ($r_d == "7") { $type = "Suspicious, Harvester & Comment Spammer"; }
if ($r_d != "0") {
$blacklisted = "1";
if ($lastseen > $maxlastseen) { $blacklisted = "0"; }
if ($blacklisted == "1") {
echo "Your IP is blacklisted";
echo "<p><b>$type</b> Last Seen <b>$lastseen</b> Day(s) ago.";
echo " Threat Level of <b>$threat</b><br>";
echo "<p>This Blacklist is managed and maintained by projecthoneypot.org";
exit;
}
}
}
// Not blacklisted then load the rest of the page.
?>