Version Description
- Rewriting/refactoring a lot of the code
- Adding Settings page
- Storing blocked comments into the Spam section
- Working on GDPR compliance
Download this release
Release Info
Developer | webvitaly |
Plugin | Anti-spam |
Version | 5.0 |
Comparing to | |
See all releases |
Code changes from version 4.4 to 5.0
- anti-spam-functions.php +118 -12
- anti-spam-settings.php +89 -0
- anti-spam.php +25 -125
- js/{anti-spam-4.4.js → anti-spam-5.0.js} +0 -0
- readme.txt +22 -22
anti-spam-functions.php
CHANGED
@@ -2,6 +2,22 @@
|
|
2 |
|
3 |
defined('ABSPATH') OR exit; // prevent full path disclosure
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
function antispam_counter_stats() {
|
6 |
$antispam_stats = get_option('antispam_stats', array());
|
7 |
if (array_key_exists('blocked_total', $antispam_stats)){
|
@@ -13,21 +29,111 @@ function antispam_counter_stats() {
|
|
13 |
}
|
14 |
|
15 |
|
16 |
-
function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
23 |
}
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
$
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
31 |
}
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
}
|
2 |
|
3 |
defined('ABSPATH') OR exit; // prevent full path disclosure
|
4 |
|
5 |
+
function antispam_default_settings() {
|
6 |
+
$settings = array(
|
7 |
+
'save_spam_comments' => 0
|
8 |
+
);
|
9 |
+
return $settings;
|
10 |
+
}
|
11 |
+
|
12 |
+
|
13 |
+
function antispam_get_settings() {
|
14 |
+
$antispam_settings = (array) get_option('antispam_settings');
|
15 |
+
$default_settings = antispam_default_settings();
|
16 |
+
$antispam_settings = array_merge($default_settings, $antispam_settings); // set empty options with default values
|
17 |
+
return $antispam_settings;
|
18 |
+
}
|
19 |
+
|
20 |
+
|
21 |
function antispam_counter_stats() {
|
22 |
$antispam_stats = get_option('antispam_stats', array());
|
23 |
if (array_key_exists('blocked_total', $antispam_stats)){
|
29 |
}
|
30 |
|
31 |
|
32 |
+
function antispam_check_for_spam() {
|
33 |
+
$spam_flag = false;
|
34 |
+
|
35 |
+
$antspm_q = '';
|
36 |
+
if (isset($_POST['antspm-q'])) {
|
37 |
+
$antspm_q = trim($_POST['antspm-q']);
|
38 |
+
}
|
39 |
+
|
40 |
+
$antspm_d = '';
|
41 |
+
if (isset($_POST['antspm-d'])) {
|
42 |
+
$antspm_d = trim($_POST['antspm-d']);
|
43 |
+
}
|
44 |
+
|
45 |
+
$antspm_e = '';
|
46 |
+
if (isset($_POST['antspm-e-email-url-website'])) {
|
47 |
+
$antspm_e = trim($_POST['antspm-e-email-url-website']);
|
48 |
+
}
|
49 |
+
|
50 |
+
if ( $antspm_q != date('Y') ) { // year-answer is wrong - it is spam
|
51 |
+
if ( $antspm_d != date('Y') ) { // extra js-only check: there is no js added input - it is spam
|
52 |
+
$spam_flag = true;
|
53 |
+
if (empty($antspm_q)) { // empty answer - it is spam
|
54 |
+
//$antispam_error_message .= 'Error: empty answer. ['.esc_attr( $antspm_q ).']<br> '.$rn;
|
55 |
+
} else {
|
56 |
+
//$antispam_error_message .= 'Error: answer is wrong. ['.esc_attr( $antspm_q ).']<br> '.$rn;
|
57 |
+
}
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
if ( ! empty($antspm_e)) { // trap field is not empty - it is spam
|
62 |
+
$spam_flag = true;
|
63 |
+
//$antispam_error_message .= 'Error: field should be empty. ['.esc_attr( $antspm_e ).']<br> '.$rn;
|
64 |
+
}
|
65 |
+
|
66 |
+
return $spam_flag;
|
67 |
+
}
|
68 |
|
69 |
+
|
70 |
+
function antispam_store_comment($commentdata) {
|
71 |
+
global $wpdb;
|
72 |
+
|
73 |
+
if ( isset( $commentdata['user_ID'] ) ) {
|
74 |
+
$commentdata['user_id'] = $commentdata['user_ID'] = (int) $commentdata['user_ID'];
|
75 |
}
|
76 |
|
77 |
+
$prefiltered_user_id = ( isset( $commentdata['user_id'] ) ) ? (int) $commentdata['user_id'] : 0;
|
78 |
+
|
79 |
+
$commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID'];
|
80 |
+
if ( isset( $commentdata['user_ID'] ) && $prefiltered_user_id !== (int) $commentdata['user_ID'] ) {
|
81 |
+
$commentdata['user_id'] = $commentdata['user_ID'] = (int) $commentdata['user_ID'];
|
82 |
+
} elseif ( isset( $commentdata['user_id'] ) ) {
|
83 |
+
$commentdata['user_id'] = (int) $commentdata['user_id'];
|
84 |
}
|
85 |
|
86 |
+
$commentdata['comment_parent'] = isset($commentdata['comment_parent']) ? absint($commentdata['comment_parent']) : 0;
|
87 |
+
$parent_status = ( 0 < $commentdata['comment_parent'] ) ? wp_get_comment_status($commentdata['comment_parent']) : '';
|
88 |
+
$commentdata['comment_parent'] = ( 'approved' == $parent_status || 'unapproved' == $parent_status ) ? $commentdata['comment_parent'] : 0;
|
89 |
+
|
90 |
+
if ( ! isset( $commentdata['comment_author_IP'] ) ) {
|
91 |
+
$commentdata['comment_author_IP'] = $_SERVER['REMOTE_ADDR'];
|
92 |
+
}
|
93 |
+
$commentdata['comment_author_IP'] = preg_replace( '/[^0-9a-fA-F:., ]/', '', $commentdata['comment_author_IP'] );
|
94 |
+
|
95 |
+
if ( ! isset( $commentdata['comment_agent'] ) ) {
|
96 |
+
$commentdata['comment_agent'] = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT']: '';
|
97 |
+
}
|
98 |
+
$commentdata['comment_agent'] = substr( $commentdata['comment_agent'], 0, 254 );
|
99 |
+
|
100 |
+
if ( empty( $commentdata['comment_date'] ) ) {
|
101 |
+
$commentdata['comment_date'] = current_time('mysql');
|
102 |
+
}
|
103 |
+
|
104 |
+
if ( empty( $commentdata['comment_date_gmt'] ) ) {
|
105 |
+
$commentdata['comment_date_gmt'] = current_time( 'mysql', 1 );
|
106 |
+
}
|
107 |
+
|
108 |
+
$commentdata = wp_filter_comment($commentdata);
|
109 |
+
|
110 |
+
$commentdata['comment_approved'] = wp_allow_comment( $commentdata, $avoid_die );
|
111 |
+
if ( is_wp_error( $commentdata['comment_approved'] ) ) {
|
112 |
+
return $commentdata['comment_approved'];
|
113 |
+
}
|
114 |
+
|
115 |
+
$comment_ID = wp_insert_comment($commentdata);
|
116 |
+
if ( ! $comment_ID ) {
|
117 |
+
$fields = array( 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content' );
|
118 |
+
|
119 |
+
foreach ( $fields as $field ) {
|
120 |
+
if ( isset( $commentdata[ $field ] ) ) {
|
121 |
+
$commentdata[ $field ] = $wpdb->strip_invalid_text_for_column( $wpdb->comments, $field, $commentdata[ $field ] );
|
122 |
+
}
|
123 |
+
}
|
124 |
+
|
125 |
+
$commentdata = wp_filter_comment( $commentdata );
|
126 |
+
|
127 |
+
$commentdata['comment_approved'] = wp_allow_comment( $commentdata, $avoid_die );
|
128 |
+
if ( is_wp_error( $commentdata['comment_approved'] ) ) {
|
129 |
+
return $commentdata['comment_approved'];
|
130 |
+
}
|
131 |
+
|
132 |
+
$comment_ID = wp_insert_comment( $commentdata );
|
133 |
+
if ( ! $comment_ID ) {
|
134 |
+
return false;
|
135 |
+
}
|
136 |
+
}
|
137 |
+
|
138 |
+
wp_set_comment_status( $comment_ID, 'spam' );
|
139 |
}
|
anti-spam-settings.php
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Anti-spam settings code
|
4 |
+
used WordPress Settings API - http://codex.wordpress.org/Settings_API
|
5 |
+
*/
|
6 |
+
|
7 |
+
if ( ! defined( 'ABSPATH' ) ) { // prevent full path disclosure
|
8 |
+
exit;
|
9 |
+
}
|
10 |
+
|
11 |
+
|
12 |
+
function antispam_menu() { // add menu item
|
13 |
+
add_options_page('Anti-spam', 'Anti-spam', 'manage_options', 'anti-spam', 'antispam_settings');
|
14 |
+
}
|
15 |
+
add_action('admin_menu', 'antispam_menu');
|
16 |
+
|
17 |
+
|
18 |
+
function antispam_admin_init() {
|
19 |
+
register_setting('antispam_settings_group', 'antispam_settings', 'antispam_settings_validate');
|
20 |
+
|
21 |
+
add_settings_section('antispam_settings_automatic_section', '', 'antispam_section_callback', 'antispam_automatic_page');
|
22 |
+
|
23 |
+
add_settings_field('save_spam_comments', 'Save spam comments', 'antispam_field_save_spam_comments_callback', 'antispam_automatic_page', 'antispam_settings_automatic_section');
|
24 |
+
|
25 |
+
}
|
26 |
+
add_action('admin_init', 'antispam_admin_init');
|
27 |
+
|
28 |
+
|
29 |
+
function antispam_settings_init() { // set default settings
|
30 |
+
global $antispam_settings;
|
31 |
+
$antispam_settings = antispam_get_settings();
|
32 |
+
update_option('antispam_settings', $antispam_settings);
|
33 |
+
}
|
34 |
+
add_action('admin_init', 'antispam_settings_init');
|
35 |
+
|
36 |
+
|
37 |
+
function antispam_settings_validate($input) {
|
38 |
+
$default_settings = antispam_get_settings();
|
39 |
+
|
40 |
+
// checkbox
|
41 |
+
$output['save_spam_comments'] = $input['save_spam_comments'];
|
42 |
+
|
43 |
+
return $output;
|
44 |
+
}
|
45 |
+
|
46 |
+
|
47 |
+
function antispam_section_callback() { // Anti-spam settings description
|
48 |
+
echo '';
|
49 |
+
}
|
50 |
+
|
51 |
+
|
52 |
+
function antispam_field_save_spam_comments_callback() {
|
53 |
+
$settings = antispam_get_settings();
|
54 |
+
echo '<label><input type="checkbox" name="antispam_settings[save_spam_comments]" '.checked(1, $settings['save_spam_comments'], false).' value="1" />';
|
55 |
+
echo ' Save spam comments into spam section</label>';
|
56 |
+
echo '<p class="description">Useful for testing how the plugin works. <a href="'. admin_url( 'edit-comments.php?comment_status=spam' ) . '">View spam section</a>.</p>';
|
57 |
+
}
|
58 |
+
|
59 |
+
|
60 |
+
function antispam_settings() {
|
61 |
+
$antispam_stats = get_option('antispam_stats', array());
|
62 |
+
$blocked_total = $antispam_stats['blocked_total'];
|
63 |
+
if (empty($blocked_total)) {
|
64 |
+
$blocked_total = 0;
|
65 |
+
}
|
66 |
+
?>
|
67 |
+
<div class="wrap">
|
68 |
+
|
69 |
+
<h2><span class="dashicons dashicons-admin-generic"></span> Anti-spam</h2>
|
70 |
+
|
71 |
+
<div class="antispam-panel-info">
|
72 |
+
<p style="margin: 0;">
|
73 |
+
<span class="dashicons dashicons-chart-bar"></span>
|
74 |
+
<strong><?php echo $blocked_total; ?></strong> spam comments were blocked by <a href="https://wordpress.org/plugins/anti-spam/" target="_blank">Anti-spam</a> plugin so far.
|
75 |
+
Upgrade to <strong><a href="http://codecanyon.net/item/antispam-pro/6491169?ref=webvitalii" target="_blank">Anti-spam Pro</a></strong> for advanced protection.
|
76 |
+
</p>
|
77 |
+
</div>
|
78 |
+
|
79 |
+
<form method="post" action="options.php">
|
80 |
+
<?php settings_fields('antispam_settings_group'); ?>
|
81 |
+
<div class="antispam-group-automatic">
|
82 |
+
<?php do_settings_sections('antispam_automatic_page'); ?>
|
83 |
+
</div>
|
84 |
+
<?php submit_button(); ?>
|
85 |
+
</form>
|
86 |
+
|
87 |
+
</div>
|
88 |
+
<?php
|
89 |
+
}
|
anti-spam.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Anti-spam
|
4 |
Plugin URI: http://wordpress.org/plugins/anti-spam/
|
5 |
Description: No spam in comments. No captcha.
|
6 |
-
Version:
|
7 |
Author: webvitaly
|
8 |
Text Domain: anti-spam
|
9 |
Author URI: http://web-profile.net/wordpress/plugins/
|
@@ -14,36 +14,23 @@ if ( ! defined( 'ABSPATH' ) ) { // prevent full path disclosure
|
|
14 |
exit;
|
15 |
}
|
16 |
|
17 |
-
|
18 |
-
$antispam_log_spam_comment = false; // if true, than rejected spam comments will be logged to wp-content/plugins/anti-spam/log/anti-spam-2015-11.log
|
19 |
-
$antispam_allow_trackbacks = false; // if true, than trackbacks will be allowed
|
20 |
-
// trackbacks almost not used by users, but mostly used by spammers; pingbacks are always enabled
|
21 |
-
// more about the difference between trackback and pingback - http://web-profile.net/web/trackback-vs-pingback/
|
22 |
-
|
23 |
-
define('ANTISPAM_PLUGIN_VERSION', '4.4');
|
24 |
-
|
25 |
-
$antispam_settings = array(
|
26 |
-
'send_spam_comment_to_admin' => $antispam_send_spam_comment_to_admin,
|
27 |
-
'allow_trackbacks' => $antispam_allow_trackbacks,
|
28 |
-
'admin_email' => get_option('admin_email'),
|
29 |
-
'log_spam_comment' => $antispam_log_spam_comment
|
30 |
-
);
|
31 |
|
32 |
include('anti-spam-functions.php');
|
|
|
33 |
include('anti-spam-info.php');
|
34 |
|
35 |
|
36 |
function antispam_enqueue_script() {
|
37 |
global $withcomments; // WP flag to show comments on all pages
|
38 |
if ((is_singular() || $withcomments) && comments_open()) { // load script only for pages with comments form
|
39 |
-
wp_enqueue_script('anti-spam-script', plugins_url('/js/anti-spam-
|
40 |
}
|
41 |
}
|
42 |
add_action('wp_enqueue_scripts', 'antispam_enqueue_script');
|
43 |
|
44 |
|
45 |
function antispam_form_part() {
|
46 |
-
global $antispam_settings;
|
47 |
$rn = "\r\n"; // .chr(13).chr(10)
|
48 |
|
49 |
if ( ! is_user_logged_in()) { // add anti-spam fields only for not logged in users
|
@@ -62,123 +49,36 @@ add_action('comment_form', 'antispam_form_part'); // add anti-spam inputs to the
|
|
62 |
|
63 |
|
64 |
function antispam_check_comment($commentdata) {
|
65 |
-
|
66 |
-
$rn = "\r\n"; // .chr(13).chr(10)
|
67 |
-
|
68 |
-
extract($commentdata);
|
69 |
-
|
70 |
-
$antispam_pre_error_message = '<p><strong><a href="javascript:window.history.back()">Go back</a></strong> and try again.</p>';
|
71 |
-
$antispam_error_message = '';
|
72 |
-
|
73 |
-
if (($antispam_settings['send_spam_comment_to_admin']) || ($antispam_settings['log_spam_comment'])) { // if sending email to admin is enabled or loging
|
74 |
-
$post = get_post($comment->comment_post_ID);
|
75 |
-
$antispam_message_spam_info = 'Spam for post: "'.$post->post_title.'"' . $rn;
|
76 |
-
$antispam_message_spam_info .= get_permalink($comment->comment_post_ID) . $rn.$rn;
|
77 |
-
|
78 |
-
$antispam_message_spam_info .= 'IP: ' . $_SERVER['REMOTE_ADDR'] . $rn;
|
79 |
-
$antispam_message_spam_info .= 'User agent: ' . $_SERVER['HTTP_USER_AGENT'] . $rn;
|
80 |
-
$antispam_message_spam_info .= 'Referer: ' . $_SERVER['HTTP_REFERER'] . $rn.$rn;
|
81 |
|
82 |
-
|
83 |
-
|
84 |
-
$
|
85 |
}
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
foreach ($_POST as $key => $value) {
|
90 |
-
$antispam_message_spam_info .= '$_POST['.$key. '] = '.$value.$rn;
|
91 |
-
}
|
92 |
-
$antispam_message_spam_info .= $rn.$rn;
|
93 |
-
|
94 |
-
$antispam_message_spam_info .= 'Cookie vars:'.$rn; // lets see what cookie vars spammers try to submit
|
95 |
-
foreach ($_COOKIE as $key => $value) {
|
96 |
-
$antispam_message_spam_info .= '$_COOKIE['.$key. '] = '.$value.$rn;
|
97 |
-
}
|
98 |
-
$antispam_message_spam_info .= $rn.$rn;
|
99 |
-
|
100 |
-
$antispam_message_append = '-----------------------------'.$rn;
|
101 |
-
$antispam_message_append .= 'This is spam comment rejected by Anti-spam plugin - wordpress.org/plugins/anti-spam/' . $rn;
|
102 |
-
$antispam_message_append .= 'You may edit "anti-spam.php" file and disable this notification.' . $rn;
|
103 |
-
$antispam_message_append .= 'You should find "$antispam_send_spam_comment_to_admin" and make it equal to "false".' . $rn;
|
104 |
}
|
105 |
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
$antspm_q = '';
|
110 |
-
if (isset($_POST['antspm-q'])) {
|
111 |
-
$antspm_q = trim($_POST['antspm-q']);
|
112 |
-
}
|
113 |
-
$antspm_d = '';
|
114 |
-
if (isset($_POST['antspm-d'])) {
|
115 |
-
$antspm_d = trim($_POST['antspm-d']);
|
116 |
-
}
|
117 |
-
$antspm_e = '';
|
118 |
-
if (isset($_POST['antspm-e-email-url-website'])) {
|
119 |
-
$antspm_e = trim($_POST['antspm-e-email-url-website']);
|
120 |
-
}
|
121 |
-
|
122 |
-
if ( $antspm_q != date('Y') ) { // year-answer is wrong - it is spam
|
123 |
-
if ( $antspm_d != date('Y') ) { // extra js-only check: there is no js added input - it is spam
|
124 |
-
$spam_flag = true;
|
125 |
-
if (empty($antspm_q)) { // empty answer - it is spam
|
126 |
-
$antispam_error_message .= 'Error: empty answer. ['.esc_attr( $antspm_q ).']<br> '.$rn;
|
127 |
-
} else {
|
128 |
-
$antispam_error_message .= 'Error: answer is wrong. ['.esc_attr( $antspm_q ).']<br> '.$rn;
|
129 |
-
}
|
130 |
-
}
|
131 |
-
}
|
132 |
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
}
|
137 |
|
138 |
-
if ($spam_flag) { // it is spam
|
139 |
-
$antispam_error_message .= '<strong>Comment was blocked because it is spam.</strong><br> ';
|
140 |
-
if ($antispam_settings['send_spam_comment_to_admin']) {
|
141 |
-
$antispam_subject = 'Spam comment on site ['.get_bloginfo('name').']'; // email subject
|
142 |
-
$antispam_message = '';
|
143 |
-
$antispam_message .= $antispam_error_message . $rn.$rn;
|
144 |
-
$antispam_message .= $antispam_message_spam_info; // spam comment, post, cookie and other data
|
145 |
-
$antispam_message .= $antispam_message_append;
|
146 |
-
@wp_mail($antispam_settings['admin_email'], $antispam_subject, $antispam_message); // send spam comment to admin email
|
147 |
-
}
|
148 |
-
if ($antispam_settings['log_spam_comment']) {
|
149 |
-
$antispam_message = $rn.$rn.'========== ========== =========='.$rn.$rn;
|
150 |
-
$antispam_message .= $antispam_error_message . $rn.$rn;
|
151 |
-
$antispam_message .= $antispam_message_spam_info; // spam comment, post, cookie and other data
|
152 |
-
antispam_log( $antispam_message );
|
153 |
-
}
|
154 |
-
antispam_counter_stats();
|
155 |
-
wp_die( $antispam_pre_error_message . $antispam_error_message ); // die - do not send comment and show errors
|
156 |
-
}
|
157 |
-
}
|
158 |
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
$antispam_message .= $antispam_error_message . $rn.$rn;
|
166 |
-
$antispam_message .= $antispam_message_spam_info; // spam comment, post, cookie and other data
|
167 |
-
$antispam_message .= $antispam_message_append;
|
168 |
-
@wp_mail($antispam_settings['admin_email'], $antispam_subject, $antispam_message); // send trackback comment to admin email
|
169 |
-
}
|
170 |
antispam_counter_stats();
|
171 |
-
wp_die($antispam_pre_error_message . $antispam_error_message); // die - do not send trackback
|
172 |
}
|
173 |
}
|
174 |
-
|
175 |
-
|
176 |
-
}
|
177 |
-
|
178 |
-
|
179 |
-
if ( ! is_admin()) {
|
180 |
-
add_filter('preprocess_comment', 'antispam_check_comment', 1);
|
181 |
-
}
|
182 |
|
183 |
|
184 |
function antispam_plugin_meta($links, $file) { // add some links to plugin meta row
|
@@ -192,4 +92,4 @@ function antispam_plugin_meta($links, $file) { // add some links to plugin meta
|
|
192 |
}
|
193 |
return (array) $links;
|
194 |
}
|
195 |
-
add_filter('plugin_row_meta', 'antispam_plugin_meta', 10, 2);
|
3 |
Plugin Name: Anti-spam
|
4 |
Plugin URI: http://wordpress.org/plugins/anti-spam/
|
5 |
Description: No spam in comments. No captcha.
|
6 |
+
Version: 5.0
|
7 |
Author: webvitaly
|
8 |
Text Domain: anti-spam
|
9 |
Author URI: http://web-profile.net/wordpress/plugins/
|
14 |
exit;
|
15 |
}
|
16 |
|
17 |
+
define('ANTISPAM_PLUGIN_VERSION', '5.0');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
include('anti-spam-functions.php');
|
20 |
+
include('anti-spam-settings.php');
|
21 |
include('anti-spam-info.php');
|
22 |
|
23 |
|
24 |
function antispam_enqueue_script() {
|
25 |
global $withcomments; // WP flag to show comments on all pages
|
26 |
if ((is_singular() || $withcomments) && comments_open()) { // load script only for pages with comments form
|
27 |
+
wp_enqueue_script('anti-spam-script', plugins_url('/js/anti-spam-5.0.js', __FILE__), null, null, true);
|
28 |
}
|
29 |
}
|
30 |
add_action('wp_enqueue_scripts', 'antispam_enqueue_script');
|
31 |
|
32 |
|
33 |
function antispam_form_part() {
|
|
|
34 |
$rn = "\r\n"; // .chr(13).chr(10)
|
35 |
|
36 |
if ( ! is_user_logged_in()) { // add anti-spam fields only for not logged in users
|
49 |
|
50 |
|
51 |
function antispam_check_comment($commentdata) {
|
52 |
+
$antispam_settings = antispam_get_settings();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
+
if( antispam_check_for_spam() ) {
|
55 |
+
if( $antispam_settings['save_spam_comments'] ) {
|
56 |
+
antispam_store_comment($commentdata);
|
57 |
}
|
58 |
+
antispam_counter_stats();
|
59 |
+
wp_die('Comment is a spam.'); // die - do not send comment and show errors
|
60 |
+
//return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
}
|
62 |
|
63 |
+
return $commentdata; // if comment does not looks like spam
|
64 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
+
if ( ! is_admin()) { // without this check it is not possible to add comment in admin section
|
67 |
+
add_filter('preprocess_comment', 'antispam_check_comment', 1);
|
68 |
+
}
|
|
|
69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
|
71 |
+
// This way still sends the email notifications
|
72 |
+
/*function antispam_process_comments( $comment_ID, $comment_approved ) {
|
73 |
+
global $antispam_settings;
|
74 |
+
if ( $antispam_settings['save_spam_comments'] ) {
|
75 |
+
if( antispam_check_for_spam() ) {
|
76 |
+
wp_set_comment_status( $comment_ID, 'spam' );
|
|
|
|
|
|
|
|
|
|
|
77 |
antispam_counter_stats();
|
|
|
78 |
}
|
79 |
}
|
80 |
+
}*/
|
81 |
+
//add_action( 'comment_post', 'antispam_process_comments', 10, 2 );
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
|
83 |
|
84 |
function antispam_plugin_meta($links, $file) { // add some links to plugin meta row
|
92 |
}
|
93 |
return (array) $links;
|
94 |
}
|
95 |
+
add_filter('plugin_row_meta', 'antispam_plugin_meta', 10, 2);
|
js/{anti-spam-4.4.js → anti-spam-5.0.js}
RENAMED
File without changes
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://web-profile.net/donate/
|
|
4 |
Tags: spam, spammer, comment, comments, comment-spam, antispam, anti-spam, block-spam, spam-free, spambot, spam-bot, bot
|
5 |
Requires at least: 3.3
|
6 |
Tested up to: 5.0
|
7 |
-
Stable tag:
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl.html
|
10 |
|
@@ -18,20 +18,17 @@ No spam in comments. No captcha.
|
|
18 |
> **[GitHub](https://github.com/webvitalii/anti-spam "Fork")**
|
19 |
|
20 |
|
21 |
-
Anti-spam plugin blocks spam in comments
|
22 |
|
23 |
-
|
24 |
-
* **no moderation queues**, because spam is not administrators' problem
|
25 |
-
* **no settings page**, because it is great to forget about spam completely and keep admin section clean
|
26 |
|
|
|
27 |
|
28 |
-
|
29 |
|
30 |
**Plugin blocks spam only in comments section**.
|
31 |
|
32 |
|
33 |
-
**Why humans should prove that they are humans by filling captchas? Lets bots prove that they are not bots with adding javascript to their user-agents!**
|
34 |
-
|
35 |
|
36 |
After installing the Anti-spam plugin **try to submit a comment on your site being logged out**.
|
37 |
If you get an error - you may check the solution in the [Support section](http://wordpress.org/support/plugin/anti-spam) or submit a new topic with detailed description of your problem.
|
@@ -48,6 +45,13 @@ If you get an error - you may check the solution in the [Support section](http:/
|
|
48 |
|
49 |
== Frequently Asked Questions ==
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
= What is the percentage of spam blocked? =
|
52 |
|
53 |
Anti-spam plugin blocks 100% of automatic spam messages (sent by spam-bots via post requests).
|
@@ -87,17 +91,6 @@ You can find the info block with total spam blocked counter in the admin comment
|
|
87 |
You can hide or show this info block in the "Screen Options" section.
|
88 |
The visibility option for this info block is saved per user.
|
89 |
|
90 |
-
= How to test what spam comments were blocked? =
|
91 |
-
|
92 |
-
You may enable sending all rejected spam comments to admin email.
|
93 |
-
Edit [anti-spam.php](http://plugins.trac.wordpress.org/browser/anti-spam/trunk/anti-spam.php) file and find "$antispam_send_spam_comment_to_admin" and make it "true".
|
94 |
-
Or you may log all blocked spam comments to log files.
|
95 |
-
Edit [anti-spam.php](http://plugins.trac.wordpress.org/browser/anti-spam/trunk/anti-spam.php) file and find "$antispam_log_spam_comment" and make it "true".
|
96 |
-
Spam comments will be saved in the file: http://site.com/wp-content/plugins/anti-spam/log/anti-spam-2015-12.log (where "site.com" is the domain and "2015-12" is year and month).
|
97 |
-
Spam log is stored in files per month and history will be saved for 1 year and older log files will be deleted automatically.
|
98 |
-
These features are made for debug purposes and values for these flags will be overwritten after plugin's update.
|
99 |
-
These features are disabled by default.
|
100 |
-
|
101 |
= Does plugin block spam from Contact or other forms? =
|
102 |
|
103 |
Plugin blocks spam only in comments form section and does not block spam from any other forms on site.
|
@@ -107,9 +100,9 @@ If you installed and activated the plugin and you still receiving spam - probabl
|
|
107 |
|
108 |
Users rarely use trackbacks because it is manual and requires extra input. Spammers uses trackbacks because it is easy to cheat here.
|
109 |
Users use pingbacks very often because they work automatically. Spammers does not use pingbacks because backlinks are checked.
|
110 |
-
So trackbacks are blocked
|
111 |
-
|
112 |
-
You may read more about the [difference between trackbacks and pingbacks](http://web-profile.net/web/trackback-vs-pingback/)
|
113 |
|
114 |
= What browsers are supported? =
|
115 |
|
@@ -133,6 +126,13 @@ The plugin is pretty small and easy to read.
|
|
133 |
|
134 |
== Changelog ==
|
135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
= 4.4 - 2017-08-30 =
|
137 |
* Fixed issue with showing comments on every page. Thanks to [johnh10](https://wordpress.org/support/topic/shows-the-captcha-on-archive-pages/)
|
138 |
|
4 |
Tags: spam, spammer, comment, comments, comment-spam, antispam, anti-spam, block-spam, spam-free, spambot, spam-bot, bot
|
5 |
Requires at least: 3.3
|
6 |
Tested up to: 5.0
|
7 |
+
Stable tag: 5.0
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl.html
|
10 |
|
18 |
> **[GitHub](https://github.com/webvitalii/anti-spam "Fork")**
|
19 |
|
20 |
|
21 |
+
Anti-spam plugin blocks automatic spam in comments section. No captcha.
|
22 |
|
23 |
+
Plugin is easy to use: just install it and it just works.
|
|
|
|
|
24 |
|
25 |
+
Blocked comments can be stored in the Spam area if needed. This can be enabled/disabled via Settings page. This is useful for testing and debug purpose. Blocked spam comments can be easily converted to regular comments if needed.
|
26 |
|
27 |
+
Anti-spam plugin is GDPR compliant and does not store any other user data except of the behavior mentioned above.
|
28 |
|
29 |
**Plugin blocks spam only in comments section**.
|
30 |
|
31 |
|
|
|
|
|
32 |
|
33 |
After installing the Anti-spam plugin **try to submit a comment on your site being logged out**.
|
34 |
If you get an error - you may check the solution in the [Support section](http://wordpress.org/support/plugin/anti-spam) or submit a new topic with detailed description of your problem.
|
45 |
|
46 |
== Frequently Asked Questions ==
|
47 |
|
48 |
+
= How to test what spam comments were blocked? =
|
49 |
+
|
50 |
+
You can visit Anti-spam settings page and enable saving blocked comments as spam in the spam section.
|
51 |
+
To enabled that you need to go to: WordPress admin dashboard => Settings section => Anti-spam
|
52 |
+
Saving blocked comments into spam section is disabled by default.
|
53 |
+
Saving spam comments can help you to keep all the comments saved and review them in future if needed. You can easily mark comment as "not spam" if some of the comments were blocked by mistake.
|
54 |
+
|
55 |
= What is the percentage of spam blocked? =
|
56 |
|
57 |
Anti-spam plugin blocks 100% of automatic spam messages (sent by spam-bots via post requests).
|
91 |
You can hide or show this info block in the "Screen Options" section.
|
92 |
The visibility option for this info block is saved per user.
|
93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
= Does plugin block spam from Contact or other forms? =
|
95 |
|
96 |
Plugin blocks spam only in comments form section and does not block spam from any other forms on site.
|
100 |
|
101 |
Users rarely use trackbacks because it is manual and requires extra input. Spammers uses trackbacks because it is easy to cheat here.
|
102 |
Users use pingbacks very often because they work automatically. Spammers does not use pingbacks because backlinks are checked.
|
103 |
+
So trackbacks are blocked but pingbacks are enabled.
|
104 |
+
You may use [Anti-spam Pro](http://codecanyon.net/item/antispam-pro/6491169?ref=webvitalii "Upgrade to Pro") plugin if you need to enable trackbacks.
|
105 |
+
You may read more about the [difference between trackbacks and pingbacks](http://web-profile.net/web/trackback-vs-pingback/)
|
106 |
|
107 |
= What browsers are supported? =
|
108 |
|
126 |
|
127 |
== Changelog ==
|
128 |
|
129 |
+
= 5.0 =
|
130 |
+
* Rewriting/refactoring a lot of the code
|
131 |
+
* Adding Settings page
|
132 |
+
* Storing blocked comments into the Spam section
|
133 |
+
* Working on GDPR compliance
|
134 |
+
|
135 |
+
|
136 |
= 4.4 - 2017-08-30 =
|
137 |
* Fixed issue with showing comments on every page. Thanks to [johnh10](https://wordpress.org/support/topic/shows-the-captcha-on-archive-pages/)
|
138 |
|