'; echo ''; } /** * Displays stats in dashboard */ function plugin_antispam_for_all_fields_stats() { $statskilled = intval(get_option('plugin_antispam_for_all_fields_statskilled')); $statsspammed = intval(get_option('plugin_antispam_for_all_fields_statsspammed')); echo '
' . sprintf(__('Antispam for all fields has blocked %2$s and spammed %3$s comments.'), 'http://wordpress.org/extend/plugins/antispam-for-all-fields/', number_format($statskilled), number_format($statsspammed)) . '
'; } /** * Calls core function to perform checks * @param unknown_type $status */ function plugin_antispam_for_all_fields($status) { global $commentdata; $afaf = new antispam_for_all_fields(); $afaf->do_bugfix(); $temp = $afaf->init($status, $commentdata); // Sometimes an IP is not added, so lets do that here ;) if(empty($commentdata['comment_author_IP'])) { $commentdata['comment_author_IP'] = $afaf->user_ip; } return $temp; } // Admin only if(mijnpress_plugin_framework::is_admin()) { add_action('admin_menu', array('antispam_for_all_fields', 'addPluginSubMenu')); add_filter('plugin_row_meta',array('antispam_for_all_fields', 'addPluginContent'), 10, 2); } /** * Class, based on my PhpBB2 antispam for all fields module: http://www.phpbbantispam.com * @author Ramon Fincken */ class antispam_for_all_fields extends antispam_for_all_fields_core { function __construct() { $this->showcredits = true; $this->showcredits_fordevelopers = true; $this->plugin_title = 'Antispam for all fields'; $this->plugin_class = 'antispam_for_all_fields'; $this->plugin_filename = 'antispam-for-all-fields/antispam-for-all-fields.php'; $this->plugin_config_url = 'plugins.php?page='.$this->plugin_filename; $this->language = array(); // TODO make seperate file $this->language['explain'] = 'Thank you for your comment!. Your comment has been temporary held by our antispam system for moderation.Layout is not prio number 1 right now, but everything is working
'; include('admin_menu.php'); break; } $plugin->content_end(); } /** * Core function to init spamchecks */ function init($status, $commentdata) { if ($commentdata['comment_type'] == 'trackback' || $commentdata['comment_type'] == 'pingback') { return $status; } $email = $commentdata['comment_author_email']; $author = $commentdata['comment_author']; $url = $commentdata['comment_author_url']; $comment_content = $commentdata['comment_content']; if (!empty ($email)) { $count = $this->check_count('comment_author_email', $email); $temp = $this->compare_counts($count, 'comment_author_email', $commentdata); if ($temp) { return $temp; } } if (!empty ($author)) { $count = $this->check_count('comment_author', $author); $temp = $this->compare_counts($count, 'comment_author', $commentdata); if ($temp) { return $temp; } } // IP check $count = $this->check_count('comment_author_IP', $this->user_ip); $temp = $this->compare_counts($count, 'comment_author_IP', $commentdata); if ($temp) { return $temp; } if (!empty ($comment_content)) { // $number_of_sites = $this->count_number_of_sites($comment_content); if($number_of_sites > $this->limits['numbersites']) { $body = "Details are below: \n"; $body .= "action: found ".$number_of_sites. " URIs in comment that is a lot, comment marked as spam \n"; $body .= "IP adress " . $this->user_ip . "\n"; $body .= "low threshold " . $this->limits['lower'] . "\n"; $body .= "upper threshold " . $this->limits['upper'] . "\n"; foreach ($commentdata as $key => $val) { $body .= "$key : $val \n"; } $commment_key = $this->store_comment($commentdata,'spammed'); $this->mail_details('rejected spammed based on '.$number_of_sites. ' URIs in comment', $body,$commment_key); $this->update_stats('spammed'); return 'spam'; } foreach ($this->words as $word) { $string_is_spam = $this->string_is_spam($word, $comment_content); if ($string_is_spam) { $body = "Details are below: \n"; $body .= "action: found spamword in comment, comment denied \n"; $body .= "IP adress " . $this->user_ip . "\n"; $body .= "low threshold " . $this->limits['lower'] . "\n"; $body .= "upper threshold " . $this->limits['upper'] . "\n"; $body .= "word found : " . $word . " \n\n"; foreach ($commentdata as $key => $val) { $body .= "$key : $val \n"; } $commment_key = $this->store_comment($commentdata,'killed'); $this->mail_details('rejected comment based on word', $body, $commment_key); $this->update_stats('killed'); if ( defined('DOING_AJAX') ) { die( __($this->language['explain']) ); } wp_die( __($this->language['explain']), '', array('response' => 403) ); } } } if (!empty ($url)) { $count = $this->check_count('comment_author_url', $url); $temp = $this->compare_counts($count, 'comment_author_url', $commentdata); if ($temp) { return $temp; } // Now check for words if ($html_body = wp_remote_retrieve_body(wp_remote_get($url))) { if (!empty ($html_body)) { foreach ($this->words as $word) { $string_is_spam = $this->string_is_spam($word, $html_body); if ($string_is_spam) { $body = "Details are below: \n"; $body .= "action: I visited URL of commenter, found spamword on that page, comment denied \n"; $body .= "IP adress " . $this->user_ip . "\n"; $body .= "low threshold " . $this->limits['lower'] . "\n"; $body .= "upper threshold " . $this->limits['upper'] . "\n"; $body .= "word found : " . $word . " \n\n"; foreach ($commentdata as $key => $val) { $body .= "$key : $val \n"; } $commment_key = $this->store_comment($commentdata,'spammed'); $this->mail_details('rejected comment based on word', $body, $commment_key); $this->update_stats('spammed'); if ( defined('DOING_AJAX') ) { die( __($this->language['explain']) ); } wp_die( __($this->language['explain']), '', array('response' => 403) ); } } } } } return $status; } } ?>