Version Description
- Added option to strip links from comments
- Added option to strip & disable the comment author website field
- Added integration with the BotScout blacklist API
Download this release
Release Info
Developer | bmarshall511 |
Plugin | WordPress Zero Spam |
Version | 4.6.0 |
Comparing to | |
See all releases |
Code changes from version 4.5.0 to 4.6.0
- classes/class-wpzerospam-blacklisted-table.php +3 -0
- inc/admin.php +51 -3
- inc/filters.php +77 -0
- inc/helpers.php +131 -7
- readme.txt +10 -1
- wordpress-zero-spam.php +7 -2
classes/class-wpzerospam-blacklisted-table.php
CHANGED
@@ -66,6 +66,9 @@ class WPZeroSpam_Blacklisted_Table extends WP_List_Table {
|
|
66 |
case 'stopforumspam':
|
67 |
return '<a href="https://www.stopforumspam.com/" target="_blank" rel="noopener noreferrer">Stop Forum Spam</a>';
|
68 |
break;
|
|
|
|
|
|
|
69 |
default:
|
70 |
return $item->blacklist_service;
|
71 |
}
|
66 |
case 'stopforumspam':
|
67 |
return '<a href="https://www.stopforumspam.com/" target="_blank" rel="noopener noreferrer">Stop Forum Spam</a>';
|
68 |
break;
|
69 |
+
case 'botscout':
|
70 |
+
return '<a href="https://botscout.com/" target="_blank" rel="noopener noreferrer">BotScout</a>';
|
71 |
+
break;
|
72 |
default:
|
73 |
return $item->blacklist_service;
|
74 |
}
|
inc/admin.php
CHANGED
@@ -324,7 +324,7 @@ function wpzerospam_validate_options( $input ) {
|
|
324 |
if ( empty( $input['log_blocked_ips'] ) ) { $input['log_blocked_ips'] = 'disabled'; }
|
325 |
if ( empty( $input['auto_block_ips'] ) ) { $input['auto_block_ips'] = 'disabled'; }
|
326 |
if ( empty( $input['auto_block_period'] ) ) { $input['auto_block_period'] = 0; }
|
327 |
-
|
328 |
|
329 |
if ( empty( $input['verify_cf7'] ) ) {
|
330 |
$input['verify_cf7'] = 'disabled';
|
@@ -354,6 +354,18 @@ function wpzerospam_validate_options( $input ) {
|
|
354 |
$input['stop_forum_spam'] = 'disabled';
|
355 |
}
|
356 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
357 |
return $input;
|
358 |
}
|
359 |
|
@@ -382,18 +394,51 @@ function wpzerospam_admin_init() {
|
|
382 |
register_setting( 'wpzerospam', 'wpzerospam', 'wpzerospam_validate_options' );
|
383 |
|
384 |
add_settings_section( 'wpzerospam_general_settings', __( 'General Settings', 'wpzerospam' ), 'wpzerospam_general_settings_cb', 'wpzerospam' );
|
|
|
385 |
add_settings_section( 'wpzerospam_spam_checks', __( 'Integrations & Third-party APIs', 'wpzerospam' ), 'wpzerospam_spam_checks_cb', 'wpzerospam' );
|
386 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
387 |
if ( 'enabled' == $options['log_spam'] ) {
|
388 |
// Redirect URL for spam detections
|
389 |
add_settings_field( 'ipstack_api', __( 'ipstack API Key', 'wpzerospam' ), 'wpzerospam_field_cb', 'wpzerospam', 'wpzerospam_spam_checks', [
|
390 |
'label_for' => 'ipstack_api',
|
391 |
'type' => 'text',
|
|
|
392 |
'class' => 'regular-text',
|
393 |
-
'desc' => 'Enter your <a href="https://ipstack.com/" target="_blank">ipstack API key</a> to enable location-based statistics.',
|
394 |
]);
|
395 |
}
|
396 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
397 |
// Enables the ability to check IPs against Stop Forum Spam blacklists.
|
398 |
add_settings_field( 'stop_forum_spam', __( 'Stop Forum Spam', 'wpzerospam' ), 'wpzerospam_field_cb', 'wpzerospam', 'wpzerospam_spam_checks', [
|
399 |
'label_for' => 'stop_forum_spam',
|
@@ -455,7 +500,7 @@ function wpzerospam_admin_init() {
|
|
455 |
'type' => 'text',
|
456 |
'class' => 'large-text',
|
457 |
'desc' => 'The message that will be displayed to a blocked user.',
|
458 |
-
'placeholder' => __( 'You have been blocked from visiting this site.', 'wpzerospam' )
|
459 |
]);
|
460 |
}
|
461 |
|
@@ -620,6 +665,9 @@ function wpzerospam_general_settings_cb() {
|
|
620 |
function wpzerospam_spam_checks_cb() {
|
621 |
}
|
622 |
|
|
|
|
|
|
|
623 |
function wpzerospam_field_cb( $args ) {
|
624 |
$options = wpzerospam_options();
|
625 |
|
324 |
if ( empty( $input['log_blocked_ips'] ) ) { $input['log_blocked_ips'] = 'disabled'; }
|
325 |
if ( empty( $input['auto_block_ips'] ) ) { $input['auto_block_ips'] = 'disabled'; }
|
326 |
if ( empty( $input['auto_block_period'] ) ) { $input['auto_block_period'] = 0; }
|
327 |
+
if ( empty( $input['botscout_api'] ) ) { $input['botscout'] = false; }
|
328 |
|
329 |
if ( empty( $input['verify_cf7'] ) ) {
|
330 |
$input['verify_cf7'] = 'disabled';
|
354 |
$input['stop_forum_spam'] = 'disabled';
|
355 |
}
|
356 |
|
357 |
+
if ( empty( $input['strip_comment_links'] ) ) {
|
358 |
+
$input['strip_comment_links'] = 'disabled';
|
359 |
+
}
|
360 |
+
|
361 |
+
if ( empty( $input['strip_comment_author_links'] ) ) {
|
362 |
+
$input['strip_comment_author_links'] = 'disabled';
|
363 |
+
}
|
364 |
+
|
365 |
+
if ( empty( $input['blocked_message'] ) ) {
|
366 |
+
$input['blocked_message'] = 'You have been blocked from visiting this site by WordPress Zero Spam due to detected spam activity.';
|
367 |
+
}
|
368 |
+
|
369 |
return $input;
|
370 |
}
|
371 |
|
394 |
register_setting( 'wpzerospam', 'wpzerospam', 'wpzerospam_validate_options' );
|
395 |
|
396 |
add_settings_section( 'wpzerospam_general_settings', __( 'General Settings', 'wpzerospam' ), 'wpzerospam_general_settings_cb', 'wpzerospam' );
|
397 |
+
add_settings_section( 'wpzerospam_onsite', __( 'On-site Spam Prevention', 'wpzerospam' ), 'wpzerospam_onsite_cb', 'wpzerospam' );
|
398 |
add_settings_section( 'wpzerospam_spam_checks', __( 'Integrations & Third-party APIs', 'wpzerospam' ), 'wpzerospam_spam_checks_cb', 'wpzerospam' );
|
399 |
|
400 |
+
// Option to strips links in comments
|
401 |
+
add_settings_field( 'strip_comment_links', __( 'Strip Comment Links', 'wpzerospam' ), 'wpzerospam_field_cb', 'wpzerospam', 'wpzerospam_onsite', [
|
402 |
+
'label_for' => 'strip_comment_links',
|
403 |
+
'type' => 'checkbox',
|
404 |
+
'multi' => false,
|
405 |
+
'desc' => 'Spambots commonly post spam links in comments. Enable this option to strip links from comments.',
|
406 |
+
'options' => [
|
407 |
+
'enabled' => __( 'Enabled', 'wpzerospam' )
|
408 |
+
]
|
409 |
+
]);
|
410 |
+
|
411 |
+
// Option to remove author links
|
412 |
+
add_settings_field( 'strip_comment_author_links', __( 'Strip Comment Author Links', 'wpzerospam' ), 'wpzerospam_field_cb', 'wpzerospam', 'wpzerospam_onsite', [
|
413 |
+
'label_for' => 'strip_comment_author_links',
|
414 |
+
'type' => 'checkbox',
|
415 |
+
'multi' => false,
|
416 |
+
'desc' => 'Spammers are well-known at injecting malicious links in the comment author website field, this option disables it.',
|
417 |
+
'options' => [
|
418 |
+
'enabled' => __( 'Enabled', 'wpzerospam' )
|
419 |
+
]
|
420 |
+
]);
|
421 |
+
|
422 |
if ( 'enabled' == $options['log_spam'] ) {
|
423 |
// Redirect URL for spam detections
|
424 |
add_settings_field( 'ipstack_api', __( 'ipstack API Key', 'wpzerospam' ), 'wpzerospam_field_cb', 'wpzerospam', 'wpzerospam_spam_checks', [
|
425 |
'label_for' => 'ipstack_api',
|
426 |
'type' => 'text',
|
427 |
+
'placeholder' => __( 'Enter your ipstack API key.', 'wpzerospam' ),
|
428 |
'class' => 'regular-text',
|
429 |
+
'desc' => 'Enter your <a href="https://ipstack.com/" target="_blank">ipstack API key</a> to enable location-based statistics. Don\'t have an API key? <a href="https://ipstack.com/signup/free" target="_blank" rel="noopener noreferrer"><strong>Get one for free!</strong></a>',
|
430 |
]);
|
431 |
}
|
432 |
|
433 |
+
// Enables the ability to check IPs against BotScout blacklists.
|
434 |
+
add_settings_field( 'botscout_api', __( 'BotScout API Key', 'wpzerospam' ), 'wpzerospam_field_cb', 'wpzerospam', 'wpzerospam_spam_checks', [
|
435 |
+
'label_for' => 'botscout_api',
|
436 |
+
'type' => 'text',
|
437 |
+
'class' => 'regular-text',
|
438 |
+
'placeholder' => __( 'Enter your free BotScout API key.', 'wpzerospam' ),
|
439 |
+
'desc' => 'Enter your BotScout API key to check user IPs against <a href="https://botscout.com/" target="_blank" rel="noopener noreferrer">BotScout</a>\'s blacklist. Don\'t have an API key? <a href="https://botscout.com/getkey.htm" target="_blank" rel="noopener noreferrer"><strong>Get one for free!</strong></a>'
|
440 |
+
]);
|
441 |
+
|
442 |
// Enables the ability to check IPs against Stop Forum Spam blacklists.
|
443 |
add_settings_field( 'stop_forum_spam', __( 'Stop Forum Spam', 'wpzerospam' ), 'wpzerospam_field_cb', 'wpzerospam', 'wpzerospam_spam_checks', [
|
444 |
'label_for' => 'stop_forum_spam',
|
500 |
'type' => 'text',
|
501 |
'class' => 'large-text',
|
502 |
'desc' => 'The message that will be displayed to a blocked user.',
|
503 |
+
'placeholder' => __( 'You have been blocked from visiting this site by WordPress Zero Spam due to detected spam activity.', 'wpzerospam' )
|
504 |
]);
|
505 |
}
|
506 |
|
665 |
function wpzerospam_spam_checks_cb() {
|
666 |
}
|
667 |
|
668 |
+
function wpzerospam_onsite_cb() {
|
669 |
+
}
|
670 |
+
|
671 |
function wpzerospam_field_cb( $args ) {
|
672 |
$options = wpzerospam_options();
|
673 |
|
inc/filters.php
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WP filters
|
4 |
+
*
|
5 |
+
* @package WordPressZeroSpam
|
6 |
+
* @since 4.6.0
|
7 |
+
*/
|
8 |
+
|
9 |
+
|
10 |
+
if ( ! function_exists( 'wpzerospam_filters' ) ) {
|
11 |
+
function wpzerospam_filters() {
|
12 |
+
$options = wpzerospam_options();
|
13 |
+
|
14 |
+
if ( 'enabled' == $options['strip_comment_links'] ) {
|
15 |
+
remove_filter( 'comment_text', 'make_clickable', 9 );
|
16 |
+
|
17 |
+
add_filter( 'comment_text', 'wpzerospam_strip_comment_links_display', 10, 1);
|
18 |
+
add_filter( 'comment_text_rss', 'wpzerospam_strip_comment_links_display', 10, 1);
|
19 |
+
add_filter( 'comment_excerpt', 'wpzerospam_strip_comment_links_display', 10, 1);
|
20 |
+
|
21 |
+
add_filter( 'preprocess_comment', 'wpzerospam_strip_comment_links', 10, 1 );
|
22 |
+
}
|
23 |
+
|
24 |
+
if ( 'enabled' == $options['strip_comment_author_links'] ) {
|
25 |
+
add_filter( 'get_comment_author_link', 'wpzerospam_remove_comment_author_link', 10, 3 );
|
26 |
+
add_filter( 'get_comment_author_url', 'wpzerospam_remove_author_url' );
|
27 |
+
add_filter( 'comment_form_default_fields', 'wpzerospam_remove_author_url_field' );
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
31 |
+
add_action( 'after_setup_theme', 'wpzerospam_filters' );
|
32 |
+
|
33 |
+
if ( ! function_exists( 'wpzerospam_remove_author_url_field' ) ) {
|
34 |
+
function wpzerospam_remove_author_url_field( $fields ) {
|
35 |
+
if ( isset( $fields['url'] ) ) {
|
36 |
+
unset( $fields['url'] );
|
37 |
+
}
|
38 |
+
|
39 |
+
return $fields;
|
40 |
+
}
|
41 |
+
}
|
42 |
+
|
43 |
+
if ( ! function_exists( 'wpzerospam_remove_comment_author_link' ) ) {
|
44 |
+
function wpzerospam_remove_comment_author_link( $return, $author, $comment_ID ) {
|
45 |
+
return $author;
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
if ( ! function_exists( 'wpzerospam_remove_author_url' ) ) {
|
50 |
+
function wpzerospam_remove_author_url() {
|
51 |
+
return false;
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
if ( ! function_exists( 'wpzerospam_strip_comment_links' ) ) {
|
56 |
+
function wpzerospam_strip_comment_links( $comment ) {
|
57 |
+
global $allowedtags;
|
58 |
+
|
59 |
+
$tags = $allowedtags;
|
60 |
+
unset( $tags['a'] );
|
61 |
+
$content = addslashes( wp_kses( stripslashes( $comment ), $tags) );
|
62 |
+
|
63 |
+
return $comment;
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
if ( ! function_exists( 'wpzerospam_strip_comment_links_display' ) ) {
|
68 |
+
function wpzerospam_strip_comment_links_display( $comment ) {
|
69 |
+
global $allowedtags;
|
70 |
+
|
71 |
+
$tags = $allowedtags;
|
72 |
+
unset( $tags['a'] );
|
73 |
+
$content = addslashes( wp_kses( stripslashes( $comment ), $tags) );
|
74 |
+
|
75 |
+
return $comment;
|
76 |
+
}
|
77 |
+
}
|
inc/helpers.php
CHANGED
@@ -16,7 +16,7 @@ require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/inc/locations.php';
|
|
16 |
*/
|
17 |
if ( ! function_exists( 'wpzerospam_get_ip_info' ) ) {
|
18 |
function wpzerospam_get_ip_info( $ip ) {
|
19 |
-
$options
|
20 |
|
21 |
if ( empty( $options['ipstack_api'] ) ) { return false; }
|
22 |
|
@@ -399,12 +399,14 @@ if ( ! function_exists( 'wpzerospam_options' ) ) {
|
|
399 |
if ( empty( $options['block_handler'] ) ) { $options['block_handler'] = '403'; }
|
400 |
if ( empty( $options['spam_redirect_url'] ) ) { $options['spam_redirect_url'] = 'https://www.google.com'; }
|
401 |
if ( empty( $options['spam_message'] ) ) { $options['spam_message'] = __( 'There was a problem with your submission. Please go back and try again.', 'wpzerospam' ); }
|
402 |
-
if ( empty( $options['blocked_message'] ) ) { $options['blocked_message'] = __( 'You have been blocked from visiting this site.', 'wpzerospam' ); }
|
403 |
if ( empty( $options['log_spam'] ) ) { $options['log_spam'] = 'disabled'; }
|
404 |
if ( empty( $options['verify_comments'] ) ) { $options['verify_comments'] = 'enabled'; }
|
405 |
if ( empty( $options['verify_registrations'] ) ) { $options['verify_registrations'] = 'enabled'; }
|
406 |
if ( empty( $options['log_blocked_ips'] ) ) { $options['log_blocked_ips'] = 'disabled'; }
|
407 |
|
|
|
|
|
408 |
if ( empty( $options['verify_cf7'] ) ) {
|
409 |
$options['verify_cf7'] = 'enabled';
|
410 |
}
|
@@ -433,6 +435,14 @@ if ( ! function_exists( 'wpzerospam_options' ) ) {
|
|
433 |
$options['stop_forum_spam'] = 'enabled';
|
434 |
}
|
435 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
436 |
return $options;
|
437 |
}
|
438 |
}
|
@@ -503,11 +513,35 @@ if ( ! function_exists( 'wpzerospam_check_access' ) ) {
|
|
503 |
|
504 |
return $access;
|
505 |
}
|
506 |
-
} else {
|
507 |
-
// Stop Forum Spam blacklist is disabled & the IP wasn't found in the
|
508 |
-
// blocked IPs table.
|
509 |
-
return $access;
|
510 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
511 |
}
|
512 |
|
513 |
// IP address was found in the blocked IPs list, determine the type and if
|
@@ -592,6 +626,91 @@ if ( ! function_exists( 'wpzerospam_current_url' ) ) {
|
|
592 |
}
|
593 |
}
|
594 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
595 |
/**
|
596 |
* Queries the Stop Forum Spam API
|
597 |
*
|
@@ -599,7 +718,7 @@ if ( ! function_exists( 'wpzerospam_current_url' ) ) {
|
|
599 |
*/
|
600 |
if ( ! function_exists( 'wpzerospam_stopforumspam_request' ) ) {
|
601 |
function wpzerospam_stopforumspam_request( $ip ) {
|
602 |
-
$api_url = '
|
603 |
$params = [ 'ip' => $ip, 'json' => '' ];
|
604 |
$endpoint = $api_url . http_build_query( $params );
|
605 |
$response = wp_remote_get( $endpoint );
|
@@ -638,6 +757,10 @@ if ( ! function_exists( 'wpzerospam_update_blacklist' ) ) {
|
|
638 |
$update['blacklist_service'] = $data['blacklist_service'];
|
639 |
}
|
640 |
|
|
|
|
|
|
|
|
|
641 |
if ( ! empty( $data['appears'] ) ) {
|
642 |
$update['blacklist_data']['appears'] = intval( $data['appears'] );
|
643 |
}
|
@@ -703,6 +826,7 @@ if ( ! function_exists( 'wpzerospam_stopforumspam_is_spam' ) ) {
|
|
703 |
// Expired, update the record
|
704 |
$stopforumspam_request = wpzerospam_stopforumspam_request( $ip );
|
705 |
if ( $stopforumspam_request ) {
|
|
|
706 |
wpzerospam_update_blacklist( $stopforumspam_request );
|
707 |
|
708 |
return $stopforumspam_request;
|
16 |
*/
|
17 |
if ( ! function_exists( 'wpzerospam_get_ip_info' ) ) {
|
18 |
function wpzerospam_get_ip_info( $ip ) {
|
19 |
+
$options = wpzerospam_options();
|
20 |
|
21 |
if ( empty( $options['ipstack_api'] ) ) { return false; }
|
22 |
|
399 |
if ( empty( $options['block_handler'] ) ) { $options['block_handler'] = '403'; }
|
400 |
if ( empty( $options['spam_redirect_url'] ) ) { $options['spam_redirect_url'] = 'https://www.google.com'; }
|
401 |
if ( empty( $options['spam_message'] ) ) { $options['spam_message'] = __( 'There was a problem with your submission. Please go back and try again.', 'wpzerospam' ); }
|
402 |
+
if ( empty( $options['blocked_message'] ) ) { $options['blocked_message'] = __( 'You have been blocked from visiting this site by WordPress Zero Spam due to detected spam activity.', 'wpzerospam' ); }
|
403 |
if ( empty( $options['log_spam'] ) ) { $options['log_spam'] = 'disabled'; }
|
404 |
if ( empty( $options['verify_comments'] ) ) { $options['verify_comments'] = 'enabled'; }
|
405 |
if ( empty( $options['verify_registrations'] ) ) { $options['verify_registrations'] = 'enabled'; }
|
406 |
if ( empty( $options['log_blocked_ips'] ) ) { $options['log_blocked_ips'] = 'disabled'; }
|
407 |
|
408 |
+
if ( empty( $options['botscout_api'] ) ) { $options['botscout_api'] = false; }
|
409 |
+
|
410 |
if ( empty( $options['verify_cf7'] ) ) {
|
411 |
$options['verify_cf7'] = 'enabled';
|
412 |
}
|
435 |
$options['stop_forum_spam'] = 'enabled';
|
436 |
}
|
437 |
|
438 |
+
if ( empty( $options['strip_comment_links'] ) ) {
|
439 |
+
$options['strip_comment_links'] = 'disabled';
|
440 |
+
}
|
441 |
+
|
442 |
+
if ( empty( $options['strip_comment_author_links'] ) ) {
|
443 |
+
$options['strip_comment_author_links'] = 'disabled';
|
444 |
+
}
|
445 |
+
|
446 |
return $options;
|
447 |
}
|
448 |
}
|
513 |
|
514 |
return $access;
|
515 |
}
|
|
|
|
|
|
|
|
|
516 |
}
|
517 |
+
|
518 |
+
// If enabled, check the BotScout blacklist
|
519 |
+
if ( 'enabled' == $options['botscout'] ) {
|
520 |
+
$botscout_request = wpzerospam_botscout_is_spam( $ip );
|
521 |
+
if ( ! $botscout_request ) {
|
522 |
+
// IP wasn't found in the Stop Forum Spam blacklist
|
523 |
+
return $access;
|
524 |
+
} else {
|
525 |
+
// IP was found in the Stop Forum Spam blacklist
|
526 |
+
$access['access'] = false;
|
527 |
+
$access['reason'] = 'BotScout';
|
528 |
+
|
529 |
+
return $access;
|
530 |
+
}
|
531 |
+
}
|
532 |
+
|
533 |
+
// Passed all tests
|
534 |
+
return $access;
|
535 |
+
}
|
536 |
+
|
537 |
+
// Check if in the blacklist
|
538 |
+
$in_blacklist = wpzerospam_in_blacklist( $ip );
|
539 |
+
if ( $in_blacklist ) {
|
540 |
+
// IP found in the blacklist
|
541 |
+
$access['access'] = false;
|
542 |
+
$access['reason'] = $in_blacklist->blacklist_service;
|
543 |
+
|
544 |
+
return $access;
|
545 |
}
|
546 |
|
547 |
// IP address was found in the blocked IPs list, determine the type and if
|
626 |
}
|
627 |
}
|
628 |
|
629 |
+
/**
|
630 |
+
* Queries the BotScout API
|
631 |
+
*
|
632 |
+
* @link http://botscout.com/api.htm
|
633 |
+
*
|
634 |
+
* @since 4.6.0
|
635 |
+
*/
|
636 |
+
if ( ! function_exists( 'wpzerospam_botscout_request' ) ) {
|
637 |
+
function wpzerospam_botscout_request( $ip ) {
|
638 |
+
$options = wpzerospam_options();
|
639 |
+
|
640 |
+
if ( empty( $options['botscout_api'] ) ) { return false; }
|
641 |
+
|
642 |
+
$api_url = 'https://botscout.com/test/?';
|
643 |
+
$params = [ 'ip' => $ip, 'key' => $options['botscout_api'] ];
|
644 |
+
$endpoint = $api_url . http_build_query( $params );
|
645 |
+
$response = wp_remote_get( $endpoint );
|
646 |
+
|
647 |
+
if ( is_array( $response ) && ! is_wp_error( $response ) ) {
|
648 |
+
$data = wp_remote_retrieve_body( $response );
|
649 |
+
|
650 |
+
// Check if there's an error
|
651 |
+
if ( strpos( $data, '!' ) === false ) {
|
652 |
+
// Valid request
|
653 |
+
list( $matched, $type, $count ) = explode( "|", $data );
|
654 |
+
return [
|
655 |
+
'matched' => ( $matched == 'Y' ) ? true : false,
|
656 |
+
'count' => $count
|
657 |
+
];
|
658 |
+
}
|
659 |
+
}
|
660 |
+
|
661 |
+
return false;
|
662 |
+
}
|
663 |
+
}
|
664 |
+
|
665 |
+
/**
|
666 |
+
* Checks the post submission for a valid key
|
667 |
+
*
|
668 |
+
* @since 4.5.0
|
669 |
+
*/
|
670 |
+
if ( ! function_exists( 'wpzerospam_botscout_is_spam' ) ) {
|
671 |
+
function wpzerospam_botscout_is_spam( $ip ) {
|
672 |
+
// First check if the IP is already in the blacklist table
|
673 |
+
$in_blacklist = wpzerospam_in_blacklist( $ip );
|
674 |
+
if ( $in_blacklist ) {
|
675 |
+
// Check if the record should be updated
|
676 |
+
$last_updated = strtotime( $in_blacklist->last_updated );
|
677 |
+
$current_time = current_time( 'timestamp' );
|
678 |
+
$expiration = $last_updated + MONTH_IN_SECONDS;
|
679 |
+
|
680 |
+
if ( $current_time > $expiration ) {
|
681 |
+
// Expired, update the record
|
682 |
+
$botscout_request = wpzerospam_botscout_request( $ip );
|
683 |
+
if ( $botscout_request && ! empty( $botscout['matched'] ) ) {
|
684 |
+
$botscout_request['blacklist_service'] = 'botscout';
|
685 |
+
$botscout_request['blacklist_id'] = $in_blacklist->blacklist_id;
|
686 |
+
wpzerospam_update_blacklist( $botscout_request );
|
687 |
+
|
688 |
+
return $botscout_request;
|
689 |
+
}
|
690 |
+
}
|
691 |
+
|
692 |
+
return $in_blacklist;
|
693 |
+
}
|
694 |
+
|
695 |
+
// Not in the blacklist, query the BotScout API now
|
696 |
+
$botscout_request = wpzerospam_botscout_request( $ip );
|
697 |
+
if (
|
698 |
+
$botscout_request &&
|
699 |
+
! empty( $botscout_request['matched'] )
|
700 |
+
) {
|
701 |
+
$new_record = $botscout_request;
|
702 |
+
$new_record['ip'] = $ip;
|
703 |
+
$new_record['blacklist_service'] = 'botscout';
|
704 |
+
|
705 |
+
wpzerospam_update_blacklist( $new_record );
|
706 |
+
|
707 |
+
return $new_record;
|
708 |
+
}
|
709 |
+
|
710 |
+
return false;
|
711 |
+
}
|
712 |
+
}
|
713 |
+
|
714 |
/**
|
715 |
* Queries the Stop Forum Spam API
|
716 |
*
|
718 |
*/
|
719 |
if ( ! function_exists( 'wpzerospam_stopforumspam_request' ) ) {
|
720 |
function wpzerospam_stopforumspam_request( $ip ) {
|
721 |
+
$api_url = 'https://api.stopforumspam.org/api?';
|
722 |
$params = [ 'ip' => $ip, 'json' => '' ];
|
723 |
$endpoint = $api_url . http_build_query( $params );
|
724 |
$response = wp_remote_get( $endpoint );
|
757 |
$update['blacklist_service'] = $data['blacklist_service'];
|
758 |
}
|
759 |
|
760 |
+
if ( ! empty( $data['count'] ) ) {
|
761 |
+
$update['blacklist_data']['count'] = intval( $data['count'] );
|
762 |
+
}
|
763 |
+
|
764 |
if ( ! empty( $data['appears'] ) ) {
|
765 |
$update['blacklist_data']['appears'] = intval( $data['appears'] );
|
766 |
}
|
826 |
// Expired, update the record
|
827 |
$stopforumspam_request = wpzerospam_stopforumspam_request( $ip );
|
828 |
if ( $stopforumspam_request ) {
|
829 |
+
$stopforumspam_request['blacklist_id'] = $in_blacklist->blacklist_id;
|
830 |
wpzerospam_update_blacklist( $stopforumspam_request );
|
831 |
|
832 |
return $stopforumspam_request;
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Donate link: https://benmarshall.me/donate/?utm_source=wordpress_zero_spam&utm_m
|
|
5 |
Requires at least: 5.2
|
6 |
Tested up to: 5.4.2
|
7 |
Requires PHP: 7.1
|
8 |
-
Stable tag: 4.
|
9 |
License: GNU GPLv3
|
10 |
License URI: https://choosealicense.com/licenses/gpl-3.0/
|
11 |
|
@@ -25,6 +25,7 @@ WordPress Zero Spam was initially built based on the work by [David Walsh](http:
|
|
25 |
* **No moderation queues**, spam isn't a administrators' problem
|
26 |
* **Blocks 99.9% of spam** submissions
|
27 |
* **Blocks spammy IPs** from ever seeing your site
|
|
|
28 |
* **Auto-block IPs** when a spam detection is triggered
|
29 |
* **Manually block IPs** either temporarily or permanently
|
30 |
* **Developer-friendly**, integrate with any theme, plugin or form
|
@@ -43,6 +44,8 @@ WordPress Zero Spam was initially built based on the work by [David Walsh](http:
|
|
43 |
* [Contact Form by WPForms](https://wordpress.org/plugins/wpforms-lite/) submissions
|
44 |
* [WP Fluent Forms](https://wordpress.org/plugins/fluentform/) submissions
|
45 |
|
|
|
|
|
46 |
This plugin does not support Jetpack Comments. For more information, see [https://wordpress.org/support/topic/incompatible-with-jetpack-comments](https://wordpress.org/support/topic/incompatible-with-jetpack-comments). If you're running something other than one of the supported plugins above, it won't detect spam submissions without some additional integration.
|
47 |
|
48 |
Feel free to report any [bugs/feature requests here](https://github.com/bmarshall511/wordpress-zero-spam/issues).
|
@@ -102,6 +105,12 @@ Yes, that's what does the magic and keeps spam bots out.
|
|
102 |
|
103 |
== Changelog ==
|
104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
= 4.5.0 =
|
106 |
|
107 |
* Added integration with the Stop Forum Spam known spammy IPs
|
5 |
Requires at least: 5.2
|
6 |
Tested up to: 5.4.2
|
7 |
Requires PHP: 7.1
|
8 |
+
Stable tag: 4.6.0
|
9 |
License: GNU GPLv3
|
10 |
License URI: https://choosealicense.com/licenses/gpl-3.0/
|
11 |
|
25 |
* **No moderation queues**, spam isn't a administrators' problem
|
26 |
* **Blocks 99.9% of spam** submissions
|
27 |
* **Blocks spammy IPs** from ever seeing your site
|
28 |
+
* **Checks known spam blacklists** to prevent access ([Stop Forum Spam](https://www.stopforumspam.com/), [BotScout](https://botscout.com/))
|
29 |
* **Auto-block IPs** when a spam detection is triggered
|
30 |
* **Manually block IPs** either temporarily or permanently
|
31 |
* **Developer-friendly**, integrate with any theme, plugin or form
|
44 |
* [Contact Form by WPForms](https://wordpress.org/plugins/wpforms-lite/) submissions
|
45 |
* [WP Fluent Forms](https://wordpress.org/plugins/fluentform/) submissions
|
46 |
|
47 |
+
While WordPress Zero Spam block 99.9% of the spam that comes through, there's still some other things you can do as a site owner to [stop WordPress spam](https://benmarshall.me/stop-wordpress-spam/).
|
48 |
+
|
49 |
This plugin does not support Jetpack Comments. For more information, see [https://wordpress.org/support/topic/incompatible-with-jetpack-comments](https://wordpress.org/support/topic/incompatible-with-jetpack-comments). If you're running something other than one of the supported plugins above, it won't detect spam submissions without some additional integration.
|
50 |
|
51 |
Feel free to report any [bugs/feature requests here](https://github.com/bmarshall511/wordpress-zero-spam/issues).
|
105 |
|
106 |
== Changelog ==
|
107 |
|
108 |
+
= 4.6.0 =
|
109 |
+
|
110 |
+
* Added option to strip links from comments
|
111 |
+
* Added option to strip & disable the comment author website field
|
112 |
+
* Added integration with the BotScout blacklist API
|
113 |
+
|
114 |
= 4.5.0 =
|
115 |
|
116 |
* Added integration with the Stop Forum Spam known spammy IPs
|
wordpress-zero-spam.php
CHANGED
@@ -13,7 +13,7 @@
|
|
13 |
* Plugin Name: WordPress Zero Spam
|
14 |
* Plugin URI: https://benmarshall.me/wordpress-zero-spam
|
15 |
* Description: Tired of all the useless and bloated WordPress spam plugins? The WordPress Zero Spam plugin makes blocking spam a cinch. <strong>Just install, activate and say goodbye to spam.</strong> Based on work by <a href="http://davidwalsh.name/wordpress-comment-spam" target="_blank">David Walsh</a>.
|
16 |
-
* Version: 4.
|
17 |
* Requires at least: 5.2
|
18 |
* Requires PHP: 7.2
|
19 |
* Author: Ben Marshall
|
@@ -31,7 +31,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
|
31 |
// Define plugin constants
|
32 |
define( 'WORDPRESS_ZERO_SPAM', __FILE__ );
|
33 |
define( 'WORDPRESS_ZERO_SPAM_DB_VERSION', '0.2' );
|
34 |
-
define( 'WORDPRESS_ZERO_SPAM_VERSION', '4.
|
35 |
|
36 |
/**
|
37 |
* Helpers
|
@@ -127,6 +127,11 @@ require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/inc/scripts.php';
|
|
127 |
*/
|
128 |
require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/inc/admin.php';
|
129 |
|
|
|
|
|
|
|
|
|
|
|
130 |
/**
|
131 |
* Below are the includes for individual spam check integrations
|
132 |
*/
|
13 |
* Plugin Name: WordPress Zero Spam
|
14 |
* Plugin URI: https://benmarshall.me/wordpress-zero-spam
|
15 |
* Description: Tired of all the useless and bloated WordPress spam plugins? The WordPress Zero Spam plugin makes blocking spam a cinch. <strong>Just install, activate and say goodbye to spam.</strong> Based on work by <a href="http://davidwalsh.name/wordpress-comment-spam" target="_blank">David Walsh</a>.
|
16 |
+
* Version: 4.6.0
|
17 |
* Requires at least: 5.2
|
18 |
* Requires PHP: 7.2
|
19 |
* Author: Ben Marshall
|
31 |
// Define plugin constants
|
32 |
define( 'WORDPRESS_ZERO_SPAM', __FILE__ );
|
33 |
define( 'WORDPRESS_ZERO_SPAM_DB_VERSION', '0.2' );
|
34 |
+
define( 'WORDPRESS_ZERO_SPAM_VERSION', '4.6.0' );
|
35 |
|
36 |
/**
|
37 |
* Helpers
|
127 |
*/
|
128 |
require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/inc/admin.php';
|
129 |
|
130 |
+
/**
|
131 |
+
* WP filters
|
132 |
+
*/
|
133 |
+
require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/inc/filters.php';
|
134 |
+
|
135 |
/**
|
136 |
* Below are the includes for individual spam check integrations
|
137 |
*/
|