Spam protection, AntiSpam, FireWall by CleanTalk - Version 5.0

Version Description

Download this release

Release Info

Developer Vlad Cleantalk
Plugin Icon 128x128 Spam protection, AntiSpam, FireWall by CleanTalk
Version 5.0
Comparing to
See all releases

Code changes from version 4.24-j to 5.0

cleantalk-ajax.php ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?
2
+
3
+ /*
4
+ AJAX functions
5
+ */
6
+
7
+ /*hooks for AJAX Login & Register email validation*/
8
+ add_action( 'wp_ajax_nopriv_validate_email', 'ct_validate_email_ajaxlogin',1 );
9
+ add_action( 'wp_ajax_validate_email', 'ct_validate_email_ajaxlogin',1 );
10
+
11
+ /*hooks for user registration*/
12
+ add_action( 'user_register', 'ct_user_register_ajaxlogin',1 );
13
+
14
+
15
+ function ct_validate_email_ajaxlogin($email=null, $is_ajax=true)
16
+ {
17
+ require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-public.php');
18
+ global $ct_agent_version, $ct_checkjs_register_form, $ct_session_request_id_label, $ct_session_register_ok_label, $bp, $ct_signup_done, $ct_formtime_label, $ct_negative_comment, $ct_options;
19
+
20
+ $ct_options=ct_get_options();
21
+
22
+ $email = is_null( $email ) ? $email : $_POST['email'];
23
+ $email=sanitize_email($email);
24
+ $is_good=true;
25
+ if ( ! filter_var( $email, FILTER_VALIDATE_EMAIL )||email_exists( $email ) )
26
+ {
27
+ $is_good=false;
28
+ }
29
+
30
+ if(class_exists('AjaxLogin')&&isset($_POST['action'])&&$_POST['action']=='validate_email')
31
+ {
32
+
33
+ $ct_options=ct_get_options();
34
+ $checkjs = js_test('ct_checkjs', $_COOKIE, true);
35
+ $submit_time = submit_time_test();
36
+ $sender_info = get_sender_info();
37
+ $sender_info['post_checkjs_passed']=$checkjs;
38
+
39
+ if ($checkjs === null)
40
+ {
41
+ $checkjs = js_test('ct_checkjs', $_COOKIE, true);
42
+ $sender_info['cookie_checkjs_passed'] = $checkjs;
43
+ }
44
+
45
+ $sender_info = json_encode($sender_info);
46
+ if ($sender_info === false)
47
+ {
48
+ $sender_info= '';
49
+ }
50
+
51
+ require_once('cleantalk.class.php');
52
+ $config = get_option('cleantalk_server');
53
+ $ct = new Cleantalk();
54
+ $ct->work_url = $config['ct_work_url'];
55
+ $ct->server_url = $ct_options['server'];
56
+
57
+ $ct->server_ttl = $config['ct_server_ttl'];
58
+ $ct->server_changed = $config['ct_server_changed'];
59
+ $ct->ssl_on = $ct_options['ssl_on'];
60
+
61
+ $ct_request = new CleantalkRequest();
62
+ $ct_request->auth_key = $ct_options['apikey'];
63
+ $ct_request->sender_email = $email;
64
+ $ct_request->sender_ip = $ct->ct_session_ip($_SERVER['REMOTE_ADDR']);
65
+ $ct_request->sender_nickname = '';
66
+ $ct_request->agent = $ct_agent_version;
67
+ $ct_request->sender_info = $sender_info;
68
+ $ct_request->js_on = $checkjs;
69
+ $ct_request->submit_time = $submit_time;
70
+
71
+ $ct_result = $ct->isAllowUser($ct_request);
72
+
73
+ if ($ct->server_change)
74
+ {
75
+ update_option(
76
+ 'cleantalk_server', array(
77
+ 'ct_work_url' => $ct->work_url,
78
+ 'ct_server_ttl' => $ct->server_ttl,
79
+ 'ct_server_changed' => time()
80
+ )
81
+ );
82
+ }
83
+ if ($ct_result->allow===0)
84
+ {
85
+ $is_good=false;
86
+ }
87
+ }
88
+ if($is_good)
89
+ {
90
+ $ajaxresult=array(
91
+ 'description' => null,
92
+ 'cssClass' => 'noon',
93
+ 'code' => 'success'
94
+ );
95
+ }
96
+ else
97
+ {
98
+ $ajaxresult=array(
99
+ 'description' => 'Invalid Email',
100
+ 'cssClass' => 'error-container',
101
+ 'code' => 'error'
102
+ );
103
+ }
104
+ $ajaxresult=json_encode($ajaxresult);
105
+ print $ajaxresult;
106
+ wp_die();
107
+ }
108
+
109
+ function ct_user_register_ajaxlogin($user_id)
110
+ {
111
+ require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-public.php');
112
+ global $ct_agent_version, $ct_checkjs_register_form, $ct_session_request_id_label, $ct_session_register_ok_label, $bp, $ct_signup_done, $ct_formtime_label, $ct_negative_comment, $ct_options;
113
+
114
+ $ct_options=ct_get_options();
115
+
116
+ if(class_exists('AjaxLogin')&&isset($_POST['action'])&&$_POST['action']=='register_submit')
117
+ {
118
+ $checkjs = js_test('ct_checkjs', $_COOKIE, true);
119
+ $submit_time = submit_time_test();
120
+ $sender_info = get_sender_info();
121
+ $sender_info['post_checkjs_passed']=$checkjs;
122
+
123
+ if ($checkjs === null)
124
+ {
125
+ $checkjs = js_test('ct_checkjs', $_COOKIE, true);
126
+ $sender_info['cookie_checkjs_passed'] = $checkjs;
127
+ }
128
+
129
+ $sender_info = json_encode($sender_info);
130
+ if ($sender_info === false)
131
+ {
132
+ $sender_info= '';
133
+ }
134
+
135
+ require_once('cleantalk.class.php');
136
+ $config = get_option('cleantalk_server');
137
+ $ct = new Cleantalk();
138
+ $ct->work_url = $config['ct_work_url'];
139
+ $ct->server_url = $ct_options['server'];
140
+
141
+ $ct->server_ttl = $config['ct_server_ttl'];
142
+ $ct->server_changed = $config['ct_server_changed'];
143
+ $ct->ssl_on = $ct_options['ssl_on'];
144
+
145
+ $ct_request = new CleantalkRequest();
146
+ $ct_request->auth_key = $ct_options['apikey'];
147
+ $ct_request->sender_email = sanitize_email($_POST['email']);
148
+ $ct_request->sender_ip = $ct->ct_session_ip($_SERVER['REMOTE_ADDR']);
149
+ $ct_request->sender_nickname = sanitize_email($_POST['login']); ;
150
+ $ct_request->agent = $ct_agent_version;
151
+ $ct_request->sender_info = $sender_info;
152
+ $ct_request->js_on = $checkjs;
153
+ $ct_request->submit_time = $submit_time;
154
+
155
+ $ct_result = $ct->isAllowUser($ct_request);
156
+
157
+ if ($ct->server_change)
158
+ {
159
+ update_option(
160
+ 'cleantalk_server', array(
161
+ 'ct_work_url' => $ct->work_url,
162
+ 'ct_server_ttl' => $ct->server_ttl,
163
+ 'ct_server_changed' => time()
164
+ )
165
+ );
166
+ }
167
+ if ($ct_result->allow===0)
168
+ {
169
+ wp_delete_user($user_id);
170
+ }
171
+ }
172
+ return $user_id;
173
+ }
174
+
175
+ ?>
cleantalk-comments-checkspam.js ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var working=false;
2
+
3
+ String.prototype.format = String.prototype.f = function ()
4
+ {
5
+ var args = arguments;
6
+ return this.replace(/\{\{|\}\}|\{(\d+)\}/g, function (m, n)
7
+ {
8
+ if (m == "{{") { return "{"; }
9
+ if (m == "}}") { return "}"; }
10
+ return args[n];
11
+ });
12
+ };
13
+
14
+ function ct_send_comments()
15
+ {
16
+ var data = {
17
+ 'action': 'ajax_check_comments',
18
+ 'security': ajax_nonce
19
+ };
20
+
21
+ jQuery.ajax({
22
+ type: "POST",
23
+ url: ajaxurl,
24
+ data: data,
25
+ success: function(msg){
26
+ if(parseInt(msg)==1)
27
+ {
28
+ ct_send_comments();
29
+ }
30
+ else if(parseInt(msg)==0)
31
+ {
32
+ working=false;
33
+ jQuery('#ct_working_message').hide();
34
+ //alert('finish!');
35
+ location.href='edit-comments.php?page=ct_check_spam';
36
+ }
37
+ else
38
+ {
39
+ working=false;
40
+ alert(msg);
41
+ }
42
+ }
43
+ });
44
+ }
45
+ function ct_show_info()
46
+ {
47
+ if(working)
48
+ {
49
+ var data = {
50
+ 'action': 'ajax_info_comments',
51
+ 'security': ajax_nonce
52
+ };
53
+ jQuery.ajax({
54
+ type: "POST",
55
+ url: ajaxurl,
56
+ data: data,
57
+ success: function(msg){
58
+ jQuery('#ct_checking_status').html(msg);
59
+ setTimeout(ct_show_info, 1000);
60
+ }
61
+ });
62
+ }
63
+ }
64
+ function ct_insert_comments()
65
+ {
66
+ var data = {
67
+ 'action': 'ajax_insert_comments',
68
+ 'security': ajax_nonce
69
+ };
70
+
71
+ jQuery.ajax({
72
+ type: "POST",
73
+ url: ajaxurl,
74
+ data: data,
75
+ success: function(msg){
76
+ if(msg=='ok')
77
+ {
78
+ alert('Added 500 comments');
79
+ }
80
+ }
81
+ });
82
+ }
83
+ function ct_delete_all()
84
+ {
85
+ var data = {
86
+ 'action': 'ajax_delete_all',
87
+ 'security': ajax_nonce
88
+ };
89
+
90
+ jQuery.ajax({
91
+ type: "POST",
92
+ url: ajaxurl,
93
+ data: data,
94
+ success: function(msg){
95
+ location.href='edit-comments.php?page=ct_check_spam';
96
+ }
97
+ });
98
+ }
99
+ function ct_delete_checked()
100
+ {
101
+ ids=Array();
102
+ var cnt=0;
103
+ jQuery('input[id^=cb-select-][id!=cb-select-all-1]').each(function(){
104
+ if(jQuery(this).prop('checked'))
105
+ {
106
+ ids[cnt]=jQuery(this).attr('id').substring(10);
107
+ cnt++;
108
+ }
109
+ });
110
+ var data = {
111
+ 'action': 'ajax_delete_checked',
112
+ 'security': ajax_nonce,
113
+ 'ids':ids
114
+ };
115
+
116
+ jQuery.ajax({
117
+ type: "POST",
118
+ url: ajaxurl,
119
+ data: data,
120
+ success: function(msg){
121
+ location.href='edit-comments.php?page=ct_check_spam';
122
+ //alert(msg);
123
+ }
124
+ });
125
+ }
126
+ jQuery("#ct_check_spam_button").click(function(){
127
+ jQuery('#ct_working_message').show();
128
+ working=true;
129
+ ct_send_comments();
130
+ });
131
+ jQuery("#ct_check_spam_button").click(function(){
132
+ jQuery('#ct_checking_status').html('');
133
+ working=true;
134
+ ct_show_info();
135
+ });
136
+ jQuery("#ct_insert_comments").click(function(){
137
+ ct_insert_comments();
138
+ });
139
+ jQuery("#ct_delete_all").click(function(){
140
+ ct_delete_all();
141
+ });
142
+ jQuery("#ct_delete_checked").click(function(){
143
+ ct_delete_checked();
144
+ });
145
+
146
+ jQuery(document).ready(function(){
147
+ working=true;
148
+ ct_show_info();
149
+ working=false;
150
+ });
cleantalk-comments-editscreen.js ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery('#post-query-submit').after('<a href="edit-comments.php?page=ct_check_spam" class="button">'+spambutton_text+'</a>');
2
+ jQuery("#ct_check_spam_button").click(function(){
3
+ var data = {
4
+ 'action': 'ajax_check_comments',
5
+ security: ajax_nonce
6
+ };
7
+
8
+ jQuery.ajax({
9
+ type: "POST",
10
+ url: ajaxurl,
11
+ data: data,
12
+ success: function(msg){
13
+ alert(msg);
14
+ }
15
+ });
16
+
17
+ });
cleantalk-comments.php ADDED
@@ -0,0 +1,414 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?
2
+ add_action('admin_menu', 'ct_add_comments_menu');
3
+
4
+ function ct_add_comments_menu()
5
+ {
6
+ add_comments_page( __("Check for spam", 'cleantalk'), __("Check for spam", 'cleantalk'), 'read', 'ct_check_spam', 'ct_show_checkspam_page');
7
+ }
8
+
9
+ function ct_show_checkspam_page()
10
+ {
11
+ ?>
12
+ <div class="wrap">
13
+ <h2><? _e("Anti-spam by CleanTalk", 'cleantalk'); ?></h2><br />
14
+ <?
15
+ $args_unchecked = array(
16
+ 'meta_query' => array(
17
+ 'relation' => 'AND',
18
+ Array(
19
+ 'key' => 'ct_checked',
20
+ 'value' => '1',
21
+ 'compare' => 'NOT EXISTS'
22
+ ),
23
+ Array(
24
+ 'key' => 'ct_hash',
25
+ 'value' => '1',
26
+ 'compare' => 'NOT EXISTS'
27
+ )
28
+ ),
29
+ 'count'=>true
30
+ );
31
+ $cnt_unchecked=get_comments($args_unchecked);
32
+ if($cnt_unchecked>0)
33
+ {
34
+ ?>
35
+ <button class="button" id="ct_check_spam_button"><? _e("Find spam comments", 'cleantalk'); ?></button><br />
36
+ <div><? _e("Anti-spam by CleanTalk will check all not spam comments against blacklists database and show you senders that have spam activity on other websites. Just click 'Find spam comments' to start.", 'cleantalk'); ?></div>
37
+ <?
38
+ }
39
+ ?>
40
+ <?
41
+ //print '<button class="button" id="ct_insert_comments">Insert comments</button><br />';
42
+ ?>
43
+
44
+ <div id="ct_working_message" style="display:none">
45
+ <? _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'); ?>
46
+ </div>
47
+ <div id="ct_done_message" <? if($cnt_unchecked>0) print 'style="display:none"'; ?>>
48
+ <? _e("Done. All comments tested via blacklists database, please see result bellow.", 'cleantalk'); ?>
49
+ </div>
50
+ <h3 id="ct_checking_status"></h3>
51
+ <?
52
+ $args_spam = array(
53
+ 'meta_query' => array(
54
+ Array(
55
+ 'key' => 'ct_marked_as_spam',
56
+ 'compare' => 'EXISTS'
57
+ )
58
+ ),
59
+ 'count'=>true
60
+ );
61
+ $cnt_spam=get_comments($args_spam);
62
+
63
+
64
+ $page=1;
65
+ if(isset($_GET['spam_page']))
66
+ {
67
+ $page=intval($_GET['spam_page']);
68
+ }
69
+ $args_spam = array(
70
+ 'meta_query' => array(
71
+ Array(
72
+ 'key' => 'ct_marked_as_spam',
73
+ 'value' => '1',
74
+ 'compare' => 'NUMERIC'
75
+ )
76
+ ),
77
+ 'number'=>30,
78
+ 'offset'=>($page-1)*30
79
+ );
80
+
81
+ $c_spam=get_comments($args_spam);
82
+ if($cnt_spam>0)
83
+ {
84
+ ?>
85
+ <table class="widefat fixed comments">
86
+ <thead>
87
+ <th scope="col" id="cb" class="manage-column column-cb check-column">
88
+ <label class="screen-reader-text" for="cb-select-all-1">Select All</label>
89
+ <input id="cb-select-all-1" type="checkbox"/>
90
+ </th>
91
+ <th scope="col" id="author" class="manage-column column-slug"><? print _e('Author');?></th>
92
+ <th scope="col" id="comment" class="manage-column column-comment"><? print _x( 'Comment', 'column name' );;?></th>
93
+ <th scope="col" id="response" class="manage-column column-response sortable desc"><? print _x( 'In Response To', 'column name' );?></th>
94
+ </thead>
95
+ <tbody id="the-comment-list" data-wp-lists="list:comment">
96
+ <?
97
+ for($i=0;$i<sizeof($c_spam);$i++)
98
+ {
99
+ ?>
100
+ <tr id="comment-<? print $c_spam[$i]->comment_ID; ?>" class="comment even thread-even depth-1 approved">
101
+ <th scope="row" class="check-column">
102
+ <label class="screen-reader-text" for="cb-select-<? print $c_spam[$i]->comment_ID; ?>">Select comment</label>
103
+ <input id="cb-select-<? print $c_spam[$i]->comment_ID; ?>" type="checkbox" name="del_comments[]" value="<? print $c_spam[$i]->comment_ID; ?>"/>
104
+ </th>
105
+ <td class="author column-author" nowrap>
106
+ <strong>
107
+ <?php echo get_avatar( $c_spam[$i]->comment_author_email , 32); ?>
108
+ <? print $c_spam[$i]->comment_author; ?>
109
+ </strong>
110
+ <br/>
111
+ <a href="mailto:<? print $c_spam[$i]->comment_author_email; ?>"><? print $c_spam[$i]->comment_author_email; ?></a> <a href="https://cleantalk.org/blacklists/<? 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>
112
+ <br/>
113
+ <a href="edit-comments.php?s=<? print $c_spam[$i]->comment_author_IP ; ?>&mode=detail"><? print $c_spam[$i]->comment_author_IP ; ?></a>
114
+ <a href="https://cleantalk.org/blacklists/<? 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>
115
+ </td>
116
+ <td class="comment column-comment">
117
+ <div class="submitted-on">
118
+ <? printf( __( 'Submitted on <a href="%1$s">%2$s at %3$s</a>' ), get_comment_link($c_spam[$i]->comment_ID),
119
+ /* translators: comment date format. See http://php.net/date */
120
+ get_comment_date( __( 'Y/m/d' ),$c_spam[$i]->comment_ID ),
121
+ get_comment_date( get_option( 'time_format' ),$c_spam[$i]->comment_ID )
122
+ );
123
+ ?>
124
+
125
+ </div>
126
+ <p>
127
+ <? print $c_spam[$i]->comment_content; ?>
128
+ </p>
129
+ </td>
130
+ <td class="response column-response">
131
+ <div class="response-links">
132
+ <span class="post-com-count-wrapper">
133
+ <a href="http://ct_wp/wp-admin/post.php?post=<? print $c_spam[$i]->comment_post_ID; ?>&action=edit"><? print get_the_title($c_spam[$i]->comment_post_ID); ?></a>
134
+ <br/>
135
+ <a href="http://ct_wp/wp-admin/edit-comments.php?p=<? print $c_spam[$i]->comment_post_ID; ?>" class="post-com-count">
136
+ <span class="comment-count"><?
137
+ $p_cnt=wp_count_comments();
138
+ print $p_cnt->total_comments;
139
+ ?></span>
140
+ </a>
141
+ </span>
142
+ <a href="<? print get_permalink($c_spam[$i]->comment_post_ID); ?>"><? print _e('View Post');?></a>
143
+ </div>
144
+ </td>
145
+ </tr>
146
+ <?
147
+ }
148
+ $args_spam = array(
149
+ 'meta_query' => array(
150
+ Array(
151
+ 'key' => 'ct_marked_as_spam',
152
+ 'value' => '1',
153
+ 'compare' => 'NUMERIC'
154
+ )
155
+
156
+ ),
157
+ 'count'=>true
158
+ );
159
+ $cnt_spam=get_comments($args_spam);
160
+ if($cnt_spam>30)
161
+ {
162
+ ?>
163
+ <tr class="comment even thread-even depth-1 approved">
164
+ <td colspan="4">
165
+ <?
166
+
167
+ $pages=ceil(intval($cnt_spam)/30);
168
+ for($i=1;$i<=$pages;$i++)
169
+ {
170
+ if($i==$page)
171
+ {
172
+ print "<a href='edit-comments.php?page=ct_check_spam&spam_page=$i'><b>$i</b></a> ";
173
+ }
174
+ else
175
+ {
176
+ print "<a href='edit-comments.php?page=ct_check_spam&spam_page=$i'>$i</a> ";
177
+ }
178
+ }
179
+ ?>
180
+ </td>
181
+ </tr>
182
+ <?
183
+ }
184
+ ?>
185
+ </tbody>
186
+ </table>
187
+ <button class="button" id="ct_delete_all"><? _e('Delete all content.'); ?></button>
188
+ <button class="button" id="ct_delete_checked"><? _e('Delete selected', 'cleantalk'); ?></button>
189
+ <?
190
+ }
191
+ ?>
192
+ </div>
193
+ <?
194
+ }
195
+
196
+ add_action('admin_print_footer_scripts','ct_add_checkspam_button');
197
+ function ct_add_checkspam_button()
198
+ {
199
+ $screen = get_current_screen();
200
+ $ajax_nonce = wp_create_nonce( "ct_secret_nonce" );
201
+ ?>
202
+ <script>
203
+ var ajax_nonce='<?php echo $ajax_nonce; ?>';
204
+ var spambutton_text='<? _e("Find spam comments", 'cleantalk'); ?>';
205
+ </script>
206
+ <?
207
+ if( $screen->id == 'edit-comments' ){
208
+ ?>
209
+ <script src="<? print plugins_url( 'cleantalk-comments-editscreen.js', __FILE__ ); ?>"></script>
210
+ <?php
211
+ }
212
+ if($screen->id == 'comments_page_ct_check_spam')
213
+ {
214
+ ?>
215
+ <script src="<? print plugins_url( 'cleantalk-comments-checkspam.js', __FILE__ ); ?>"></script>
216
+ <?php
217
+ }
218
+ }
219
+
220
+
221
+ add_action( 'wp_ajax_ajax_check_comments', 'ct_ajax_check_comments' );
222
+
223
+ function ct_ajax_check_comments()
224
+ {
225
+ check_ajax_referer( 'ct_secret_nonce', 'security' );
226
+
227
+ $ct_options = ct_get_options();
228
+
229
+ $args_unchecked = array(
230
+ 'meta_query' => array(
231
+ 'relation' => 'AND',
232
+ Array(
233
+ 'key' => 'ct_checked',
234
+ 'value' => '1',
235
+ 'compare' => 'NOT EXISTS'
236
+ ),
237
+ Array(
238
+ 'key' => 'ct_hash',
239
+ 'value' => '1',
240
+ 'compare' => 'NOT EXISTS'
241
+ )
242
+ ),
243
+ 'number'=>999
244
+ );
245
+
246
+ $u=get_comments($args_unchecked);
247
+ if(sizeof($u)>0)
248
+ {
249
+ //print_r($unchecked);
250
+ $data=Array();
251
+ for($i=0;$i<sizeof($u);$i++)
252
+ {
253
+ $data[]=$u[$i]->comment_author_IP;
254
+ $data[]=$u[$i]->comment_author_email;
255
+ }
256
+ $data=implode(',',$data);
257
+
258
+ $request="data=$data";
259
+
260
+ $opts = array(
261
+ 'http'=>array(
262
+ 'method'=>"POST",
263
+ 'content'=>$request,
264
+ )
265
+ );
266
+
267
+ $context = stream_context_create($opts);
268
+
269
+ $result = @file_get_contents("https://api.cleantalk.org/?method_name=spam_check&auth_key=".$ct_options['apikey'], 0, $context);
270
+ $result=json_decode($result);
271
+ if(isset($result->error_message))
272
+ {
273
+ print $result->error_message;
274
+ }
275
+ else
276
+ {
277
+ for($i=0;$i<sizeof($u);$i++)
278
+ {
279
+ add_comment_meta($u[$i]->comment_ID,'ct_checked',date("Y-m-d H:m:s"),true);
280
+ $uip=$u[$i]->comment_author_IP;
281
+ if(empty($uip))continue;
282
+ $uim=$u[$i]->comment_author_email;
283
+ if(empty($uim))continue;
284
+ if($result->data->$uip->appears==1||$result->data->$uim->appears==1)
285
+ {
286
+ add_comment_meta($u[$i]->comment_ID,'ct_marked_as_spam','1',true);
287
+ }
288
+ }
289
+ print 1;
290
+ }
291
+ }
292
+ else
293
+ {
294
+ print 0;
295
+ }
296
+
297
+ die;
298
+ }
299
+
300
+ add_action( 'wp_ajax_ajax_info_comments', 'ct_ajax_info_comments' );
301
+ function ct_ajax_info_comments()
302
+ {
303
+ check_ajax_referer( 'ct_secret_nonce', 'security' );
304
+ $cnt=get_comments(Array('count'=>true));
305
+
306
+ $args_spam = array(
307
+ 'meta_query' => array(
308
+ Array(
309
+ 'key' => 'ct_marked_as_spam',
310
+ 'value' => '1',
311
+ 'compare' => 'NUMERIC'
312
+ )
313
+ ),
314
+ 'count'=>true,
315
+ );
316
+
317
+ $cnt_spam=get_comments($args_spam);
318
+
319
+ $args_checked1=array(
320
+ 'meta_query' => array(
321
+ Array(
322
+ 'key' => 'ct_hash',
323
+ 'compare' => 'EXISTS'
324
+ )
325
+ ),
326
+ 'count'=>true
327
+ );
328
+ $args_checked2=array(
329
+ 'meta_query' => array(
330
+ Array(
331
+ 'key' => 'ct_checked',
332
+ 'compare' => 'EXISTS'
333
+ )
334
+ ),
335
+ 'count'=>true
336
+ );
337
+
338
+ $cnt_checked1=get_comments($args_checked1);
339
+ $cnt_checked2=get_comments($args_checked2);
340
+ $cnt_checked=$cnt_checked1+$cnt_checked2;
341
+
342
+ printf (__("Total comments %s, checked %s, found %s spam comments.", 'cleantalk'), $cnt, $cnt_checked, $cnt_spam);
343
+ die();
344
+ }
345
+
346
+ add_action( 'wp_ajax_ajax_insert_comments', 'ct_ajax_insert_comments' );
347
+ function ct_ajax_insert_comments()
348
+ {
349
+ check_ajax_referer( 'ct_secret_nonce', 'security' );
350
+ $time = current_time('mysql');
351
+
352
+ for($i=0;$i<500;$i++)
353
+ {
354
+ $rnd=mt_rand(1,100);
355
+ if($rnd<20)
356
+ {
357
+ $email="stop_email@example.com";
358
+ }
359
+ else
360
+ {
361
+ $email="stop_email_$rnd@example.com";
362
+ }
363
+ $data = array(
364
+ 'comment_post_ID' => 1,
365
+ 'comment_author' => "author_$rnd",
366
+ 'comment_author_email' => $email,
367
+ 'comment_author_url' => 'http://',
368
+ 'comment_content' => "comment content ".mt_rand(1,10000)." ".mt_rand(1,10000)." ".mt_rand(1,10000),
369
+ 'comment_type' => '',
370
+ 'comment_parent' => 0,
371
+ 'user_id' => 1,
372
+ 'comment_author_IP' => '127.0.0.1',
373
+ '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)',
374
+ 'comment_date' => $time,
375
+ 'comment_approved' => 1,
376
+ );
377
+
378
+ wp_insert_comment($data);
379
+ }
380
+ print "ok";
381
+ die();
382
+ }
383
+
384
+ add_action( 'wp_ajax_ajax_delete_checked', 'ct_ajax_delete_checked' );
385
+ function ct_ajax_delete_checked()
386
+ {
387
+ check_ajax_referer( 'ct_secret_nonce', 'security' );
388
+ foreach($_POST['ids'] as $key=>$value)
389
+ {
390
+ wp_delete_comment($value, true);
391
+ }
392
+ die();
393
+ }
394
+
395
+ add_action( 'wp_ajax_ajax_delete_all', 'ct_ajax_delete_all' );
396
+ function ct_ajax_delete_all()
397
+ {
398
+ check_ajax_referer( 'ct_secret_nonce', 'security' );
399
+ $args_spam = array(
400
+ 'meta_query' => array(
401
+ Array(
402
+ 'key' => 'ct_marked_as_spam',
403
+ 'value' => '1',
404
+ 'compare' => 'NUMERIC'
405
+ )
406
+ )
407
+ );
408
+ $c_spam=get_comments($args_spam);
409
+ for($i=0;$i<sizeof($c_spam);$i++)
410
+ {
411
+ wp_delete_comment($c_spam[$i]->comment_ID, true);
412
+ }
413
+ die();
414
+ }
cleantalk-public.php CHANGED
@@ -1440,7 +1440,7 @@ function ct_contact_form_validate () {
1440
  'sender_email' => $sender_email,
1441
  'sender_nickname' => $sender_nickname,
1442
  'post_info' => $post_info,
1443
- 'sender_info' => $sender_info,
1444
  'checkjs' => $checkjs
1445
  ));
1446
 
1440
  'sender_email' => $sender_email,
1441
  'sender_nickname' => $sender_nickname,
1442
  'post_info' => $post_info,
1443
+ 'sender_info' => get_sender_info(),
1444
  'checkjs' => $checkjs
1445
  ));
1446
 
cleantalk.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Anti-spam 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.
6
- Version: 4.24
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: http://cleantalk.org
9
  */
@@ -29,6 +29,11 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
29
  add_action('admin_menu', 'ct_admin_add_page');
30
  add_action('admin_notices', 'admin_notice_message');
31
  }
 
 
 
 
 
32
 
33
  add_action('admin_enqueue_scripts', 'ct_enqueue_scripts');
34
  add_action('comment_unapproved_to_approvecomment', 'ct_comment_approved'); // param - comment object
@@ -86,4 +91,6 @@ if (!function_exists ( 'ct_deactivation')) {
86
  }
87
  }
88
 
89
- ?>
 
 
3
  Plugin Name: Anti-spam 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.
6
+ Version: 5.0
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: http://cleantalk.org
9
  */
29
  add_action('admin_menu', 'ct_admin_add_page');
30
  add_action('admin_notices', 'admin_notice_message');
31
  }
32
+ if (defined( 'DOING_AJAX' ) && DOING_AJAX)
33
+ {
34
+ require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-public.php');
35
+ require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-ajax.php');
36
+ }
37
 
38
  add_action('admin_enqueue_scripts', 'ct_enqueue_scripts');
39
  add_action('comment_unapproved_to_approvecomment', 'ct_comment_approved'); // param - comment object
91
  }
92
  }
93
 
94
+ require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-comments.php');
95
+
96
+ ?>
i18n/cleantalk-ru_RU.mo CHANGED
Binary file
i18n/cleantalk.pot CHANGED
@@ -89,3 +89,27 @@ msgstr ""
89
 
90
  msgid "Anti spam test for any WordPress or themes contacts forms"
91
  msgstr ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
 
90
  msgid "Anti spam test for any WordPress or themes contacts forms"
91
  msgstr ""
92
+
93
+ msgid "Find spam comments"
94
+ msgstr ""
95
+
96
+ msgid "Total comments %s, checked %s, found %s spam comments."
97
+ msgstr ""
98
+
99
+ msgid "Done. All comments tested via blacklists database, please see result bellow."
100
+ msgstr ""
101
+
102
+ msgid "Delete selected"
103
+ msgstr ""
104
+
105
+ msgid "Check for spam"
106
+ msgstr ""
107
+
108
+ msgid "Anti-spam by CleanTalk"
109
+ msgstr ""
110
+
111
+ msgid "Anti-spam by CleanTalk will check all not spam comments against blacklists database and show you senders that have spam activity on other websites. Just click 'Find spam comments' to start."
112
+ msgstr ""
113
+
114
+ msgid "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."
115
+ msgstr ""
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: znaeff, shagimuratov, vlad-cleantalk
3
  Tags: akismet, anti-spam, antispam, bbpress spam, buddypress spam, captcha antispam, cf7 spam, comments spam, contact form spam, fast secure contact form spam, form, Formidable spam, jetpack spam, landing pages, math, registration spam, s2member spam, signup spam, spam, spammers, spammy, WooCommerce spam, wordpress spam, booking spam, order spam, subscriptions spam, comments, gravity spam, gravity forms spam
4
  Requires at least: 3.0
5
  Tested up to: 4.1.1
6
- Stable tag: 4.24
7
  License: GPLv2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -175,6 +175,11 @@ WordPress 3.0 at least. PHP 5 with CURL or file_get_contents() function and enab
175
  1. Setup Android/iOS app to have push notices when new legitiamte comments/registrations or contactcs appears on the website.
176
 
177
  == Changelog ==
 
 
 
 
 
178
  = 4.24 2015-03-20 =
179
  * Added immediate spam protection activation.
180
 
@@ -522,6 +527,11 @@ WordPress 3.0 at least. PHP 5 with CURL or file_get_contents() function and enab
522
  * First version
523
 
524
  == Upgrade Notice ==
 
 
 
 
 
525
  = 4.24 2015-03-20 =
526
  Added immediate spam protection activation.
527
 
3
  Tags: akismet, anti-spam, antispam, bbpress spam, buddypress spam, captcha antispam, cf7 spam, comments spam, contact form spam, fast secure contact form spam, form, Formidable spam, jetpack spam, landing pages, math, registration spam, s2member spam, signup spam, spam, spammers, spammy, WooCommerce spam, wordpress spam, booking spam, order spam, subscriptions spam, comments, gravity spam, gravity forms spam
4
  Requires at least: 3.0
5
  Tested up to: 4.1.1
6
+ Stable tag: 5.0
7
  License: GPLv2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
175
  1. Setup Android/iOS app to have push notices when new legitiamte comments/registrations or contactcs appears on the website.
176
 
177
  == Changelog ==
178
+ = 5.00 2015-03-24 =
179
+ * Added bulk comments checking via CleanTalk blacklists
180
+ * Added form protection for 'Ajax Login & Register'
181
+ * Fixed JetPack form protection
182
+
183
  = 4.24 2015-03-20 =
184
  * Added immediate spam protection activation.
185
 
527
  * First version
528
 
529
  == Upgrade Notice ==
530
+ = 5.00 2015-03-24 =
531
+ * Added bulk comments checking via CleanTalk blacklists
532
+ * Added form protection for 'Ajax Login & Register'
533
+ * Fixed JetPack form protection
534
+
535
  = 4.24 2015-03-20 =
536
  Added immediate spam protection activation.
537