settings = get_settings('dnsblcheck'); /* offer up the options menu */ if (is_plugin_page()) { DNSBLCheck::plugin_options(); } add_action('admin_menu', array(&$this, 'admin_menu')); add_action('comment_post', array(&$this, 'comment_post')); // Set the defaults: if (!isset($this->settings) || empty($this->settings)) { $this->settings['enabled'] = 0; // Provide a small list of common DNSBLs: $this->settings['dnsbls'] = array( 'cbl.abuseat.org' => '127.0.0.2' ); $this->settings['error_page'] = <<Sorry, your IP address (%%IP_ADDRESS%%) appears to be listed in a blacklist at %%BLACKLIST%%.

If you're not a spammer and you feel this is in error, you might visit http://rbls.org/ and find instructions for removal from the blacklist under which you are listed.

Alternately, you may contact the administrator at %%CONTACT_EMAIL%%.

EOD; } update_option('dnsblcheck', $this->settings); } } //end constructor function admin_menu() { if (function_exists('add_options_page')) { add_options_page('DNSBLCheck', 'DNSBLCheck', 8, basename(__FILE__)); } } function plugin_options() { $dnsbls = array(); if( $_POST['action'] == 'update' ) { $this->settings['enabled'] = isset($_POST['enabled']) ? 1 : 0; if (isset($_POST['dnsbls']) && !empty($_POST['dnsbls'])) { $lines = explode("\n", $_POST['dnsbls']); foreach ($lines as $line) { $trimmed_line = rtrim($line); list($dnsbl, $response) = preg_split("/\s+/", $trimmed_line); if (!empty($dnsbl)) { if (empty($response)) { $response = "127.0.0.2"; $dnsbls[$dnsbl] = $response; } elseif ($this->validate_response($response)) { $dnsbls[$dnsbl] = $response; } } } $this->settings['dnsbls'] = $dnsbls; } if (isset($_POST['error_page']) && !empty($_POST['error_page'])) { if (get_magic_quotes_gpc()) { $this->settings['error_page'] = stripslashes($_POST['error_page']); } else { $this->settings['error_page'] = $_POST['error_page']; } } if (isset($_POST['contact_email'])) { $this->settings['contact_email'] = $_POST['contact_email']; } update_option('dnsblcheck', $this->settings); echo '

' . __('Options updated.') . '

'; } ?>

DNSBL Options

This plugin enables checking of DNSBLs (DNS Blacklists) for the IP address attempting to make a comment or trackback/pingback. If it's found, the comment is not allowed. If you don't know what a DNSBL is, you may want to read Wikipedia's article on the topic before using this plugin.

Parameters:

DNSBLs is a list of DNS blacklists to use. Each entry is listed on its own line. The DNSBL you wish to use comes first, followed by the response you expect for blacklisted hosts, separated by whitespace. If you do not enter a response, it will set 127.0.0.2 as the default. Example:

				cbl.abuseat.org 127.0.0.2
				relays.ordb.org 127.0.0.2
				...
				

The plugin is "primed" with one popular DNSBL, cbl.abuseat.org. This blacklist was chosen because it tends to track PCs compromised by viruses or other exploits that tend to comprise botnets, which are a large source of comment spam. You can find a more extensive list of DNSBLs at rbls.org. Please take time to read about each DNSBL and their criteria for listing -- some blacklists merely track categories of IP addresses, for example dial-up users. You don't want to inadvertantly blacklist legitimate users.

Error Page is the template that is displayed when an IP is found in the blacklist. You have three variables at your disposal for substitution:

Contact E-mail can be provided in the error page for the benefit of people that may be inadvertantly blocked can send mail. This is optional, since there's likely little you can do about them being listed on a blacklist, but you may want to know nonetheless so you can disable a particular DNSBL if it's over-aggressive for your needs.

Enabled is a checkbox that must be checked for the plugin to operate properly. It's unchecked at the time of installation so you can check the DNSBLs being checked before enabling. Without this box checked, the plugin will not check any DNSBLs and will not interfere with the comment-posting process.

DNSBLs:
Error page:
Contact E-mail (optional):
Enabled: settings['enabled'] ? "checked=\"checked\"" : ""; ?> />

settings['enabled'] ) { // Check the blacklists if ($dnsbl = $this->check_dnsbls($client_ip)) { if ($wp_version < 2.0) { wp_set_comment_status($comment_ID, 'delete'); } else { wp_delete_comment($comment_ID); } $error_page = preg_replace("/%%BLACKLIST%%/", $dnsbl, $this->settings['error_page']); $error_page = preg_replace("/%%IP_ADDRESS%%/", $client_ip, $error_page); $error_page = preg_replace("/%%CONTACT_EMAIL%%/", $this->settings['contact_email'], $error_page); header("HTTP/1.0 403 Forbidden"); die($error_page); } } } function check_dnsbls($client_ip) { $rev_array = array_reverse(explode('.', $client_ip)); $rev_query = implode('.', $rev_array); foreach ($this->settings['dnsbls'] as $dnsbl => $expected_response) { $lookup = $rev_query . '.' . $dnsbl; if (gethostbyname($lookup) == $expected_response) { // Found in a blacklist. Return the blacklist that we found the IP // in: return $dnsbl; } } return 0; } }//end class endif; $dnsblcheck = new DNSBLCheck(); ?>