Version Description
July 21 2016 = * Optimized bulk spam comments deletion. * Turned off JavaScript anti-spam cookies if the option 'Set cookies' is turned off. It helps to avoid issues with Varnish. * Added links to bulk spam comments&users removal tool.
Download this release
Release Info
Developer | shagimuratov |
Plugin | Spam protection, AntiSpam, FireWall by CleanTalk |
Version | 5.45 |
Comparing to | |
See all releases |
Code changes from version 5.44.1 to 5.45
- cleantalk.php +3 -4
- inc/cleantalk-admin.js +3 -2
- inc/cleantalk-admin.php +38 -19
- inc/cleantalk-comments-checkspam.js +21 -7
- inc/cleantalk-comments.php +515 -476
- inc/cleantalk-common.php +16 -3
- inc/cleantalk-public.php +46 -16
- inc/cleantalk-users-checkspam.js +10 -3
- inc/cleantalk-users.php +24 -23
- inc/cleantalk.class.php +1 -1
- inc/images/new_window.gif +0 -0
- readme.txt +11 -1
cleantalk.php
CHANGED
@@ -3,12 +3,12 @@
|
|
3 |
Plugin Name: Spam Protection by CleanTalk
|
4 |
Plugin URI: http://cleantalk.org
|
5 |
Description: Max power, all-in-one, captcha less, premium anti-spam plugin. No comment spam, no registration spam, no contact spam, protects any WordPress forms. Formerly Anti-Spam by CleanTalk.
|
6 |
-
Version: 5.
|
7 |
Author: СleanTalk <welcome@cleantalk.org>
|
8 |
Author URI: http://cleantalk.org
|
9 |
*/
|
10 |
-
$cleantalk_plugin_version='5.
|
11 |
-
$ct_agent_version = 'wordpress-
|
12 |
$cleantalk_executed=false;
|
13 |
$ct_sfw_updated = false;
|
14 |
|
@@ -271,7 +271,6 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
|
|
271 |
require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-public.php');
|
272 |
|
273 |
// Init action.
|
274 |
-
add_action('init', 'ct_init_after_all', 100);
|
275 |
add_action('plugins_loaded', 'ct_init', 1);
|
276 |
|
277 |
// Hourly run hook
|
3 |
Plugin Name: Spam Protection by CleanTalk
|
4 |
Plugin URI: http://cleantalk.org
|
5 |
Description: Max power, all-in-one, captcha less, premium anti-spam plugin. No comment spam, no registration spam, no contact spam, protects any WordPress forms. Formerly Anti-Spam by CleanTalk.
|
6 |
+
Version: 5.45
|
7 |
Author: СleanTalk <welcome@cleantalk.org>
|
8 |
Author URI: http://cleantalk.org
|
9 |
*/
|
10 |
+
$cleantalk_plugin_version='5.45';
|
11 |
+
$ct_agent_version = 'wordpress-545';
|
12 |
$cleantalk_executed=false;
|
13 |
$ct_sfw_updated = false;
|
14 |
|
271 |
require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-public.php');
|
272 |
|
273 |
// Init action.
|
|
|
274 |
add_action('plugins_loaded', 'ct_init', 1);
|
275 |
|
276 |
// Hourly run hook
|
inc/cleantalk-admin.js
CHANGED
@@ -27,7 +27,8 @@ jQuery(document).ready(function(){
|
|
27 |
jQuery('.form-table').first().before(banner_html);
|
28 |
if(!cleantalk_wpmu)
|
29 |
{
|
30 |
-
jQuery('.form-table').first().before("<br /><a href='#' style='font-size:10pt;' id='cleantalk_access_key_link'>Show the access key</a>");
|
|
|
31 |
}
|
32 |
}
|
33 |
|
@@ -63,4 +64,4 @@ jQuery(document).ready(function(){
|
|
63 |
}
|
64 |
|
65 |
});
|
66 |
-
});
|
27 |
jQuery('.form-table').first().before(banner_html);
|
28 |
if(!cleantalk_wpmu)
|
29 |
{
|
30 |
+
// jQuery('.form-table').first().before("<br /><a href='#' style='font-size:10pt;' id='cleantalk_access_key_link'>Show the access key</a>");
|
31 |
+
jQuery('.form-table').first().before(cleantalk_support_links);
|
32 |
}
|
33 |
}
|
34 |
|
64 |
}
|
65 |
|
66 |
});
|
67 |
+
});
|
inc/cleantalk-admin.php
CHANGED
@@ -4,8 +4,6 @@ $ct_plugin_basename = 'cleantalk-spam-protect/cleantalk.php';
|
|
4 |
$ct_options=ct_get_options();
|
5 |
$ct_data=ct_get_data();
|
6 |
|
7 |
-
//error_log(print_r($ct_options, true));
|
8 |
-
|
9 |
add_filter( 'activity_box_end', 'cleantalk_custom_glance_items', 10, 1 );
|
10 |
function cleantalk_custom_glance_items( )
|
11 |
{
|
@@ -288,9 +286,8 @@ function ct_admin_init()
|
|
288 |
add_settings_section('cleantalk_settings_main', __($ct_plugin_name, 'cleantalk'), 'ct_section_settings_main', 'cleantalk');
|
289 |
|
290 |
add_settings_section('cleantalk_settings_state', "<hr>".__('Protection is active', 'cleantalk'), 'ct_section_settings_state', 'cleantalk');
|
291 |
-
|
292 |
-
add_settings_section('
|
293 |
-
add_settings_section('cleantalk_settings_anti_spam', "<a href='#' style='text-decoration:underline;font-size:10pt;font-weight:400;'>".__('Advanced settings', 'cleantalk')."</a>", 'ct_section_settings_anti_spam', 'cleantalk');
|
294 |
|
295 |
if(!defined('CLEANTALK_ACCESS_KEY'))
|
296 |
{
|
@@ -436,7 +433,22 @@ function ct_add_admin_menu( $wp_admin_bar ) {
|
|
436 |
);
|
437 |
$wp_admin_bar->add_node( $args );
|
438 |
|
439 |
-
// add a child item to our parent item.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
440 |
$args = array(
|
441 |
'id' => 'ct_reset_counter',
|
442 |
'title' => '<hr style="margin-top: 7px;"><a href="?ct_reset_user_counter=1" title="Reset your personal counter of submissions.">'.__('Reset counter', 'cleantalk').'</a>',
|
@@ -559,6 +571,8 @@ function ct_input_apikey() {
|
|
559 |
{
|
560 |
$blocked=$ct_data['admin_blocked'];
|
561 |
}
|
|
|
|
|
562 |
|
563 |
if($blocked>0)
|
564 |
{
|
@@ -584,7 +598,7 @@ function ct_input_apikey() {
|
|
584 |
$is_wpmu=false;
|
585 |
if(!defined('CLEANTALK_ACCESS_KEY'))
|
586 |
{
|
587 |
-
echo "<input id='cleantalk_apikey' name='cleantalk_settings[apikey]' size='20' type='text' value='$value' style=\"font-size: 14pt;\"/>";
|
588 |
echo "<script>var cleantalk_wpmu=false;</script>";
|
589 |
}
|
590 |
else
|
@@ -592,6 +606,7 @@ function ct_input_apikey() {
|
|
592 |
echo "<script>var cleantalk_wpmu=true;</script>";
|
593 |
$is_wpmu=true;
|
594 |
}
|
|
|
595 |
echo "<script src='".plugins_url( 'cleantalk-admin.js', __FILE__ )."'></script>\n";
|
596 |
if (ct_valid_key($value) === false && !$is_wpmu) {
|
597 |
echo "<script>var cleantalk_good_key=false;</script>";
|
@@ -606,11 +621,15 @@ function ct_input_apikey() {
|
|
606 |
admin_addDescriptionsFields(sprintf('<a target="__blank" style="color:#BBB;" href="https://cleantalk.org/publicoffer">%s</a>', __('License agreement', 'cleantalk')));
|
607 |
}
|
608 |
} else {
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
|
|
|
|
|
|
|
|
614 |
}
|
615 |
}
|
616 |
|
@@ -627,7 +646,7 @@ function ct_input_comments_test() {
|
|
627 |
echo "<input type='radio' id='cleantalk_comments_test1' name='cleantalk_settings[comments_test]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_comments_test1'> " . __('Yes') . "</label>";
|
628 |
echo ' ';
|
629 |
echo "<input type='radio' id='cleantalk_comments_test0' name='cleantalk_settings[comments_test]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_comments_test0'> " . __('No') . "</label>";
|
630 |
-
admin_addDescriptionsFields(__('WordPress, JetPack, WooCommerce', 'cleantalk'));
|
631 |
}
|
632 |
|
633 |
/**
|
@@ -643,7 +662,7 @@ function ct_input_registrations_test() {
|
|
643 |
echo "<input type='radio' id='cleantalk_registrations_test1' name='cleantalk_settings[registrations_test]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_registrations_test1'> " . __('Yes') . "</label>";
|
644 |
echo ' ';
|
645 |
echo "<input type='radio' id='cleantalk_registrations_test0' name='cleantalk_settings[registrations_test]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_registrations_test0'> " . __('No') . "</label>";
|
646 |
-
admin_addDescriptionsFields(__('WordPress, BuddyPress, bbPress, S2Member, WooCommerce', 'cleantalk'));
|
647 |
}
|
648 |
|
649 |
/**
|
@@ -659,7 +678,7 @@ function ct_input_contact_forms_test() {
|
|
659 |
echo "<input type='radio' id='cleantalk_contact_forms_test1' name='cleantalk_settings[contact_forms_test]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_contact_forms_test1'> " . __('Yes') . "</label>";
|
660 |
echo ' ';
|
661 |
echo "<input type='radio' id='cleantalk_contact_forms_test0' name='cleantalk_settings[contact_forms_test]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_contact_forms_test0'> " . __('No') . "</label>";
|
662 |
-
admin_addDescriptionsFields(__('Contact Form 7, Formidable forms, JetPack, Fast Secure Contact Form, WordPress Landing Pages', 'cleantalk'));
|
663 |
}
|
664 |
|
665 |
/**
|
@@ -675,7 +694,7 @@ function ct_input_general_contact_forms_test() {
|
|
675 |
echo "<input type='radio' id='cleantalk_general_contact_forms_test1' name='cleantalk_settings[general_contact_forms_test]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_general_contact_forms_test1'> " . __('Yes') . "</label>";
|
676 |
echo ' ';
|
677 |
echo "<input type='radio' id='cleantalk_general_contact_forms_test0' name='cleantalk_settings[general_contact_forms_test]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_general_contact_forms_test0'> " . __('No') . "</label>";
|
678 |
-
admin_addDescriptionsFields(__('Anti spam test for any WordPress or themes contacts forms', 'cleantalk'));
|
679 |
}
|
680 |
|
681 |
/**
|
@@ -764,7 +783,7 @@ function ct_input_use_ajax() {
|
|
764 |
echo "<input type='radio' id='cleantalk_use_ajax1' name='cleantalk_settings[use_ajax]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_use_ajax1'> " . __('Yes') . "</label>";
|
765 |
echo ' ';
|
766 |
echo "<input type='radio' id='cleantalk_use_ajax0' name='cleantalk_settings[use_ajax]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_use_ajax0'> " . __('No') . "</label>";
|
767 |
-
@admin_addDescriptionsFields(sprintf(__('', 'cleantalk'), $ct_options['use_ajax']));
|
768 |
}
|
769 |
|
770 |
function ct_input_check_comments_number() {
|
@@ -794,7 +813,7 @@ function ct_input_check_comments_number() {
|
|
794 |
echo "<input type='radio' id='cleantalk_check_comments_number1' name='cleantalk_settings[check_comments_number]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_check_comments_number1'> " . __('Yes') . "</label>";
|
795 |
echo ' ';
|
796 |
echo "<input type='radio' id='cleantalk_check_comments_number0' name='cleantalk_settings[check_comments_number]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_check_comments_number0'> " . __('No') . "</label>";
|
797 |
-
@admin_addDescriptionsFields(sprintf(__("Dont't check comments for users with above $comments_check_number comments", 'cleantalk'), $ct_options['check_comments_number']));
|
798 |
}
|
799 |
|
800 |
function ct_input_collect_details() {
|
@@ -871,7 +890,7 @@ function ct_input_check_external() {
|
|
871 |
echo "<input type='radio' id='cleantalk_check_external1' name='cleantalk_settings[check_external]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_check_external1'> " . __('Yes') . "</label>";
|
872 |
echo ' ';
|
873 |
echo "<input type='radio' id='cleantalk_check_external0' name='cleantalk_settings[check_external]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_check_external0'> " . __('No') . "</label>";
|
874 |
-
@admin_addDescriptionsFields(sprintf(__('', 'cleantalk'), $ct_options['check_external']));
|
875 |
}
|
876 |
|
877 |
function ct_input_set_cookies() {
|
4 |
$ct_options=ct_get_options();
|
5 |
$ct_data=ct_get_data();
|
6 |
|
|
|
|
|
7 |
add_filter( 'activity_box_end', 'cleantalk_custom_glance_items', 10, 1 );
|
8 |
function cleantalk_custom_glance_items( )
|
9 |
{
|
286 |
add_settings_section('cleantalk_settings_main', __($ct_plugin_name, 'cleantalk'), 'ct_section_settings_main', 'cleantalk');
|
287 |
|
288 |
add_settings_section('cleantalk_settings_state', "<hr>".__('Protection is active', 'cleantalk'), 'ct_section_settings_state', 'cleantalk');
|
289 |
+
add_settings_section('cleantalk_settings_banner', "<hr>", '', 'cleantalk');
|
290 |
+
add_settings_section('cleantalk_settings_anti_spam', "<a href='#' class='ct_support_link'>".__('Advanced settings', 'cleantalk')."</a>", 'ct_section_settings_anti_spam', 'cleantalk');
|
|
|
291 |
|
292 |
if(!defined('CLEANTALK_ACCESS_KEY'))
|
293 |
{
|
433 |
);
|
434 |
$wp_admin_bar->add_node( $args );
|
435 |
|
436 |
+
// add a child item to our parent item. Bulk checks.
|
437 |
+
$args = array(
|
438 |
+
'id' => 'ct_settings_bulk_comments',
|
439 |
+
'title' => '<hr style="margin-top: 7px;" /><a href="edit-comments.php?page=ct_check_spam" title="Bulk spam comments removal tool.">'.__('Check comments for spam', 'cleantalk').'</a>',
|
440 |
+
'parent' => 'ct_parent_node'
|
441 |
+
);
|
442 |
+
$wp_admin_bar->add_node( $args );
|
443 |
+
// add a child item to our parent item. Bulk checks.
|
444 |
+
$args = array(
|
445 |
+
'id' => 'ct_settings_bulk_users',
|
446 |
+
'title' => '<a href="users.php?page=ct_check_users" title="Bulk spam users removal tool.">'.__('Check users for spam', 'cleantalk').'</a>',
|
447 |
+
'parent' => 'ct_parent_node'
|
448 |
+
);
|
449 |
+
$wp_admin_bar->add_node( $args );
|
450 |
+
|
451 |
+
// add a child item to our parent item. Counter reset.
|
452 |
$args = array(
|
453 |
'id' => 'ct_reset_counter',
|
454 |
'title' => '<hr style="margin-top: 7px;"><a href="?ct_reset_user_counter=1" title="Reset your personal counter of submissions.">'.__('Reset counter', 'cleantalk').'</a>',
|
571 |
{
|
572 |
$blocked=$ct_data['admin_blocked'];
|
573 |
}
|
574 |
+
|
575 |
+
echo "<style>a.ct_support_link{color: #666; margin-right: 0.5em; font-size: 10pt; font-weight: normal;}</style>";
|
576 |
|
577 |
if($blocked>0)
|
578 |
{
|
598 |
$is_wpmu=false;
|
599 |
if(!defined('CLEANTALK_ACCESS_KEY'))
|
600 |
{
|
601 |
+
echo "<input id='cleantalk_apikey' name='cleantalk_settings[apikey]' size='20' type='text' value='$value' style=\"font-size: 14pt;\" placeholder='" . __('Enter the key', 'cleantalk') . "' />";
|
602 |
echo "<script>var cleantalk_wpmu=false;</script>";
|
603 |
}
|
604 |
else
|
606 |
echo "<script>var cleantalk_wpmu=true;</script>";
|
607 |
$is_wpmu=true;
|
608 |
}
|
609 |
+
|
610 |
echo "<script src='".plugins_url( 'cleantalk-admin.js', __FILE__ )."'></script>\n";
|
611 |
if (ct_valid_key($value) === false && !$is_wpmu) {
|
612 |
echo "<script>var cleantalk_good_key=false;</script>";
|
621 |
admin_addDescriptionsFields(sprintf('<a target="__blank" style="color:#BBB;" href="https://cleantalk.org/publicoffer">%s</a>', __('License agreement', 'cleantalk')));
|
622 |
}
|
623 |
} else {
|
624 |
+
$cleantalk_support_links = "<br /><div>";
|
625 |
+
$cleantalk_support_links .= "<style>a.ct_support_link{color: #666; margin-right: 0.5em; font-size: 10pt; font-weight: normal;}</style>";
|
626 |
+
$cleantalk_support_links .= "<a href='#' id='cleantalk_access_key_link' class='ct_support_link'>" . __("Show the access key", 'cleantalk') . "</a>";
|
627 |
+
$cleantalk_support_links .= " ";
|
628 |
+
$cleantalk_support_links .= " ";
|
629 |
+
$cleantalk_support_links .= "<a href='edit-comments.php?page=ct_check_spam' class='ct_support_link'>" . __("Check comments for spam", 'cleantalk') . "</a>";
|
630 |
+
$cleantalk_support_links .= "<a href='users.php?page=ct_check_users' class='ct_support_link'>" . __("Check users for spam", 'cleantalk') . "</a>";
|
631 |
+
$cleantalk_support_links .= "</div>";
|
632 |
+
echo "<script type=\"text/javascript\">var cleantalk_good_key=true; var cleantalk_support_links = \"$cleantalk_support_links\";</script>";
|
633 |
}
|
634 |
}
|
635 |
|
646 |
echo "<input type='radio' id='cleantalk_comments_test1' name='cleantalk_settings[comments_test]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_comments_test1'> " . __('Yes') . "</label>";
|
647 |
echo ' ';
|
648 |
echo "<input type='radio' id='cleantalk_comments_test0' name='cleantalk_settings[comments_test]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_comments_test0'> " . __('No') . "</label>";
|
649 |
+
admin_addDescriptionsFields(__('WordPress, JetPack, WooCommerce.', 'cleantalk'));
|
650 |
}
|
651 |
|
652 |
/**
|
662 |
echo "<input type='radio' id='cleantalk_registrations_test1' name='cleantalk_settings[registrations_test]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_registrations_test1'> " . __('Yes') . "</label>";
|
663 |
echo ' ';
|
664 |
echo "<input type='radio' id='cleantalk_registrations_test0' name='cleantalk_settings[registrations_test]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_registrations_test0'> " . __('No') . "</label>";
|
665 |
+
admin_addDescriptionsFields(__('WordPress, BuddyPress, bbPress, S2Member, WooCommerce.', 'cleantalk'));
|
666 |
}
|
667 |
|
668 |
/**
|
678 |
echo "<input type='radio' id='cleantalk_contact_forms_test1' name='cleantalk_settings[contact_forms_test]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_contact_forms_test1'> " . __('Yes') . "</label>";
|
679 |
echo ' ';
|
680 |
echo "<input type='radio' id='cleantalk_contact_forms_test0' name='cleantalk_settings[contact_forms_test]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_contact_forms_test0'> " . __('No') . "</label>";
|
681 |
+
admin_addDescriptionsFields(__('Contact Form 7, Formidable forms, JetPack, Fast Secure Contact Form, WordPress Landing Pages, Gravity Forms.', 'cleantalk'));
|
682 |
}
|
683 |
|
684 |
/**
|
694 |
echo "<input type='radio' id='cleantalk_general_contact_forms_test1' name='cleantalk_settings[general_contact_forms_test]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_general_contact_forms_test1'> " . __('Yes') . "</label>";
|
695 |
echo ' ';
|
696 |
echo "<input type='radio' id='cleantalk_general_contact_forms_test0' name='cleantalk_settings[general_contact_forms_test]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_general_contact_forms_test0'> " . __('No') . "</label>";
|
697 |
+
admin_addDescriptionsFields(__('Anti spam test for any WordPress or themes contacts forms.', 'cleantalk'));
|
698 |
}
|
699 |
|
700 |
/**
|
783 |
echo "<input type='radio' id='cleantalk_use_ajax1' name='cleantalk_settings[use_ajax]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_use_ajax1'> " . __('Yes') . "</label>";
|
784 |
echo ' ';
|
785 |
echo "<input type='radio' id='cleantalk_use_ajax0' name='cleantalk_settings[use_ajax]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_use_ajax0'> " . __('No') . "</label>";
|
786 |
+
@admin_addDescriptionsFields(sprintf(__('Options helps protect WordPress against spam with any caching plugins. Turn this option on to avoid issues with caching plugins.', 'cleantalk'), $ct_options['use_ajax']));
|
787 |
}
|
788 |
|
789 |
function ct_input_check_comments_number() {
|
813 |
echo "<input type='radio' id='cleantalk_check_comments_number1' name='cleantalk_settings[check_comments_number]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_check_comments_number1'> " . __('Yes') . "</label>";
|
814 |
echo ' ';
|
815 |
echo "<input type='radio' id='cleantalk_check_comments_number0' name='cleantalk_settings[check_comments_number]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_check_comments_number0'> " . __('No') . "</label>";
|
816 |
+
@admin_addDescriptionsFields(sprintf(__("Dont't check comments for users with above $comments_check_number comments.", 'cleantalk'), $ct_options['check_comments_number']));
|
817 |
}
|
818 |
|
819 |
function ct_input_collect_details() {
|
890 |
echo "<input type='radio' id='cleantalk_check_external1' name='cleantalk_settings[check_external]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_check_external1'> " . __('Yes') . "</label>";
|
891 |
echo ' ';
|
892 |
echo "<input type='radio' id='cleantalk_check_external0' name='cleantalk_settings[check_external]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_check_external0'> " . __('No') . "</label>";
|
893 |
+
@admin_addDescriptionsFields(sprintf(__('Turn this option on to protect forms on your WordPress that send data to third-part servers (like MailChimp).', 'cleantalk'), $ct_options['check_external']));
|
894 |
}
|
895 |
|
896 |
function ct_input_set_cookies() {
|
inc/cleantalk-comments-checkspam.js
CHANGED
@@ -79,7 +79,14 @@ function ct_send_comments()
|
|
79 |
working=false;
|
80 |
alert(msg);
|
81 |
}
|
82 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
});
|
84 |
}
|
85 |
function ct_show_info()
|
@@ -175,22 +182,29 @@ jQuery("#ct_check_spam_button").click(function(){
|
|
175 |
jQuery('#ct_working_message').show();
|
176 |
jQuery('#ct_check_spam_button').hide();
|
177 |
jQuery('#ct_info_message').hide();
|
178 |
-
working=true;
|
179 |
-
ct_clear_comments();
|
180 |
-
});
|
181 |
-
jQuery("#ct_check_spam_button").click(function(){
|
182 |
-
jQuery('#ct_checking_status').html('');
|
183 |
jQuery('#ct_check_comments_table').hide();
|
184 |
jQuery('#ct_delete_all').hide();
|
185 |
jQuery('#ct_delete_checked').hide();
|
186 |
jQuery('#ct_preloader').show();
|
187 |
-
|
|
|
|
|
188 |
ct_show_info();
|
|
|
189 |
});
|
|
|
190 |
jQuery("#ct_insert_comments").click(function(){
|
191 |
ct_insert_comments();
|
192 |
});
|
193 |
jQuery("#ct_delete_all").click(function(){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
jQuery('#ct_check_comments_table').hide();
|
195 |
jQuery('#ct_deleting_message').show();
|
196 |
jQuery("html, body").animate({ scrollTop: 0 }, "slow");
|
79 |
working=false;
|
80 |
alert(msg);
|
81 |
}
|
82 |
+
},
|
83 |
+
error: function(jqXHR, textStatus, errorThrown) {
|
84 |
+
if(textStatus === 'timeout') {
|
85 |
+
alert('Failed from timeout. Going to check comments again.');
|
86 |
+
ct_send_comments();
|
87 |
+
}
|
88 |
+
},
|
89 |
+
timeout: 10000
|
90 |
});
|
91 |
}
|
92 |
function ct_show_info()
|
182 |
jQuery('#ct_working_message').show();
|
183 |
jQuery('#ct_check_spam_button').hide();
|
184 |
jQuery('#ct_info_message').hide();
|
|
|
|
|
|
|
|
|
|
|
185 |
jQuery('#ct_check_comments_table').hide();
|
186 |
jQuery('#ct_delete_all').hide();
|
187 |
jQuery('#ct_delete_checked').hide();
|
188 |
jQuery('#ct_preloader').show();
|
189 |
+
jQuery('#ct_search_info').hide();
|
190 |
+
|
191 |
+
working=true;
|
192 |
ct_show_info();
|
193 |
+
ct_clear_comments();
|
194 |
});
|
195 |
+
|
196 |
jQuery("#ct_insert_comments").click(function(){
|
197 |
ct_insert_comments();
|
198 |
});
|
199 |
jQuery("#ct_delete_all").click(function(){
|
200 |
+
if (!confirm('Delete all spam comments?')) {
|
201 |
+
return false;
|
202 |
+
}
|
203 |
+
|
204 |
+
jQuery('#ct_checking_status').hide();
|
205 |
+
jQuery('#ct_tools_buttons').hide();
|
206 |
+
jQuery('#ct_search_info').hide();
|
207 |
+
jQuery('#ct_bottom_tools').hide();
|
208 |
jQuery('#ct_check_comments_table').hide();
|
209 |
jQuery('#ct_deleting_message').show();
|
210 |
jQuery("html, body").animate({ scrollTop: 0 }, "slow");
|
inc/cleantalk-comments.php
CHANGED
@@ -1,477 +1,516 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
add_action('admin_menu', 'ct_add_comments_menu');
|
4 |
-
|
5 |
-
function ct_add_comments_menu()
|
6 |
-
{
|
7 |
-
if(current_user_can('activate_plugins'))
|
8 |
-
{
|
9 |
-
add_comments_page( __("Check for spam", 'cleantalk'), __("Check for spam", 'cleantalk'), 'read', 'ct_check_spam', 'ct_show_checkspam_page');
|
10 |
-
}
|
11 |
-
}
|
12 |
-
|
13 |
-
function ct_show_checkspam_page()
|
14 |
-
{
|
15 |
-
?>
|
16 |
-
<div class="wrap">
|
17 |
-
<h2><?php _e("Anti-spam by CleanTalk", 'cleantalk'); ?></h2><br />
|
18 |
-
|
19 |
-
<h3 id="ct_checking_status" style="text-align:center;width:90%;"></h3>
|
20 |
-
<div style="text-align:center;width:100%;display:none;" id="ct_preloader"><img border=0 src="<?php print plugin_dir_url(__FILE__); ?>images/preloader.gif" /></div>
|
21 |
-
<?php
|
22 |
-
$args_spam = array(
|
23 |
-
'meta_query' => array(
|
24 |
-
Array(
|
25 |
-
'key' => 'ct_marked_as_spam',
|
26 |
-
'compare' => 'EXISTS'
|
27 |
-
)
|
28 |
-
),
|
29 |
-
'count'=>true
|
30 |
-
);
|
31 |
-
$cnt_spam=get_comments($args_spam);
|
32 |
-
|
33 |
-
|
34 |
-
$page=1;
|
35 |
-
if(isset($_GET['spam_page']))
|
36 |
-
{
|
37 |
-
$page=intval($_GET['spam_page']);
|
38 |
-
}
|
39 |
-
$args_spam = array(
|
40 |
-
'meta_query' => array(
|
41 |
-
Array(
|
42 |
-
'key' => 'ct_marked_as_spam',
|
43 |
-
'value' => '1',
|
44 |
-
'compare' => 'NUMERIC'
|
45 |
-
)
|
46 |
-
),
|
47 |
-
'number'=>30,
|
48 |
-
'offset'=>($page-1)*30
|
49 |
-
);
|
50 |
-
|
51 |
-
$c_spam=get_comments($args_spam);
|
52 |
-
if($cnt_spam>0)
|
53 |
-
{
|
54 |
-
?>
|
55 |
-
<table class="widefat fixed comments" id="ct_check_comments_table">
|
56 |
-
<thead>
|
57 |
-
<th scope="col" id="cb" class="manage-column column-cb check-column">
|
58 |
-
<label class="screen-reader-text" for="cb-select-all-1">Select All</label>
|
59 |
-
<input id="cb-select-all-1" type="checkbox" style="margin-top:0;"/>
|
60 |
-
</th>
|
61 |
-
<th scope="col" id="author" class="manage-column column-slug"><?php print _e('Author');?></th>
|
62 |
-
<th scope="col" id="comment" class="manage-column column-comment"><?php print _x( 'Comment', 'column name' );;?></th>
|
63 |
-
<th scope="col" id="response" class="manage-column column-response sortable desc"><?php print _x( 'In Response To', 'column name' );?></th>
|
64 |
-
</thead>
|
65 |
-
<tbody id="the-comment-list" data-wp-lists="list:comment">
|
66 |
-
<?php
|
67 |
-
for($i=0;$i<sizeof($c_spam);$i++)
|
68 |
-
{
|
69 |
-
?>
|
70 |
-
<tr id="comment-<?php print $c_spam[$i]->comment_ID; ?>" class="comment even thread-even depth-1 approved cleantalk_comment" data-id="<?php print $c_spam[$i]->comment_ID; ?>">
|
71 |
-
<th scope="row" class="check-column">
|
72 |
-
<label class="screen-reader-text" for="cb-select-<?php print $c_spam[$i]->comment_ID; ?>">Select comment</label>
|
73 |
-
<input id="cb-select-<?php print $c_spam[$i]->comment_ID; ?>" type="checkbox" name="del_comments[]" value="<?php print $c_spam[$i]->comment_ID; ?>"/>
|
74 |
-
</th>
|
75 |
-
<td class="author column-author" nowrap>
|
76 |
-
<strong>
|
77 |
-
<?php echo get_avatar( $c_spam[$i]->comment_author_email , 32); ?>
|
78 |
-
<?php print $c_spam[$i]->comment_author; ?>
|
79 |
-
</strong>
|
80 |
-
<br/>
|
81 |
-
<a href="mailto:<?php print $c_spam[$i]->comment_author_email; ?>"><?php print $c_spam[$i]->comment_author_email; ?></a> <a href="https://cleantalk.org/blacklists/<?php print $c_spam[$i]->comment_author_email ; ?>" target="_blank"><img src="https://cleantalk.ru/images/icons/new_window.gif" border="0" style="float:none"/></a>
|
82 |
-
<br/>
|
83 |
-
<a href="edit-comments.php?s=<?php print $c_spam[$i]->comment_author_IP ; ?>&mode=detail"><?php print $c_spam[$i]->comment_author_IP ; ?></a>
|
84 |
-
<a href="https://cleantalk.org/blacklists/<?php print $c_spam[$i]->comment_author_IP ; ?>" target="_blank"><img src="https://cleantalk.ru/images/icons/new_window.gif" border="0" style="float:none"/></a>
|
85 |
-
</td>
|
86 |
-
<td class="comment column-comment">
|
87 |
-
<div class="submitted-on">
|
88 |
-
<?php printf( __( 'Submitted on <a href="%1$s">%2$s at %3$s</a>' ), get_comment_link($c_spam[$i]->comment_ID),
|
89 |
-
/* translators: comment date format. See http://php.net/date */
|
90 |
-
get_comment_date( __( 'Y/m/d' ),$c_spam[$i]->comment_ID ),
|
91 |
-
get_comment_date( get_option( 'time_format' ),$c_spam[$i]->comment_ID )
|
92 |
-
);
|
93 |
-
?>
|
94 |
-
|
95 |
-
</div>
|
96 |
-
<p>
|
97 |
-
<?php print $c_spam[$i]->comment_content; ?>
|
98 |
-
</p>
|
99 |
-
<div style="height:16px;">
|
100 |
-
<a href="#" class="cleantalk_delete_button" id="cleantalk_delete_<?php print $c_spam[$i]->comment_ID; ?>" data-id="<?php print $c_spam[$i]->comment_ID; ?>" style="color:#a00;display:none;" onclick="return false;">Delete</a>
|
101 |
-
</div>
|
102 |
-
</td>
|
103 |
-
<td class="response column-response">
|
104 |
-
<div>
|
105 |
-
<span>
|
106 |
-
<a href="http://ct_wp/wp-admin/post.php?post=<?php print $c_spam[$i]->comment_post_ID; ?>&action=edit"><?php print get_the_title($c_spam[$i]->comment_post_ID); ?></a>
|
107 |
-
<br/>
|
108 |
-
<a href="http://ct_wp/wp-admin/edit-comments.php?p=<?php print $c_spam[$i]->comment_post_ID; ?>" class="post-com-count">
|
109 |
-
<span class="comment-count"><?php
|
110 |
-
$p_cnt=wp_count_comments();
|
111 |
-
print $p_cnt->total_comments;
|
112 |
-
?></span>
|
113 |
-
</a>
|
114 |
-
</span>
|
115 |
-
<a href="<?php print get_permalink($c_spam[$i]->comment_post_ID); ?>"><?php print _e('View Post');?></a>
|
116 |
-
</div>
|
117 |
-
</td>
|
118 |
-
</tr>
|
119 |
-
<?php
|
120 |
-
}
|
121 |
-
$args_spam = array(
|
122 |
-
'meta_query' => array(
|
123 |
-
Array(
|
124 |
-
'key' => 'ct_marked_as_spam',
|
125 |
-
'value' => '1',
|
126 |
-
'compare' => 'NUMERIC'
|
127 |
-
)
|
128 |
-
|
129 |
-
),
|
130 |
-
'count'=>true
|
131 |
-
);
|
132 |
-
$cnt_spam=get_comments($args_spam);
|
133 |
-
if($cnt_spam>30)
|
134 |
-
{
|
135 |
-
?>
|
136 |
-
<tr class="comment even thread-even depth-1 approved">
|
137 |
-
<td colspan="4">
|
138 |
-
<?php
|
139 |
-
|
140 |
-
$pages=ceil(intval($cnt_spam)/30);
|
141 |
-
for($i=1;$i<=$pages;$i++)
|
142 |
-
{
|
143 |
-
if($i==$page)
|
144 |
-
{
|
145 |
-
print "<a href='edit-comments.php?page=ct_check_spam&spam_page=$i'><b>$i</b></a> ";
|
146 |
-
}
|
147 |
-
else
|
148 |
-
{
|
149 |
-
print "<a href='edit-comments.php?page=ct_check_spam&spam_page=$i'>$i</a> ";
|
150 |
-
}
|
151 |
-
}
|
152 |
-
?>
|
153 |
-
</td>
|
154 |
-
</tr>
|
155 |
-
<?php
|
156 |
-
}
|
157 |
-
?>
|
158 |
-
</tbody>
|
159 |
-
</table>
|
160 |
-
<button class="button" id="ct_delete_all"><?php _e('Delete all comments from the list'); ?></button>
|
161 |
-
<button class="button" id="ct_delete_checked"><?php _e('Delete selected', 'cleantalk'); ?></button><br /><br />
|
162 |
-
<?php
|
163 |
-
}
|
164 |
-
?>
|
165 |
-
<?php
|
166 |
-
$args_unchecked = array(
|
167 |
-
'meta_query' => array(
|
168 |
-
'relation' => 'AND',
|
169 |
-
Array(
|
170 |
-
'key' => 'ct_checked',
|
171 |
-
'value' => '1',
|
172 |
-
'compare' => 'NOT EXISTS'
|
173 |
-
),
|
174 |
-
Array(
|
175 |
-
'key' => 'ct_hash',
|
176 |
-
'value' => '1',
|
177 |
-
'compare' => 'NOT EXISTS'
|
178 |
-
)
|
179 |
-
),
|
180 |
-
'count'=>true
|
181 |
-
);
|
182 |
-
$cnt_unchecked=get_comments($args_unchecked);
|
183 |
-
|
184 |
-
$args_spam = array(
|
185 |
-
'meta_query' => array(
|
186 |
-
Array(
|
187 |
-
'key' => 'ct_marked_as_spam',
|
188 |
-
'compare' => 'EXISTS'
|
189 |
-
)
|
190 |
-
),
|
191 |
-
'count'=>true
|
192 |
-
);
|
193 |
-
$cnt_spam=get_comments($args_spam);
|
194 |
-
//if($cnt_unchecked>0)
|
195 |
-
{
|
196 |
-
?>
|
197 |
-
<div id="ct_info_message"><?php _e("Anti-spam by CleanTalk checks all not spam comments against blacklists database and show you senders that have spam activity on other websites.", 'cleantalk'); ?>
|
198 |
-
<?php
|
199 |
-
if($cnt_spam>0)
|
200 |
-
{
|
201 |
-
print "<br />
|
202 |
-
There is some differencies between blacklists database and our API mechanisms. Blacklists shows all history of spam activity, but our API (that used in spam checking) used another parameters, too: last day of activity, number of spam attacks during last days etc. This mechanisms help us to reduce number of false positivitie. So, there is nothing strange, if some emails/IPs will be not found by this checking.";
|
203 |
-
}
|
204 |
-
?></div>
|
205 |
-
<?php
|
206 |
-
}
|
207 |
-
?>
|
208 |
-
<?php
|
209 |
-
if($_SERVER['REMOTE_ADDR']=='127.0.0.1')print '<button class="button" id="ct_insert_comments">Insert comments</button><br />';
|
210 |
-
?>
|
211 |
-
|
212 |
-
<div id="ct_working_message" style="margin:auto;padding:3px;width:70%;border:2px dotted gray;display:none;background:#ffff99;">
|
213 |
-
<?php _e("Please wait for a while. CleanTalk is checking all approved and pending comments via blacklist database at cleantalk.org. You will have option to delete found spam comments after plugin finish.", 'cleantalk'); ?>
|
214 |
-
</div>
|
215 |
-
<div id="ct_deleting_message" style="display:none;">
|
216 |
-
<?php _e("Please wait for a while. CleanTalk is deleting spam comments. Comments left: ", 'cleantalk'); ?> <span id="cleantalk_comments_left"></span>
|
217 |
-
</div>
|
218 |
-
<div id="ct_done_message" <?php if($cnt_unchecked>0) print 'style="display:none"'; ?>>
|
219 |
-
<?php //_e("Done. All comments tested via blacklists database, please see result bellow.", 'cleantalk');
|
220 |
-
?>
|
221 |
-
</div><br />
|
222 |
-
<button class="button" id="ct_check_spam_button"><?php _e("Check for spam again", 'cleantalk'); ?></button><br /><br />
|
223 |
-
</div>
|
224 |
-
<br /><a href="options-general.php?page=cleantalk">«<?php print __('Back to CleanTalk settings', 'cleantalk'); ?></a>
|
225 |
-
<?php
|
226 |
-
}
|
227 |
-
|
228 |
-
add_action('admin_print_footer_scripts','ct_add_checkspam_button');
|
229 |
-
function ct_add_checkspam_button()
|
230 |
-
{
|
231 |
-
$screen = get_current_screen();
|
232 |
-
$ajax_nonce = wp_create_nonce( "ct_secret_nonce" );
|
233 |
-
?>
|
234 |
-
<script>
|
235 |
-
var ajax_nonce='<?php echo $ajax_nonce; ?>';
|
236 |
-
var spambutton_text='<?php _e("Find spam comments", 'cleantalk'); ?>';
|
237 |
-
</script>
|
238 |
-
<?php
|
239 |
-
if( $screen->id == 'edit-comments' ){
|
240 |
-
?>
|
241 |
-
<script src="<?php print plugins_url( 'cleantalk-comments-editscreen.js', __FILE__ ); ?>"></script>
|
242 |
-
<?php
|
243 |
-
}
|
244 |
-
if($screen->id == 'comments_page_ct_check_spam')
|
245 |
-
{
|
246 |
-
?>
|
247 |
-
<script src="<?php print plugins_url( 'cleantalk-comments-checkspam.js', __FILE__ ); ?>"></script>
|
248 |
-
<?php
|
249 |
-
}
|
250 |
-
}
|
251 |
-
|
252 |
-
|
253 |
-
add_action( 'wp_ajax_ajax_check_comments', 'ct_ajax_check_comments' );
|
254 |
-
|
255 |
-
function ct_ajax_check_comments()
|
256 |
-
{
|
257 |
-
check_ajax_referer( 'ct_secret_nonce', 'security' );
|
258 |
-
global $ct_options;
|
259 |
-
$ct_options = ct_get_options();
|
260 |
-
|
261 |
-
$args_unchecked = array(
|
262 |
-
'meta_query' => array(
|
263 |
-
//'relation' => 'AND',
|
264 |
-
Array(
|
265 |
-
'key' => 'ct_checked',
|
266 |
-
'value' => '1',
|
267 |
-
'compare' => 'NOT EXISTS'
|
268 |
-
),
|
269 |
-
/*Array(
|
270 |
-
'key' => 'ct_hash',
|
271 |
-
'value' => '1',
|
272 |
-
'compare' => 'NOT EXISTS'
|
273 |
-
)*/
|
274 |
-
),
|
275 |
-
'number'=>500,
|
276 |
-
'status' => 'all'
|
277 |
-
);
|
278 |
-
|
279 |
-
$u=get_comments($args_unchecked);
|
280 |
-
$u=array_slice($u,0,500);
|
281 |
-
$u=array_values($u);
|
282 |
-
if(sizeof($u)>0)
|
283 |
-
{
|
284 |
-
//print_r($u);
|
285 |
-
//die();
|
286 |
-
$data=Array();
|
287 |
-
for($i=0;$i<sizeof($u);$i++)
|
288 |
-
{
|
289 |
-
$data[]=$u[$i]->comment_author_IP;
|
290 |
-
$data[]=$u[$i]->comment_author_email;
|
291 |
-
}
|
292 |
-
$data=implode(',',$data);
|
293 |
-
|
294 |
-
$request="data=$data";
|
295 |
-
|
296 |
-
$opts = array(
|
297 |
-
'http'=>array(
|
298 |
-
'method'=>"POST",
|
299 |
-
'content'=>$request,
|
300 |
-
)
|
301 |
-
);
|
302 |
-
|
303 |
-
$context = stream_context_create($opts);
|
304 |
-
$result = @file_get_contents("https://api.cleantalk.org/?method_name=spam_check&auth_key=".$ct_options['apikey'], 0, $context);
|
305 |
-
$result=json_decode($result);
|
306 |
-
if(isset($result->error_message))
|
307 |
-
{
|
308 |
-
print $result->error_message;
|
309 |
-
}
|
310 |
-
else
|
311 |
-
{
|
312 |
-
for($i=0;$i<sizeof($u);$i++)
|
313 |
-
{
|
314 |
-
add_comment_meta($u[$i]->comment_ID,'ct_checked',date("Y-m-d H:m:s"),true);
|
315 |
-
$uip=$u[$i]->comment_author_IP;
|
316 |
-
if(empty($uip))continue;
|
317 |
-
$uim=$u[$i]->comment_author_email;
|
318 |
-
if(empty($uim))continue;
|
319 |
-
if(isset($result->data->$uip) && $result->data->$uip->appears==1 || isset($result->data->$uim) && $result->data->$uim->appears==1)
|
320 |
-
{
|
321 |
-
add_comment_meta($u[$i]->comment_ID,'ct_marked_as_spam','1',true);
|
322 |
-
}
|
323 |
-
}
|
324 |
-
print 1;
|
325 |
-
}
|
326 |
-
}
|
327 |
-
else
|
328 |
-
{
|
329 |
-
print 0;
|
330 |
-
}
|
331 |
-
|
332 |
-
die;
|
333 |
-
}
|
334 |
-
|
335 |
-
add_action( 'wp_ajax_ajax_info_comments', 'ct_ajax_info_comments' );
|
336 |
-
function ct_ajax_info_comments()
|
337 |
-
{
|
338 |
-
check_ajax_referer( 'ct_secret_nonce', 'security' );
|
339 |
-
$cnt=get_comments(Array('count'=>true));
|
340 |
-
|
341 |
-
$args_spam = array(
|
342 |
-
'meta_query' => array(
|
343 |
-
Array(
|
344 |
-
'key' => 'ct_marked_as_spam',
|
345 |
-
'value' => '1',
|
346 |
-
'compare' => 'NUMERIC'
|
347 |
-
)
|
348 |
-
),
|
349 |
-
'count'=>true
|
350 |
-
);
|
351 |
-
|
352 |
-
$cnt_spam=get_comments($args_spam);
|
353 |
-
|
354 |
-
$args_checked1=array(
|
355 |
-
'meta_query' => array(
|
356 |
-
Array(
|
357 |
-
'key' => 'ct_hash',
|
358 |
-
//'value'=>'1',
|
359 |
-
'compare' => 'EXISTS'
|
360 |
-
)
|
361 |
-
),
|
362 |
-
'count'=>true
|
363 |
-
);
|
364 |
-
$args_checked2=array(
|
365 |
-
'meta_query' => array(
|
366 |
-
Array(
|
367 |
-
'key' => 'ct_checked',
|
368 |
-
//'value'=>'1',
|
369 |
-
'compare' => 'EXISTS'
|
370 |
-
)
|
371 |
-
),
|
372 |
-
'count'=>true
|
373 |
-
);
|
374 |
-
|
375 |
-
$cnt_checked1=get_comments($args_checked1);
|
376 |
-
$cnt_checked2=get_comments($args_checked2);
|
377 |
-
$cnt_checked=$cnt_checked1+$cnt_checked2;
|
378 |
-
|
379 |
-
printf (__("Total comments %s, checked %s, found %s spam comments.", 'cleantalk'), $cnt, $cnt_checked, $cnt_spam);
|
380 |
-
die();
|
381 |
-
}
|
382 |
-
|
383 |
-
add_action( 'wp_ajax_ajax_insert_comments', 'ct_ajax_insert_comments' );
|
384 |
-
function ct_ajax_insert_comments()
|
385 |
-
{
|
386 |
-
check_ajax_referer( 'ct_secret_nonce', 'security' );
|
387 |
-
$time = current_time('mysql');
|
388 |
-
|
389 |
-
for($i=0;$i<500;$i++)
|
390 |
-
{
|
391 |
-
$rnd=mt_rand(1,100);
|
392 |
-
if($rnd<20)
|
393 |
-
{
|
394 |
-
$email="stop_email@example.com";
|
395 |
-
}
|
396 |
-
else
|
397 |
-
{
|
398 |
-
$email="stop_email_$rnd@example.com";
|
399 |
-
}
|
400 |
-
$data = array(
|
401 |
-
'comment_post_ID' => 1,
|
402 |
-
'comment_author' => "author_$rnd",
|
403 |
-
'comment_author_email' => $email,
|
404 |
-
'comment_author_url' => 'http://',
|
405 |
-
'comment_content' => "comment content ".mt_rand(1,10000)." ".mt_rand(1,10000)." ".mt_rand(1,10000),
|
406 |
-
'comment_type' => '',
|
407 |
-
'comment_parent' => 0,
|
408 |
-
'user_id' => 1,
|
409 |
-
'comment_author_IP' => '127.0.0.1',
|
410 |
-
'comment_agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)',
|
411 |
-
'comment_date' => $time,
|
412 |
-
'comment_approved' => 1,
|
413 |
-
);
|
414 |
-
|
415 |
-
wp_insert_comment($data);
|
416 |
-
}
|
417 |
-
print "ok";
|
418 |
-
die();
|
419 |
-
}
|
420 |
-
|
421 |
-
add_action( 'wp_ajax_ajax_delete_checked', 'ct_ajax_delete_checked' );
|
422 |
-
function ct_ajax_delete_checked()
|
423 |
-
{
|
424 |
-
check_ajax_referer( 'ct_secret_nonce', 'security' );
|
425 |
-
foreach($_POST['ids'] as $key=>$value)
|
426 |
-
{
|
427 |
-
wp_delete_comment($value, false);
|
428 |
-
}
|
429 |
-
die();
|
430 |
-
}
|
431 |
-
|
432 |
-
add_action( 'wp_ajax_ajax_delete_all', 'ct_ajax_delete_all' );
|
433 |
-
function ct_ajax_delete_all()
|
434 |
-
{
|
435 |
-
check_ajax_referer( 'ct_secret_nonce', 'security' );
|
436 |
-
$args_spam = array(
|
437 |
-
'number'=>100,
|
438 |
-
'meta_query' => array(
|
439 |
-
Array(
|
440 |
-
'key' => 'ct_marked_as_spam',
|
441 |
-
'value' => '1',
|
442 |
-
'compare' => 'NUMERIC'
|
443 |
-
)
|
444 |
-
)
|
445 |
-
);
|
446 |
-
$c_spam=get_comments($args_spam);
|
447 |
-
$cnt=sizeof($c_spam);
|
448 |
-
|
449 |
-
$args_spam = array(
|
450 |
-
'count'=>true,
|
451 |
-
'meta_query' => array(
|
452 |
-
Array(
|
453 |
-
'key' => 'ct_marked_as_spam',
|
454 |
-
'value' => '1',
|
455 |
-
'compare' => 'NUMERIC'
|
456 |
-
)
|
457 |
-
)
|
458 |
-
);
|
459 |
-
$cnt_all=get_comments($args_spam);
|
460 |
-
for($i=0;$i<sizeof($c_spam);$i++)
|
461 |
-
{
|
462 |
-
wp_delete_comment($c_spam[$i]->comment_ID, false);
|
463 |
-
usleep(10000);
|
464 |
-
}
|
465 |
-
print $cnt_all;
|
466 |
-
die();
|
467 |
-
}
|
468 |
-
|
469 |
-
add_action( 'wp_ajax_ajax_clear_comments', 'ct_ajax_clear_comments' );
|
470 |
-
function ct_ajax_clear_comments()
|
471 |
-
{
|
472 |
-
check_ajax_referer( 'ct_secret_nonce', 'security' );
|
473 |
-
global $wpdb;
|
474 |
-
$wpdb->query("delete from $wpdb->commentmeta where meta_key='ct_hash' or meta_key='ct_checked' or meta_key='ct_marked_as_spam';");
|
475 |
-
die();
|
476 |
}
|
477 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
add_action('admin_menu', 'ct_add_comments_menu');
|
4 |
+
|
5 |
+
function ct_add_comments_menu()
|
6 |
+
{
|
7 |
+
if(current_user_can('activate_plugins'))
|
8 |
+
{
|
9 |
+
add_comments_page( __("Check for spam", 'cleantalk'), __("Check for spam", 'cleantalk'), 'read', 'ct_check_spam', 'ct_show_checkspam_page');
|
10 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
}
|
12 |
+
|
13 |
+
function ct_show_checkspam_page()
|
14 |
+
{
|
15 |
+
global $ct_plugin_name;
|
16 |
+
?>
|
17 |
+
<div class="wrap">
|
18 |
+
<h2><?php echo $ct_plugin_name; ?></h2><br />
|
19 |
+
|
20 |
+
<h3 id="ct_checking_status" style="text-align:center;width:90%;"><?php ct_ajax_info_comments(true);?></h3>
|
21 |
+
<div style="text-align:center;width:100%;display:none;" id="ct_preloader"><img border=0 src="<?php print plugin_dir_url(__FILE__); ?>images/preloader.gif" />
|
22 |
+
<br />
|
23 |
+
<br />
|
24 |
+
</div>
|
25 |
+
<?php
|
26 |
+
$args_spam = array(
|
27 |
+
'meta_query' => array(
|
28 |
+
Array(
|
29 |
+
'key' => 'ct_marked_as_spam',
|
30 |
+
'compare' => 'EXISTS'
|
31 |
+
)
|
32 |
+
),
|
33 |
+
'count'=>true
|
34 |
+
);
|
35 |
+
$cnt_spam=get_comments($args_spam);
|
36 |
+
|
37 |
+
|
38 |
+
$page=1;
|
39 |
+
if(isset($_GET['spam_page']))
|
40 |
+
{
|
41 |
+
$page=intval($_GET['spam_page']);
|
42 |
+
}
|
43 |
+
$args_spam = array(
|
44 |
+
'meta_query' => array(
|
45 |
+
Array(
|
46 |
+
'key' => 'ct_marked_as_spam',
|
47 |
+
'value' => '1',
|
48 |
+
'compare' => 'NUMERIC'
|
49 |
+
)
|
50 |
+
),
|
51 |
+
'number'=>30,
|
52 |
+
'offset'=>($page-1)*30
|
53 |
+
);
|
54 |
+
|
55 |
+
$c_spam=get_comments($args_spam);
|
56 |
+
if($cnt_spam>0)
|
57 |
+
{
|
58 |
+
?>
|
59 |
+
<table class="widefat fixed comments" id="ct_check_comments_table">
|
60 |
+
<thead>
|
61 |
+
<th scope="col" id="cb" class="manage-column column-cb check-column">
|
62 |
+
<label class="screen-reader-text" for="cb-select-all-1">Select All</label>
|
63 |
+
<input id="cb-select-all-1" type="checkbox" style="margin-top:0;"/>
|
64 |
+
</th>
|
65 |
+
<th scope="col" id="author" class="manage-column column-slug"><?php print _e('Author');?></th>
|
66 |
+
<th scope="col" id="comment" class="manage-column column-comment"><?php print _x( 'Comment', 'column name' );;?></th>
|
67 |
+
<th scope="col" id="response" class="manage-column column-response sortable desc"><?php print _x( 'In Response To', 'column name' );?></th>
|
68 |
+
</thead>
|
69 |
+
<tbody id="the-comment-list" data-wp-lists="list:comment">
|
70 |
+
<?php
|
71 |
+
for($i=0;$i<sizeof($c_spam);$i++)
|
72 |
+
{
|
73 |
+
?>
|
74 |
+
<tr id="comment-<?php print $c_spam[$i]->comment_ID; ?>" class="comment even thread-even depth-1 approved cleantalk_comment" data-id="<?php print $c_spam[$i]->comment_ID; ?>">
|
75 |
+
<th scope="row" class="check-column">
|
76 |
+
<label class="screen-reader-text" for="cb-select-<?php print $c_spam[$i]->comment_ID; ?>">Select comment</label>
|
77 |
+
<input id="cb-select-<?php print $c_spam[$i]->comment_ID; ?>" type="checkbox" name="del_comments[]" value="<?php print $c_spam[$i]->comment_ID; ?>"/>
|
78 |
+
</th>
|
79 |
+
<td class="author column-author" nowrap>
|
80 |
+
<table>
|
81 |
+
<tr>
|
82 |
+
<td>
|
83 |
+
<?php echo get_avatar( $c_spam[$i]->comment_author_email , 32); ?>
|
84 |
+
</td>
|
85 |
+
<td>
|
86 |
+
<?php print $c_spam[$i]->comment_author; ?><br />
|
87 |
+
<a href="mailto:<?php print $c_spam[$i]->comment_author_email; ?>"><?php print $c_spam[$i]->comment_author_email; ?></a> <a href="https://cleantalk.org/blacklists/<?php print $c_spam[$i]->comment_author_email ; ?>" target="_blank"><img src="<?php print plugin_dir_url(__FILE__); ?>images/new_window.gif" border="0" style="float:none"/></a>
|
88 |
+
<br/>
|
89 |
+
<a href="edit-comments.php?s=<?php print $c_spam[$i]->comment_author_IP ; ?>&mode=detail"><?php print $c_spam[$i]->comment_author_IP ; ?></a>
|
90 |
+
<a href="https://cleantalk.org/blacklists/<?php print $c_spam[$i]->comment_author_IP ; ?>" target="_blank"><img src="<?php print plugin_dir_url(__FILE__); ?>images/new_window.gif" border="0" style="float:none"/></a>
|
91 |
+
</td>
|
92 |
+
</tr>
|
93 |
+
</table>
|
94 |
+
</td>
|
95 |
+
<td class="comment column-comment">
|
96 |
+
<div class="submitted-on">
|
97 |
+
<?php printf( __( 'Submitted on <a href="%1$s">%2$s at %3$s</a>' ), get_comment_link($c_spam[$i]->comment_ID),
|
98 |
+
/* translators: comment date format. See http://php.net/date */
|
99 |
+
get_comment_date( __( 'Y/m/d' ),$c_spam[$i]->comment_ID ),
|
100 |
+
get_comment_date( get_option( 'time_format' ),$c_spam[$i]->comment_ID )
|
101 |
+
);
|
102 |
+
?>
|
103 |
+
|
104 |
+
</div>
|
105 |
+
<p>
|
106 |
+
<?php print $c_spam[$i]->comment_content; ?>
|
107 |
+
</p>
|
108 |
+
<div style="height:16px;">
|
109 |
+
<a href="#" class="cleantalk_delete_button" id="cleantalk_delete_<?php print $c_spam[$i]->comment_ID; ?>" data-id="<?php print $c_spam[$i]->comment_ID; ?>" style="color:#a00;display:none;" onclick="return false;">Delete</a>
|
110 |
+
</div>
|
111 |
+
</td>
|
112 |
+
<td class="response column-response">
|
113 |
+
<div>
|
114 |
+
<span>
|
115 |
+
<a href="http://ct_wp/wp-admin/post.php?post=<?php print $c_spam[$i]->comment_post_ID; ?>&action=edit"><?php print get_the_title($c_spam[$i]->comment_post_ID); ?></a>
|
116 |
+
<br/>
|
117 |
+
<a href="http://ct_wp/wp-admin/edit-comments.php?p=<?php print $c_spam[$i]->comment_post_ID; ?>" class="post-com-count">
|
118 |
+
<span class="comment-count"><?php
|
119 |
+
$p_cnt=wp_count_comments();
|
120 |
+
print $p_cnt->total_comments;
|
121 |
+
?></span>
|
122 |
+
</a>
|
123 |
+
</span>
|
124 |
+
<a href="<?php print get_permalink($c_spam[$i]->comment_post_ID); ?>"><?php print _e('View Post');?></a>
|
125 |
+
</div>
|
126 |
+
</td>
|
127 |
+
</tr>
|
128 |
+
<?php
|
129 |
+
}
|
130 |
+
$args_spam = array(
|
131 |
+
'meta_query' => array(
|
132 |
+
Array(
|
133 |
+
'key' => 'ct_marked_as_spam',
|
134 |
+
'value' => '1',
|
135 |
+
'compare' => 'NUMERIC'
|
136 |
+
)
|
137 |
+
|
138 |
+
),
|
139 |
+
'count'=>true
|
140 |
+
);
|
141 |
+
$cnt_spam=get_comments($args_spam);
|
142 |
+
if($cnt_spam>30)
|
143 |
+
{
|
144 |
+
?>
|
145 |
+
<tr class="comment even thread-even depth-1 approved">
|
146 |
+
<td colspan="4">
|
147 |
+
<?php
|
148 |
+
|
149 |
+
$pages=ceil(intval($cnt_spam)/30);
|
150 |
+
for($i=1;$i<=$pages;$i++)
|
151 |
+
{
|
152 |
+
if($i==$page)
|
153 |
+
{
|
154 |
+
print "<a href='edit-comments.php?page=ct_check_spam&spam_page=$i'><b>$i</b></a> ";
|
155 |
+
}
|
156 |
+
else
|
157 |
+
{
|
158 |
+
print "<a href='edit-comments.php?page=ct_check_spam&spam_page=$i'>$i</a> ";
|
159 |
+
}
|
160 |
+
}
|
161 |
+
?>
|
162 |
+
</td>
|
163 |
+
</tr>
|
164 |
+
<?php
|
165 |
+
}
|
166 |
+
?>
|
167 |
+
</tbody>
|
168 |
+
</table>
|
169 |
+
<div id="ct_tools_buttons">
|
170 |
+
<button class="button" id="ct_delete_all"><?php _e('Delete all comments from the list'); ?></button>
|
171 |
+
<button class="button" id="ct_delete_checked"><?php _e('Delete selected', 'cleantalk'); ?></button><br /><br />
|
172 |
+
</div>
|
173 |
+
<?php
|
174 |
+
}
|
175 |
+
?>
|
176 |
+
<?php
|
177 |
+
$args_unchecked = array(
|
178 |
+
'meta_query' => array(
|
179 |
+
'relation' => 'AND',
|
180 |
+
Array(
|
181 |
+
'key' => 'ct_checked',
|
182 |
+
'value' => '1',
|
183 |
+
'compare' => 'NOT EXISTS'
|
184 |
+
),
|
185 |
+
Array(
|
186 |
+
'key' => 'ct_hash',
|
187 |
+
'value' => '1',
|
188 |
+
'compare' => 'NOT EXISTS'
|
189 |
+
)
|
190 |
+
),
|
191 |
+
'count'=>true
|
192 |
+
);
|
193 |
+
$cnt_unchecked=get_comments($args_unchecked);
|
194 |
+
|
195 |
+
$args_spam = array(
|
196 |
+
'meta_query' => array(
|
197 |
+
Array(
|
198 |
+
'key' => 'ct_marked_as_spam',
|
199 |
+
'compare' => 'EXISTS'
|
200 |
+
)
|
201 |
+
),
|
202 |
+
'count'=>true
|
203 |
+
);
|
204 |
+
$cnt_spam=get_comments($args_spam);
|
205 |
+
//if($cnt_unchecked>0)
|
206 |
+
{
|
207 |
+
?>
|
208 |
+
<?php
|
209 |
+
if($cnt_spam>0)
|
210 |
+
{
|
211 |
+
print "<br />
|
212 |
+
<div id=\"ct_search_info\">
|
213 |
+
<br />
|
214 |
+
There is some differencies between blacklists database and our API mechanisms. Blacklists shows all history of spam activity, but our API (that used in spam checking) used another parameters, too: last day of activity, number of spam attacks during last days etc. This mechanisms help us to reduce number of false positivitie. So, there is nothing strange, if some emails/IPs will be not found by this checking.
|
215 |
+
</div>";
|
216 |
+
}
|
217 |
+
?></div>
|
218 |
+
<?php
|
219 |
+
}
|
220 |
+
?>
|
221 |
+
<div id="ct_working_message" style="margin:auto;padding:3px;width:70%;border:2px dotted gray;display:none;background:#ffff99;">
|
222 |
+
<?php _e("Please wait! CleanTalk is checking all approved and pending comments via blacklist database at cleantalk.org. You will have option to delete found spam comments after plugin finish.", 'cleantalk'); ?>
|
223 |
+
</div>
|
224 |
+
<div id="ct_deleting_message" style="display:none;">
|
225 |
+
<?php _e("Please wait for a while. CleanTalk is deleting spam comments. Comments left: ", 'cleantalk'); ?> <span id="cleantalk_comments_left">
|
226 |
+
<?php echo $cnt_spam;?>
|
227 |
+
</span>
|
228 |
+
</div>
|
229 |
+
<div id="ct_done_message" <?php if($cnt_unchecked>0) print 'style="display:none"'; ?>>
|
230 |
+
<?php //_e("Done. All comments tested via blacklists database, please see result bellow.", 'cleantalk');
|
231 |
+
?>
|
232 |
+
</div><br />
|
233 |
+
<div id="ct_bottom_tools">
|
234 |
+
<table id="new_test_table">
|
235 |
+
<tr valign="top">
|
236 |
+
<td>
|
237 |
+
<button class="button" id="ct_check_spam_button"><?php _e("Check for spam", 'cleantalk'); ?></button><br /><br />
|
238 |
+
</td>
|
239 |
+
<td style="padding-left: 2em;">
|
240 |
+
<div id="ct_info_message"><?php _e("The plugin will check all comments against blacklists database and show you senders that have spam activity on other websites.", 'cleantalk'); ?>
|
241 |
+
</td>
|
242 |
+
</tr>
|
243 |
+
</table>
|
244 |
+
<?php
|
245 |
+
if($_SERVER['REMOTE_ADDR']=='127.0.0.1')print '<button class="button" id="ct_insert_comments">Insert comments</button><br />';
|
246 |
+
?>
|
247 |
+
|
248 |
+
</div>
|
249 |
+
</div>
|
250 |
+
<?php
|
251 |
+
}
|
252 |
+
|
253 |
+
add_action('admin_print_footer_scripts','ct_add_checkspam_button');
|
254 |
+
function ct_add_checkspam_button()
|
255 |
+
{
|
256 |
+
$screen = get_current_screen();
|
257 |
+
$ajax_nonce = wp_create_nonce( "ct_secret_nonce" );
|
258 |
+
?>
|
259 |
+
<script>
|
260 |
+
var ajax_nonce='<?php echo $ajax_nonce; ?>';
|
261 |
+
var spambutton_text='<?php _e("Find spam comments", 'cleantalk'); ?>';
|
262 |
+
</script>
|
263 |
+
<?php
|
264 |
+
if( $screen->id == 'edit-comments' ){
|
265 |
+
?>
|
266 |
+
<script src="<?php print plugins_url( 'cleantalk-comments-editscreen.js', __FILE__ ); ?>"></script>
|
267 |
+
<?php
|
268 |
+
}
|
269 |
+
if($screen->id == 'comments_page_ct_check_spam')
|
270 |
+
{
|
271 |
+
?>
|
272 |
+
<script src="<?php print plugins_url( 'cleantalk-comments-checkspam.js', __FILE__ ); ?>"></script>
|
273 |
+
<?php
|
274 |
+
}
|
275 |
+
}
|
276 |
+
|
277 |
+
|
278 |
+
add_action( 'wp_ajax_ajax_check_comments', 'ct_ajax_check_comments' );
|
279 |
+
|
280 |
+
function ct_ajax_check_comments()
|
281 |
+
{
|
282 |
+
check_ajax_referer( 'ct_secret_nonce', 'security' );
|
283 |
+
global $ct_options;
|
284 |
+
$ct_options = ct_get_options();
|
285 |
+
|
286 |
+
$args_unchecked = array(
|
287 |
+
'meta_query' => array(
|
288 |
+
//'relation' => 'AND',
|
289 |
+
Array(
|
290 |
+
'key' => 'ct_checked',
|
291 |
+
'value' => '1',
|
292 |
+
'compare' => 'NOT EXISTS'
|
293 |
+
),
|
294 |
+
/*Array(
|
295 |
+
'key' => 'ct_hash',
|
296 |
+
'value' => '1',
|
297 |
+
'compare' => 'NOT EXISTS'
|
298 |
+
)*/
|
299 |
+
),
|
300 |
+
'number'=>100,
|
301 |
+
'status' => 'all'
|
302 |
+
);
|
303 |
+
|
304 |
+
$u=get_comments($args_unchecked);
|
305 |
+
|
306 |
+
$u=array_values($u);
|
307 |
+
|
308 |
+
if(sizeof($u)>0)
|
309 |
+
{
|
310 |
+
$data=Array();
|
311 |
+
for($i=0;$i<sizeof($u);$i++)
|
312 |
+
{
|
313 |
+
$data[]=$u[$i]->comment_author_IP;
|
314 |
+
$data[]=$u[$i]->comment_author_email;
|
315 |
+
}
|
316 |
+
$data=implode(',',$data);
|
317 |
+
|
318 |
+
$request=Array();
|
319 |
+
$request['method_name'] = 'spam_check';
|
320 |
+
$request['auth_key'] = $ct_options['apikey'];
|
321 |
+
$request['data'] = $data;
|
322 |
+
$url='https://api.cleantalk.org';
|
323 |
+
if(!function_exists('sendRawRequest'))
|
324 |
+
{
|
325 |
+
require_once('cleantalk.class.php');
|
326 |
+
}
|
327 |
+
$result=sendRawRequest($url, $request);
|
328 |
+
|
329 |
+
$result=json_decode($result);
|
330 |
+
|
331 |
+
if(isset($result->error_message))
|
332 |
+
{
|
333 |
+
print $result->error_message;
|
334 |
+
}
|
335 |
+
else
|
336 |
+
{
|
337 |
+
for($i=0;$i<sizeof($u);$i++)
|
338 |
+
{
|
339 |
+
add_comment_meta($u[$i]->comment_ID,'ct_checked',date("Y-m-d H:m:s"),true);
|
340 |
+
$uip=$u[$i]->comment_author_IP;
|
341 |
+
if(empty($uip))continue;
|
342 |
+
$uim=$u[$i]->comment_author_email;
|
343 |
+
if(empty($uim))continue;
|
344 |
+
if(isset($result->data->$uip) && $result->data->$uip->appears==1 || isset($result->data->$uim) && $result->data->$uim->appears==1)
|
345 |
+
{
|
346 |
+
add_comment_meta($u[$i]->comment_ID,'ct_marked_as_spam','1',true);
|
347 |
+
}
|
348 |
+
}
|
349 |
+
print 1;
|
350 |
+
}
|
351 |
+
}
|
352 |
+
else
|
353 |
+
{
|
354 |
+
print 0;
|
355 |
+
}
|
356 |
+
|
357 |
+
die;
|
358 |
+
}
|
359 |
+
|
360 |
+
add_action( 'wp_ajax_ajax_info_comments', 'ct_ajax_info_comments' );
|
361 |
+
function ct_ajax_info_comments($direct_call = true)
|
362 |
+
{
|
363 |
+
if (!$direct_call) {
|
364 |
+
check_ajax_referer( 'ct_secret_nonce', 'security' );
|
365 |
+
}
|
366 |
+
|
367 |
+
$cnt=get_comments(Array('count'=>true));
|
368 |
+
|
369 |
+
$args_spam = array(
|
370 |
+
'meta_query' => array(
|
371 |
+
Array(
|
372 |
+
'key' => 'ct_marked_as_spam',
|
373 |
+
'value' => '1',
|
374 |
+
'compare' => 'NUMERIC'
|
375 |
+
)
|
376 |
+
),
|
377 |
+
'count'=>true
|
378 |
+
);
|
379 |
+
|
380 |
+
$cnt_spam=get_comments($args_spam);
|
381 |
+
|
382 |
+
$args_checked1=array(
|
383 |
+
'meta_query' => array(
|
384 |
+
Array(
|
385 |
+
'key' => 'ct_hash',
|
386 |
+
//'value'=>'1',
|
387 |
+
'compare' => 'EXISTS'
|
388 |
+
)
|
389 |
+
),
|
390 |
+
'count'=>true
|
391 |
+
);
|
392 |
+
$args_checked2=array(
|
393 |
+
'meta_query' => array(
|
394 |
+
Array(
|
395 |
+
'key' => 'ct_checked',
|
396 |
+
//'value'=>'1',
|
397 |
+
'compare' => 'EXISTS'
|
398 |
+
)
|
399 |
+
),
|
400 |
+
'count'=>true
|
401 |
+
);
|
402 |
+
|
403 |
+
$cnt_checked1=get_comments($args_checked1);
|
404 |
+
$cnt_checked2=get_comments($args_checked2);
|
405 |
+
$cnt_checked=$cnt_checked1+$cnt_checked2;
|
406 |
+
|
407 |
+
// error_log($cnt_checked);
|
408 |
+
printf (__("Total comments %s, checked %s, found %s spam comments.", 'cleantalk'), $cnt, $cnt_checked, $cnt_spam);
|
409 |
+
$backup_notice = ' ';
|
410 |
+
if ($cnt_spam > 0) {
|
411 |
+
$backup_notice = __("Please do backup of WordPress database before delete any comments!", 'cleantalk');
|
412 |
+
}
|
413 |
+
print "<p>$backup_notice</p>";
|
414 |
+
if (!$direct_call) {
|
415 |
+
die();
|
416 |
+
}
|
417 |
+
return null;
|
418 |
+
}
|
419 |
+
|
420 |
+
add_action( 'wp_ajax_ajax_insert_comments', 'ct_ajax_insert_comments' );
|
421 |
+
function ct_ajax_insert_comments()
|
422 |
+
{
|
423 |
+
check_ajax_referer( 'ct_secret_nonce', 'security' );
|
424 |
+
$time = current_time('mysql');
|
425 |
+
|
426 |
+
for($i=0;$i<500;$i++)
|
427 |
+
{
|
428 |
+
$rnd=mt_rand(1,100);
|
429 |
+
if($rnd<20)
|
430 |
+
{
|
431 |
+
$email="stop_email@example.com";
|
432 |
+
}
|
433 |
+
else
|
434 |
+
{
|
435 |
+
$email="stop_email_$rnd@example.com";
|
436 |
+
}
|
437 |
+
$data = array(
|
438 |
+
'comment_post_ID' => 1,
|
439 |
+
'comment_author' => "author_$rnd",
|
440 |
+
'comment_author_email' => $email,
|
441 |
+
'comment_author_url' => 'http://',
|
442 |
+
'comment_content' => "comment content ".mt_rand(1,10000)." ".mt_rand(1,10000)." ".mt_rand(1,10000),
|
443 |
+
'comment_type' => '',
|
444 |
+
'comment_parent' => 0,
|
445 |
+
'user_id' => 1,
|
446 |
+
'comment_author_IP' => '127.0.0.1',
|
447 |
+
'comment_agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)',
|
448 |
+
'comment_date' => $time,
|
449 |
+
'comment_approved' => 1,
|
450 |
+
);
|
451 |
+
|
452 |
+
wp_insert_comment($data);
|
453 |
+
}
|
454 |
+
print "ok";
|
455 |
+
die();
|
456 |
+
}
|
457 |
+
|
458 |
+
add_action( 'wp_ajax_ajax_delete_checked', 'ct_ajax_delete_checked' );
|
459 |
+
function ct_ajax_delete_checked()
|
460 |
+
{
|
461 |
+
check_ajax_referer( 'ct_secret_nonce', 'security' );
|
462 |
+
foreach($_POST['ids'] as $key=>$value)
|
463 |
+
{
|
464 |
+
wp_delete_comment($value, false);
|
465 |
+
}
|
466 |
+
die();
|
467 |
+
}
|
468 |
+
|
469 |
+
add_action( 'wp_ajax_ajax_delete_all', 'ct_ajax_delete_all' );
|
470 |
+
function ct_ajax_delete_all()
|
471 |
+
{
|
472 |
+
check_ajax_referer( 'ct_secret_nonce', 'security' );
|
473 |
+
$args_spam = array(
|
474 |
+
'number'=>100,
|
475 |
+
'meta_query' => array(
|
476 |
+
Array(
|
477 |
+
'key' => 'ct_marked_as_spam',
|
478 |
+
'value' => '1',
|
479 |
+
'compare' => 'NUMERIC'
|
480 |
+
)
|
481 |
+
)
|
482 |
+
);
|
483 |
+
$c_spam=get_comments($args_spam);
|
484 |
+
// error_log($c_spam);
|
485 |
+
$cnt=sizeof($c_spam);
|
486 |
+
|
487 |
+
$args_spam = array(
|
488 |
+
'count'=>true,
|
489 |
+
'meta_query' => array(
|
490 |
+
Array(
|
491 |
+
'key' => 'ct_marked_as_spam',
|
492 |
+
'value' => '1',
|
493 |
+
'compare' => 'NUMERIC'
|
494 |
+
)
|
495 |
+
)
|
496 |
+
);
|
497 |
+
$cnt_all=get_comments($args_spam);
|
498 |
+
// error_log($cnt_all);
|
499 |
+
for($i=0;$i<sizeof($c_spam);$i++)
|
500 |
+
{
|
501 |
+
wp_delete_comment($c_spam[$i]->comment_ID, false);
|
502 |
+
usleep(10000);
|
503 |
+
}
|
504 |
+
print $cnt_all;
|
505 |
+
die();
|
506 |
+
}
|
507 |
+
|
508 |
+
add_action( 'wp_ajax_ajax_clear_comments', 'ct_ajax_clear_comments' );
|
509 |
+
function ct_ajax_clear_comments()
|
510 |
+
{
|
511 |
+
check_ajax_referer( 'ct_secret_nonce', 'security' );
|
512 |
+
global $wpdb;
|
513 |
+
$wpdb->query("delete from $wpdb->commentmeta where meta_key='ct_hash' or meta_key='ct_checked' or meta_key='ct_marked_as_spam';");
|
514 |
+
die();
|
515 |
+
}
|
516 |
+
?>
|
inc/cleantalk-common.php
CHANGED
@@ -103,6 +103,8 @@ $ct_data = NULL;
|
|
103 |
$ct_server = NULL;
|
104 |
$admin_email = NULL;
|
105 |
|
|
|
|
|
106 |
|
107 |
/**
|
108 |
* Public action 'plugins_loaded' - Loads locale, see http://codex.wordpress.org/Function_Reference/load_plugin_textdomain
|
@@ -241,7 +243,7 @@ function submit_time_test() {
|
|
241 |
* @return array
|
242 |
*/
|
243 |
function get_sender_info() {
|
244 |
-
global $ct_direct_post, $ct_options, $ct_data, $wp_rewrite;
|
245 |
|
246 |
$ct_options = ct_get_options();
|
247 |
$ct_data = ct_get_data();
|
@@ -272,6 +274,14 @@ function get_sender_info() {
|
|
272 |
$js_info=mb_convert_encoding($js_info, "UTF-8", "Windows-1252");
|
273 |
}
|
274 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
275 |
return $sender_info = array(
|
276 |
'page_url' => htmlspecialchars(@$_SERVER['SERVER_NAME'].@$_SERVER['REQUEST_URI']),
|
277 |
'cms_lang' => substr(get_locale(), 0, 2),
|
@@ -412,6 +422,9 @@ function ct_get_options($force=false) {
|
|
412 |
global $ct_options;
|
413 |
if(!$force && isset($ct_options) && isset($ct_options['apikey']) && strlen($ct_options['apikey'])>3)
|
414 |
{
|
|
|
|
|
|
|
415 |
if(defined('CLEANTALK_ACCESS_KEY'))
|
416 |
{
|
417 |
$options['apikey']=CLEANTALK_ACCESS_KEY;
|
@@ -433,7 +446,7 @@ function ct_get_options($force=false) {
|
|
433 |
}
|
434 |
$options = array_merge(ct_def_options(), (array) $options);
|
435 |
|
436 |
-
if ($options['apikey'] === 'enter key') {
|
437 |
if ($options['protect_logged_in'] == -1) {
|
438 |
$options['protect_logged_in'] = 1;
|
439 |
}
|
@@ -450,7 +463,7 @@ function ct_get_options($force=false) {
|
|
450 |
function ct_def_options() {
|
451 |
return array(
|
452 |
'server' => 'http://moderate.cleantalk.org',
|
453 |
-
'apikey' => __('
|
454 |
'autoPubRevelantMess' => '0',
|
455 |
'registrations_test' => '1',
|
456 |
'comments_test' => '1',
|
103 |
$ct_server = NULL;
|
104 |
$admin_email = NULL;
|
105 |
|
106 |
+
// Timer in PHP sessions state.
|
107 |
+
$ct_page_timer_setuped = false;
|
108 |
|
109 |
/**
|
110 |
* Public action 'plugins_loaded' - Loads locale, see http://codex.wordpress.org/Function_Reference/load_plugin_textdomain
|
243 |
* @return array
|
244 |
*/
|
245 |
function get_sender_info() {
|
246 |
+
global $ct_direct_post, $ct_options, $ct_data, $wp_rewrite, $ct_formtime_label;
|
247 |
|
248 |
$ct_options = ct_get_options();
|
249 |
$ct_data = ct_get_data();
|
274 |
$js_info=mb_convert_encoding($js_info, "UTF-8", "Windows-1252");
|
275 |
}
|
276 |
|
277 |
+
|
278 |
+
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
279 |
+
ct_init_session();
|
280 |
+
if (isset($_SESSION) && is_array($_SESSION) && !array_key_exists($ct_formtime_label, $_SESSION) && session_id() != '') {
|
281 |
+
$ct_direct_post = 1;
|
282 |
+
}
|
283 |
+
}
|
284 |
+
|
285 |
return $sender_info = array(
|
286 |
'page_url' => htmlspecialchars(@$_SERVER['SERVER_NAME'].@$_SERVER['REQUEST_URI']),
|
287 |
'cms_lang' => substr(get_locale(), 0, 2),
|
422 |
global $ct_options;
|
423 |
if(!$force && isset($ct_options) && isset($ct_options['apikey']) && strlen($ct_options['apikey'])>3)
|
424 |
{
|
425 |
+
//
|
426 |
+
// Skip query to get options because we already have options.
|
427 |
+
//
|
428 |
if(defined('CLEANTALK_ACCESS_KEY'))
|
429 |
{
|
430 |
$options['apikey']=CLEANTALK_ACCESS_KEY;
|
446 |
}
|
447 |
$options = array_merge(ct_def_options(), (array) $options);
|
448 |
|
449 |
+
if ($options['apikey'] === 'enter key' || $options['apikey'] === '') {
|
450 |
if ($options['protect_logged_in'] == -1) {
|
451 |
$options['protect_logged_in'] = 1;
|
452 |
}
|
463 |
function ct_def_options() {
|
464 |
return array(
|
465 |
'server' => 'http://moderate.cleantalk.org',
|
466 |
+
'apikey' => __('', 'cleantalk'),
|
467 |
'autoPubRevelantMess' => '0',
|
468 |
'registrations_test' => '1',
|
469 |
'comments_test' => '1',
|
inc/cleantalk-public.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
function ct_init() {
|
8 |
global $ct_wplp_result_label, $ct_jp_comments, $ct_post_data_label, $ct_post_data_authnet_label, $ct_formtime_label, $ct_direct_post, $ct_options, $ct_data, $ct_check_post_result, $test_external_forms, $cleantalk_executed;
|
9 |
|
10 |
-
$ct_options=ct_get_options();
|
11 |
$ct_data=ct_get_data();
|
12 |
|
13 |
//fix for EPM registration form
|
@@ -199,21 +199,37 @@ function ct_init() {
|
|
199 |
}
|
200 |
|
201 |
/**
|
202 |
-
*
|
203 |
-
*
|
204 |
*/
|
205 |
-
function
|
206 |
-
global $
|
207 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
|
209 |
-
|
210 |
-
|
211 |
-
|
|
|
|
|
|
|
|
|
212 |
}
|
213 |
-
} else {
|
214 |
-
$_SESSION[$ct_formtime_label] = time();
|
215 |
}
|
216 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
217 |
|
218 |
function ct_ajaxurl() {
|
219 |
?>
|
@@ -241,7 +257,9 @@ function ct_comment_form($post_id) {
|
|
241 |
}
|
242 |
|
243 |
ct_add_hidden_fields(true, 'ct_checkjs', false, false);
|
244 |
-
|
|
|
|
|
245 |
return null;
|
246 |
}
|
247 |
|
@@ -249,9 +267,8 @@ function ct_comment_form($post_id) {
|
|
249 |
* Adds cookie script filed to footer
|
250 |
*/
|
251 |
function ct_footer_add_cookie() {
|
252 |
-
|
253 |
-
|
254 |
-
}
|
255 |
|
256 |
ct_add_hidden_fields(true, 'ct_checkjs', false, true);
|
257 |
|
@@ -344,6 +361,8 @@ function ct_frm_entries_footer_scripts($fields, $form) {
|
|
344 |
$ct_checkjs_key = ct_get_checkjs_value();
|
345 |
$ct_frm_base_name = 'form_';
|
346 |
$ct_frm_name = $ct_frm_base_name . $form->form_key;
|
|
|
|
|
347 |
|
348 |
?>
|
349 |
var input = document.createElement("input");
|
@@ -865,6 +884,8 @@ function ct_register_form() {
|
|
865 |
}
|
866 |
|
867 |
ct_add_hidden_fields(true, $ct_checkjs_register_form, false);
|
|
|
|
|
868 |
|
869 |
return null;
|
870 |
}
|
@@ -1207,6 +1228,8 @@ function ct_grunion_contact_form_field_html($r, $field_label) {
|
|
1207 |
|
1208 |
$r .= ct_add_hidden_fields(true, $ct_checkjs_jpcf, true);
|
1209 |
$ct_jpcf_patched = true;
|
|
|
|
|
1210 |
}
|
1211 |
|
1212 |
return $r;
|
@@ -1352,6 +1375,8 @@ function ct_wpcf7_form_elements($html) {
|
|
1352 |
}
|
1353 |
|
1354 |
$html .= ct_add_hidden_fields(true, $ct_checkjs_cf7, true);
|
|
|
|
|
1355 |
|
1356 |
return $html;
|
1357 |
}
|
@@ -1468,6 +1493,9 @@ function ct_wpcf7_display_message($message, $status = 'spam') {
|
|
1468 |
*/
|
1469 |
function ct_si_contact_display_after_fields($string = '', $style = '', $form_errors = array(), $form_id_num = 0) {
|
1470 |
$string .= ct_add_hidden_fields(true, 'ct_checkjs', true);
|
|
|
|
|
|
|
1471 |
return $string;
|
1472 |
}
|
1473 |
|
@@ -1637,6 +1665,8 @@ function ct_gforms_hidden_field ( $form_string, $form ) {
|
|
1637 |
$search = "</form>";
|
1638 |
$js_code = ct_add_hidden_fields(true, $ct_hidden_field, true, false);
|
1639 |
$form_string = str_replace($search, $js_code . $search, $form_string);
|
|
|
|
|
1640 |
|
1641 |
return $form_string;
|
1642 |
}
|
7 |
function ct_init() {
|
8 |
global $ct_wplp_result_label, $ct_jp_comments, $ct_post_data_label, $ct_post_data_authnet_label, $ct_formtime_label, $ct_direct_post, $ct_options, $ct_data, $ct_check_post_result, $test_external_forms, $cleantalk_executed;
|
9 |
|
10 |
+
$ct_options = ct_get_options();
|
11 |
$ct_data=ct_get_data();
|
12 |
|
13 |
//fix for EPM registration form
|
199 |
}
|
200 |
|
201 |
/**
|
202 |
+
* Does actions to prepare anti-spam tests.
|
203 |
+
* @return bool;
|
204 |
*/
|
205 |
+
function ct_setup_page_timer($set_global = false) {
|
206 |
+
global $ct_formtime_label, $ct_page_timer_setuped;
|
207 |
+
|
208 |
+
//
|
209 |
+
// Timer is already setuped.
|
210 |
+
//
|
211 |
+
if ($ct_page_timer_setuped) {
|
212 |
+
return $ct_page_timer_setuped;
|
213 |
+
}
|
214 |
|
215 |
+
//
|
216 |
+
// Skip sessions to do not break Varnish caching.
|
217 |
+
//
|
218 |
+
if ($set_global) {
|
219 |
+
$ct_options = ct_get_options();
|
220 |
+
if ($ct_options['set_cookies'] != 1) {
|
221 |
+
return false;
|
222 |
}
|
|
|
|
|
223 |
}
|
224 |
+
|
225 |
+
ct_init_session();
|
226 |
+
|
227 |
+
$_SESSION[$ct_formtime_label] = time();
|
228 |
+
|
229 |
+
$ct_page_timer_setuped = true;
|
230 |
+
|
231 |
+
return true;
|
232 |
+
}
|
233 |
|
234 |
function ct_ajaxurl() {
|
235 |
?>
|
257 |
}
|
258 |
|
259 |
ct_add_hidden_fields(true, 'ct_checkjs', false, false);
|
260 |
+
|
261 |
+
ct_setup_page_timer();
|
262 |
+
|
263 |
return null;
|
264 |
}
|
265 |
|
267 |
* Adds cookie script filed to footer
|
268 |
*/
|
269 |
function ct_footer_add_cookie() {
|
270 |
+
|
271 |
+
ct_setup_page_timer(true);
|
|
|
272 |
|
273 |
ct_add_hidden_fields(true, 'ct_checkjs', false, true);
|
274 |
|
361 |
$ct_checkjs_key = ct_get_checkjs_value();
|
362 |
$ct_frm_base_name = 'form_';
|
363 |
$ct_frm_name = $ct_frm_base_name . $form->form_key;
|
364 |
+
|
365 |
+
ct_setup_page_timer();
|
366 |
|
367 |
?>
|
368 |
var input = document.createElement("input");
|
884 |
}
|
885 |
|
886 |
ct_add_hidden_fields(true, $ct_checkjs_register_form, false);
|
887 |
+
|
888 |
+
ct_setup_page_timer();
|
889 |
|
890 |
return null;
|
891 |
}
|
1228 |
|
1229 |
$r .= ct_add_hidden_fields(true, $ct_checkjs_jpcf, true);
|
1230 |
$ct_jpcf_patched = true;
|
1231 |
+
|
1232 |
+
ct_setup_page_timer();
|
1233 |
}
|
1234 |
|
1235 |
return $r;
|
1375 |
}
|
1376 |
|
1377 |
$html .= ct_add_hidden_fields(true, $ct_checkjs_cf7, true);
|
1378 |
+
|
1379 |
+
ct_setup_page_timer();
|
1380 |
|
1381 |
return $html;
|
1382 |
}
|
1493 |
*/
|
1494 |
function ct_si_contact_display_after_fields($string = '', $style = '', $form_errors = array(), $form_id_num = 0) {
|
1495 |
$string .= ct_add_hidden_fields(true, 'ct_checkjs', true);
|
1496 |
+
|
1497 |
+
ct_setup_page_timer();
|
1498 |
+
|
1499 |
return $string;
|
1500 |
}
|
1501 |
|
1665 |
$search = "</form>";
|
1666 |
$js_code = ct_add_hidden_fields(true, $ct_hidden_field, true, false);
|
1667 |
$form_string = str_replace($search, $js_code . $search, $form_string);
|
1668 |
+
|
1669 |
+
ct_setup_page_timer();
|
1670 |
|
1671 |
return $form_string;
|
1672 |
}
|
inc/cleantalk-users-checkspam.js
CHANGED
@@ -58,7 +58,6 @@ function ct_send_users()
|
|
58 |
'action': 'ajax_check_users',
|
59 |
'security': ajax_nonce
|
60 |
};
|
61 |
-
|
62 |
jQuery.ajax({
|
63 |
type: "POST",
|
64 |
url: ajaxurl,
|
@@ -80,7 +79,14 @@ function ct_send_users()
|
|
80 |
working=false;
|
81 |
alert(msg);
|
82 |
}
|
83 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
});
|
85 |
}
|
86 |
function ct_show_users_info()
|
@@ -98,7 +104,8 @@ function ct_show_users_info()
|
|
98 |
success: function(msg){
|
99 |
jQuery('#ct_checking_users_status').html(msg);
|
100 |
setTimeout(ct_show_users_info, 1000);
|
101 |
-
}
|
|
|
102 |
});
|
103 |
}
|
104 |
}
|
58 |
'action': 'ajax_check_users',
|
59 |
'security': ajax_nonce
|
60 |
};
|
|
|
61 |
jQuery.ajax({
|
62 |
type: "POST",
|
63 |
url: ajaxurl,
|
79 |
working=false;
|
80 |
alert(msg);
|
81 |
}
|
82 |
+
},
|
83 |
+
error: function(jqXHR, textStatus, errorThrown) {
|
84 |
+
if(textStatus === 'timeout') {
|
85 |
+
alert('Failed from timeout. Going to check users again.');
|
86 |
+
ct_send_users();
|
87 |
+
}
|
88 |
+
},
|
89 |
+
timeout: 10000
|
90 |
});
|
91 |
}
|
92 |
function ct_show_users_info()
|
104 |
success: function(msg){
|
105 |
jQuery('#ct_checking_users_status').html(msg);
|
106 |
setTimeout(ct_show_users_info, 1000);
|
107 |
+
},
|
108 |
+
timeout: 5000
|
109 |
});
|
110 |
}
|
111 |
}
|
inc/cleantalk-users.php
CHANGED
@@ -43,7 +43,7 @@ $cnt_spam1=$r[0]['cnt'];
|
|
43 |
<?php //_e("Done. All comments tested via blacklists database, please see result bellow.", 'cleantalk');
|
44 |
?>
|
45 |
</div>
|
46 |
-
<h3 id="ct_checking_users_status" style="text-align:center;width:90%;"
|
47 |
<div style="text-align:center;width:100%;display:none;" id="ct_preloader"><img border=0 src="<?php print plugin_dir_url(__FILE__); ?>images/preloader.gif" /></div>
|
48 |
<div id="ct_working_message" style="margin:auto;padding:3px;width:70%;border:2px dotted gray;display:none;background:#ffff99;margin-top: 1em;">
|
49 |
<?php _e("Please wait for a while. CleanTalk is checking all users via blacklist database at cleantalk.org. You will have option to delete found spam users after plugin finish.", 'cleantalk'); ?>
|
@@ -181,7 +181,7 @@ $cnt_spam1=$r[0]['cnt'];
|
|
181 |
<table>
|
182 |
<tr>
|
183 |
<td>
|
184 |
-
<button class="button" id="ct_check_users_button"><?php _e("Check for spam
|
185 |
</td>
|
186 |
<td style="padding-left: 2em;">
|
187 |
<div id="ct_info_message" class="wrap"><?php _e("The plugin will check all users against blacklists database and show you senders that have spam activity on other websites. Just click 'Find spam users' to start.", 'cleantalk'); ?>
|
@@ -282,23 +282,19 @@ function ct_ajax_check_users()
|
|
282 |
}
|
283 |
$data=implode(',',$data);
|
284 |
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
$url = sprintf("https://api.cleantalk.org/?method_name=spam_check&auth_key=%s",
|
297 |
-
$ct_options['apikey']
|
298 |
-
);
|
299 |
-
$result = file_get_contents($url, 0, $context);
|
300 |
|
301 |
-
|
|
|
302 |
if(isset($result->error_message))
|
303 |
{
|
304 |
print $result->error_message;
|
@@ -343,17 +339,18 @@ function ct_ajax_check_users()
|
|
343 |
}
|
344 |
|
345 |
add_action( 'wp_ajax_ajax_info_users', 'ct_ajax_info_users' );
|
346 |
-
function ct_ajax_info_users()
|
347 |
{
|
348 |
-
|
|
|
|
|
|
|
349 |
global $wpdb;
|
350 |
$r=$wpdb->get_results("select distinct count($wpdb->users.ID) as cnt from $wpdb->users inner join $wpdb->usermeta on $wpdb->users.ID=$wpdb->usermeta.user_id where $wpdb->usermeta.meta_key='ct_checked' or $wpdb->usermeta.meta_key='ct_hash';");
|
351 |
$cnt_checked=$r[0]->cnt;
|
352 |
$r=$wpdb->get_results("select count(ID) as cnt from $wpdb->users;");
|
353 |
$cnt=$r[0]->cnt;
|
354 |
|
355 |
-
$cnt_unchecked=$cnt_all-$cnt_checked;
|
356 |
-
|
357 |
$r=$wpdb->get_results("select distinct count($wpdb->users.ID) as cnt from $wpdb->users inner join $wpdb->usermeta on $wpdb->users.ID=$wpdb->usermeta.user_id where $wpdb->usermeta.meta_key='ct_marked_as_spam';", ARRAY_A);
|
358 |
$cnt_spam1=$r[0]['cnt'];
|
359 |
|
@@ -364,7 +361,11 @@ $cnt_spam1=$r[0]['cnt'];
|
|
364 |
}
|
365 |
print "<p>$backup_notice</p>";
|
366 |
|
367 |
-
|
|
|
|
|
|
|
|
|
368 |
}
|
369 |
|
370 |
add_action( 'wp_ajax_ajax_insert_users', 'ct_ajax_insert_users' );
|
43 |
<?php //_e("Done. All comments tested via blacklists database, please see result bellow.", 'cleantalk');
|
44 |
?>
|
45 |
</div>
|
46 |
+
<h3 id="ct_checking_users_status" style="text-align:center;width:90%;"><?php ct_ajax_info_users(true);?></h3>
|
47 |
<div style="text-align:center;width:100%;display:none;" id="ct_preloader"><img border=0 src="<?php print plugin_dir_url(__FILE__); ?>images/preloader.gif" /></div>
|
48 |
<div id="ct_working_message" style="margin:auto;padding:3px;width:70%;border:2px dotted gray;display:none;background:#ffff99;margin-top: 1em;">
|
49 |
<?php _e("Please wait for a while. CleanTalk is checking all users via blacklist database at cleantalk.org. You will have option to delete found spam users after plugin finish.", 'cleantalk'); ?>
|
181 |
<table>
|
182 |
<tr>
|
183 |
<td>
|
184 |
+
<button class="button" id="ct_check_users_button"><?php _e("Check for spam", 'cleantalk'); ?></button>
|
185 |
</td>
|
186 |
<td style="padding-left: 2em;">
|
187 |
<div id="ct_info_message" class="wrap"><?php _e("The plugin will check all users against blacklists database and show you senders that have spam activity on other websites. Just click 'Find spam users' to start.", 'cleantalk'); ?>
|
282 |
}
|
283 |
$data=implode(',',$data);
|
284 |
|
285 |
+
$request=Array();
|
286 |
+
$request['method_name'] = 'spam_check';
|
287 |
+
$request['auth_key'] = $ct_options['apikey'];
|
288 |
+
$request['data'] = $data;
|
289 |
+
$url='https://api.cleantalk.org';
|
290 |
+
if(!function_exists('sendRawRequest'))
|
291 |
+
{
|
292 |
+
require_once('cleantalk.class.php');
|
293 |
+
}
|
294 |
+
$result=sendRawRequest($url, $request);
|
|
|
|
|
|
|
|
|
|
|
295 |
|
296 |
+
$result=json_decode($result);
|
297 |
+
|
298 |
if(isset($result->error_message))
|
299 |
{
|
300 |
print $result->error_message;
|
339 |
}
|
340 |
|
341 |
add_action( 'wp_ajax_ajax_info_users', 'ct_ajax_info_users' );
|
342 |
+
function ct_ajax_info_users($direct_call = false)
|
343 |
{
|
344 |
+
if (!$direct_call) {
|
345 |
+
check_ajax_referer( 'ct_secret_nonce', 'security' );
|
346 |
+
}
|
347 |
+
|
348 |
global $wpdb;
|
349 |
$r=$wpdb->get_results("select distinct count($wpdb->users.ID) as cnt from $wpdb->users inner join $wpdb->usermeta on $wpdb->users.ID=$wpdb->usermeta.user_id where $wpdb->usermeta.meta_key='ct_checked' or $wpdb->usermeta.meta_key='ct_hash';");
|
350 |
$cnt_checked=$r[0]->cnt;
|
351 |
$r=$wpdb->get_results("select count(ID) as cnt from $wpdb->users;");
|
352 |
$cnt=$r[0]->cnt;
|
353 |
|
|
|
|
|
354 |
$r=$wpdb->get_results("select distinct count($wpdb->users.ID) as cnt from $wpdb->users inner join $wpdb->usermeta on $wpdb->users.ID=$wpdb->usermeta.user_id where $wpdb->usermeta.meta_key='ct_marked_as_spam';", ARRAY_A);
|
355 |
$cnt_spam1=$r[0]['cnt'];
|
356 |
|
361 |
}
|
362 |
print "<p>$backup_notice</p>";
|
363 |
|
364 |
+
if (!$direct_call) {
|
365 |
+
die();
|
366 |
+
};
|
367 |
+
|
368 |
+
return null;
|
369 |
}
|
370 |
|
371 |
add_action( 'wp_ajax_ajax_insert_users', 'ct_ajax_insert_users' );
|
inc/cleantalk.class.php
CHANGED
@@ -1193,4 +1193,4 @@ function cleantalk_get_real_ip()
|
|
1193 |
function cleantalk_is_JSON($string)
|
1194 |
{
|
1195 |
return ((is_string($string) && (is_object(json_decode($string)) || is_array(json_decode($string))))) ? true : false;
|
1196 |
-
}
|
1193 |
function cleantalk_is_JSON($string)
|
1194 |
{
|
1195 |
return ((is_string($string) && (is_object(json_decode($string)) || is_array(json_decode($string))))) ? true : false;
|
1196 |
+
}
|
inc/images/new_window.gif
ADDED
Binary file
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: znaeff, shagimuratov, serge00
|
|
3 |
Tags: spam, anti-spam, antispam, anti spam, bbpress, buddypress, captcha, capcha, captha, catcha, cf7 spam, comments, contact form spam, signup, spammers, spammy, woocommerce, wordpress spam, booking, order, subscription, gravity spam, jetpack, bots, contact form 7, contact form, registrations, ninja, Fast Secure Contact, Gravity forms, formidable, mailchimp, s2member, protection, protect, email, akismet, plugin, contact, recaptcha, google captcha, google recaptcha, math, security, login, blacklist, prevent spam comments, wordpress, User Frontend, bulk delete, bulk remove, cloudflare, widget, review, auth forms, firewall, ddos, cleantalk, mailpoet, profile builder, comment spam, registration spam, spam comments, comment moderation, spam bots, block spam, signup spam, spam blocker, spam filter, user registration spam,pingback,trackback, anti-spam plugin, varnish, amp, spam free, userpro
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 4.5.3
|
6 |
-
Stable tag: 5.
|
7 |
License: GPLv2
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -469,6 +469,11 @@ WordPress 3.0 at least. PHP 5 with CURL or file_get_contents() function and enab
|
|
469 |
1. CleanTalk works faster than most of other anti-spam plugins.
|
470 |
|
471 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
472 |
= 5.44.1 July 13 2016 =
|
473 |
* Optimized options getting code.
|
474 |
* Added the option 'Protect Logged in users' to do anti-spam tests for submissions by logged in users.
|
@@ -1087,6 +1092,11 @@ WordPress 3.0 at least. PHP 5 with CURL or file_get_contents() function and enab
|
|
1087 |
* First version
|
1088 |
|
1089 |
== Upgrade Notice ==
|
|
|
|
|
|
|
|
|
|
|
1090 |
= 5.44.1 July 13 2016 =
|
1091 |
* Optimized options getting code.
|
1092 |
* Added the option 'Protect Logged in users' to do anti-spam tests for submissions by logged in users.
|
3 |
Tags: spam, anti-spam, antispam, anti spam, bbpress, buddypress, captcha, capcha, captha, catcha, cf7 spam, comments, contact form spam, signup, spammers, spammy, woocommerce, wordpress spam, booking, order, subscription, gravity spam, jetpack, bots, contact form 7, contact form, registrations, ninja, Fast Secure Contact, Gravity forms, formidable, mailchimp, s2member, protection, protect, email, akismet, plugin, contact, recaptcha, google captcha, google recaptcha, math, security, login, blacklist, prevent spam comments, wordpress, User Frontend, bulk delete, bulk remove, cloudflare, widget, review, auth forms, firewall, ddos, cleantalk, mailpoet, profile builder, comment spam, registration spam, spam comments, comment moderation, spam bots, block spam, signup spam, spam blocker, spam filter, user registration spam,pingback,trackback, anti-spam plugin, varnish, amp, spam free, userpro
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 4.5.3
|
6 |
+
Stable tag: 5.45
|
7 |
License: GPLv2
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
469 |
1. CleanTalk works faster than most of other anti-spam plugins.
|
470 |
|
471 |
== Changelog ==
|
472 |
+
= 5.45 July 21 2016 =
|
473 |
+
* Optimized bulk spam comments deletion.
|
474 |
+
* Turned off JavaScript anti-spam cookies if the option 'Set cookies' is turned off. It helps to avoid issues with Varnish.
|
475 |
+
* Added links to bulk spam comments&users removal tool.
|
476 |
+
|
477 |
= 5.44.1 July 13 2016 =
|
478 |
* Optimized options getting code.
|
479 |
* Added the option 'Protect Logged in users' to do anti-spam tests for submissions by logged in users.
|
1092 |
* First version
|
1093 |
|
1094 |
== Upgrade Notice ==
|
1095 |
+
= 5.45 July 21 2016 =
|
1096 |
+
* Optimized bulk spam comments deletion.
|
1097 |
+
* Turned off JavaScript anti-spam cookies if the option 'Set cookies' is turned off. It helps to avoid issues with Varnish.
|
1098 |
+
* Added links to bulk spam comments&users removal tool.
|
1099 |
+
|
1100 |
= 5.44.1 July 13 2016 =
|
1101 |
* Optimized options getting code.
|
1102 |
* Added the option 'Protect Logged in users' to do anti-spam tests for submissions by logged in users.
|