MP Spam Be Gone Options

Brought to you by MikesPickz Web Solutions, Inc. | Support Site | Other Plugins

If you enjoy this plugin, you could always make a small donation to buy me a coffee for my coding sessions. Thanks in advance.

'.__("Settings").''; array_unshift($links, $settings_link); } return $links; } add_filter('plugin_action_links', 'mp_spam_be_gone_add_settings_link', 10, 2); //Script Includes function mp_spam_be_gone_script_includes() { wp_enqueue_script( 'jquery' ); } add_action('wp_print_scripts', 'mp_spam_be_gone_script_includes'); //Add the Spam prevention to the Comment form function mp_spam_be_gone_insert_check() { if(!is_user_logged_in()){ echo ''; echo '
'; ?> '; } else { echo ""; } } add_filter('comment_form_after_fields', 'mp_spam_be_gone_insert_check', 25); //Check the custom fields function mp_sbg_check_comment($commentdata){ if(is_user_logged_in()){ return $commentdata; } if(!isset($_POST['mp_sbg_checkbox'])){ wp_die("Dang, you didn't check the box indicating you are human"); } elseif (isset($_POST['mp_sbg_email']) && $_POST['mp_sbg_email'] !== ''){ wp_die("Pretty impressive filling that field in"); } elseif (isset($_POST['mp_sbg_facebook']) && $_POST['mp_sbg_facebook'] !== ''){ wp_die("While you're on Facebook, like my page!"); } elseif (isset($_POST['mp_sbg_pw']) && $_POST['mp_sbg_pw'] !== $_POST['mp_sbg_cpw']){ wp_die("Sorry, the password was incorrect."); } $spam = false; if($commentdata['comment_type'] == 'pingback' || $commentdata['comment_type'] == 'trackback'){ //Topsy check if(stristr($commentdata['comment_author_url'],"topsy")) { $spam = "topsy"; } if(stristr($commentdata['comment_author'],"topsy")) { $spam = "topsy"; } //Verify IP address if (!$spam) { $user_IP = preg_replace('/[^0-9.]/', '', $_SERVER['REMOTE_ADDR'] ); $authDomainname = mp_sbg_get_domainname_from_uri($commentdata['comment_author_url']); $url_IP = preg_replace('/[^0-9.]/', '', gethostbyname($authDomainname) ); if ($user_IP != $url_IP) { $spam = "ip"; } } //Verify actual link from site if (!spam) { $permalink = get_permalink($commentmeta['comment_post_ID']); $site = file_get_contents($commentdata['comment_author_url']); if(!stristr($site,$permalink)) { $spam = "url"; } } //Is it spam? if (!$spam) { return $commentdata; } else { if ($spam == "topsy") { die('Your trackback has been rejected.'); } elseif ($spam == "ip") { die('Your trackback has been rejected.'); } elseif ($spam == "url") { $commentdata['comment_author'] = '[BLOCKED BY MP_SBG] ' . $commentdata['comment_author']; add_filter('pre_comment_approved', create_function('$mp', 'return \'spam\';')); return $commentdata; } } } return $commentdata; } add_filter('preprocess_comment','mp_sbg_check_comment',1,1); //Get the domain for the IP check function mp_sbg_get_domainname_from_uri($uri) { $exp1 = '/^(http|https|ftp)?(:\/\/)?([^\/]+)/i'; preg_match($exp1, $uri, $matches); if (isset($matches[3])) { return $matches[3]; } else { return ''; } } ?>