Spam protection, AntiSpam, FireWall by CleanTalk - Version 5.71

Version Description

July 20 2017 = * Improved spam protection for external forms. * Optimization. * Minor fixes.

Download this release

Release Info

Developer Safronik
Plugin Icon 128x128 Spam protection, AntiSpam, FireWall by CleanTalk
Version 5.71
Comparing to
See all releases

Code changes from version 5.70.2 to 5.71

assets/js/cleantalk-admin-settings-page.js CHANGED
@@ -1,82 +1,82 @@
1
- var ct_adv_settings=null;
2
- var ct_adv_settings_title=null;
3
- var ct_adv_settings_show=false;
4
- jQuery(document).ready(function(){
5
- var d = new Date();
6
- var n = d.getTimezoneOffset();
7
- var data = {
8
- 'action': 'ajax_get_timezone',
9
- 'security': ctSettingsPage.ct_ajax_nonce,
10
- 'offset': n
11
- };
12
- jQuery.ajax({
13
- type: "POST",
14
- url: ajaxurl,
15
- data: data,
16
- success: function(msg){
17
- //
18
- }
19
- });
20
-
21
- if(cleantalk_good_key)
22
- {
23
- if(cleantalk_testing_failed !== true)
24
- jQuery('.form-table').first().hide();
25
-
26
- banner_html="<div id='ct_stats_banner'>"+cleantalk_blocked_message;
27
- banner_html+=cleantalk_statistics_link+"&nbsp;&nbsp;"+cleantalk_support_link+'</div>';
28
- jQuery('.form-table').first().before(banner_html);
29
- if(!cleantalk_wpmu)
30
- {
31
- // jQuery('.form-table').first().before("<br /><a href='#' style='font-size:10pt;' id='cleantalk_access_key_link'>Show the access key</a>");
32
- jQuery('.form-table').first().before(cleantalk_support_links);
33
- }
34
- }else{
35
- jQuery('#ct_admin_timezone').val(d.getTimezoneOffset()/60*(-1));
36
- }
37
-
38
- jQuery('#cleantalk_access_key_link').click(function(){
39
- if(jQuery('.form-table').first().is(":visible"))
40
- {
41
- jQuery('.form-table').first().hide();
42
- }
43
- else
44
- {
45
- jQuery('.form-table').first().show();
46
- }
47
- });
48
-
49
- ct_adv_settings=jQuery('#cleantalk_registrations_test1').parent().parent().parent().parent();
50
- ct_adv_settings.hide();
51
- ct_adv_settings_title=ct_adv_settings.prev();
52
- ct_adv_settings.wrap("<div id='ct_advsettings_hide'>");
53
- ct_adv_settings_title.append(" <span id='ct_adv_showhide' style='cursor:pointer'><b><a href='#' style='text-decoration:none;'></a></b></span>");
54
- ct_adv_settings_title.css('cursor','pointer');
55
- ct_adv_settings_title.click(function(){
56
- if(ct_adv_settings_show)
57
- {
58
- ct_adv_settings.hide();
59
- ct_adv_settings_show=false;
60
- jQuery('#ct_adv_showhide').html("<b><a href='#' style='text-decoration:none;'></a></b>");
61
- }
62
- else
63
- {
64
- ct_adv_settings.show();
65
- ct_adv_settings_show=true;
66
- jQuery('#ct_adv_showhide').html("<b><a href='#' style='text-decoration:none;'></a></b>");
67
- }
68
-
69
- });
70
-
71
- //For counters settings.
72
- jQuery('#ct_advsettings_hide').on('click', '#cleantalk_show_adminbar1', function(){
73
- jQuery('.ct-depends-of-show-adminbar').each(function(){
74
- jQuery(this).removeAttr('disabled');
75
- });
76
- });
77
- jQuery('#ct_advsettings_hide').on('click', '#cleantalk_show_adminbar0', function(){
78
- jQuery('.ct-depends-of-show-adminbar').each(function(){
79
- jQuery(this).attr('disabled', 'disabled');
80
- });
81
- });
82
- });
1
+ var ct_adv_settings=null;
2
+ var ct_adv_settings_title=null;
3
+ var ct_adv_settings_show=false;
4
+ jQuery(document).ready(function(){
5
+ var d = new Date();
6
+ var n = d.getTimezoneOffset();
7
+ var data = {
8
+ 'action': 'ajax_get_timezone',
9
+ 'security': ctSettingsPage.ct_ajax_nonce,
10
+ 'offset': n
11
+ };
12
+ jQuery.ajax({
13
+ type: "POST",
14
+ url: ajaxurl,
15
+ data: data,
16
+ success: function(msg){
17
+ //
18
+ }
19
+ });
20
+
21
+ if(cleantalk_good_key)
22
+ {
23
+ if(cleantalk_testing_failed !== true)
24
+ jQuery('.form-table').first().hide();
25
+
26
+ banner_html="<div id='ct_stats_banner'>"+cleantalk_blocked_message;
27
+ banner_html+=cleantalk_statistics_link+"&nbsp;&nbsp;"+cleantalk_support_link+'</div>';
28
+ jQuery('.form-table').first().before(banner_html);
29
+ if(!cleantalk_wpmu)
30
+ {
31
+ // jQuery('.form-table').first().before("<br /><a href='#' style='font-size:10pt;' id='cleantalk_access_key_link'>Show the access key</a>");
32
+ jQuery('.form-table').first().before(cleantalk_support_links);
33
+ }
34
+ }else{
35
+ jQuery('#ct_admin_timezone').val(d.getTimezoneOffset()/60*(-1));
36
+ }
37
+
38
+ jQuery('#cleantalk_access_key_link').click(function(){
39
+ if(jQuery('.form-table').first().is(":visible"))
40
+ {
41
+ jQuery('.form-table').first().hide();
42
+ }
43
+ else
44
+ {
45
+ jQuery('.form-table').first().show();
46
+ }
47
+ });
48
+
49
+ ct_adv_settings=jQuery('#cleantalk_registrations_test1').parent().parent().parent().parent();
50
+ ct_adv_settings.hide();
51
+ ct_adv_settings_title=ct_adv_settings.prev();
52
+ ct_adv_settings.wrap("<div id='ct_advsettings_hide'>");
53
+ ct_adv_settings_title.append(" <span id='ct_adv_showhide' style='cursor:pointer'><b><a href='#' style='text-decoration:none;'></a></b></span>");
54
+ ct_adv_settings_title.css('cursor','pointer');
55
+ ct_adv_settings_title.click(function(){
56
+ if(ct_adv_settings_show)
57
+ {
58
+ ct_adv_settings.hide();
59
+ ct_adv_settings_show=false;
60
+ jQuery('#ct_adv_showhide').html("<b><a href='#' style='text-decoration:none;'></a></b>");
61
+ }
62
+ else
63
+ {
64
+ ct_adv_settings.show();
65
+ ct_adv_settings_show=true;
66
+ jQuery('#ct_adv_showhide').html("<b><a href='#' style='text-decoration:none;'></a></b>");
67
+ }
68
+
69
+ });
70
+
71
+ //For counters settings.
72
+ jQuery('#ct_advsettings_hide').on('click', '#cleantalk_show_adminbar1', function(){
73
+ jQuery('.ct-depends-of-show-adminbar').each(function(){
74
+ jQuery(this).removeAttr('disabled');
75
+ });
76
+ });
77
+ jQuery('#ct_advsettings_hide').on('click', '#cleantalk_show_adminbar0', function(){
78
+ jQuery('.ct-depends-of-show-adminbar').each(function(){
79
+ jQuery(this).attr('disabled', 'disabled');
80
+ });
81
+ });
82
+ });
assets/js/cleantalk-admin.js CHANGED
@@ -1,8 +1,8 @@
1
- jQuery(document).ready(function(){
2
-
3
- jQuery('.ct-trial-notice').on('click', 'button', function(){
4
- var ct_date = new Date(new Date().getTime() + 86400 * 1000);
5
- document.cookie = "ct_trial_banner_closed=1; path=/; expires=" + ct_date.toUTCString();
6
- });
7
-
8
  });
1
+ jQuery(document).ready(function(){
2
+
3
+ jQuery('.ct-trial-notice').on('click', 'button', function(){
4
+ var ct_date = new Date(new Date().getTime() + 86400 * 1000);
5
+ document.cookie = "ct_trial_banner_closed=1; path=/; expires=" + ct_date.toUTCString();
6
+ });
7
+
8
  });
assets/js/cleantalk-comments-checkspam.js CHANGED
@@ -1,375 +1,375 @@
1
- // Printf for JS
2
- String.prototype.printf = function(){
3
- var formatted = this;
4
- for( var arg in arguments ) {
5
- var before_formatted = formatted.substring(0, formatted.indexOf("%s", 0));
6
- var after_formatted = formatted.substring(formatted.indexOf("%s", 0)+2, formatted.length);
7
- formatted = before_formatted + arguments[arg] + after_formatted;
8
- }
9
- return formatted;
10
- };
11
-
12
- // Flags
13
- var ct_working = false,
14
- ct_new_check = true,
15
- ct_cooling_down_flag = false,
16
- ct_close_animate = true;
17
- // Settings
18
- var ct_cool_down_time = 65000,
19
- ct_requests_counter = 0,
20
- ct_max_requests = 95;
21
- // Variables
22
- var ct_ajax_nonce = ctCommentsCheck.ct_ajax_nonce,
23
- ct_comments_total = 0,
24
- ct_comments_checked = 0,
25
- ct_comments_spam = 0,
26
- ct_comments_bad = 0,
27
- ct_unchecked = 'unset';
28
-
29
- function animate_comment(to,id){
30
- if(ct_close_animate){
31
- if(to==0.3){
32
- jQuery('#comment-'+id).fadeTo(200,to,function(){
33
- animate_comment(1,id)
34
- });
35
- }else{
36
- jQuery('#comment-'+id).fadeTo(200,to,function(){
37
- animate_comment(0.3,id)
38
- });
39
- }
40
- }else{
41
- ct_close_animate=true;
42
- }
43
- }
44
-
45
- function ct_clear_comments(){
46
- var data = {
47
- 'action': 'ajax_clear_comments',
48
- 'security': ct_ajax_nonce
49
- };
50
-
51
- jQuery.ajax({
52
- type: "POST",
53
- url: ajaxurl,
54
- data: data,
55
- success: function(msg){
56
- ct_send_comments();
57
- }
58
- });
59
- }
60
-
61
- //Continues the check after cooldown time
62
- //Called by ct_send_users();
63
- function ct_cooling_down_toggle(){
64
- ct_cooling_down_flag = false;
65
- ct_send_comments();
66
- ct_show_info();
67
- }
68
-
69
- function ct_send_comments(){
70
-
71
- if(ct_cooling_down_flag == true)
72
- return;
73
-
74
- if(ct_requests_counter >= ct_max_requests){
75
- setTimeout(ct_cooling_down_toggle, ct_cool_down_time);
76
- ct_requests_counter = 0;
77
- ct_cooling_down_flag = true;
78
- return;
79
- }else{
80
- ct_requests_counter++;
81
- }
82
-
83
- var data = {
84
- 'action': 'ajax_check_comments',
85
- 'security': ct_ajax_nonce,
86
- 'new_check': ct_new_check,
87
- 'unchecked': ct_unchecked
88
- };
89
-
90
- jQuery.ajax({
91
- type: "POST",
92
- url: ajaxurl,
93
- data: data,
94
- success: function(msg){
95
-
96
- msg = jQuery.parseJSON(msg);
97
-
98
- if(parseInt(msg.error)){
99
- ct_working=false;
100
- alert(msg.error_message);
101
- location.href='edit-comments.php?page=ct_check_spam&ct_worked=1';
102
- }else{
103
- ct_new_check = false;
104
- if(parseInt(msg.end) == 0){
105
- ct_comments_checked += msg.checked;
106
- ct_comments_spam += msg.spam;
107
- ct_comments_bad += msg.bad;
108
- ct_unchecked = ct_comments_total - ct_comments_checked - ct_comments_bad;
109
- var status_string = String(ctCommentsCheck.ct_status_string);
110
- var status_string = status_string.printf(ct_comments_total, ct_comments_checked, ct_comments_spam, ct_comments_bad);
111
- if(parseInt(ct_comments_spam) > 0)
112
- status_string += ctCommentsCheck.ct_status_string_warning;
113
- jQuery('#ct_checking_status').html(status_string);
114
- jQuery('#ct_error_message').hide();
115
- ct_send_comments();
116
- }else if(parseInt(msg.end) == 1){
117
- ct_working=false;
118
- jQuery('#ct_working_message').hide();
119
- location.href='edit-comments.php?page=ct_check_spam&ct_worked=1';
120
- }
121
- }
122
- },
123
- error: function(jqXHR, textStatus, errorThrown) {
124
- jQuery('#ct_error_message').show();
125
- jQuery('#cleantalk_ajax_error').html(textStatus);
126
- jQuery('#cleantalk_js_func').html('Check comments');
127
- setTimeout(ct_send_comments(), 3000);
128
- },
129
- timeout: 25000
130
- });
131
- }
132
- function ct_show_info(){
133
-
134
- if(ct_working){
135
-
136
- if(ct_cooling_down_flag == true){
137
- jQuery('#ct_cooling_notice').html('Waiting for API to cool down. (About a minute)');
138
- jQuery('#ct_cooling_notice').show();
139
- return;
140
- }else{
141
- jQuery('#ct_cooling_notice').hide();
142
- }
143
-
144
- setTimeout(ct_show_info, 3000);
145
-
146
- if(!ct_comments_total){
147
- var data = {
148
- 'action': 'ajax_info_comments',
149
- 'security': ct_ajax_nonce
150
- };
151
- jQuery.ajax({
152
- type: "POST",
153
- url: ajaxurl,
154
- data: data,
155
- success: function(msg){
156
- msg = jQuery.parseJSON(msg);
157
- jQuery('#ct_checking_status').html(msg.message);
158
- ct_comments_total = msg.total;
159
- },
160
- error: function(jqXHR, textStatus, errorThrown) {
161
- jQuery('#ct_error_message').show();
162
- jQuery('#cleantalk_ajax_error').html(textStatus);
163
- jQuery('#cleantalk_js_func').html('Check comments');
164
- setTimeout(ct_show_info(), 3000);
165
- },
166
- timeout: 15000
167
- });
168
- }
169
- }
170
- }
171
- function ct_insert_comments(){
172
- var data = {
173
- 'action': 'ajax_insert_comments',
174
- 'security': ct_ajax_nonce
175
- };
176
-
177
- jQuery.ajax({
178
- type: "POST",
179
- url: ajaxurl,
180
- data: data,
181
- success: function(msg){
182
- alert(ctCommentsCheck.ct_comments_added + ' ' + msg + ' ' + ctCommentsCheck.ct_comments_added_after);
183
- }
184
- });
185
- }
186
- function ct_delete_all(){
187
- var data = {
188
- 'action': 'ajax_delete_all',
189
- 'security': ct_ajax_nonce
190
- };
191
-
192
- jQuery.ajax({
193
- type: "POST",
194
- url: ajaxurl,
195
- data: data,
196
- success: function(msg){
197
- if(msg>0){
198
- jQuery('#cleantalk_comments_left').html(msg);
199
- ct_delete_all();
200
- }else{
201
- location.href='edit-comments.php?page=ct_check_spam&ct_worked=1';
202
- }
203
- },
204
- error: function(jqXHR, textStatus, errorThrown) {
205
- jQuery('#ct_error_message').show();
206
- jQuery('#cleantalk_ajax_error').html(textStatus);
207
- jQuery('#cleantalk_js_func').html('Check comments');
208
- setTimeout(ct_delete_all(), 3000);
209
- }
210
- });
211
- }
212
- function ct_delete_checked(){
213
- ids=Array();
214
- var cnt=0;
215
- jQuery('input[id^=cb-select-][id!=cb-select-all-1]').each(function(){
216
- if(jQuery(this).prop('checked')){
217
- ids[cnt]=jQuery(this).attr('id').substring(10);
218
- cnt++;
219
- }
220
- });
221
- var data = {
222
- 'action': 'ajax_delete_checked',
223
- 'security': ct_ajax_nonce,
224
- 'ids':ids
225
- };
226
-
227
- jQuery.ajax({
228
- type: "POST",
229
- url: ajaxurl,
230
- data: data,
231
- success: function(msg){
232
- location.href='edit-comments.php?page=ct_check_spam&ct_worked=1';
233
- //alert(msg);
234
- },
235
- error: function(jqXHR, textStatus, errorThrown) {
236
- jQuery('#ct_error_message').show();
237
- jQuery('#cleantalk_ajax_error').html(textStatus);
238
- jQuery('#cleantalk_js_func').html('Check comments');
239
- setTimeout(ct_delete_checked(), 3000);
240
- }
241
- });
242
- }
243
-
244
-
245
- jQuery(document).ready(function(){
246
-
247
- jQuery("#ct_check_spam_button").click(function(){
248
- jQuery('#ct_check_spam_button').hide();
249
- jQuery('#ct_info_message').hide();
250
- jQuery('#ct_check_comments_table').hide();
251
- jQuery('#ct_delete_all').hide();
252
- jQuery('div.pagination').hide();
253
- jQuery('#ct_delete_checked').hide();
254
- jQuery('#ct_working_message').show();
255
- jQuery('#ct_preloader').show();
256
-
257
- ct_working=true;
258
- ct_show_info();
259
- ct_clear_comments();
260
- });
261
-
262
- jQuery("#ct_insert_comments").click(function(){
263
- ct_insert_comments();
264
- });
265
- jQuery("#ct_delete_all").click(function(){
266
- if (!confirm(ctCommentsCheck.ct_confirm_deletion_all))
267
- return false;
268
-
269
- jQuery('#ct_checking_status').hide();
270
- jQuery('#ct_tools_buttons').hide();
271
- jQuery('#ct_search_info').hide();
272
- jQuery('#ct_check_comments_table').hide();
273
- jQuery('div.pagination').hide();
274
- jQuery('#ct_deleting_message').show();
275
- jQuery("html, body").animate({ scrollTop: 0 }, "slow");
276
- ct_delete_all();
277
- });
278
- jQuery("#ct_delete_checked").click(function(){
279
- if (!confirm(ctCommentsCheck.ct_confirm_deletion_checked))
280
- return false;
281
-
282
- ct_delete_checked();
283
- });
284
-
285
- jQuery(".cleantalk_delete_button").click(function(){
286
- id = jQuery(this).attr("data-id");
287
- ids=Array();
288
- ids[0]=id;
289
- var data = {
290
- 'action': 'ajax_delete_checked',
291
- 'security': ct_ajax_nonce,
292
- 'ids':ids
293
- };
294
- jQuery.ajax({
295
- type: "POST",
296
- url: ajaxurl,
297
- data: data,
298
- success: function(msg){
299
- ct_close_animate=false;
300
- jQuery("#comment-"+id).hide();
301
- jQuery("#comment-"+id).remove();
302
- ct_close_animate=true;
303
- }
304
- });
305
- });
306
- jQuery(".cleantalk_delete_button").click(function(){
307
- id = jQuery(this).attr("data-id");
308
- animate_comment(0.3, id);
309
- });
310
-
311
- //Show/hide action on mouse over/out
312
- jQuery(".cleantalk_comment").mouseover(function(){
313
- id = jQuery(this).attr("data-id");
314
- jQuery("#cleantalk_button_set_"+id).show();
315
- });
316
- jQuery(".cleantalk_comment").mouseout(function(){
317
- id = jQuery(this).attr("data-id");
318
- jQuery("#cleantalk_button_set_"+id).hide();
319
- });
320
-
321
- //Approve button
322
- jQuery(".cleantalk_delete_from_list_button").click(function(){
323
- var ct_id = jQuery(this).attr("data-id");
324
-
325
- // Approving
326
- var data = {
327
- 'action': 'ajax_ct_approve_comment',
328
- 'security': ct_ajax_nonce,
329
- 'id': ct_id
330
- };
331
- jQuery.ajax({
332
- type: "POST",
333
- url: ajaxurl,
334
- data: data,
335
- success: function(msg){
336
- jQuery("#comment-"+ct_id).fadeOut('slow', function(){
337
- jQuery("#comment-"+ct_id).remove();
338
- });
339
- },
340
- });
341
-
342
- // Positive feedback
343
- var data = {
344
- 'action': 'ct_feedback_comment',
345
- 'security': ct_ajax_nonce,
346
- 'comment_id': ct_id,
347
- 'comment_status': 'approve'
348
- };
349
- jQuery.ajax({
350
- type: "POST",
351
- url: ajaxurl,
352
- data: data,
353
- success: function(msg){
354
- if(msg == 1){
355
- // Success
356
- }
357
- if(msg == 0){
358
- // Error occurred
359
- }
360
- if(msg == 'no_hash'){
361
- // No hash
362
- }
363
- },
364
- error: function(jqXHR, textStatus, errorThrown) {
365
-
366
- },
367
- timeout: 5000
368
- });
369
- });
370
-
371
- //Default load actions
372
- if(location.href.match(/ct_check_spam/) && !location.href.match(/ct_worked=1/)){
373
- jQuery("#ct_check_spam_button").click();
374
- }
375
- });
1
+ // Printf for JS
2
+ String.prototype.printf = function(){
3
+ var formatted = this;
4
+ for( var arg in arguments ) {
5
+ var before_formatted = formatted.substring(0, formatted.indexOf("%s", 0));
6
+ var after_formatted = formatted.substring(formatted.indexOf("%s", 0)+2, formatted.length);
7
+ formatted = before_formatted + arguments[arg] + after_formatted;
8
+ }
9
+ return formatted;
10
+ };
11
+
12
+ // Flags
13
+ var ct_working = false,
14
+ ct_new_check = true,
15
+ ct_cooling_down_flag = false,
16
+ ct_close_animate = true;
17
+ // Settings
18
+ var ct_cool_down_time = 65000,
19
+ ct_requests_counter = 0,
20
+ ct_max_requests = 95;
21
+ // Variables
22
+ var ct_ajax_nonce = ctCommentsCheck.ct_ajax_nonce,
23
+ ct_comments_total = 0,
24
+ ct_comments_checked = 0,
25
+ ct_comments_spam = 0,
26
+ ct_comments_bad = 0,
27
+ ct_unchecked = 'unset';
28
+
29
+ function animate_comment(to,id){
30
+ if(ct_close_animate){
31
+ if(to==0.3){
32
+ jQuery('#comment-'+id).fadeTo(200,to,function(){
33
+ animate_comment(1,id)
34
+ });
35
+ }else{
36
+ jQuery('#comment-'+id).fadeTo(200,to,function(){
37
+ animate_comment(0.3,id)
38
+ });
39
+ }
40
+ }else{
41
+ ct_close_animate=true;
42
+ }
43
+ }
44
+
45
+ function ct_clear_comments(){
46
+ var data = {
47
+ 'action': 'ajax_clear_comments',
48
+ 'security': ct_ajax_nonce
49
+ };
50
+
51
+ jQuery.ajax({
52
+ type: "POST",
53
+ url: ajaxurl,
54
+ data: data,
55
+ success: function(msg){
56
+ ct_send_comments();
57
+ }
58
+ });
59
+ }
60
+
61
+ //Continues the check after cooldown time
62
+ //Called by ct_send_users();
63
+ function ct_cooling_down_toggle(){
64
+ ct_cooling_down_flag = false;
65
+ ct_send_comments();
66
+ ct_show_info();
67
+ }
68
+
69
+ function ct_send_comments(){
70
+
71
+ if(ct_cooling_down_flag == true)
72
+ return;
73
+
74
+ if(ct_requests_counter >= ct_max_requests){
75
+ setTimeout(ct_cooling_down_toggle, ct_cool_down_time);
76
+ ct_requests_counter = 0;
77
+ ct_cooling_down_flag = true;
78
+ return;
79
+ }else{
80
+ ct_requests_counter++;
81
+ }
82
+
83
+ var data = {
84
+ 'action': 'ajax_check_comments',
85
+ 'security': ct_ajax_nonce,
86
+ 'new_check': ct_new_check,
87
+ 'unchecked': ct_unchecked
88
+ };
89
+
90
+ jQuery.ajax({
91
+ type: "POST",
92
+ url: ajaxurl,
93
+ data: data,
94
+ success: function(msg){
95
+
96
+ msg = jQuery.parseJSON(msg);
97
+
98
+ if(parseInt(msg.error)){
99
+ ct_working=false;
100
+ alert(msg.error_message);
101
+ location.href='edit-comments.php?page=ct_check_spam&ct_worked=1';
102
+ }else{
103
+ ct_new_check = false;
104
+ if(parseInt(msg.end) == 0){
105
+ ct_comments_checked += msg.checked;
106
+ ct_comments_spam += msg.spam;
107
+ ct_comments_bad += msg.bad;
108
+ ct_unchecked = ct_comments_total - ct_comments_checked - ct_comments_bad;
109
+ var status_string = String(ctCommentsCheck.ct_status_string);
110
+ var status_string = status_string.printf(ct_comments_total, ct_comments_checked, ct_comments_spam, ct_comments_bad);
111
+ if(parseInt(ct_comments_spam) > 0)
112
+ status_string += ctCommentsCheck.ct_status_string_warning;
113
+ jQuery('#ct_checking_status').html(status_string);
114
+ jQuery('#ct_error_message').hide();
115
+ ct_send_comments();
116
+ }else if(parseInt(msg.end) == 1){
117
+ ct_working=false;
118
+ jQuery('#ct_working_message').hide();
119
+ location.href='edit-comments.php?page=ct_check_spam&ct_worked=1';
120
+ }
121
+ }
122
+ },
123
+ error: function(jqXHR, textStatus, errorThrown) {
124
+ jQuery('#ct_error_message').show();
125
+ jQuery('#cleantalk_ajax_error').html(textStatus);
126
+ jQuery('#cleantalk_js_func').html('Check comments');
127
+ setTimeout(ct_send_comments(), 3000);
128
+ },
129
+ timeout: 25000
130
+ });
131
+ }
132
+ function ct_show_info(){
133
+
134
+ if(ct_working){
135
+
136
+ if(ct_cooling_down_flag == true){
137
+ jQuery('#ct_cooling_notice').html('Waiting for API to cool down. (About a minute)');
138
+ jQuery('#ct_cooling_notice').show();
139
+ return;
140
+ }else{
141
+ jQuery('#ct_cooling_notice').hide();
142
+ }
143
+
144
+ setTimeout(ct_show_info, 3000);
145
+
146
+ if(!ct_comments_total){
147
+ var data = {
148
+ 'action': 'ajax_info_comments',
149
+ 'security': ct_ajax_nonce
150
+ };
151
+ jQuery.ajax({
152
+ type: "POST",
153
+ url: ajaxurl,
154
+ data: data,
155
+ success: function(msg){
156
+ msg = jQuery.parseJSON(msg);
157
+ jQuery('#ct_checking_status').html(msg.message);
158
+ ct_comments_total = msg.total;
159
+ },
160
+ error: function(jqXHR, textStatus, errorThrown) {
161
+ jQuery('#ct_error_message').show();
162
+ jQuery('#cleantalk_ajax_error').html(textStatus);
163
+ jQuery('#cleantalk_js_func').html('Check comments');
164
+ setTimeout(ct_show_info(), 3000);
165
+ },
166
+ timeout: 15000
167
+ });
168
+ }
169
+ }
170
+ }
171
+ function ct_insert_comments(){
172
+ var data = {
173
+ 'action': 'ajax_insert_comments',
174
+ 'security': ct_ajax_nonce
175
+ };
176
+
177
+ jQuery.ajax({
178
+ type: "POST",
179
+ url: ajaxurl,
180
+ data: data,
181
+ success: function(msg){
182
+ alert(ctCommentsCheck.ct_comments_added + ' ' + msg + ' ' + ctCommentsCheck.ct_comments_added_after);
183
+ }
184
+ });
185
+ }
186
+ function ct_delete_all(){
187
+ var data = {
188
+ 'action': 'ajax_delete_all',
189
+ 'security': ct_ajax_nonce
190
+ };
191
+
192
+ jQuery.ajax({
193
+ type: "POST",
194
+ url: ajaxurl,
195
+ data: data,
196
+ success: function(msg){
197
+ if(msg>0){
198
+ jQuery('#cleantalk_comments_left').html(msg);
199
+ ct_delete_all();
200
+ }else{
201
+ location.href='edit-comments.php?page=ct_check_spam&ct_worked=1';
202
+ }
203
+ },
204
+ error: function(jqXHR, textStatus, errorThrown) {
205
+ jQuery('#ct_error_message').show();
206
+ jQuery('#cleantalk_ajax_error').html(textStatus);
207
+ jQuery('#cleantalk_js_func').html('Check comments');
208
+ setTimeout(ct_delete_all(), 3000);
209
+ }
210
+ });
211
+ }
212
+ function ct_delete_checked(){
213
+ ids=Array();
214
+ var cnt=0;
215
+ jQuery('input[id^=cb-select-][id!=cb-select-all-1]').each(function(){
216
+ if(jQuery(this).prop('checked')){
217
+ ids[cnt]=jQuery(this).attr('id').substring(10);
218
+ cnt++;
219
+ }
220
+ });
221
+ var data = {
222
+ 'action': 'ajax_delete_checked',
223
+ 'security': ct_ajax_nonce,
224
+ 'ids':ids
225
+ };
226
+
227
+ jQuery.ajax({
228
+ type: "POST",
229
+ url: ajaxurl,
230
+ data: data,
231
+ success: function(msg){
232
+ location.href='edit-comments.php?page=ct_check_spam&ct_worked=1';
233
+ //alert(msg);
234
+ },
235
+ error: function(jqXHR, textStatus, errorThrown) {
236
+ jQuery('#ct_error_message').show();
237
+ jQuery('#cleantalk_ajax_error').html(textStatus);
238
+ jQuery('#cleantalk_js_func').html('Check comments');
239
+ setTimeout(ct_delete_checked(), 3000);
240
+ }
241
+ });
242
+ }
243
+
244
+
245
+ jQuery(document).ready(function(){
246
+
247
+ jQuery("#ct_check_spam_button").click(function(){
248
+ jQuery('#ct_check_spam_button').hide();
249
+ jQuery('#ct_info_message').hide();
250
+ jQuery('#ct_check_comments_table').hide();
251
+ jQuery('#ct_delete_all').hide();
252
+ jQuery('div.pagination').hide();
253
+ jQuery('#ct_delete_checked').hide();
254
+ jQuery('#ct_working_message').show();
255
+ jQuery('#ct_preloader').show();
256
+
257
+ ct_working=true;
258
+ ct_show_info();
259
+ ct_clear_comments();
260
+ });
261
+
262
+ jQuery("#ct_insert_comments").click(function(){
263
+ ct_insert_comments();
264
+ });
265
+ jQuery("#ct_delete_all").click(function(){
266
+ if (!confirm(ctCommentsCheck.ct_confirm_deletion_all))
267
+ return false;
268
+
269
+ jQuery('#ct_checking_status').hide();
270
+ jQuery('#ct_tools_buttons').hide();
271
+ jQuery('#ct_search_info').hide();
272
+ jQuery('#ct_check_comments_table').hide();
273
+ jQuery('div.pagination').hide();
274
+ jQuery('#ct_deleting_message').show();
275
+ jQuery("html, body").animate({ scrollTop: 0 }, "slow");
276
+ ct_delete_all();
277
+ });
278
+ jQuery("#ct_delete_checked").click(function(){
279
+ if (!confirm(ctCommentsCheck.ct_confirm_deletion_checked))
280
+ return false;
281
+
282
+ ct_delete_checked();
283
+ });
284
+
285
+ jQuery(".cleantalk_delete_button").click(function(){
286
+ id = jQuery(this).attr("data-id");
287
+ ids=Array();
288
+ ids[0]=id;
289
+ var data = {
290
+ 'action': 'ajax_delete_checked',
291
+ 'security': ct_ajax_nonce,
292
+ 'ids':ids
293
+ };
294
+ jQuery.ajax({
295
+ type: "POST",
296
+ url: ajaxurl,
297
+ data: data,
298
+ success: function(msg){
299
+ ct_close_animate=false;
300
+ jQuery("#comment-"+id).hide();
301
+ jQuery("#comment-"+id).remove();
302
+ ct_close_animate=true;
303
+ }
304
+ });
305
+ });
306
+ jQuery(".cleantalk_delete_button").click(function(){
307
+ id = jQuery(this).attr("data-id");
308
+ animate_comment(0.3, id);
309
+ });
310
+
311
+ //Show/hide action on mouse over/out
312
+ jQuery(".cleantalk_comment").mouseover(function(){
313
+ id = jQuery(this).attr("data-id");
314
+ jQuery("#cleantalk_button_set_"+id).show();
315
+ });
316
+ jQuery(".cleantalk_comment").mouseout(function(){
317
+ id = jQuery(this).attr("data-id");
318
+ jQuery("#cleantalk_button_set_"+id).hide();
319
+ });
320
+
321
+ //Approve button
322
+ jQuery(".cleantalk_delete_from_list_button").click(function(){
323
+ var ct_id = jQuery(this).attr("data-id");
324
+
325
+ // Approving
326
+ var data = {
327
+ 'action': 'ajax_ct_approve_comment',
328
+ 'security': ct_ajax_nonce,
329
+ 'id': ct_id
330
+ };
331
+ jQuery.ajax({
332
+ type: "POST",
333
+ url: ajaxurl,
334
+ data: data,
335
+ success: function(msg){
336
+ jQuery("#comment-"+ct_id).fadeOut('slow', function(){
337
+ jQuery("#comment-"+ct_id).remove();
338
+ });
339
+ },
340
+ });
341
+
342
+ // Positive feedback
343
+ var data = {
344
+ 'action': 'ct_feedback_comment',
345
+ 'security': ct_ajax_nonce,
346
+ 'comment_id': ct_id,
347
+ 'comment_status': 'approve'
348
+ };
349
+ jQuery.ajax({
350
+ type: "POST",
351
+ url: ajaxurl,
352
+ data: data,
353
+ success: function(msg){
354
+ if(msg == 1){
355
+ // Success
356
+ }
357
+ if(msg == 0){
358
+ // Error occurred
359
+ }
360
+ if(msg == 'no_hash'){
361
+ // No hash
362
+ }
363
+ },
364
+ error: function(jqXHR, textStatus, errorThrown) {
365
+
366
+ },
367
+ timeout: 5000
368
+ });
369
+ });
370
+
371
+ //Default load actions
372
+ if(location.href.match(/ct_check_spam/) && !location.href.match(/ct_worked=1/)){
373
+ jQuery("#ct_check_spam_button").click();
374
+ }
375
+ });
assets/js/cleantalk-comments-editscreen.js CHANGED
@@ -1,136 +1,136 @@
1
- function ct_is_email(str){
2
- return str.search(/.*@.*\..*/);
3
- }
4
- function ct_is_ip(str){
5
- return str.search(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/);
6
- }
7
-
8
- jQuery(document).ready(function(){
9
-
10
- /* Shows "Find spam users" Buttons */
11
- jQuery('#post-query-submit').after('<a href="edit-comments.php?page=ct_check_spam" class="button" style="margin:1px 0 0 0; display: inline-block;">'+ctCommentsScreen.spambutton_text+'</a>' +
12
- ' <a href="edit-comments.php?page=ct_check_spam&ct_worked=1" class="button" style="margin:1px 0 0 0; display: inline-block;">'+ctCommentsScreen.spambutton_text_show+'</a>&nbsp;');
13
-
14
- /* Shows link to blacklists near every email and IP address */
15
- if(parseInt(ctCommentsScreen.ct_show_check_links))
16
- jQuery('.column-author a, .comment-author a').each(function(){
17
- var ct_curr_str = jQuery(this).html();
18
- if(ct_is_email(ct_curr_str) != -1 || ct_is_ip(ct_curr_str) != -1){
19
- jQuery(this).after('&nbsp;<a href="https://cleantalk.org/blacklists/'+ct_curr_str+'" target="_blank" title="https://cleantalk.org/blacklists/'+ct_curr_str+'" class="ct_link_new_tab"><img src="'+ctCommentsScreen.ct_img_src_new_tab+'"></a>');
20
- }
21
- });
22
-
23
- /* Feedback for comments */
24
- var ct_comment_id;
25
-
26
- // For approved
27
- jQuery('span.approve').on('click', function(){
28
- var result = jQuery(this).children('a').attr('href');
29
- result = result.match(/^comment\.php\?.*c=(\d).*/);
30
- ct_comment_id = result[1];
31
- undo_comment_id = ct_comment_id;
32
- ct_send_feedback_request(ct_comment_id, 'approve', 0);
33
- });
34
-
35
- // For unapprove
36
- jQuery('span.unapprove').on('click', function(){
37
- var result = jQuery(this).children('a').attr('href');
38
- result = result.match(/^comment\.php\?.*c=(\d).*/);
39
- ct_comment_id = result[1];
40
- undo_comment_id = ct_comment_id;
41
- ct_send_feedback_request(ct_comment_id, 'spam', 0);
42
- });
43
-
44
- // For spammed
45
- jQuery('span.spam').on('click', function(){
46
- var result = jQuery(this).children('a').attr('href');
47
- result = result.match(/^comment\.php\?.*c=(\d).*/);
48
- ct_comment_id = result[1];
49
- undo_comment_id = ct_comment_id;
50
- ct_send_feedback_request(ct_comment_id, 'spam', 0);
51
-
52
- setTimeout(function(){
53
- jQuery('tr#undo-'+ct_comment_id+' span.unspam a').click(function(){
54
- var result = jQuery(this).attr('href');
55
- result = result.match(/^comment\.php\?.*&c=(\d).*/);
56
- ct_comment_id = result[1];
57
- ct_send_feedback_request(ct_comment_id, 'approve', 1);
58
- });
59
- }, 202);
60
-
61
- });
62
-
63
- // For unspammed
64
- jQuery('span.unspam').on('click', function(){
65
- var result = jQuery(this).children('a').attr('href');
66
- result = result.match(/^comment\.php\?.*c=(\d).*/);
67
- ct_comment_id = result[1];
68
- ct_send_feedback_request(ct_comment_id, 'approve', 0);
69
- });
70
-
71
- // For untrashed
72
- jQuery('span.untrash a').on('click', function(){
73
- var result = jQuery(this).attr('href');
74
- result = result.match(/^comment\.php\?.*c=(\d).*/);
75
- ct_comment_id = result[1];
76
- feedback_result = ct_send_feedback_request(ct_comment_id, 'approve', 0);
77
- });
78
- });
79
-
80
- // Send feedback to backend
81
- function ct_send_feedback_request(ct_comment_id, ct_comment_status, ct_undo){
82
-
83
- var data = {
84
- 'action': 'ct_feedback_comment',
85
- 'security': ctCommentsScreen.ct_ajax_nonce,
86
- 'comment_id': ct_comment_id,
87
- 'comment_status': ct_comment_status
88
- };
89
-
90
- jQuery.ajax({
91
- type: "POST",
92
- url: ajaxurl,
93
- data: data,
94
- success: function(msg){
95
- ct_feedback_message_output(ct_comment_id, ct_comment_status, msg, ct_undo);
96
- },
97
- error: function(jqXHR, textStatus, errorThrown) {
98
-
99
- },
100
- timeout: 5000
101
- });
102
- }
103
-
104
- // Outputs CT message about feedback
105
- function ct_feedback_message_output(ct_comment_id, ct_comment_status, ct_result, ct_undo){
106
- if(ct_result == 1){
107
- if(ct_comment_status == 'approve' && !ct_undo){
108
- jQuery('tr#comment-'+ct_comment_id)
109
- .html('')
110
- .show()
111
- .append("<td colspan='5'></td>").children('td')
112
- .css('background', 'rgba(110,240,110,0.7)')
113
- .append("<div class='spam-undo-inside'>"+ctCommentsScreen.ct_feedback_msg_whitelisted+" "+ctCommentsScreen.ct_feedback_msg+"</div>");
114
- }
115
- if(ct_comment_status == 'spam'){
116
- if(jQuery('tr').is('#undo-'+ct_comment_id)){
117
- jQuery('tr#undo-'+ct_comment_id)
118
- .css('background', 'rgba(240,110,110,0.7)');
119
- jQuery('tr#undo-'+ct_comment_id+' div.spam-undo-inside')
120
- .append(" "+ctCommentsScreen.ct_feedback_msg_blacklisted+" "+ctCommentsScreen.ct_feedback_msg);
121
- }else{
122
- jQuery('tr#comment-'+ct_comment_id)
123
- .html('')
124
- .show()
125
- .css('background', 'rgba(240,110,110,0.7)')
126
- .append("<td colspan='5'></td>").children('td')
127
- .append("<div class='spam-undo-inside'>"+ctCommentsScreen.ct_feedback_msg_blacklisted+" "+ctCommentsScreen.ct_feedback_msg+"</div>");
128
- }
129
- }
130
- }
131
- if(ct_result == 0){
132
- // Error occurred
133
- }if(ct_result == 'no_hash'){
134
- // No hash for this comment
135
- }
136
- }
1
+ function ct_is_email(str){
2
+ return str.search(/.*@.*\..*/);
3
+ }
4
+ function ct_is_ip(str){
5
+ return str.search(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/);
6
+ }
7
+
8
+ jQuery(document).ready(function(){
9
+
10
+ /* Shows "Find spam users" Buttons */
11
+ jQuery('#post-query-submit').after('<a href="edit-comments.php?page=ct_check_spam" class="button" style="margin:1px 0 0 0; display: inline-block;">'+ctCommentsScreen.spambutton_text+'</a>' +
12
+ ' <a href="edit-comments.php?page=ct_check_spam&ct_worked=1" class="button" style="margin:1px 0 0 0; display: inline-block;">'+ctCommentsScreen.spambutton_text_show+'</a>&nbsp;');
13
+
14
+ /* Shows link to blacklists near every email and IP address */
15
+ if(parseInt(ctCommentsScreen.ct_show_check_links))
16
+ jQuery('.column-author a, .comment-author a').each(function(){
17
+ var ct_curr_str = jQuery(this).html();
18
+ if(ct_is_email(ct_curr_str) != -1 || ct_is_ip(ct_curr_str) != -1){
19
+ jQuery(this).after('&nbsp;<a href="https://cleantalk.org/blacklists/'+ct_curr_str+'" target="_blank" title="https://cleantalk.org/blacklists/'+ct_curr_str+'" class="ct_link_new_tab"><img src="'+ctCommentsScreen.ct_img_src_new_tab+'"></a>');
20
+ }
21
+ });
22
+
23
+ /* Feedback for comments */
24
+ var ct_comment_id;
25
+
26
+ // For approved
27
+ jQuery('span.approve').on('click', function(){
28
+ var result = jQuery(this).children('a').attr('href');
29
+ result = result.match(/^comment\.php\?.*c=(\d).*/);
30
+ ct_comment_id = result[1];
31
+ undo_comment_id = ct_comment_id;
32
+ ct_send_feedback_request(ct_comment_id, 'approve', 0);
33
+ });
34
+
35
+ // For unapprove
36
+ jQuery('span.unapprove').on('click', function(){
37
+ var result = jQuery(this).children('a').attr('href');
38
+ result = result.match(/^comment\.php\?.*c=(\d).*/);
39
+ ct_comment_id = result[1];
40
+ undo_comment_id = ct_comment_id;
41
+ ct_send_feedback_request(ct_comment_id, 'spam', 0);
42
+ });
43
+
44
+ // For spammed
45
+ jQuery('span.spam').on('click', function(){
46
+ var result = jQuery(this).children('a').attr('href');
47
+ result = result.match(/^comment\.php\?.*c=(\d).*/);
48
+ ct_comment_id = result[1];
49
+ undo_comment_id = ct_comment_id;
50
+ ct_send_feedback_request(ct_comment_id, 'spam', 0);
51
+
52
+ setTimeout(function(){
53
+ jQuery('tr#undo-'+ct_comment_id+' span.unspam a').click(function(){
54
+ var result = jQuery(this).attr('href');
55
+ result = result.match(/^comment\.php\?.*&c=(\d).*/);
56
+ ct_comment_id = result[1];
57
+ ct_send_feedback_request(ct_comment_id, 'approve', 1);
58
+ });
59
+ }, 202);
60
+
61
+ });
62
+
63
+ // For unspammed
64
+ jQuery('span.unspam').on('click', function(){
65
+ var result = jQuery(this).children('a').attr('href');
66
+ result = result.match(/^comment\.php\?.*c=(\d).*/);
67
+ ct_comment_id = result[1];
68
+ ct_send_feedback_request(ct_comment_id, 'approve', 0);
69
+ });
70
+
71
+ // For untrashed
72
+ jQuery('span.untrash a').on('click', function(){
73
+ var result = jQuery(this).attr('href');
74
+ result = result.match(/^comment\.php\?.*c=(\d).*/);
75
+ ct_comment_id = result[1];
76
+ feedback_result = ct_send_feedback_request(ct_comment_id, 'approve', 0);
77
+ });
78
+ });
79
+
80
+ // Send feedback to backend
81
+ function ct_send_feedback_request(ct_comment_id, ct_comment_status, ct_undo){
82
+
83
+ var data = {
84
+ 'action': 'ct_feedback_comment',
85
+ 'security': ctCommentsScreen.ct_ajax_nonce,
86
+ 'comment_id': ct_comment_id,
87
+ 'comment_status': ct_comment_status
88
+ };
89
+
90
+ jQuery.ajax({
91
+ type: "POST",
92
+ url: ajaxurl,
93
+ data: data,
94
+ success: function(msg){
95
+ ct_feedback_message_output(ct_comment_id, ct_comment_status, msg, ct_undo);
96
+ },
97
+ error: function(jqXHR, textStatus, errorThrown) {
98
+
99
+ },
100
+ timeout: 5000
101
+ });
102
+ }
103
+
104
+ // Outputs CT message about feedback
105
+ function ct_feedback_message_output(ct_comment_id, ct_comment_status, ct_result, ct_undo){
106
+ if(ct_result == 1){
107
+ if(ct_comment_status == 'approve' && !ct_undo){
108
+ jQuery('tr#comment-'+ct_comment_id)
109
+ .html('')
110
+ .show()
111
+ .append("<td colspan='5'></td>").children('td')
112
+ .css('background', 'rgba(110,240,110,0.7)')
113
+ .append("<div class='spam-undo-inside'>"+ctCommentsScreen.ct_feedback_msg_whitelisted+" "+ctCommentsScreen.ct_feedback_msg+"</div>");
114
+ }
115
+ if(ct_comment_status == 'spam'){
116
+ if(jQuery('tr').is('#undo-'+ct_comment_id)){
117
+ jQuery('tr#undo-'+ct_comment_id)
118
+ .css('background', 'rgba(240,110,110,0.7)');
119
+ jQuery('tr#undo-'+ct_comment_id+' div.spam-undo-inside')
120
+ .append(" "+ctCommentsScreen.ct_feedback_msg_blacklisted+" "+ctCommentsScreen.ct_feedback_msg);
121
+ }else{
122
+ jQuery('tr#comment-'+ct_comment_id)
123
+ .html('')
124
+ .show()
125
+ .css('background', 'rgba(240,110,110,0.7)')
126
+ .append("<td colspan='5'></td>").children('td')
127
+ .append("<div class='spam-undo-inside'>"+ctCommentsScreen.ct_feedback_msg_blacklisted+" "+ctCommentsScreen.ct_feedback_msg+"</div>");
128
+ }
129
+ }
130
+ }
131
+ if(ct_result == 0){
132
+ // Error occurred
133
+ }if(ct_result == 'no_hash'){
134
+ // No hash for this comment
135
+ }
136
+ }
assets/js/cleantalk-dashboard-widget.js CHANGED
@@ -1,56 +1,56 @@
1
- jQuery(document).ready(function(){
2
-
3
- // Set "refresh" link handler
4
- jQuery(".ct_widget_refresh_link").on('click', function(){
5
- jQuery('.ct_preloader').show();
6
- setTimeout(function(){window.scrollTo(0, jQuery('#ct_widget_wrapper').offset().top - 130);}, 1);
7
- setTimeout(function(){jQuery("#ct_refresh_form").submit();}, 2500);
8
- });
9
-
10
- if(location.hash == '#ct_widget')
11
- setTimeout(function(){window.scrollTo(0, jQuery('#ct_widget_wrapper').offset().top - 130);}, 1);
12
-
13
- // Fixing default wrapper style
14
- jQuery("#ct_widget_wrapper").parent().css('padding', 0);
15
-
16
-
17
- // Chart
18
- var ct_chart = jQuery("#ct_widget_chart"),
19
- locale = navigator.language || navigator.userLanguage;
20
-
21
- function ctParseData(date){
22
- var date_formatter = new Intl.DateTimeFormat(locale, {
23
- month: "short",
24
- day: "numeric"
25
- });
26
- date.forEach(function(d){
27
- d[0] = Date.parse(d[0]);
28
- d[0] = date_formatter.format(d[0]);
29
- });
30
- }
31
-
32
- google.charts.load('current', {packages:['corechart', 'bar']});
33
- google.charts.setOnLoadCallback(drawStuff);
34
-
35
- function drawStuff() {
36
- var data = new google.visualization.DataTable();
37
- data.addColumn('string', 'Spam Blocked');
38
- data.addColumn('number', 'Frequency');
39
-
40
- ctParseData(ct_chart_data);
41
- data.addRows(ct_chart_data);
42
-
43
- var options = {
44
- width: jQuery(".ct_widget_block").first().width(),
45
- height: 300,
46
- colors: ['steelblue'],
47
- legend: 'none',
48
- bar: {groupWidth: '95%'},
49
- chartArea:{left:30,top:20,width:'93%',height:'80%'},
50
- vAxis: { gridlines: { count: 5 } }
51
- };
52
-
53
- var chart = new google.visualization.ColumnChart(document.getElementById('ct_widget_chart'));
54
- chart.draw(data, options);
55
- };
56
  });
1
+ jQuery(document).ready(function(){
2
+
3
+ // Set "refresh" link handler
4
+ jQuery(".ct_widget_refresh_link").on('click', function(){
5
+ jQuery('.ct_preloader').show();
6
+ setTimeout(function(){window.scrollTo(0, jQuery('#ct_widget_wrapper').offset().top - 130);}, 1);
7
+ setTimeout(function(){jQuery("#ct_refresh_form").submit();}, 2500);
8
+ });
9
+
10
+ if(location.hash == '#ct_widget')
11
+ setTimeout(function(){window.scrollTo(0, jQuery('#ct_widget_wrapper').offset().top - 130);}, 1);
12
+
13
+ // Fixing default wrapper style
14
+ jQuery("#ct_widget_wrapper").parent().css('padding', 0);
15
+
16
+
17
+ // Chart
18
+ var ct_chart = jQuery("#ct_widget_chart"),
19
+ locale = navigator.language || navigator.userLanguage;
20
+
21
+ function ctParseData(date){
22
+ var date_formatter = new Intl.DateTimeFormat(locale, {
23
+ month: "short",
24
+ day: "numeric"
25
+ });
26
+ date.forEach(function(d){
27
+ d[0] = Date.parse(d[0]);
28
+ d[0] = date_formatter.format(d[0]);
29
+ });
30
+ }
31
+
32
+ google.charts.load('current', {packages:['corechart', 'bar']});
33
+ google.charts.setOnLoadCallback(drawStuff);
34
+
35
+ function drawStuff() {
36
+ var data = new google.visualization.DataTable();
37
+ data.addColumn('string', 'Spam Blocked');
38
+ data.addColumn('number', 'Frequency');
39
+
40
+ ctParseData(ct_chart_data);
41
+ data.addRows(ct_chart_data);
42
+
43
+ var options = {
44
+ width: jQuery(".ct_widget_block").first().width(),
45
+ height: 300,
46
+ colors: ['steelblue'],
47
+ legend: 'none',
48
+ bar: {groupWidth: '95%'},
49
+ chartArea:{left:30,top:20,width:'93%',height:'80%'},
50
+ vAxis: { gridlines: { count: 5 } }
51
+ };
52
+
53
+ var chart = new google.visualization.ColumnChart(document.getElementById('ct_widget_chart'));
54
+ chart.draw(data, options);
55
+ };
56
  });
assets/js/cleantalk-debug-ajax.js CHANGED
@@ -1,14 +1,14 @@
1
- jQuery(document).ready(function(){
2
-
3
- console.log('CT debug');
4
-
5
- // Debug. Console all AJAX requests.
6
- jQuery(document).ajaxComplete(function(e, xhr, settings, data) {
7
- console.log("Success:")
8
- console.log(e);
9
- console.log(xhr);
10
- console.log(settings);
11
- console.log(data);
12
- });
13
-
14
  });
1
+ jQuery(document).ready(function(){
2
+
3
+ console.log('CT debug');
4
+
5
+ // Debug. Console all AJAX requests.
6
+ jQuery(document).ajaxComplete(function(e, xhr, settings, data) {
7
+ console.log("Success:")
8
+ console.log(e);
9
+ console.log(xhr);
10
+ console.log(settings);
11
+ console.log(data);
12
+ });
13
+
14
  });
assets/js/cleantalk-public.js CHANGED
@@ -1,79 +1,79 @@
1
- jQuery(document).ready(function(){
2
-
3
- // Set background-color similar to parents
4
- var ct_current_wrapper = jQuery('.ct_comment_info').parent(),
5
- ct_current_background_color;
6
- for(var i=0; i < 30; i++){
7
- if(ct_current_wrapper.css('background-color') == 'rgba(0, 0, 0, 0)' || i == 29)
8
- ct_current_wrapper = ct_current_wrapper.parent();
9
- else{
10
- jQuery('.ct_comment_info').css('background', ct_current_wrapper.css('background-color'));
11
- break;
12
- }
13
- }
14
-
15
- jQuery('.ct_this_is').on('click', function(){
16
-
17
- var ct_current_button = jQuery(this),
18
- ct_feedback_wrap = jQuery(this).siblings('.ct_feedback_wrap'),
19
- ct_feedback_msg = jQuery('.ct_feedback_msg'),
20
- ct_comment_status;
21
-
22
- if(ct_current_button.hasClass('ct_this_is_spam'))
23
- ct_comment_status = 'spam';
24
- else
25
- ct_comment_status = 'approve';
26
-
27
- var data = {
28
- 'action': 'ct_feedback_comment',
29
- 'security': ctPublic.ct_ajax_nonce,
30
- 'comment_id': ct_current_button.attr('commentid'),
31
- 'comment_status': ct_comment_status,
32
- 'change_status': 1
33
- };
34
-
35
- jQuery.ajax({
36
- type: "POST",
37
- url: ctPublic.ajaxurl,
38
- data: data,
39
- success: function(msg){
40
- ct_current_button.hide();
41
- ct_current_button.siblings('span.ct_this_is').show();
42
-
43
- jQuery('.ct_feedback_result').hide();
44
- if(ct_comment_status == 'approve')
45
- jQuery('.ct_feedback_result_not_spam').show();
46
- else
47
- jQuery('.ct_feedback_result_spam').show();
48
-
49
- if(msg == 1){
50
- ct_feedback_msg.addClass('ct_feedback_success');
51
- ct_feedback_msg.html(ctPublic.ct_feedback_msg);
52
- }else if(msg == 0){
53
- // Error occurred
54
- ct_feedback_msg.addClass('ct_feedback_error');
55
- ct_feedback_msg.html(ctPublic.ct_feedback_error);
56
- }else if(msg == 'no_hash'){
57
- // No hash for this comment
58
- ct_feedback_msg.addClass('ct_feedback_no_hash');
59
- ct_feedback_msg.html(ctPublic.ct_feedback_no_hash);
60
- }
61
- // Hidding feedback message for every message type
62
- ct_feedback_wrap.show();
63
- ct_feedback_wrap.css('display', 'inline-block');
64
-
65
- var ct_timeout_id = ct_feedback_wrap.data('interval_id');
66
- clearInterval(ct_timeout_id);
67
- ct_timeout_id = setTimeout(function(){
68
- ct_feedback_wrap.fadeOut(1000);
69
- }, 5000);
70
- ct_feedback_wrap.data('interval_id', ct_timeout_id);
71
- },
72
- error: function(jqXHR, textStatus, errorThrown) {
73
-
74
- },
75
- timeout: 5000
76
- });
77
- });
78
-
79
  });
1
+ jQuery(document).ready(function(){
2
+
3
+ // Set background-color similar to parents
4
+ var ct_current_wrapper = jQuery('.ct_comment_info').parent(),
5
+ ct_current_background_color;
6
+ for(var i=0; i < 30; i++){
7
+ if(ct_current_wrapper.css('background-color') == 'rgba(0, 0, 0, 0)' || i == 29)
8
+ ct_current_wrapper = ct_current_wrapper.parent();
9
+ else{
10
+ jQuery('.ct_comment_info').css('background', ct_current_wrapper.css('background-color'));
11
+ break;
12
+ }
13
+ }
14
+
15
+ jQuery('.ct_this_is').on('click', function(){
16
+
17
+ var ct_current_button = jQuery(this),
18
+ ct_feedback_wrap = jQuery(this).siblings('.ct_feedback_wrap'),
19
+ ct_feedback_msg = jQuery('.ct_feedback_msg'),
20
+ ct_comment_status;
21
+
22
+ if(ct_current_button.hasClass('ct_this_is_spam'))
23
+ ct_comment_status = 'spam';
24
+ else
25
+ ct_comment_status = 'approve';
26
+
27
+ var data = {
28
+ 'action': 'ct_feedback_comment',
29
+ 'security': ctPublic.ct_ajax_nonce,
30
+ 'comment_id': ct_current_button.attr('commentid'),
31
+ 'comment_status': ct_comment_status,
32
+ 'change_status': 1
33
+ };
34
+
35
+ jQuery.ajax({
36
+ type: "POST",
37
+ url: ctPublic.ajaxurl,
38
+ data: data,
39
+ success: function(msg){
40
+ ct_current_button.hide();
41
+ ct_current_button.siblings('span.ct_this_is').show();
42
+
43
+ jQuery('.ct_feedback_result').hide();
44
+ if(ct_comment_status == 'approve')
45
+ jQuery('.ct_feedback_result_not_spam').show();
46
+ else
47
+ jQuery('.ct_feedback_result_spam').show();
48
+
49
+ if(msg == 1){
50
+ ct_feedback_msg.addClass('ct_feedback_success');
51
+ ct_feedback_msg.html(ctPublic.ct_feedback_msg);
52
+ }else if(msg == 0){
53
+ // Error occurred
54
+ ct_feedback_msg.addClass('ct_feedback_error');
55
+ ct_feedback_msg.html(ctPublic.ct_feedback_error);
56
+ }else if(msg == 'no_hash'){
57
+ // No hash for this comment
58
+ ct_feedback_msg.addClass('ct_feedback_no_hash');
59
+ ct_feedback_msg.html(ctPublic.ct_feedback_no_hash);
60
+ }
61
+ // Hidding feedback message for every message type
62
+ ct_feedback_wrap.show();
63
+ ct_feedback_wrap.css('display', 'inline-block');
64
+
65
+ var ct_timeout_id = ct_feedback_wrap.data('interval_id');
66
+ clearInterval(ct_timeout_id);
67
+ ct_timeout_id = setTimeout(function(){
68
+ ct_feedback_wrap.fadeOut(1000);
69
+ }, 5000);
70
+ ct_feedback_wrap.data('interval_id', ct_timeout_id);
71
+ },
72
+ error: function(jqXHR, textStatus, errorThrown) {
73
+
74
+ },
75
+ timeout: 5000
76
+ });
77
+ });
78
+
79
  });
assets/js/cleantalk-users-checkspam.js CHANGED
@@ -1,422 +1,422 @@
1
- // Printf for JS
2
- String.prototype.printf = function(){
3
- var formatted = this;
4
- for( var arg in arguments ) {
5
- var before_formatted = formatted.substring(0, formatted.indexOf("%s", 0));
6
- var after_formatted = formatted.substring(formatted.indexOf("%s", 0)+2, formatted.length);
7
- formatted = before_formatted + arguments[arg] + after_formatted;
8
- }
9
- return formatted;
10
- };
11
-
12
- // Flags
13
- var ct_working = false,
14
- ct_new_check = true,
15
- ct_cooling_down_flag = false,
16
- ct_close_animate = true;
17
- // Settings
18
- var ct_cool_down_time = 65000,
19
- ct_requests_counter = 0,
20
- ct_max_requests = 95;
21
- // Variables
22
- var ct_ajax_nonce = ctUsersCheck.ct_ajax_nonce,
23
- ct_users_total = 0,
24
- ct_users_checked = 0,
25
- ct_users_spam = 0,
26
- ct_users_bad = 0,
27
- ct_unchecked = 'unset';
28
-
29
- function animate_comment(to,id){
30
- if(ct_close_animate){
31
- if(to==0.3){
32
- jQuery('#comment-'+id).fadeTo(200,to,function(){
33
- animate_comment(1,id)
34
- });
35
- }else{
36
- jQuery('#comment-'+id).fadeTo(200,to,function(){
37
- animate_comment(0.3,id)
38
- });
39
- }
40
- }else{
41
- ct_close_animate=true;
42
- }
43
- }
44
-
45
- function ct_clear_users(){
46
- var data = {
47
- 'action': 'ajax_clear_users',
48
- 'security': ct_ajax_nonce
49
- };
50
-
51
- jQuery.ajax({
52
- type: "POST",
53
- url: ajaxurl,
54
- data: data,
55
- success: function(msg){
56
- ct_send_users();
57
- }
58
- });
59
- }
60
-
61
- //Continues the check after cooldown time
62
- //Called by ct_send_users();
63
- function ct_cooling_down_toggle(){
64
- ct_cooling_down_flag = false;
65
- ct_send_users();
66
- ct_show_users_info();
67
- }
68
-
69
- function ct_send_users(){
70
-
71
- if(ct_cooling_down_flag == true)
72
- return;
73
-
74
- if(ct_requests_counter >= ct_max_requests){
75
- setTimeout(ct_cooling_down_toggle, ct_cool_down_time);
76
- ct_requests_counter = 0;
77
- ct_cooling_down_flag = true;
78
- return;
79
- }else{
80
- ct_requests_counter++;
81
- }
82
-
83
- var data = {
84
- 'action': 'ajax_check_users',
85
- 'security': ct_ajax_nonce,
86
- 'new_check': ct_new_check,
87
- 'unchecked': ct_unchecked
88
- };
89
-
90
- jQuery.ajax({
91
- type: "POST",
92
- url: ajaxurl,
93
- data: data,
94
- success: function(msg){
95
-
96
- msg = jQuery.parseJSON(msg);
97
-
98
- if(parseInt(msg.error)){
99
- ct_working=false;
100
- alert(msg.error_message);
101
- location.href='users.php?page=ct_check_users&ct_worked=1';
102
- }else{
103
- ct_new_check = false;
104
- if(parseInt(msg.end) == 0){
105
- ct_users_checked += msg.checked;
106
- ct_users_spam += msg.spam;
107
- ct_users_bad += msg.bad;
108
- ct_unchecked = ct_users_total - ct_users_checked - ct_users_bad;
109
- var status_string = String(ctUsersCheck.ct_status_string);
110
- var status_string = status_string.printf(ct_users_total, ct_users_checked, ct_users_spam, ct_users_bad);
111
- if(parseInt(ct_users_spam) > 0)
112
- status_string += ctUsersCheck.ct_status_string_warning;
113
- jQuery('#ct_checking_users_status').html(status_string);
114
- jQuery('#ct_error_message').hide();
115
- ct_send_users();
116
- }else if(parseInt(msg.end) == 1){
117
- ct_working=false;
118
- jQuery('#ct_working_message').hide();
119
- location.href='users.php?page=ct_check_users&ct_worked=1';
120
- }
121
- }
122
- },
123
- error: function(jqXHR, textStatus, errorThrown) {
124
- jQuery('#ct_error_message').show();
125
- jQuery('#cleantalk_ajax_error').html(textStatus);
126
- jQuery('#cleantalk_js_func').html('Check users');
127
- setTimeout(ct_send_users(), 3000);
128
- },
129
- timeout: 15000
130
- });
131
- }
132
- function ct_show_users_info(){
133
-
134
- if(ct_working){
135
-
136
- if(ct_cooling_down_flag == true){
137
- jQuery('#ct_cooling_notice').html('Waiting for API to cool down. (About a minute)');
138
- jQuery('#ct_cooling_notice').show();
139
- return;
140
- }else{
141
- jQuery('#ct_cooling_notice').hide();
142
- }
143
-
144
- setTimeout(ct_show_users_info, 3000);
145
-
146
- if(!ct_users_total){
147
- var data = {
148
- 'action': 'ajax_info_users',
149
- 'security': ct_ajax_nonce
150
- };
151
- jQuery.ajax({
152
- type: "POST",
153
- url: ajaxurl,
154
- data: data,
155
- success: function(msg){
156
- msg = jQuery.parseJSON(msg);
157
- jQuery('#ct_checking_users_status').html(msg.message);
158
- ct_users_total = msg.total;
159
- },
160
- error: function (jqXHR, textStatus, errorThrown){
161
- jQuery('#ct_error_message').show();
162
- jQuery('#cleantalk_ajax_error').html(textStatus);
163
- jQuery('#cleantalk_js_func').html('Show users');
164
- setTimeout(ct_show_users_info(), 3000);
165
- },
166
- timeout: 15000
167
- });
168
- }
169
- }
170
- }
171
- function ct_insert_users(){
172
-
173
- var data = {
174
- 'action': 'ajax_insert_users',
175
- 'security': ct_ajax_nonce
176
- };
177
-
178
- jQuery.ajax({
179
- type: "POST",
180
- url: ajaxurl,
181
- data: data,
182
- success: function(msg){
183
- alert(ctUsersCheck.ct_inserted + ' ' + msg + ' ' + ctUsersCheck.ct_iusers);
184
- }
185
- });
186
- }
187
- function ct_delete_all_users(){
188
-
189
- var data = {
190
- 'action': 'ajax_delete_all_users',
191
- 'security': ct_ajax_nonce
192
- };
193
-
194
- jQuery.ajax({
195
- type: "POST",
196
- url: ajaxurl,
197
- data: data,
198
- success: function(msg){
199
- if(msg>0){
200
- jQuery('#cleantalk_users_left').html(msg);
201
- ct_delete_all_users();
202
- }else{
203
- location.href='users.php?page=ct_check_users&ct_worked=1';
204
- }
205
- },
206
- error: function(jqXHR, textStatus, errorThrown) {
207
- jQuery('#ct_error_message').show();
208
- jQuery('#cleantalk_ajax_error').html(textStatus);
209
- jQuery('#cleantalk_js_func').html('All users deleteion');
210
- setTimeout(ct_delete_all_users(), 3000);
211
- },
212
- timeout: 25000
213
- });
214
- }
215
- function ct_delete_checked_users(){
216
-
217
- ids=Array();
218
- var cnt=0;
219
- jQuery('input[id^=cb-select-][id!=cb-select-all-1]').each(function(){
220
- if(jQuery(this).prop('checked')){
221
- ids[cnt]=jQuery(this).attr('id').substring(10);
222
- cnt++;
223
- }
224
- });
225
- var data = {
226
- 'action': 'ajax_delete_checked_users',
227
- 'security': ct_ajax_nonce,
228
- 'ids':ids
229
- };
230
-
231
- jQuery.ajax({
232
- type: "POST",
233
- url: ajaxurl,
234
- data: data,
235
- success: function(msg){
236
- location.href='users.php?page=ct_check_users&ct_worked=1';
237
- //alert(msg);
238
- },
239
- error: function(jqXHR, textStatus, errorThrown) {
240
- jQuery('#ct_error_message').show();
241
- jQuery('#cleantalk_ajax_error').html(textStatus);
242
- jQuery('#cleantalk_js_func').html('All users deleteion');
243
- setTimeout(ct_delete_checked_users(), 3000);
244
- },
245
- timeout: 15000
246
- });
247
- return false;
248
- }
249
-
250
- jQuery(document).ready(function(){
251
-
252
- jQuery(".cleantalk_delete_user_button").click(function(){
253
- id = jQuery(this).attr("data-id");
254
- ids=Array();
255
- ids[0]=id;
256
- var data = {
257
- 'action': 'ajax_delete_checked_users',
258
- 'security': ct_ajax_nonce,
259
- 'ids':ids
260
- };
261
- jQuery.ajax({
262
- type: "POST",
263
- url: ajaxurl,
264
- data: data,
265
- success: function(msg){
266
- ct_close_animate=false;
267
- jQuery("#comment-"+id).hide();
268
- jQuery("#comment-"+id).remove();
269
- ct_close_animate=true;
270
- },
271
- timeout: 15000
272
- });
273
- });
274
-
275
- jQuery(".cleantalk_delete_user_button").click(function(){
276
- id = jQuery(this).attr("data-id");
277
- animate_comment(0.3, id);
278
- });
279
-
280
- // Check users
281
- jQuery("#ct_check_users_button").click(function(){
282
- // jQuery('#ct_checking_users_status').html('');
283
- jQuery('#ct_delete_checked_users').hide();
284
- jQuery('#ct_check_users_table').hide();
285
- jQuery('#ct_check_users_button').hide();
286
- jQuery('#ct_delete_all_users').hide();
287
- jQuery('#ct_get_csv_file').hide();
288
- jQuery('div.pagination').hide();
289
- jQuery('#ct_info_message').hide();
290
- jQuery('#ct_working_message').show();
291
- jQuery('#ct_preloader').show();
292
- ct_working=true;
293
- ct_clear_users();
294
- ct_show_users_info();
295
- });
296
-
297
- jQuery("#ct_insert_users").click(function(){
298
- ct_insert_users();
299
- });
300
-
301
- jQuery("#ct_stop_deletion").click(function(){
302
- //window.location.reload();
303
- window.location.href='users.php?page=ct_check_users&ct_worked=1';
304
- });
305
-
306
- // Delete all spam users
307
- jQuery("#ct_delete_all_users").click(function(){
308
- if (!confirm(ctUsersCheck.ct_confirm_deletion_all))
309
- return false;
310
- jQuery('#ct_checking_users_status').hide();
311
- jQuery('#ct_check_users_table').hide();
312
- jQuery('#ct_tools_buttons').hide();
313
- jQuery('#ct_info_message').hide();
314
- jQuery('#ct_ajax_info_users').hide();
315
- jQuery('#ct_check_users_button').hide();
316
- jQuery('#ct_search_info').hide();
317
- jQuery('div.pagination').hide();
318
- jQuery('#ct_deleting_message').show();
319
- jQuery('#ct_preloader').show();
320
- jQuery('#ct_stop_deletion').show();
321
- jQuery("html, body").animate({ scrollTop: 0 }, "slow");
322
- ct_delete_all_users();
323
- });
324
- jQuery("#ct_delete_checked_users").click(function(){
325
- if (!confirm(ctUsersCheck.ct_confirm_deletion_checked))
326
- return false;
327
-
328
- ct_delete_checked_users();
329
- });
330
- jQuery(".cleantalk_user").mouseover(function(){
331
- id = jQuery(this).attr("data-id");
332
- jQuery("#cleantalk_delete_user_"+id).show();
333
- });
334
- jQuery(".cleantalk_user").mouseout(function(){
335
- id = jQuery(this).attr("data-id");
336
- jQuery("#cleantalk_delete_user_"+id).hide();
337
- });
338
-
339
- //Show/hide action on mouse over/out
340
- jQuery(".cleantalk_user").mouseover(function(){
341
- id = jQuery(this).attr("data-id");
342
- jQuery("#cleantalk_button_set_"+id).show();
343
- });
344
- jQuery(".cleantalk_user").mouseout(function(){
345
- id = jQuery(this).attr("data-id");
346
- jQuery("#cleantalk_button_set_"+id).hide();
347
- });
348
-
349
- //Approve button
350
- jQuery(".cleantalk_delete_from_list_button").click(function(){
351
- ct_id = jQuery(this).attr("data-id");
352
- var data = {
353
- 'action': 'ajax_ct_approve_user',
354
- 'security': ct_ajax_nonce,
355
- 'id': ct_id
356
- };
357
- jQuery.ajax({
358
- type: "POST",
359
- url: ajaxurl,
360
- data: data,
361
- success: function(msg){
362
- jQuery("#comment-"+ct_id).fadeOut('slow', function(){
363
- jQuery("#comment-"+ct_id).remove();
364
- });
365
- },
366
- });
367
-
368
- // Positive feedback
369
- var data = {
370
- 'action': 'ct_feedback_user',
371
- 'security': ct_ajax_nonce,
372
- 'user_id': ct_id,
373
- 'status': 'approve'
374
- };
375
- jQuery.ajax({
376
- type: "POST",
377
- url: ajaxurl,
378
- data: data,
379
- success: function(msg){
380
- if(msg == 1){
381
- // Success
382
- }
383
- if(msg == 0){
384
- // Error occurred
385
- }
386
- if(msg == 'no_hash'){
387
- // No hash
388
- }
389
- },
390
- error: function(jqXHR, textStatus, errorThrown) {
391
-
392
- },
393
- timeout: 5000
394
- });
395
-
396
- });
397
-
398
- // Request to Download CSV file.
399
- jQuery("#ct_get_csv_file").click(function(){
400
- var data = {
401
- 'action': 'ajax_ct_get_csv_file',
402
- 'security': ct_ajax_nonce,
403
- 'filename': ctUsersCheck.ct_csv_filename
404
- };
405
- jQuery.ajax({
406
- type: "POST",
407
- url: ajaxurl,
408
- data: data,
409
- success: function(msg){
410
- if(parseInt(msg)==0)
411
- alert(ctUsersCheck.ct_bad_csv);
412
- else
413
- jQuery("#ct_csv_wrapper").html("<iframe src='"+location.protocol+"//"+location.hostname+"/wp-content/plugins/cleantalk-spam-protect/check-results/"+ctUsersCheck.ct_csv_filename+".csv'></iframe>");
414
- },
415
- });
416
- });
417
-
418
- //Default load actions
419
- if(location.href.match(/ct_check_users/) && !location.href.match(/ct_worked=1/)){
420
- jQuery("#ct_check_users_button").click();
421
- }
422
- });
1
+ // Printf for JS
2
+ String.prototype.printf = function(){
3
+ var formatted = this;
4
+ for( var arg in arguments ) {
5
+ var before_formatted = formatted.substring(0, formatted.indexOf("%s", 0));
6
+ var after_formatted = formatted.substring(formatted.indexOf("%s", 0)+2, formatted.length);
7
+ formatted = before_formatted + arguments[arg] + after_formatted;
8
+ }
9
+ return formatted;
10
+ };
11
+
12
+ // Flags
13
+ var ct_working = false,
14
+ ct_new_check = true,
15
+ ct_cooling_down_flag = false,
16
+ ct_close_animate = true;
17
+ // Settings
18
+ var ct_cool_down_time = 65000,
19
+ ct_requests_counter = 0,
20
+ ct_max_requests = 95;
21
+ // Variables
22
+ var ct_ajax_nonce = ctUsersCheck.ct_ajax_nonce,
23
+ ct_users_total = 0,
24
+ ct_users_checked = 0,
25
+ ct_users_spam = 0,
26
+ ct_users_bad = 0,
27
+ ct_unchecked = 'unset';
28
+
29
+ function animate_comment(to,id){
30
+ if(ct_close_animate){
31
+ if(to==0.3){
32
+ jQuery('#comment-'+id).fadeTo(200,to,function(){
33
+ animate_comment(1,id)
34
+ });
35
+ }else{
36
+ jQuery('#comment-'+id).fadeTo(200,to,function(){
37
+ animate_comment(0.3,id)
38
+ });
39
+ }
40
+ }else{
41
+ ct_close_animate=true;
42
+ }
43
+ }
44
+
45
+ function ct_clear_users(){
46
+ var data = {
47
+ 'action': 'ajax_clear_users',
48
+ 'security': ct_ajax_nonce
49
+ };
50
+
51
+ jQuery.ajax({
52
+ type: "POST",
53
+ url: ajaxurl,
54
+ data: data,
55
+ success: function(msg){
56
+ ct_send_users();
57
+ }
58
+ });
59
+ }
60
+
61
+ //Continues the check after cooldown time
62
+ //Called by ct_send_users();
63
+ function ct_cooling_down_toggle(){
64
+ ct_cooling_down_flag = false;
65
+ ct_send_users();
66
+ ct_show_users_info();
67
+ }
68
+
69
+ function ct_send_users(){
70
+
71
+ if(ct_cooling_down_flag == true)
72
+ return;
73
+
74
+ if(ct_requests_counter >= ct_max_requests){
75
+ setTimeout(ct_cooling_down_toggle, ct_cool_down_time);
76
+ ct_requests_counter = 0;
77
+ ct_cooling_down_flag = true;
78
+ return;
79
+ }else{
80
+ ct_requests_counter++;
81
+ }
82
+
83
+ var data = {
84
+ 'action': 'ajax_check_users',
85
+ 'security': ct_ajax_nonce,
86
+ 'new_check': ct_new_check,
87
+ 'unchecked': ct_unchecked
88
+ };
89
+
90
+ jQuery.ajax({
91
+ type: "POST",
92
+ url: ajaxurl,
93
+ data: data,
94
+ success: function(msg){
95
+
96
+ msg = jQuery.parseJSON(msg);
97
+
98
+ if(parseInt(msg.error)){
99
+ ct_working=false;
100
+ alert(msg.error_message);
101
+ location.href='users.php?page=ct_check_users&ct_worked=1';
102
+ }else{
103
+ ct_new_check = false;
104
+ if(parseInt(msg.end) == 0){
105
+ ct_users_checked += msg.checked;
106
+ ct_users_spam += msg.spam;
107
+ ct_users_bad += msg.bad;
108
+ ct_unchecked = ct_users_total - ct_users_checked - ct_users_bad;
109
+ var status_string = String(ctUsersCheck.ct_status_string);
110
+ var status_string = status_string.printf(ct_users_total, ct_users_checked, ct_users_spam, ct_users_bad);
111
+ if(parseInt(ct_users_spam) > 0)
112
+ status_string += ctUsersCheck.ct_status_string_warning;
113
+ jQuery('#ct_checking_users_status').html(status_string);
114
+ jQuery('#ct_error_message').hide();
115
+ ct_send_users();
116
+ }else if(parseInt(msg.end) == 1){
117
+ ct_working=false;
118
+ jQuery('#ct_working_message').hide();
119
+ location.href='users.php?page=ct_check_users&ct_worked=1';
120
+ }
121
+ }
122
+ },
123
+ error: function(jqXHR, textStatus, errorThrown) {
124
+ jQuery('#ct_error_message').show();
125
+ jQuery('#cleantalk_ajax_error').html(textStatus);
126
+ jQuery('#cleantalk_js_func').html('Check users');
127
+ setTimeout(ct_send_users(), 3000);
128
+ },
129
+ timeout: 15000
130
+ });
131
+ }
132
+ function ct_show_users_info(){
133
+
134
+ if(ct_working){
135
+
136
+ if(ct_cooling_down_flag == true){
137
+ jQuery('#ct_cooling_notice').html('Waiting for API to cool down. (About a minute)');
138
+ jQuery('#ct_cooling_notice').show();
139
+ return;
140
+ }else{
141
+ jQuery('#ct_cooling_notice').hide();
142
+ }
143
+
144
+ setTimeout(ct_show_users_info, 3000);
145
+
146
+ if(!ct_users_total){
147
+ var data = {
148
+ 'action': 'ajax_info_users',
149
+ 'security': ct_ajax_nonce
150
+ };
151
+ jQuery.ajax({
152
+ type: "POST",
153
+ url: ajaxurl,
154
+ data: data,
155
+ success: function(msg){
156
+ msg = jQuery.parseJSON(msg);
157
+ jQuery('#ct_checking_users_status').html(msg.message);
158
+ ct_users_total = msg.total;
159
+ },
160
+ error: function (jqXHR, textStatus, errorThrown){
161
+ jQuery('#ct_error_message').show();
162
+ jQuery('#cleantalk_ajax_error').html(textStatus);
163
+ jQuery('#cleantalk_js_func').html('Show users');
164
+ setTimeout(ct_show_users_info(), 3000);
165
+ },
166
+ timeout: 15000
167
+ });
168
+ }
169
+ }
170
+ }
171
+ function ct_insert_users(){
172
+
173
+ var data = {
174
+ 'action': 'ajax_insert_users',
175
+ 'security': ct_ajax_nonce
176
+ };
177
+
178
+ jQuery.ajax({
179
+ type: "POST",
180
+ url: ajaxurl,
181
+ data: data,
182
+ success: function(msg){
183
+ alert(ctUsersCheck.ct_inserted + ' ' + msg + ' ' + ctUsersCheck.ct_iusers);
184
+ }
185
+ });
186
+ }
187
+ function ct_delete_all_users(){
188
+
189
+ var data = {
190
+ 'action': 'ajax_delete_all_users',
191
+ 'security': ct_ajax_nonce
192
+ };
193
+
194
+ jQuery.ajax({
195
+ type: "POST",
196
+ url: ajaxurl,
197
+ data: data,
198
+ success: function(msg){
199
+ if(msg>0){
200
+ jQuery('#cleantalk_users_left').html(msg);
201
+ ct_delete_all_users();
202
+ }else{
203
+ location.href='users.php?page=ct_check_users&ct_worked=1';
204
+ }
205
+ },
206
+ error: function(jqXHR, textStatus, errorThrown) {
207
+ jQuery('#ct_error_message').show();
208
+ jQuery('#cleantalk_ajax_error').html(textStatus);
209
+ jQuery('#cleantalk_js_func').html('All users deleteion');
210
+ setTimeout(ct_delete_all_users(), 3000);
211
+ },
212
+ timeout: 25000
213
+ });
214
+ }
215
+ function ct_delete_checked_users(){
216
+
217
+ ids=Array();
218
+ var cnt=0;
219
+ jQuery('input[id^=cb-select-][id!=cb-select-all-1]').each(function(){
220
+ if(jQuery(this).prop('checked')){
221
+ ids[cnt]=jQuery(this).attr('id').substring(10);
222
+ cnt++;
223
+ }
224
+ });
225
+ var data = {
226
+ 'action': 'ajax_delete_checked_users',
227
+ 'security': ct_ajax_nonce,
228
+ 'ids':ids
229
+ };
230
+
231
+ jQuery.ajax({
232
+ type: "POST",
233
+ url: ajaxurl,
234
+ data: data,
235
+ success: function(msg){
236
+ location.href='users.php?page=ct_check_users&ct_worked=1';
237
+ //alert(msg);
238
+ },
239
+ error: function(jqXHR, textStatus, errorThrown) {
240
+ jQuery('#ct_error_message').show();
241
+ jQuery('#cleantalk_ajax_error').html(textStatus);
242
+ jQuery('#cleantalk_js_func').html('All users deleteion');
243
+ setTimeout(ct_delete_checked_users(), 3000);
244
+ },
245
+ timeout: 15000
246
+ });
247
+ return false;
248
+ }
249
+
250
+ jQuery(document).ready(function(){
251
+
252
+ jQuery(".cleantalk_delete_user_button").click(function(){
253
+ id = jQuery(this).attr("data-id");
254
+ ids=Array();
255
+ ids[0]=id;
256
+ var data = {
257
+ 'action': 'ajax_delete_checked_users',
258
+ 'security': ct_ajax_nonce,
259
+ 'ids':ids
260
+ };
261
+ jQuery.ajax({
262
+ type: "POST",
263
+ url: ajaxurl,
264
+ data: data,
265
+ success: function(msg){
266
+ ct_close_animate=false;
267
+ jQuery("#comment-"+id).hide();
268
+ jQuery("#comment-"+id).remove();
269
+ ct_close_animate=true;
270
+ },
271
+ timeout: 15000
272
+ });
273
+ });
274
+
275
+ jQuery(".cleantalk_delete_user_button").click(function(){
276
+ id = jQuery(this).attr("data-id");
277
+ animate_comment(0.3, id);
278
+ });
279
+
280
+ // Check users
281
+ jQuery("#ct_check_users_button").click(function(){
282
+ // jQuery('#ct_checking_users_status').html('');
283
+ jQuery('#ct_delete_checked_users').hide();
284
+ jQuery('#ct_check_users_table').hide();
285
+ jQuery('#ct_check_users_button').hide();
286
+ jQuery('#ct_delete_all_users').hide();
287
+ jQuery('#ct_get_csv_file').hide();
288
+ jQuery('div.pagination').hide();
289
+ jQuery('#ct_info_message').hide();
290
+ jQuery('#ct_working_message').show();
291
+ jQuery('#ct_preloader').show();
292
+ ct_working=true;
293
+ ct_clear_users();
294
+ ct_show_users_info();
295
+ });
296
+
297
+ jQuery("#ct_insert_users").click(function(){
298
+ ct_insert_users();
299
+ });
300
+
301
+ jQuery("#ct_stop_deletion").click(function(){
302
+ //window.location.reload();
303
+ window.location.href='users.php?page=ct_check_users&ct_worked=1';
304
+ });
305
+
306
+ // Delete all spam users
307
+ jQuery("#ct_delete_all_users").click(function(){
308
+ if (!confirm(ctUsersCheck.ct_confirm_deletion_all))
309
+ return false;
310
+ jQuery('#ct_checking_users_status').hide();
311
+ jQuery('#ct_check_users_table').hide();
312
+ jQuery('#ct_tools_buttons').hide();
313
+ jQuery('#ct_info_message').hide();
314
+ jQuery('#ct_ajax_info_users').hide();
315
+ jQuery('#ct_check_users_button').hide();
316
+ jQuery('#ct_search_info').hide();
317
+ jQuery('div.pagination').hide();
318
+ jQuery('#ct_deleting_message').show();
319
+ jQuery('#ct_preloader').show();
320
+ jQuery('#ct_stop_deletion').show();
321
+ jQuery("html, body").animate({ scrollTop: 0 }, "slow");
322
+ ct_delete_all_users();
323
+ });
324
+ jQuery("#ct_delete_checked_users").click(function(){
325
+ if (!confirm(ctUsersCheck.ct_confirm_deletion_checked))
326
+ return false;
327
+
328
+ ct_delete_checked_users();
329
+ });
330
+ jQuery(".cleantalk_user").mouseover(function(){
331
+ id = jQuery(this).attr("data-id");
332
+ jQuery("#cleantalk_delete_user_"+id).show();
333
+ });
334
+ jQuery(".cleantalk_user").mouseout(function(){
335
+ id = jQuery(this).attr("data-id");
336
+ jQuery("#cleantalk_delete_user_"+id).hide();
337
+ });
338
+
339
+ //Show/hide action on mouse over/out
340
+ jQuery(".cleantalk_user").mouseover(function(){
341
+ id = jQuery(this).attr("data-id");
342
+ jQuery("#cleantalk_button_set_"+id).show();
343
+ });
344
+ jQuery(".cleantalk_user").mouseout(function(){
345
+ id = jQuery(this).attr("data-id");
346
+ jQuery("#cleantalk_button_set_"+id).hide();
347
+ });
348
+
349
+ //Approve button
350
+ jQuery(".cleantalk_delete_from_list_button").click(function(){
351
+ ct_id = jQuery(this).attr("data-id");
352
+ var data = {
353
+ 'action': 'ajax_ct_approve_user',
354
+ 'security': ct_ajax_nonce,
355
+ 'id': ct_id
356
+ };
357
+ jQuery.ajax({
358
+ type: "POST",
359
+ url: ajaxurl,
360
+ data: data,
361
+ success: function(msg){
362
+ jQuery("#comment-"+ct_id).fadeOut('slow', function(){
363
+ jQuery("#comment-"+ct_id).remove();
364
+ });
365
+ },
366
+ });
367
+
368
+ // Positive feedback
369
+ var data = {
370
+ 'action': 'ct_feedback_user',
371
+ 'security': ct_ajax_nonce,
372
+ 'user_id': ct_id,
373
+ 'status': 'approve'
374
+ };
375
+ jQuery.ajax({
376
+ type: "POST",
377
+ url: ajaxurl,
378
+ data: data,
379
+ success: function(msg){
380
+ if(msg == 1){
381
+ // Success
382
+ }
383
+ if(msg == 0){
384
+ // Error occurred
385
+ }
386
+ if(msg == 'no_hash'){
387
+ // No hash
388
+ }
389
+ },
390
+ error: function(jqXHR, textStatus, errorThrown) {
391
+
392
+ },
393
+ timeout: 5000
394
+ });
395
+
396
+ });
397
+
398
+ // Request to Download CSV file.
399
+ jQuery("#ct_get_csv_file").click(function(){
400
+ var data = {
401
+ 'action': 'ajax_ct_get_csv_file',
402
+ 'security': ct_ajax_nonce,
403
+ 'filename': ctUsersCheck.ct_csv_filename
404
+ };
405
+ jQuery.ajax({
406
+ type: "POST",
407
+ url: ajaxurl,
408
+ data: data,
409
+ success: function(msg){
410
+ if(parseInt(msg)==0)
411
+ alert(ctUsersCheck.ct_bad_csv);
412
+ else
413
+ jQuery("#ct_csv_wrapper").html("<iframe src='"+location.protocol+"//"+location.hostname+"/wp-content/plugins/cleantalk-spam-protect/check-results/"+ctUsersCheck.ct_csv_filename+".csv'></iframe>");
414
+ },
415
+ });
416
+ });
417
+
418
+ //Default load actions
419
+ if(location.href.match(/ct_check_users/) && !location.href.match(/ct_worked=1/)){
420
+ jQuery("#ct_check_users_button").click();
421
+ }
422
+ });
assets/js/cleantalk-users-editscreen.js CHANGED
@@ -1,22 +1,22 @@
1
- function ct_is_email(str){
2
- return str.search(/.*@.*\..*/);
3
- }
4
- function ct_is_ip(str){
5
- return str.search(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/);
6
- }
7
-
8
- jQuery(document).ready(function(){
9
-
10
- /* Shows "Find spam users" Buttons */
11
- jQuery('#changeit').after(' <a href="users.php?page=ct_check_users" class="button" style="margin:1px 0 0 0; display: inline-block;">'+ctUsersScreen.spambutton_users_text+'</a>' +
12
- ' <a href="users.php?page=ct_check_users&ct_worked=1" class="button" style="margin:1px 0 0 0; display: inline-block;">'+ctUsersScreen.spambutton_users_text_show+'</a>');
13
-
14
- /* Shows link to blacklists near every email and IP address */
15
- if(parseInt(ctUsersScreen.ct_show_check_links))
16
- jQuery('.column-email a').each(function(){
17
- var ct_curr_str = jQuery(this).html();
18
- if(ct_is_email(ct_curr_str) != -1){
19
- jQuery(this).after('&nbsp;<a href="https://cleantalk.org/blacklists/'+ct_curr_str+'" target="_blank" title="https://cleantalk.org/blacklists/'+ct_curr_str+'" class="ct_link_new_tab"><img src="'+ctUsersScreen.ct_img_src_new_tab+'"></a>');
20
- }
21
- });
22
  });
1
+ function ct_is_email(str){
2
+ return str.search(/.*@.*\..*/);
3
+ }
4
+ function ct_is_ip(str){
5
+ return str.search(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/);
6
+ }
7
+
8
+ jQuery(document).ready(function(){
9
+
10
+ /* Shows "Find spam users" Buttons */
11
+ jQuery('#changeit').after(' <a href="users.php?page=ct_check_users" class="button" style="margin:1px 0 0 0; display: inline-block;">'+ctUsersScreen.spambutton_users_text+'</a>' +
12
+ ' <a href="users.php?page=ct_check_users&ct_worked=1" class="button" style="margin:1px 0 0 0; display: inline-block;">'+ctUsersScreen.spambutton_users_text_show+'</a>');
13
+
14
+ /* Shows link to blacklists near every email and IP address */
15
+ if(parseInt(ctUsersScreen.ct_show_check_links))
16
+ jQuery('.column-email a').each(function(){
17
+ var ct_curr_str = jQuery(this).html();
18
+ if(ct_is_email(ct_curr_str) != -1){
19
+ jQuery(this).after('&nbsp;<a href="https://cleantalk.org/blacklists/'+ct_curr_str+'" target="_blank" title="https://cleantalk.org/blacklists/'+ct_curr_str+'" class="ct_link_new_tab"><img src="'+ctUsersScreen.ct_img_src_new_tab+'"></a>');
20
+ }
21
+ });
22
  });
cleantalk.php CHANGED
@@ -1,535 +1,531 @@
1
- <?php
2
- /*
3
- Plugin Name: Anti-Spam by CleanTalk
4
- Plugin URI: http://cleantalk.org
5
- Description: Max power, all-in-one, no Captcha, 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.70.2
7
- Author: СleanTalk <welcome@cleantalk.org>
8
- Author URI: http://cleantalk.org
9
- */
10
- $cleantalk_plugin_version='5.70.2';
11
- $ct_agent_version = 'wordpress-5702';
12
- $cleantalk_executed=false;
13
- $ct_sfw_updated = false;
14
-
15
- define('CLEANTALK_REMOTE_CALL_SLEEP', 10); // Minimum time between remote call
16
-
17
- if(!defined('CLEANTALK_PLUGIN_DIR')){
18
-
19
- global $ct_options, $ct_data, $pagenow;
20
-
21
- define('CLEANTALK_PLUGIN_DIR', plugin_dir_path(__FILE__));
22
-
23
- require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-common.php');
24
- require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-widget.php');
25
-
26
- $ct_options=ct_get_options();
27
- $ct_data=ct_get_data();
28
-
29
- // Self cron
30
- if(!defined('DOING_CRON') || (defined('DOING_CRON') && DOING_CRON !== true)){
31
-
32
- require_once(CLEANTALK_PLUGIN_DIR. 'lib/CleantalkCron.php');
33
-
34
- $ct_cron = new cleantalk\antispam\CleantalkCron();
35
- $ct_cron->checkTasks();
36
-
37
- if(!empty($ct_cron->tasks_to_run)){
38
-
39
- define('CT_CRON', true); // Letting know functions that they are running under CT_CRON
40
- $ct_cron->runTasks();
41
- unset($ct_cron);
42
-
43
- }
44
- }
45
-
46
- //Delete cookie for admin trial notice
47
- add_action('wp_logout', 'ct_wp_logout');
48
-
49
- // Early checks
50
- // Facebook
51
- if (isset($ct_options['general_contact_forms_test']) && $ct_options['general_contact_forms_test'] == 1
52
- && (!empty($_POST['action']) && $_POST['action'] == 'fb_intialize')
53
- && !empty($_POST['FB_userdata'])
54
- ){
55
- require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-public.php');
56
- if (ct_is_user_enable()){
57
- ct_cookies_test();
58
- $ct_check_post_result=false;
59
- ct_registration_errors(null);
60
- }
61
-
62
- }
63
-
64
- if(isset($_SERVER['REQUEST_URI']) && stripos($_SERVER['REQUEST_URI'],'admin-ajax.php')!==false && sizeof($_POST)>0 && isset($_GET['action']) && $_GET['action']=='ninja_forms_ajax_submit')
65
- $_POST['action']='ninja_forms_ajax_submit';
66
-
67
- // SFW start
68
- $value = (isset($ct_options['spam_firewall']) ? intval($ct_options['spam_firewall']) : 0);
69
- /*
70
- Turn off the SpamFireWall if current url in the exceptions list.
71
- */
72
- if ($value == 1 && isset($cleantalk_url_exclusions) && is_array($cleantalk_url_exclusions)) {
73
- foreach ($cleantalk_url_exclusions as $v) {
74
- if (stripos($_SERVER['REQUEST_URI'], $v) !== false) {
75
- $value = 0;
76
- break;
77
- }
78
- }
79
- }
80
-
81
- /*
82
- Turn off the SpamFireWall for WordPress core pages
83
- */
84
- $ct_wordpress_core_pages = array(
85
- '/wp-admin',
86
- '/feed'
87
- );
88
- if ($value == 1) {
89
- if(!empty($_SERVER['REQUEST_URI'])){
90
- foreach ($ct_wordpress_core_pages as $v) {
91
- if (stripos($_SERVER['REQUEST_URI'], $v) !== false) {
92
- $value = 0;
93
- break;
94
- }
95
- }
96
- }
97
- }
98
-
99
- // SpamFireWall check
100
- if($value==1 && !is_admin() || $value==1 && defined( 'DOING_AJAX' ) && DOING_AJAX && $_SERVER["REQUEST_METHOD"] == 'GET'){
101
-
102
- include_once(CLEANTALK_PLUGIN_DIR . "lib/CleantalkSFW.php");
103
-
104
- $is_sfw_check = true;
105
- $sfw = new cleantalk\antispam\CleantalkSFW();
106
- $sfw_ip = $sfw->cleantalk_get_real_ip();
107
-
108
- foreach($sfw_ip as $ct_cur_ip){
109
- if(isset($_COOKIE['ct_sfw_pass_key']) && $_COOKIE['ct_sfw_pass_key'] == md5($ct_cur_ip.$ct_options['apikey'])){
110
- $is_sfw_check=false;
111
- if(isset($_COOKIE['ct_sfw_passed'])){
112
- $sfw->sfw_update_logs($ct_cur_ip, 'passed');
113
- $ct_data['sfw_counter']['all']++;
114
- update_option('cleantalk_data', $ct_data);
115
- if(!headers_sent())
116
- setcookie ('ct_sfw_passed', '0', 1, "/");
117
- }
118
- }else{
119
- $is_sfw_check=true;
120
- }
121
- }
122
- if($is_sfw_check){
123
- $sfw->check_ip();
124
- if($sfw->result){
125
- $sfw->sfw_update_logs($sfw->blocked_ip, 'blocked');
126
- $ct_data['sfw_counter']['blocked']++;
127
- update_option('cleantalk_data', $ct_data);
128
- $sfw->sfw_die($ct_options['apikey']);
129
- }else{
130
- if(!empty($ct_options['set_cookies']))
131
- setcookie ('ct_sfw_pass_key', md5($sfw->passed_ip.$ct_options['apikey']), 0, "/");
132
- }
133
- }
134
- unset($is_sfw_check, $sfw, $sfw_ip, $ct_cur_ip);
135
- }
136
-
137
- // Remote calls
138
- if(isset($_GET['spbc_remote_call_token'], $_GET['spbc_remote_call_action'], $_GET['plugin_name']) && ($_GET['plugin_name'] == 'antispam' || $_GET['plugin_name'] == 'anti-spam')){
139
-
140
- if(isset($ct_data['last_remote_call']) && time() - $ct_data['last_remote_call'] < CLEANTALK_REMOTE_CALL_SLEEP){
141
- echo "FAIL TOO_MANY_ATTEMPTS";
142
- die();
143
- }else{
144
- $ct_data['last_remote_call'] = time();
145
- update_option('cleantalk_data', $ct_data);
146
- }
147
-
148
- $spbc_remote_call_token = md5($ct_options['apikey']);
149
-
150
- if($_GET['spbc_remote_call_token'] == $spbc_remote_call_token){
151
-
152
- if($_GET['spbc_remote_call_action'] == 'close_renew_banner'){
153
- $ct_data['show_ct_notice_trial'] = 0;
154
- $ct_data['show_ct_notice_renew'] = 0;
155
- update_option('cleantalk_data', $ct_data);
156
- cleantalk\antispam\CleantalkCron::updateTask('check_account_status', 'ct_account_status_check', 86400);
157
- echo "OK";
158
- die();
159
- }elseif($_GET['spbc_remote_call_action'] == 'sfw_update'){
160
- $rc_result = ct_sfw_update();
161
- echo $rc_result === true ? 'OK' : 'FAIL '.$rc_result;
162
- die();
163
- }elseif($_GET['spbc_remote_call_action'] == 'sfw_send_logs'){
164
- $rc_result = ct_sfw_send_logs();
165
- echo $rc_result === true ? 'OK' : 'FAIL '.$rc_result;
166
- die();
167
- }
168
- }else{
169
- echo "FAIL WRONG_TOKEN";
170
- die();
171
- }
172
- }
173
-
174
- // Activation/deactivation functions must be in main plugin file.
175
- // http://codex.wordpress.org/Function_Reference/register_activation_hook
176
- register_activation_hook( __FILE__, 'ct_activation' );
177
- register_deactivation_hook( __FILE__, 'ct_deactivation' );
178
-
179
- // Redirect admin to plugin settings.
180
- if(!defined('WP_ALLOW_MULTISITE') || defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE == false)
181
- add_action('admin_init', 'ct_plugin_redirect');
182
-
183
- // After plugin loaded - to load locale as described in manual
184
- add_action('plugin_loaded', 'ct_plugin_loaded' );
185
-
186
- if( !empty($ct_options['use_ajax']) &&
187
- stripos($_SERVER['REQUEST_URI'],'.xml')===false &&
188
- stripos($_SERVER['REQUEST_URI'],'.xsl')===false)
189
- {
190
- add_action( 'wp_ajax_nopriv_ct_get_cookie', 'ct_get_cookie',1 );
191
- add_action( 'wp_ajax_ct_get_cookie', 'ct_get_cookie',1 );
192
- }
193
-
194
- if(isset($ct_options['show_link']) && intval($ct_options['show_link']) == 1)
195
- add_action('comment_form_after', 'ct_show_comment_link');
196
-
197
- if(is_admin()){
198
- require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-comments.php');
199
- require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-users.php');
200
- }
201
-
202
- // Admin panel actions
203
- if (is_admin()||is_network_admin()){
204
-
205
- require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-admin.php');
206
-
207
- if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)){
208
- add_action('admin_init', 'ct_admin_init', 1);
209
- add_action('admin_menu', 'ct_admin_add_page');
210
- if(is_network_admin())
211
- add_action('network_admin_menu', 'ct_admin_add_page');
212
-
213
- add_action('admin_notices', 'cleantalk_admin_notice_message');
214
- add_action('network_admin_notices', 'cleantalk_admin_notice_message');
215
-
216
- //Show widget only if not IP license
217
- if(empty($ct_data['moderate_ip']))
218
- add_action('wp_dashboard_setup', 'ct_dashboard_statistics_widget' );
219
-
220
- }
221
- if (defined( 'DOING_AJAX' ) && DOING_AJAX||isset($_POST['cma-action'])){
222
-
223
- // Feedback for comments
224
- if(isset($_POST['action']) && $_POST['action'] == 'ct_feedback_comment'){
225
- add_action( 'wp_ajax_nopriv_ct_feedback_comment', 'ct_comment_send_feedback',1 );
226
- add_action( 'wp_ajax_ct_feedback_comment', 'ct_comment_send_feedback',1 );
227
- }
228
- if(isset($_POST['action']) && $_POST['action'] == 'ct_feedback_user'){
229
- add_action( 'wp_ajax_nopriv_ct_feedback_user', 'ct_user_send_feedback',1 );
230
- add_action( 'wp_ajax_ct_feedback_user', 'ct_user_send_feedback',1 );
231
- }
232
-
233
- $cleantalk_hooked_actions = array();
234
- $cleantalk_ajax_actions_to_check = array();
235
- require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-public.php');
236
- require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-ajax.php');
237
-
238
- // Do check for AJAX if Unknown action or Known action with mandatory check
239
- if( isset($_POST['action']) &&
240
- defined('LOGGED_IN_COOKIE') &&
241
- !isset($_COOKIE[LOGGED_IN_COOKIE]) &&
242
- (!in_array($_POST['action'], $cleantalk_hooked_actions) || in_array($_POST['action'], $cleantalk_ajax_actions_to_check))
243
- ){
244
- ct_ajax_hook();
245
- }
246
- //
247
- // Some of plugins to register a users use AJAX context.
248
- //
249
- add_filter('registration_errors', 'ct_registration_errors', 1, 3);
250
- add_filter('registration_errors', 'ct_check_registration_erros', 999999, 3);
251
- add_action('user_register', 'ct_user_register');
252
-
253
- //QAEngine Theme answers
254
- if (intval($ct_options['general_contact_forms_test']))
255
- add_filter('et_pre_insert_answer', 'ct_ajax_hook', 1, 1);
256
- }
257
-
258
- require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-public.php');
259
-
260
- //Bitrix24 contact form
261
- if (ct_is_user_enable()) {
262
- ct_cookies_test();
263
-
264
- if (isset($ct_options['general_contact_forms_test']) && $ct_options['general_contact_forms_test'] == 1 &&
265
- !empty($_POST['your-phone']) &&
266
- !empty($_POST['your-email']) &&
267
- !empty($_POST['your-message'])
268
- ){
269
- $ct_check_post_result=false;
270
- ct_contact_form_validate();
271
- }
272
- }
273
-
274
- add_action('admin_enqueue_scripts', 'ct_enqueue_scripts');
275
-
276
- // Sends feedback to the cloud about comments
277
- // add_action('wp_set_comment_status', 'ct_comment_send_feedback', 10, 2);
278
-
279
- // Sends feedback to the cloud about deleted users
280
- if($pagenow=='users.php')
281
- add_action('delete_user', 'ct_delete_user', 10, 2);
282
-
283
- if($pagenow=='plugins.php' || (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'],'plugins.php') !== false)){
284
-
285
- add_filter('plugin_action_links_'.plugin_basename(__FILE__), 'ct_plugin_action_links', 10, 2);
286
- add_filter('network_admin_plugin_action_links_'.plugin_basename(__FILE__), 'ct_plugin_action_links', 10, 2);
287
-
288
- add_filter('plugin_row_meta', 'ct_register_plugin_links', 10, 2);
289
- }
290
- add_action('updated_option', 'ct_update_option'); // param - option name, i.e. 'cleantalk_settings'
291
-
292
- // Public pages actions
293
- }else{
294
-
295
- require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-public.php');
296
-
297
- add_action('wp_enqueue_scripts', 'ct_enqueue_scripts_public');
298
-
299
- // Init action.
300
- add_action('plugins_loaded', 'ct_init', 1);
301
-
302
- // Comments
303
- add_filter('preprocess_comment', 'ct_preprocess_comment', 1, 1); // param - comment data array
304
- add_filter('comment_text', 'ct_comment_text' );
305
-
306
- // Registrations
307
- add_action('register_form','ct_register_form');
308
- add_filter('registration_errors', 'ct_registration_errors', 1, 3);
309
- add_filter('registration_errors', 'ct_check_registration_erros', 999999, 3);
310
- add_action('user_register', 'ct_user_register');
311
-
312
- // Multisite registrations
313
- add_action('signup_extra_fields','ct_register_form');
314
- add_filter('wpmu_validate_user_signup', 'ct_registration_errors_wpmu', 10, 3);
315
-
316
- // Login form - for notifications only
317
- add_filter('login_message', 'ct_login_message');
318
-
319
- // Comments output hook
320
- add_filter('wp_list_comments_args', 'ct_wp_list_comments_args');
321
-
322
- // Ait-Themes fix
323
- if(isset($_GET['ait-action']) && $_GET['ait-action']=='register'){
324
- $tmp=$_POST['redirect_to'];
325
- unset($_POST['redirect_to']);
326
- ct_contact_form_validate();
327
- $_POST['redirect_to']=$tmp;
328
- }
329
- }
330
- }
331
-
332
- /**
333
- * On activation, set a time, frequency and name of an action hook to be scheduled.
334
- */
335
- if (!function_exists ( 'ct_activation')) {
336
- function ct_activation() {
337
-
338
- global $wpdb;
339
-
340
- $wpdb->query("CREATE TABLE IF NOT EXISTS `".$wpdb->base_prefix."cleantalk_sfw` (
341
- `network` int(11) unsigned NOT NULL,
342
- `mask` int(11) unsigned NOT NULL,
343
- INDEX ( `network` , `mask` )
344
- ) ENGINE = MYISAM ;"
345
- );
346
-
347
- $wpdb->query("CREATE TABLE IF NOT EXISTS `".$wpdb->base_prefix."cleantalk_sfw_logs` (
348
- `ip` VARCHAR(15) NOT NULL,
349
- `all_entries` INT NOT NULL,
350
- `blocked_entries` INT NOT NULL,
351
- `entries_timestamp` INT NOT NULL,
352
- PRIMARY KEY (`ip`))
353
- ENGINE = MYISAM;"
354
- );
355
-
356
- // Cron tasks
357
- cleantalk\antispam\CleantalkCron::addTask('check_account_status', 'ct_account_status_check', 3600, time()+1800); // Checks account status
358
- cleantalk\antispam\CleantalkCron::addTask('delete_spam_comments', 'ct_delete_spam_comments', 3600, time()+3500); // Formerly ct_hourly_event_hook()
359
- cleantalk\antispam\CleantalkCron::addTask('send_feedback', 'ct_send_feedback', 3600, time()+3500); // Formerly ct_hourly_event_hook()
360
- cleantalk\antispam\CleantalkCron::addTask('sfw_update', 'ct_sfw_update', 86400, time()+43200);// SFW update
361
- cleantalk\antispam\CleantalkCron::addTask('send_sfw_logs', 'ct_sfw_send_logs', 3600, time()+1800); // SFW send logs
362
- cleantalk\antispam\CleantalkCron::addTask('get_brief_data', 'cleantalk_get_brief_data', 86400, time()+3500); // Get data for dashboard widget
363
-
364
- // Additional options
365
- add_option('ct_plugin_do_activation_redirect', true);
366
- add_option('ct_installing', true);
367
-
368
- // Updating SFW
369
- ct_sfw_update();
370
- }
371
- }
372
-
373
- /**
374
- * On deactivation, clear schedule.
375
- */
376
- if (!function_exists ( 'ct_deactivation')) {
377
- function ct_deactivation() {
378
-
379
- global $wpdb;
380
-
381
- // Deleting SFW tables
382
- $wpdb->query("DROP TABLE IF EXISTS `".$wpdb->base_prefix."cleantalk_sfw`;");
383
- $wpdb->query("DROP TABLE IF EXISTS `".$wpdb->base_prefix."cleantalk_sfw_logs`;");
384
-
385
- // Deleting cron entries
386
- delete_option('cleantalk_cron');
387
-
388
- }
389
- }
390
-
391
- /**
392
- * Redirects admin to plugin settings after activation.
393
- */
394
- function ct_plugin_redirect()
395
- {
396
- if (get_option('ct_plugin_do_activation_redirect', false) && !isset($_GET['activate-multi'])){
397
- delete_option('ct_plugin_do_activation_redirect');
398
- wp_redirect("options-general.php?page=cleantalk");
399
- }
400
- }
401
-
402
- function ct_add_event($event_type)
403
- {
404
- global $ct_data,$cleantalk_executed;
405
-
406
- //
407
- // To migrate on the new version of ct_add_event().
408
- //
409
- switch ($event_type) {
410
- case '0': $event_type = 'no';break;
411
- case '1': $event_type = 'yes';break;
412
- }
413
-
414
- $ct_data = ct_get_data();
415
- $current_hour = intval(date('G'));
416
-
417
- // Updating current hour
418
- if($current_hour!=$ct_data['current_hour']){
419
- $ct_data['current_hour']=$current_hour;
420
- $ct_data['array_accepted'][$current_hour]=0;
421
- $ct_data['array_blocked'][$current_hour]=0;
422
- }
423
-
424
- //Add 1 to counters
425
- if($event_type=='yes'){
426
- $ct_data['array_accepted'][$current_hour]++;
427
- $ct_data['all_time_counter']['accepted']++;
428
- $ct_data['user_counter']['accepted']++;
429
- }
430
- if($event_type=='no'){
431
- $ct_data['array_blocked'][$current_hour]++;
432
- $ct_data['all_time_counter']['blocked']++;
433
- $ct_data['user_counter']['blocked']++;
434
- }
435
-
436
- update_option('cleantalk_data', $ct_data);
437
- $cleantalk_executed=true;
438
- }
439
-
440
- /**
441
- * return new cookie value
442
- */
443
- function ct_get_cookie()
444
- {
445
- global $ct_checkjs_def;
446
- $ct_checkjs_key = ct_get_checkjs_value(true);
447
- print $ct_checkjs_key;
448
- die();
449
- }
450
-
451
- function ct_show_comment_link(){
452
-
453
- print "<div style='font-size:10pt;'><a href='https://cleantalk.org/wordpress-anti-spam-plugin' target='_blank'>".__( 'WordPress spam', 'cleantalk' )."</a> ".__( 'blocked by', 'cleantalk' )." CleanTalk.</div>";
454
-
455
- }
456
-
457
- add_action( 'right_now_content_table_end', 'my_add_counts_to_dashboard' );
458
-
459
- function ct_sfw_update(){
460
-
461
- global $ct_options;
462
-
463
- if(!function_exists('sendRawRequest'))
464
- require_once('inc/cleantalk.class.php');
465
-
466
- if(isset($ct_options['spam_firewall']) && intval($ct_options['spam_firewall']) == 1){
467
-
468
- include_once(CLEANTALK_PLUGIN_DIR . "lib/CleantalkSFW.php");
469
-
470
- $sfw = new cleantalk\antispam\CleantalkSFW();
471
- $result = $sfw->sfw_update($ct_options['apikey']);
472
- unset($sfw);
473
-
474
- return $result === true ? true : $result;
475
-
476
- }
477
-
478
- return 'SFW_DISABLED';
479
-
480
- }
481
-
482
- function ct_sfw_send_logs()
483
- {
484
- global $ct_options, $ct_data;
485
-
486
- $ct_options=ct_get_options();
487
- $ct_data=ct_get_data();
488
-
489
- if(isset($ct_options['spam_firewall']) && intval($ct_options['spam_firewall']) == 1){
490
-
491
- include_once(CLEANTALK_PLUGIN_DIR . "lib/CleantalkSFW.php");
492
-
493
- $sfw = new cleantalk\antispam\CleantalkSFW();
494
- $result = $sfw->send_logs($ct_options['apikey']);
495
- unset($sfw);
496
-
497
- return $result === true ? true : $result;
498
-
499
- }
500
-
501
- return 'SFW_DISABLED';
502
- }
503
-
504
- function cleantalk_get_brief_data(){
505
- $ct_options = ct_get_options();
506
- $ct_data = ct_get_data();
507
-
508
- require_once('inc/cleantalk.class.php');
509
- $result = getAntispamReportBreif($ct_options['apikey']);
510
-
511
- $ct_data['brief_data'] = $result;
512
- update_option('cleantalk_data', $ct_data);
513
-
514
- return;
515
- }
516
-
517
- //Delete cookie for admin trial notice
518
- function ct_wp_logout(){
519
- if(!headers_sent())
520
- setcookie('ct_trial_banner_closed', '', time()-3600);
521
- }
522
-
523
- /*
524
- function myplugin_update_field( $new_value, $old_value ) {
525
- error_log('cleantalk_data dump: '. strlen(serialize($new_value)));
526
- return $new_value;
527
- }
528
-
529
- function myplugin_init() {
530
- add_filter( 'pre_update_option_cleantalk_data', 'myplugin_update_field', 10, 2 );
531
- }
532
-
533
- add_action( 'init', 'myplugin_init' );
534
- */
535
  ?>
1
+ <?php
2
+ /*
3
+ Plugin Name: Anti-Spam by CleanTalk
4
+ Plugin URI: http://cleantalk.org
5
+ Description: Max power, all-in-one, no Captcha, 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.71
7
+ Author: СleanTalk <welcome@cleantalk.org>
8
+ Author URI: http://cleantalk.org
9
+ */
10
+ $cleantalk_plugin_version='5.71';
11
+ $ct_agent_version = 'wordpress-571';
12
+ $cleantalk_executed=false;
13
+ $ct_sfw_updated = false;
14
+
15
+ define('CLEANTALK_REMOTE_CALL_SLEEP', 10); // Minimum time between remote call
16
+
17
+ if(!defined('CLEANTALK_PLUGIN_DIR')){
18
+
19
+ global $ct_options, $ct_data, $pagenow;
20
+
21
+ define('CLEANTALK_PLUGIN_DIR', plugin_dir_path(__FILE__));
22
+
23
+ require_once( CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-common.php');
24
+ require_once( CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-widget.php');
25
+ require_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkCron.php');
26
+
27
+ $ct_options=ct_get_options();
28
+ $ct_data=ct_get_data();
29
+
30
+ // Self cron
31
+ if(!defined('DOING_CRON') || (defined('DOING_CRON') && DOING_CRON !== true)){
32
+
33
+ $ct_cron = new CleantalkCron();
34
+ $ct_cron->checkTasks();
35
+
36
+ if(!empty($ct_cron->tasks_to_run)){
37
+
38
+ define('CT_CRON', true); // Letting know functions that they are running under CT_CRON
39
+ $ct_cron->runTasks();
40
+ unset($ct_cron);
41
+
42
+ }
43
+ }
44
+
45
+ //Delete cookie for admin trial notice
46
+ add_action('wp_logout', 'ct_wp_logout');
47
+
48
+ // Early checks
49
+ // Facebook
50
+ if (isset($ct_options['general_contact_forms_test']) && $ct_options['general_contact_forms_test'] == 1
51
+ && (!empty($_POST['action']) && $_POST['action'] == 'fb_intialize')
52
+ && !empty($_POST['FB_userdata'])
53
+ ){
54
+ require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-public.php');
55
+ if (ct_is_user_enable()){
56
+ ct_cookies_test();
57
+ $ct_check_post_result=false;
58
+ ct_registration_errors(null);
59
+ }
60
+
61
+ }
62
+
63
+ if(isset($_SERVER['REQUEST_URI']) && stripos($_SERVER['REQUEST_URI'],'admin-ajax.php')!==false && sizeof($_POST)>0 && isset($_GET['action']) && $_GET['action']=='ninja_forms_ajax_submit')
64
+ $_POST['action']='ninja_forms_ajax_submit';
65
+
66
+ // SFW start
67
+ $value = (isset($ct_options['spam_firewall']) ? intval($ct_options['spam_firewall']) : 0);
68
+ /*
69
+ Turn off the SpamFireWall if current url in the exceptions list.
70
+ */
71
+ if ($value == 1 && isset($cleantalk_url_exclusions) && is_array($cleantalk_url_exclusions)) {
72
+ foreach ($cleantalk_url_exclusions as $v) {
73
+ if (stripos($_SERVER['REQUEST_URI'], $v) !== false) {
74
+ $value = 0;
75
+ break;
76
+ }
77
+ }
78
+ }
79
+
80
+ /*
81
+ Turn off the SpamFireWall for WordPress core pages
82
+ */
83
+ $ct_wordpress_core_pages = array(
84
+ '/wp-admin',
85
+ '/feed'
86
+ );
87
+ if ($value == 1) {
88
+ if(!empty($_SERVER['REQUEST_URI'])){
89
+ foreach ($ct_wordpress_core_pages as $v) {
90
+ if (stripos($_SERVER['REQUEST_URI'], $v) !== false) {
91
+ $value = 0;
92
+ break;
93
+ }
94
+ }
95
+ }
96
+ }
97
+
98
+ // SpamFireWall check
99
+ if($value==1 && !is_admin() || $value==1 && defined( 'DOING_AJAX' ) && DOING_AJAX && $_SERVER["REQUEST_METHOD"] == 'GET'){
100
+
101
+ include_once(CLEANTALK_PLUGIN_DIR . "lib/CleantalkSFW.php");
102
+
103
+ $is_sfw_check = true;
104
+ $sfw = new CleantalkSFW();
105
+ $sfw_ip = $sfw->cleantalk_get_real_ip();
106
+
107
+ foreach($sfw_ip as $ct_cur_ip){
108
+ if(isset($_COOKIE['ct_sfw_pass_key']) && $_COOKIE['ct_sfw_pass_key'] == md5($ct_cur_ip.$ct_options['apikey'])){
109
+ $is_sfw_check=false;
110
+ if(isset($_COOKIE['ct_sfw_passed'])){
111
+ $sfw->sfw_update_logs($ct_cur_ip, 'passed');
112
+ $ct_data['sfw_counter']['all']++;
113
+ update_option('cleantalk_data', $ct_data);
114
+ if(!headers_sent())
115
+ setcookie ('ct_sfw_passed', '0', 1, "/");
116
+ }
117
+ }else{
118
+ $is_sfw_check=true;
119
+ }
120
+ }
121
+ if($is_sfw_check){
122
+ $sfw->check_ip();
123
+ if($sfw->result){
124
+ $sfw->sfw_update_logs($sfw->blocked_ip, 'blocked');
125
+ $ct_data['sfw_counter']['blocked']++;
126
+ update_option('cleantalk_data', $ct_data);
127
+ $sfw->sfw_die($ct_options['apikey']);
128
+ }else{
129
+ if(!empty($ct_options['set_cookies']))
130
+ setcookie ('ct_sfw_pass_key', md5($sfw->passed_ip.$ct_options['apikey']), 0, "/");
131
+ }
132
+ }
133
+ unset($is_sfw_check, $sfw, $sfw_ip, $ct_cur_ip);
134
+ }
135
+
136
+ // Remote calls
137
+ if(isset($_GET['spbc_remote_call_token'], $_GET['spbc_remote_call_action'], $_GET['plugin_name']) && ($_GET['plugin_name'] == 'antispam' || $_GET['plugin_name'] == 'anti-spam')){
138
+
139
+ if(isset($ct_data['last_remote_call']) && time() - $ct_data['last_remote_call'] < CLEANTALK_REMOTE_CALL_SLEEP){
140
+ echo "FAIL TOO_MANY_ATTEMPTS";
141
+ die();
142
+ }else{
143
+ $ct_data['last_remote_call'] = time();
144
+ update_option('cleantalk_data', $ct_data);
145
+ }
146
+
147
+ $spbc_remote_call_token = md5($ct_options['apikey']);
148
+
149
+ if($_GET['spbc_remote_call_token'] == $spbc_remote_call_token){
150
+
151
+ if($_GET['spbc_remote_call_action'] == 'close_renew_banner'){
152
+ $ct_data['show_ct_notice_trial'] = 0;
153
+ $ct_data['show_ct_notice_renew'] = 0;
154
+ update_option('cleantalk_data', $ct_data);
155
+ CleantalkCron::updateTask('check_account_status', 'ct_account_status_check', 86400);
156
+ echo "OK";
157
+ die();
158
+ }elseif($_GET['spbc_remote_call_action'] == 'sfw_update'){
159
+ $rc_result = ct_sfw_update();
160
+ echo $rc_result === true ? 'OK' : 'FAIL '.$rc_result;
161
+ die();
162
+ }elseif($_GET['spbc_remote_call_action'] == 'sfw_send_logs'){
163
+ $rc_result = ct_sfw_send_logs();
164
+ echo $rc_result === true ? 'OK' : 'FAIL '.$rc_result;
165
+ die();
166
+ }
167
+ }else{
168
+ echo "FAIL WRONG_TOKEN";
169
+ die();
170
+ }
171
+ }
172
+
173
+ // Activation/deactivation functions must be in main plugin file.
174
+ // http://codex.wordpress.org/Function_Reference/register_activation_hook
175
+ register_activation_hook( __FILE__, 'ct_activation' );
176
+ register_deactivation_hook( __FILE__, 'ct_deactivation' );
177
+
178
+ // Redirect admin to plugin settings.
179
+ if(!defined('WP_ALLOW_MULTISITE') || defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE == false)
180
+ add_action('admin_init', 'ct_plugin_redirect');
181
+
182
+ // After plugin loaded - to load locale as described in manual
183
+ add_action('plugin_loaded', 'ct_plugin_loaded' );
184
+
185
+ if( !empty($ct_options['use_ajax']) &&
186
+ stripos($_SERVER['REQUEST_URI'],'.xml')===false &&
187
+ stripos($_SERVER['REQUEST_URI'],'.xsl')===false)
188
+ {
189
+ add_action( 'wp_ajax_nopriv_ct_get_cookie', 'ct_get_cookie',1 );
190
+ add_action( 'wp_ajax_ct_get_cookie', 'ct_get_cookie',1 );
191
+ }
192
+
193
+ if(isset($ct_options['show_link']) && intval($ct_options['show_link']) == 1)
194
+ add_action('comment_form_after', 'ct_show_comment_link');
195
+
196
+ if(is_admin()){
197
+ require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-comments.php');
198
+ require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-users.php');
199
+ }
200
+
201
+ // Admin panel actions
202
+ if (is_admin()||is_network_admin()){
203
+
204
+ require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-admin.php');
205
+
206
+ if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)){
207
+ add_action('admin_init', 'ct_admin_init', 1);
208
+ add_action('admin_menu', 'ct_admin_add_page');
209
+ if(is_network_admin())
210
+ add_action('network_admin_menu', 'ct_admin_add_page');
211
+
212
+ add_action('admin_notices', 'cleantalk_admin_notice_message');
213
+ add_action('network_admin_notices', 'cleantalk_admin_notice_message');
214
+
215
+ //Show widget only if not IP license
216
+ if(empty($ct_data['moderate_ip']))
217
+ add_action('wp_dashboard_setup', 'ct_dashboard_statistics_widget' );
218
+
219
+ }
220
+ if (defined( 'DOING_AJAX' ) && DOING_AJAX||isset($_POST['cma-action'])){
221
+
222
+ // Feedback for comments
223
+ if(isset($_POST['action']) && $_POST['action'] == 'ct_feedback_comment'){
224
+ add_action( 'wp_ajax_nopriv_ct_feedback_comment', 'ct_comment_send_feedback',1 );
225
+ add_action( 'wp_ajax_ct_feedback_comment', 'ct_comment_send_feedback',1 );
226
+ }
227
+ if(isset($_POST['action']) && $_POST['action'] == 'ct_feedback_user'){
228
+ add_action( 'wp_ajax_nopriv_ct_feedback_user', 'ct_user_send_feedback',1 );
229
+ add_action( 'wp_ajax_ct_feedback_user', 'ct_user_send_feedback',1 );
230
+ }
231
+
232
+ $cleantalk_hooked_actions = array();
233
+ $cleantalk_ajax_actions_to_check = array();
234
+ require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-public.php');
235
+ require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-ajax.php');
236
+
237
+ // Do check for AJAX if Unknown action or Known action with mandatory check
238
+ if( isset($_POST['action']) &&
239
+ defined('LOGGED_IN_COOKIE') &&
240
+ !isset($_COOKIE[LOGGED_IN_COOKIE]) &&
241
+ (!in_array($_POST['action'], $cleantalk_hooked_actions) || in_array($_POST['action'], $cleantalk_ajax_actions_to_check))
242
+ ){
243
+ ct_ajax_hook();
244
+ }
245
+ //
246
+ // Some of plugins to register a users use AJAX context.
247
+ //
248
+ add_filter('registration_errors', 'ct_registration_errors', 1, 3);
249
+ add_filter('registration_errors', 'ct_check_registration_erros', 999999, 3);
250
+ add_action('user_register', 'ct_user_register');
251
+
252
+ //QAEngine Theme answers
253
+ if (intval($ct_options['general_contact_forms_test']))
254
+ add_filter('et_pre_insert_answer', 'ct_ajax_hook', 1, 1);
255
+ }
256
+
257
+ require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-public.php');
258
+
259
+ //Bitrix24 contact form
260
+ if (ct_is_user_enable()) {
261
+ ct_cookies_test();
262
+
263
+ if (isset($ct_options['general_contact_forms_test']) && $ct_options['general_contact_forms_test'] == 1 &&
264
+ !empty($_POST['your-phone']) &&
265
+ !empty($_POST['your-email']) &&
266
+ !empty($_POST['your-message'])
267
+ ){
268
+ $ct_check_post_result=false;
269
+ ct_contact_form_validate();
270
+ }
271
+ }
272
+
273
+ add_action('admin_enqueue_scripts', 'ct_enqueue_scripts');
274
+
275
+ // Sends feedback to the cloud about comments
276
+ // add_action('wp_set_comment_status', 'ct_comment_send_feedback', 10, 2);
277
+
278
+ // Sends feedback to the cloud about deleted users
279
+ if($pagenow=='users.php')
280
+ add_action('delete_user', 'ct_delete_user', 10, 2);
281
+
282
+ if($pagenow=='plugins.php' || (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'],'plugins.php') !== false)){
283
+
284
+ add_filter('plugin_action_links_'.plugin_basename(__FILE__), 'ct_plugin_action_links', 10, 2);
285
+ add_filter('network_admin_plugin_action_links_'.plugin_basename(__FILE__), 'ct_plugin_action_links', 10, 2);
286
+
287
+ add_filter('plugin_row_meta', 'ct_register_plugin_links', 10, 2);
288
+ }
289
+ add_action('updated_option', 'ct_update_option'); // param - option name, i.e. 'cleantalk_settings'
290
+
291
+ // Public pages actions
292
+ }else{
293
+
294
+ require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-public.php');
295
+
296
+ add_action('wp_enqueue_scripts', 'ct_enqueue_scripts_public');
297
+
298
+ // Init action.
299
+ add_action('plugins_loaded', 'ct_init', 1);
300
+
301
+ // Comments
302
+ add_filter('preprocess_comment', 'ct_preprocess_comment', 1, 1); // param - comment data array
303
+ add_filter('comment_text', 'ct_comment_text' );
304
+
305
+ // Registrations
306
+ add_action('register_form','ct_register_form');
307
+ add_filter('registration_errors', 'ct_registration_errors', 1, 3);
308
+ add_filter('registration_errors', 'ct_check_registration_erros', 999999, 3);
309
+ add_action('user_register', 'ct_user_register');
310
+
311
+ // Multisite registrations
312
+ add_action('signup_extra_fields','ct_register_form');
313
+ add_filter('wpmu_validate_user_signup', 'ct_registration_errors_wpmu', 10, 3);
314
+
315
+ // Login form - for notifications only
316
+ add_filter('login_message', 'ct_login_message');
317
+
318
+ // Comments output hook
319
+ add_filter('wp_list_comments_args', 'ct_wp_list_comments_args');
320
+
321
+ // Ait-Themes fix
322
+ if(isset($_GET['ait-action']) && $_GET['ait-action']=='register'){
323
+ $tmp=$_POST['redirect_to'];
324
+ unset($_POST['redirect_to']);
325
+ ct_contact_form_validate();
326
+ $_POST['redirect_to']=$tmp;
327
+ }
328
+ }
329
+ }
330
+
331
+ /**
332
+ * On activation, set a time, frequency and name of an action hook to be scheduled.
333
+ */
334
+ if (!function_exists ( 'ct_activation')) {
335
+ function ct_activation() {
336
+
337
+ global $wpdb;
338
+
339
+ $wpdb->query("CREATE TABLE IF NOT EXISTS `".$wpdb->base_prefix."cleantalk_sfw` (
340
+ `network` int(11) unsigned NOT NULL,
341
+ `mask` int(11) unsigned NOT NULL,
342
+ INDEX ( `network` , `mask` )
343
+ ) ENGINE = MYISAM ;"
344
+ );
345
+
346
+ $wpdb->query("CREATE TABLE IF NOT EXISTS `".$wpdb->base_prefix."cleantalk_sfw_logs` (
347
+ `ip` VARCHAR(15) NOT NULL,
348
+ `all_entries` INT NOT NULL,
349
+ `blocked_entries` INT NOT NULL,
350
+ `entries_timestamp` INT NOT NULL,
351
+ PRIMARY KEY (`ip`))
352
+ ENGINE = MYISAM;"
353
+ );
354
+
355
+ // Cron tasks
356
+ CleantalkCron::addTask('check_account_status', 'ct_account_status_check', 3600, time()+1800); // Checks account status
357
+ CleantalkCron::addTask('delete_spam_comments', 'ct_delete_spam_comments', 3600, time()+3500); // Formerly ct_hourly_event_hook()
358
+ CleantalkCron::addTask('send_feedback', 'ct_send_feedback', 3600, time()+3500); // Formerly ct_hourly_event_hook()
359
+ CleantalkCron::addTask('sfw_update', 'ct_sfw_update', 86400, time()+43200);// SFW update
360
+ CleantalkCron::addTask('send_sfw_logs', 'ct_sfw_send_logs', 3600, time()+1800); // SFW send logs
361
+ CleantalkCron::addTask('get_brief_data', 'cleantalk_get_brief_data', 86400, time()+3500); // Get data for dashboard widget
362
+
363
+ // Additional options
364
+ add_option('ct_plugin_do_activation_redirect', true);
365
+ add_option('ct_installing', true);
366
+
367
+ // Updating SFW
368
+ ct_sfw_update();
369
+ }
370
+ }
371
+
372
+ /**
373
+ * On deactivation, clear schedule.
374
+ */
375
+ if (!function_exists ( 'ct_deactivation')) {
376
+ function ct_deactivation() {
377
+
378
+ global $wpdb;
379
+
380
+ // Deleting SFW tables
381
+ $wpdb->query("DROP TABLE IF EXISTS `".$wpdb->base_prefix."cleantalk_sfw`;");
382
+ $wpdb->query("DROP TABLE IF EXISTS `".$wpdb->base_prefix."cleantalk_sfw_logs`;");
383
+
384
+ // Deleting cron entries
385
+ delete_option('cleantalk_cron');
386
+
387
+ }
388
+ }
389
+
390
+ /**
391
+ * Redirects admin to plugin settings after activation.
392
+ */
393
+ function ct_plugin_redirect()
394
+ {
395
+ if (get_option('ct_plugin_do_activation_redirect', false) && !isset($_GET['activate-multi'])){
396
+ delete_option('ct_plugin_do_activation_redirect');
397
+ wp_redirect("options-general.php?page=cleantalk");
398
+ }
399
+ }
400
+
401
+ function ct_add_event($event_type)
402
+ {
403
+ global $ct_data,$cleantalk_executed;
404
+
405
+ //
406
+ // To migrate on the new version of ct_add_event().
407
+ //
408
+ switch ($event_type) {
409
+ case '0': $event_type = 'no';break;
410
+ case '1': $event_type = 'yes';break;
411
+ }
412
+
413
+ $ct_data = ct_get_data();
414
+ $current_hour = intval(date('G'));
415
+
416
+ // Updating current hour
417
+ if($current_hour!=$ct_data['current_hour']){
418
+ $ct_data['current_hour']=$current_hour;
419
+ $ct_data['array_accepted'][$current_hour]=0;
420
+ $ct_data['array_blocked'][$current_hour]=0;
421
+ }
422
+
423
+ //Add 1 to counters
424
+ if($event_type=='yes'){
425
+ $ct_data['array_accepted'][$current_hour]++;
426
+ $ct_data['all_time_counter']['accepted']++;
427
+ $ct_data['user_counter']['accepted']++;
428
+ }
429
+ if($event_type=='no'){
430
+ $ct_data['array_blocked'][$current_hour]++;
431
+ $ct_data['all_time_counter']['blocked']++;
432
+ $ct_data['user_counter']['blocked']++;
433
+ }
434
+
435
+ update_option('cleantalk_data', $ct_data);
436
+ $cleantalk_executed=true;
437
+ }
438
+
439
+ /**
440
+ * return new cookie value
441
+ */
442
+ function ct_get_cookie()
443
+ {
444
+ global $ct_checkjs_def;
445
+ $ct_checkjs_key = ct_get_checkjs_value(true);
446
+ print $ct_checkjs_key;
447
+ die();
448
+ }
449
+
450
+ function ct_show_comment_link(){
451
+
452
+ print "<div style='font-size:10pt;'><a href='https://cleantalk.org/wordpress-anti-spam-plugin' target='_blank'>".__( 'WordPress spam', 'cleantalk' )."</a> ".__( 'blocked by', 'cleantalk' )." CleanTalk.</div>";
453
+
454
+ }
455
+
456
+ add_action( 'right_now_content_table_end', 'my_add_counts_to_dashboard' );
457
+
458
+ function ct_sfw_update(){
459
+
460
+ global $ct_options;
461
+
462
+ if(isset($ct_options['spam_firewall']) && intval($ct_options['spam_firewall']) == 1){
463
+
464
+ include_once(CLEANTALK_PLUGIN_DIR . "lib/CleantalkSFW.php");
465
+
466
+ $sfw = new CleantalkSFW();
467
+ $result = $sfw->sfw_update($ct_options['apikey']);
468
+ unset($sfw);
469
+
470
+ return $result === true ? true : $result;
471
+
472
+ }
473
+
474
+ return 'SFW_DISABLED';
475
+
476
+ }
477
+
478
+ function ct_sfw_send_logs()
479
+ {
480
+ global $ct_options, $ct_data;
481
+
482
+ $ct_options=ct_get_options();
483
+ $ct_data=ct_get_data();
484
+
485
+ if(isset($ct_options['spam_firewall']) && intval($ct_options['spam_firewall']) == 1){
486
+
487
+ include_once(CLEANTALK_PLUGIN_DIR . "lib/CleantalkSFW.php");
488
+
489
+ $sfw = new CleantalkSFW();
490
+ $result = $sfw->send_logs($ct_options['apikey']);
491
+ unset($sfw);
492
+
493
+ return $result === true ? true : $result;
494
+
495
+ }
496
+
497
+ return 'SFW_DISABLED';
498
+ }
499
+
500
+ function cleantalk_get_brief_data(){
501
+ $ct_options = ct_get_options();
502
+ $ct_data = ct_get_data();
503
+
504
+ require_once('inc/cleantalk.class.php');
505
+ $result = getAntispamReportBreif($ct_options['apikey']);
506
+
507
+ $ct_data['brief_data'] = $result;
508
+ update_option('cleantalk_data', $ct_data);
509
+
510
+ return;
511
+ }
512
+
513
+ //Delete cookie for admin trial notice
514
+ function ct_wp_logout(){
515
+ if(!headers_sent())
516
+ setcookie('ct_trial_banner_closed', '', time()-3600);
517
+ }
518
+
519
+ /*
520
+ function myplugin_update_field( $new_value, $old_value ) {
521
+ error_log('cleantalk_data dump: '. strlen(serialize($new_value)));
522
+ return $new_value;
523
+ }
524
+
525
+ function myplugin_init() {
526
+ add_filter( 'pre_update_option_cleantalk_data', 'myplugin_update_field', 10, 2 );
527
+ }
528
+
529
+ add_action( 'init', 'myplugin_init' );
530
+ */
 
 
 
 
531
  ?>
inc/cleantalk-admin.php CHANGED
@@ -333,13 +333,13 @@ function ct_account_status_check(){
333
  if (isset($result['show_notice'])){
334
 
335
  if ($result['show_notice'] == 1 && isset($result['trial']) && $result['trial'] == 1){
336
- cleantalk\antispam\CleantalkCron::updateTask('check_account_status', 'ct_account_status_check', 3600);
337
  $show_ct_notice_trial = true;
338
  $ct_data['show_ct_notice_trial']=1;
339
  }
340
 
341
  if ($result['show_notice'] == 1 && isset($result['renew']) && $result['renew'] == 1){
342
- cleantalk\antispam\CleantalkCron::updateTask('check_account_status', 'ct_account_status_check', 1800);
343
  $show_ct_notice_renew = true;
344
  $ct_data['show_ct_notice_renew']=1;
345
  }
@@ -348,7 +348,7 @@ function ct_account_status_check(){
348
  $ct_data['show_ct_notice_review'] = 1;
349
 
350
  if ($result['show_notice'] == 0)
351
- cleantalk\antispam\CleantalkCron::updateTask('check_account_status', 'ct_account_status_check', 86400);
352
 
353
  $ct_data['show_ct_notice_trial'] = (int) $show_ct_notice_trial;
354
  $ct_data['show_ct_notice_renew'] = (int) $show_ct_notice_renew;
@@ -639,7 +639,7 @@ function ct_input_all_time_counter() {
639
  echo "<input type='radio' class='ct-depends-of-show-adminbar' id='cleantalk_all_time_counter1' name='cleantalk_settings[all_time_counter]' value='1' ".($value=='1'?'checked':'').($value2=='0'?' disabled':'')." /><label for='cleantalk_all_time_counter1'> ".__('Yes')."</label>";
640
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
641
  echo "<input type='radio' class='ct-depends-of-show-adminbar' id='cleantalk_all_time_counter0' name='cleantalk_settings[all_time_counter]' value='0' ".($value=='0'?'checked':'').($value2=='0'?' disabled':'')." /><label for='cleantalk_all_time_counter0'> ".__('No')."</label>";
642
- @admin_addDescriptionsFields(sprintf(__('Display all-time requests counter in the admin bar. Counter displays number of requests since plugin installation.', 'cleantalk'), $ct_options['all_time_counter']));
643
  }
644
 
645
  function ct_input_daily_counter() {
@@ -654,7 +654,7 @@ function ct_input_daily_counter() {
654
  echo "<input type='radio' class='ct-depends-of-show-adminbar' id='cleantalk_daily_counter1' name='cleantalk_settings[daily_counter]' value='1' ".($value=='1'?'checked':'').($value2=='0'?' disabled':'')." /><label for='cleantalk_daily_counter1'> ".__('Yes')."</label>";
655
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
656
  echo "<input type='radio' class='ct-depends-of-show-adminbar' id='cleantalk_daily_counter0' name='cleantalk_settings[daily_counter]' value='0' ".($value=='0'?'checked':'').($value2=='0'?' disabled':'')." /><label for='cleantalk_daily_counter0'> ".__('No')."</label>";
657
- @admin_addDescriptionsFields(sprintf(__('Display daily requests counter in the admin bar. Counter displays number of requests of the past 24 hours.', 'cleantalk'), $ct_options['all_time_counter']));
658
  }
659
 
660
  function ct_input_sfw_counter() {
@@ -669,7 +669,7 @@ function ct_input_sfw_counter() {
669
  echo "<input type='radio' class='ct-depends-of-show-adminbar' id='cleantalk_sfw_counter1' name='cleantalk_settings[sfw_counter]' value='1' ".($value=='1'?'checked':'').($value2=='0'?' disabled':'')." /><label for='cleantalk_sfw_counter1'> ".__('Yes')."</label>";
670
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
671
  echo "<input type='radio' class='ct-depends-of-show-adminbar' id='cleantalk_sfw_counter0' name='cleantalk_settings[sfw_counter]' value='0' ".($value=='0'?'checked':'').($value2=='0'?' disabled':'')." /><label for='cleantalk_sfw_counter0'> ".__('No')."</label>";
672
- @admin_addDescriptionsFields(sprintf(__('Display all-time requests counter in the admin bar. Counter displays number of requests since plugin installation.', 'cleantalk'), $ct_options['sfw_counter']));
673
  }
674
 
675
  function ct_add_admin_menu( $wp_admin_bar ) {
@@ -955,8 +955,8 @@ function ct_input_apikey() {
955
  echo "<br />";
956
  echo "<br />";
957
 
958
- admin_addDescriptionsFields(sprintf(__('Admin e-mail (%s) will be used for registration', 'cleantalk'), ct_get_admin_email()));
959
- admin_addDescriptionsFields(sprintf('<a target="__blank" style="color:#BBB;" href="https://cleantalk.org/publicoffer">%s</a>', __('License agreement', 'cleantalk')));
960
  }
961
  } else {
962
  $cleantalk_support_links = "<br /><div>";
@@ -998,7 +998,7 @@ function ct_input_comments_test() {
998
  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>";
999
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1000
  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>";
1001
- admin_addDescriptionsFields(__('WordPress, JetPack, WooCommerce.', 'cleantalk'));
1002
  }
1003
 
1004
  //Titles for advanced settings.
@@ -1031,7 +1031,7 @@ function ct_input_remove_links_from_approved_comments() {
1031
  echo "<input type='radio' id='cleantalk_remove_links_from_comments1' name='cleantalk_settings[remove_comments_links]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_remove_links_from_comments1'> " . __('Yes') . "</label>";
1032
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1033
  echo "<input type='radio' id='cleantalk_remove_links_from_comments0' name='cleantalk_settings[remove_comments_links]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_remove_links_from_comments0'> " . __('No') . "</label>";
1034
- admin_addDescriptionsFields(__('Remove links from approved comments. Replace it with "[Link deleted]"', 'cleantalk'));
1035
  }
1036
 
1037
  /**
@@ -1048,7 +1048,7 @@ function ct_input_show_check_links() {
1048
  echo "<input type='radio' id='cleantalk_show_check_links1' name='cleantalk_settings[show_check_links]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_show_check_links1'> " . __('Yes') . "</label>";
1049
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1050
  echo "<input type='radio' id='cleantalk_show_check_links1' name='cleantalk_settings[show_check_links]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_show_check_links1'> " . __('No') . "</label>";
1051
- admin_addDescriptionsFields(__('Shows little icon near IP addresses and Emails allowing you to check it via CleanTalk\'s database. Also allowing you to manage comments from the public post\'s page.', 'cleantalk'));
1052
  }
1053
 
1054
  /**
@@ -1064,7 +1064,7 @@ function ct_input_registrations_test() {
1064
  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>";
1065
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1066
  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>";
1067
- admin_addDescriptionsFields(__('WordPress, BuddyPress, bbPress, S2Member, WooCommerce.', 'cleantalk'));
1068
  }
1069
 
1070
  /**
@@ -1080,7 +1080,7 @@ function ct_input_contact_forms_test() {
1080
  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>";
1081
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1082
  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>";
1083
- admin_addDescriptionsFields(__('Contact Form 7, Formidable forms, JetPack, Fast Secure Contact Form, WordPress Landing Pages, Gravity Forms.', 'cleantalk'));
1084
  }
1085
 
1086
  /**
@@ -1096,7 +1096,7 @@ function ct_input_general_contact_forms_test() {
1096
  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>";
1097
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1098
  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>";
1099
- admin_addDescriptionsFields(__('Anti spam test for any WordPress themes or contacts forms.', 'cleantalk'));
1100
  }
1101
 
1102
  /**
@@ -1112,7 +1112,7 @@ function ct_input_wc_chekout_test() {
1112
  echo "<input type='radio' id='cleantalk_wc_checkout_test1' name='cleantalk_settings[wc_checkout_test]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_wc_checkout_test1'> " . __('Yes') . "</label>";
1113
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1114
  echo "<input type='radio' id='cleantalk_wc_checkout_test0' name='cleantalk_settings[wc_checkout_test]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_wc_checkout_test0'> " . __('No') . "</label>";
1115
- admin_addDescriptionsFields(__('Anti spam test for WooCommerce checkout form.', 'cleantalk'));
1116
  }
1117
 
1118
  /**
@@ -1128,7 +1128,7 @@ function ct_input_bp_private_messages() {
1128
  echo "<input type='radio' id='bp_private_messages1' name='cleantalk_settings[bp_private_messages]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='bp_private_messages1'> " . __('Yes') . "</label>";
1129
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1130
  echo "<input type='radio' id='bp_private_messages0' name='cleantalk_settings[bp_private_messages]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='bp_private_messages0'> " . __('No') . "</label>";
1131
- admin_addDescriptionsFields(__('Check buddyPress private messages.', 'cleantalk'));
1132
  }
1133
 
1134
  /**
@@ -1147,7 +1147,7 @@ function ct_input_remove_old_spam() {
1147
  echo "<input type='radio' id='cleantalk_remove_old_spam1' name='cleantalk_settings[remove_old_spam]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_remove_old_spam1'> " . __('Yes') . "</label>";
1148
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1149
  echo "<input type='radio' id='cleantalk_remove_old_spam0' name='cleantalk_settings[remove_old_spam]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_remove_old_spam0'> " . __('No') . "</label>";
1150
- admin_addDescriptionsFields(sprintf(__('Delete spam comments older than %d days.', 'cleantalk'), $ct_options['spam_store_days']));
1151
  }
1152
 
1153
  /**
@@ -1172,7 +1172,7 @@ function ct_input_show_adminbar() {
1172
  echo "<input type='radio' id='cleantalk_show_adminbar1' name='cleantalk_settings[show_adminbar]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_show_adminbar1'> " . __('Yes') . "</label>";
1173
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1174
  echo "<input type='radio' id='cleantalk_show_adminbar0' name='cleantalk_settings[show_adminbar]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_show_adminbar0'> " . __('No') . "</label>";
1175
- admin_addDescriptionsFields(sprintf(__('Show/hide CleanTalk icon in top level menu in WordPress backend. The number of submissions is being counted for past 24 hours.', 'cleantalk'), $ct_options['show_adminbar']));
1176
  }
1177
 
1178
  /**
@@ -1197,7 +1197,7 @@ function ct_input_general_postdata_test() {
1197
  echo "<input type='radio' id='cleantalk_general_postdata_test1' name='cleantalk_settings[general_postdata_test]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_general_postdata_test1'> " . __('Yes') . "</label>";
1198
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1199
  echo "<input type='radio' id='cleantalk_general_postdata_test0' name='cleantalk_settings[general_postdata_test]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_general_postdata_test0'> " . __('No') . "</label>";
1200
- @admin_addDescriptionsFields(sprintf(__('Check all POST submissions from website visitors. Enable this option if you have spam misses on website or you don`t have records about missed spam here:', 'cleantalk') . '&nbsp;' . '<a href="https://cleantalk.org/my/?user_token='.@$ct_data['user_token'].'&utm_source=wp-backend&utm_medium=admin-bar&cp_mode=antispam" target="_blank">' . __('CleanTalk dashboard', 'cleantalk') . '</a>.<br />' . __('СAUTION! Option can catch POST requests in WordPress backend', 'cleantalk'), $ct_options['general_postdata_test']));
1201
  }
1202
 
1203
  function ct_input_use_ajax() {
@@ -1217,7 +1217,7 @@ function ct_input_use_ajax() {
1217
  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>";
1218
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1219
  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>";
1220
- @admin_addDescriptionsFields(sprintf(__('Options helps protect WordPress against spam with any caching plugins. Turn this option on to avoid issues with caching plugins.', 'cleantalk')."<strong> ".__('Attention! Incompatible with AMP plugins!', 'cleantalk')."</strong>", $ct_options['use_ajax']));
1221
  }
1222
 
1223
  function ct_input_check_comments_number() {
@@ -1247,7 +1247,7 @@ function ct_input_check_comments_number() {
1247
  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>";
1248
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1249
  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>";
1250
- @admin_addDescriptionsFields(sprintf(__("Dont't check comments for users with above", 'cleantalk') . $comments_check_number . __("comments.", 'cleantalk'), $ct_options['check_comments_number']));
1251
  }
1252
 
1253
  function ct_input_collect_details() {
@@ -1267,7 +1267,7 @@ function ct_input_collect_details() {
1267
 
1268
  echo "<div id='cleantalk_anchor2' style='display:none'></div><input type=hidden name='cleantalk_settings[collect_details]' value='0' />";
1269
  echo "<input type='checkbox' id='collect_details1' name='cleantalk_settings[collect_details]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='collect_details1'> " . __('Collect details about browsers', 'cleantalk') . "</label>";
1270
- @admin_addDescriptionsFields(sprintf(__("Checking this box you allow plugin store information about screen size and browser plugins of website visitors. The option in a beta state.", 'cleantalk'), $ct_options['spam_firewall']));
1271
  echo "<script>
1272
  jQuery(document).ready(function(){
1273
  jQuery('#cleantalk_anchor2').parent().parent().children().first().hide();
@@ -1304,7 +1304,7 @@ function ct_input_check_messages_number() {
1304
  echo "<input type='radio' id='cleantalk_check_messages_number1' name='cleantalk_settings[check_messages_number]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_check_messages_number1'> " . __('Yes') . "</label>";
1305
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1306
  echo "<input type='radio' id='cleantalk_check_messages_number0' name='cleantalk_settings[check_messages_number]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_check_messages_number0'> " . __('No') . "</label>";
1307
- @admin_addDescriptionsFields(sprintf(__("Dont't check messages for users with above $messages_check_number messages", 'cleantalk'), $ct_options['check_messages_number']));
1308
  }
1309
 
1310
  function ct_input_check_external() {
@@ -1324,7 +1324,7 @@ function ct_input_check_external() {
1324
  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>";
1325
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1326
  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>";
1327
- @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']));
1328
  }
1329
 
1330
  function ct_input_check_internal() {
@@ -1344,7 +1344,7 @@ function ct_input_check_internal() {
1344
  echo "<input type='radio' id='cleantalk_check_internal1' name='cleantalk_settings[check_internal]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_check_internal1'> " . __('Yes') . "</label>";
1345
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1346
  echo "<input type='radio' id='cleantalk_check_internal0' name='cleantalk_settings[check_internal]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_check_internal0'> " . __('No') . "</label>";
1347
- @admin_addDescriptionsFields(sprintf(__('This option will enable protection for custom (hand-made) AJAX forms with PHP scripts handlers on your WordPress.', 'cleantalk'), $ct_options['check_internal']));
1348
  }
1349
 
1350
  function ct_input_set_cookies() {
@@ -1356,7 +1356,7 @@ function ct_input_set_cookies() {
1356
  echo "<input type='radio' id='cleantalk_set_cookies1' name='cleantalk_settings[set_cookies]' value='1' " . (!empty($ct_options['set_cookies']) ? 'checked' : '') . " /><label for='cleantalk_set_cookies1'> " . __('Yes') . "</label>";
1357
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1358
  echo "<input type='radio' id='cleantalk_set_cookies0' name='cleantalk_settings[set_cookies]' value='0' " . (empty($ct_options['set_cookies']) ? 'checked' : '') . " /><label for='cleantalk_set_cookies0'> " . __('No') . "</label>";
1359
- @admin_addDescriptionsFields(sprintf(__('Turn this option off to deny plugin generates any cookies on website front-end. This option is helpful if you use Varnish. But most of contact forms will not be protected by CleanTalk if the option is turned off!', 'cleantalk')));
1360
  }
1361
 
1362
  function ct_input_ssl_on() {
@@ -1368,7 +1368,7 @@ function ct_input_ssl_on() {
1368
  echo "<input type='radio' id='cleantalk_ssl_on1' name='cleantalk_settings[ssl_on]' value='1' " . (!empty($ct_options['ssl_on']) ? 'checked' : '') . " /><label for='cleantalk_ssl_on1'> " . __('Yes') . "</label>";
1369
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1370
  echo "<input type='radio' id='cleantalk_ssl_on0' name='cleantalk_settings[ssl_on]' value='0' " . (empty($ct_options['ssl_on']) ? 'checked' : '') . " /><label for='cleantalk_ssl_on0'> " . __('No') . "</label>";
1371
- @admin_addDescriptionsFields(sprintf(__('Turn this option on to use encrypted (SSL) connection with CleanTalk servers.', 'cleantalk')));
1372
  }
1373
 
1374
  function ct_input_protect_logged_in() {
@@ -1380,7 +1380,7 @@ function ct_input_protect_logged_in() {
1380
  echo "<input type='radio' id='cleantalk_protect_logged_in1' name='cleantalk_settings[protect_logged_in]' value='1' " . (!empty($ct_options['protect_logged_in']) ? 'checked' : '') . " /><label for='cleantalk_protect_logged_in1'> " . __('Yes') . "</label>";
1381
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1382
  echo "<input type='radio' id='cleantalk_protect_logged_in0' name='cleantalk_settings[protect_logged_in]' value='0' " . (empty($ct_options['protect_logged_in']) ? 'checked' : '') . " /><label for='cleantalk_protect_logged_in0'> " . __('No') . "</label>";
1383
- @admin_addDescriptionsFields(sprintf(__('Turn this option on to check for spam any submissions (comments, contact forms and etc.) from registered Users.', 'cleantalk')));
1384
 
1385
  return null;
1386
  }
@@ -1397,7 +1397,7 @@ function ct_input_show_link() {
1397
 
1398
  echo "<div id='cleantalk_anchor' style='display:none'></div><input type=hidden name='cleantalk_settings[show_link]' value='0' />";
1399
  echo "<input type='checkbox' id='cleantalk_show_link1' name='cleantalk_settings[show_link]' value='1' " . (!empty($ct_options['show_link']) ? 'checked' : '') . " /><label for='cleantalk_show_link1'> " . __('Tell others about CleanTalk', 'cleantalk') . "</label>";
1400
- @admin_addDescriptionsFields(sprintf(__("Checking this box places a small link under the comment form that lets others know what anti-spam tool protects your site.", 'cleantalk'), $ct_options['show_link']));
1401
  echo "<script>
1402
  jQuery(document).ready(function(){
1403
  jQuery('#cleantalk_anchor').parent().parent().children().first().hide();
@@ -1414,7 +1414,7 @@ function ct_input_spam_firewall() {
1414
 
1415
  echo "<div id='cleantalk_anchor1' style='display:none'></div><input type=hidden name='cleantalk_settings[spam_firewall]' value='0' />";
1416
  echo "<input type='checkbox' id='cleantalk_spam_firewall1' name='cleantalk_settings[spam_firewall]' value='1' " . (!empty($ct_options['spam_firewall']) ? 'checked' : '') . " /><label for='cleantalk_spam_firewall1'> " . __('SpamFireWall') . "</label>";
1417
- @admin_addDescriptionsFields(sprintf(__("This option allows to filter spam bots before they access website. Also reduces CPU usage on hosting server and accelerates pages load time.", 'cleantalk'), $ct_options['spam_firewall']) .
1418
  " " .
1419
  '<a href="https://cleantalk.org/cleantalk-spam-firewall" style="font-size: 10pt; color: #666 !important" target="_blank">' . __('Learn more', 'cleantalk') . '</a>.'
1420
  );
@@ -1660,7 +1660,7 @@ function cleantalk_admin_notice_message(){
1660
  *
1661
  * Add descriptions for field
1662
  */
1663
- function admin_addDescriptionsFields($descr = '') {
1664
  echo "<div style='font-size: 10pt; color: #666 !important'>$descr</div>";
1665
  }
1666
 
333
  if (isset($result['show_notice'])){
334
 
335
  if ($result['show_notice'] == 1 && isset($result['trial']) && $result['trial'] == 1){
336
+ CleantalkCron::updateTask('check_account_status', 'ct_account_status_check', 3600);
337
  $show_ct_notice_trial = true;
338
  $ct_data['show_ct_notice_trial']=1;
339
  }
340
 
341
  if ($result['show_notice'] == 1 && isset($result['renew']) && $result['renew'] == 1){
342
+ CleantalkCron::updateTask('check_account_status', 'ct_account_status_check', 1800);
343
  $show_ct_notice_renew = true;
344
  $ct_data['show_ct_notice_renew']=1;
345
  }
348
  $ct_data['show_ct_notice_review'] = 1;
349
 
350
  if ($result['show_notice'] == 0)
351
+ CleantalkCron::updateTask('check_account_status', 'ct_account_status_check', 86400);
352
 
353
  $ct_data['show_ct_notice_trial'] = (int) $show_ct_notice_trial;
354
  $ct_data['show_ct_notice_renew'] = (int) $show_ct_notice_renew;
639
  echo "<input type='radio' class='ct-depends-of-show-adminbar' id='cleantalk_all_time_counter1' name='cleantalk_settings[all_time_counter]' value='1' ".($value=='1'?'checked':'').($value2=='0'?' disabled':'')." /><label for='cleantalk_all_time_counter1'> ".__('Yes')."</label>";
640
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
641
  echo "<input type='radio' class='ct-depends-of-show-adminbar' id='cleantalk_all_time_counter0' name='cleantalk_settings[all_time_counter]' value='0' ".($value=='0'?'checked':'').($value2=='0'?' disabled':'')." /><label for='cleantalk_all_time_counter0'> ".__('No')."</label>";
642
+ ct_add_descriptions_to_fields(sprintf(__('Display all-time requests counter in the admin bar. Counter displays number of requests since plugin installation.', 'cleantalk'), $ct_options['all_time_counter']));
643
  }
644
 
645
  function ct_input_daily_counter() {
654
  echo "<input type='radio' class='ct-depends-of-show-adminbar' id='cleantalk_daily_counter1' name='cleantalk_settings[daily_counter]' value='1' ".($value=='1'?'checked':'').($value2=='0'?' disabled':'')." /><label for='cleantalk_daily_counter1'> ".__('Yes')."</label>";
655
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
656
  echo "<input type='radio' class='ct-depends-of-show-adminbar' id='cleantalk_daily_counter0' name='cleantalk_settings[daily_counter]' value='0' ".($value=='0'?'checked':'').($value2=='0'?' disabled':'')." /><label for='cleantalk_daily_counter0'> ".__('No')."</label>";
657
+ ct_add_descriptions_to_fields(sprintf(__('Display daily requests counter in the admin bar. Counter displays number of requests of the past 24 hours.', 'cleantalk'), $ct_options['all_time_counter']));
658
  }
659
 
660
  function ct_input_sfw_counter() {
669
  echo "<input type='radio' class='ct-depends-of-show-adminbar' id='cleantalk_sfw_counter1' name='cleantalk_settings[sfw_counter]' value='1' ".($value=='1'?'checked':'').($value2=='0'?' disabled':'')." /><label for='cleantalk_sfw_counter1'> ".__('Yes')."</label>";
670
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
671
  echo "<input type='radio' class='ct-depends-of-show-adminbar' id='cleantalk_sfw_counter0' name='cleantalk_settings[sfw_counter]' value='0' ".($value=='0'?'checked':'').($value2=='0'?' disabled':'')." /><label for='cleantalk_sfw_counter0'> ".__('No')."</label>";
672
+ ct_add_descriptions_to_fields(sprintf(__('Display all-time requests counter in the admin bar. Counter displays number of requests since plugin installation.', 'cleantalk'), $ct_options['sfw_counter']));
673
  }
674
 
675
  function ct_add_admin_menu( $wp_admin_bar ) {
955
  echo "<br />";
956
  echo "<br />";
957
 
958
+ ct_add_descriptions_to_fields(sprintf(__('Admin e-mail (%s) will be used for registration', 'cleantalk'), ct_get_admin_email()));
959
+ ct_add_descriptions_to_fields(sprintf('<a target="__blank" style="color:#BBB;" href="https://cleantalk.org/publicoffer">%s</a>', __('License agreement', 'cleantalk')));
960
  }
961
  } else {
962
  $cleantalk_support_links = "<br /><div>";
998
  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>";
999
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1000
  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>";
1001
+ ct_add_descriptions_to_fields(__('WordPress, JetPack, WooCommerce.', 'cleantalk'));
1002
  }
1003
 
1004
  //Titles for advanced settings.
1031
  echo "<input type='radio' id='cleantalk_remove_links_from_comments1' name='cleantalk_settings[remove_comments_links]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_remove_links_from_comments1'> " . __('Yes') . "</label>";
1032
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1033
  echo "<input type='radio' id='cleantalk_remove_links_from_comments0' name='cleantalk_settings[remove_comments_links]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_remove_links_from_comments0'> " . __('No') . "</label>";
1034
+ ct_add_descriptions_to_fields(__('Remove links from approved comments. Replace it with "[Link deleted]"', 'cleantalk'));
1035
  }
1036
 
1037
  /**
1048
  echo "<input type='radio' id='cleantalk_show_check_links1' name='cleantalk_settings[show_check_links]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_show_check_links1'> " . __('Yes') . "</label>";
1049
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1050
  echo "<input type='radio' id='cleantalk_show_check_links1' name='cleantalk_settings[show_check_links]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_show_check_links1'> " . __('No') . "</label>";
1051
+ ct_add_descriptions_to_fields(__('Shows little icon near IP addresses and Emails allowing you to check it via CleanTalk\'s database. Also allowing you to manage comments from the public post\'s page.', 'cleantalk'));
1052
  }
1053
 
1054
  /**
1064
  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>";
1065
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1066
  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>";
1067
+ ct_add_descriptions_to_fields(__('WordPress, BuddyPress, bbPress, S2Member, WooCommerce.', 'cleantalk'));
1068
  }
1069
 
1070
  /**
1080
  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>";
1081
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1082
  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>";
1083
+ ct_add_descriptions_to_fields(__('Contact Form 7, Formidable forms, JetPack, Fast Secure Contact Form, WordPress Landing Pages, Gravity Forms.', 'cleantalk'));
1084
  }
1085
 
1086
  /**
1096
  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>";
1097
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1098
  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>";
1099
+ ct_add_descriptions_to_fields(__('Anti spam test for any WordPress themes or contacts forms.', 'cleantalk'));
1100
  }
1101
 
1102
  /**
1112
  echo "<input type='radio' id='cleantalk_wc_checkout_test1' name='cleantalk_settings[wc_checkout_test]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_wc_checkout_test1'> " . __('Yes') . "</label>";
1113
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1114
  echo "<input type='radio' id='cleantalk_wc_checkout_test0' name='cleantalk_settings[wc_checkout_test]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_wc_checkout_test0'> " . __('No') . "</label>";
1115
+ ct_add_descriptions_to_fields(__('Anti spam test for WooCommerce checkout form.', 'cleantalk'));
1116
  }
1117
 
1118
  /**
1128
  echo "<input type='radio' id='bp_private_messages1' name='cleantalk_settings[bp_private_messages]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='bp_private_messages1'> " . __('Yes') . "</label>";
1129
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1130
  echo "<input type='radio' id='bp_private_messages0' name='cleantalk_settings[bp_private_messages]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='bp_private_messages0'> " . __('No') . "</label>";
1131
+ ct_add_descriptions_to_fields(__('Check buddyPress private messages.', 'cleantalk'));
1132
  }
1133
 
1134
  /**
1147
  echo "<input type='radio' id='cleantalk_remove_old_spam1' name='cleantalk_settings[remove_old_spam]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_remove_old_spam1'> " . __('Yes') . "</label>";
1148
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1149
  echo "<input type='radio' id='cleantalk_remove_old_spam0' name='cleantalk_settings[remove_old_spam]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_remove_old_spam0'> " . __('No') . "</label>";
1150
+ ct_add_descriptions_to_fields(sprintf(__('Delete spam comments older than %d days.', 'cleantalk'), $ct_options['spam_store_days']));
1151
  }
1152
 
1153
  /**
1172
  echo "<input type='radio' id='cleantalk_show_adminbar1' name='cleantalk_settings[show_adminbar]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_show_adminbar1'> " . __('Yes') . "</label>";
1173
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1174
  echo "<input type='radio' id='cleantalk_show_adminbar0' name='cleantalk_settings[show_adminbar]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_show_adminbar0'> " . __('No') . "</label>";
1175
+ ct_add_descriptions_to_fields(sprintf(__('Show/hide CleanTalk icon in top level menu in WordPress backend. The number of submissions is being counted for past 24 hours.', 'cleantalk'), $ct_options['show_adminbar']));
1176
  }
1177
 
1178
  /**
1197
  echo "<input type='radio' id='cleantalk_general_postdata_test1' name='cleantalk_settings[general_postdata_test]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_general_postdata_test1'> " . __('Yes') . "</label>";
1198
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1199
  echo "<input type='radio' id='cleantalk_general_postdata_test0' name='cleantalk_settings[general_postdata_test]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_general_postdata_test0'> " . __('No') . "</label>";
1200
+ ct_add_descriptions_to_fields(sprintf(__('Check all POST submissions from website visitors. Enable this option if you have spam misses on website or you don`t have records about missed spam here:', 'cleantalk') . '&nbsp;' . '<a href="https://cleantalk.org/my/?user_token='.@$ct_data['user_token'].'&utm_source=wp-backend&utm_medium=admin-bar&cp_mode=antispam" target="_blank">' . __('CleanTalk dashboard', 'cleantalk') . '</a>.<br />' . __('СAUTION! Option can catch POST requests in WordPress backend', 'cleantalk'), $ct_options['general_postdata_test']));
1201
  }
1202
 
1203
  function ct_input_use_ajax() {
1217
  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>";
1218
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1219
  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>";
1220
+ ct_add_descriptions_to_fields(sprintf(__('Options helps protect WordPress against spam with any caching plugins. Turn this option on to avoid issues with caching plugins.', 'cleantalk')."<strong> ".__('Attention! Incompatible with AMP plugins!', 'cleantalk')."</strong>", $ct_options['use_ajax']));
1221
  }
1222
 
1223
  function ct_input_check_comments_number() {
1247
  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>";
1248
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1249
  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>";
1250
+ ct_add_descriptions_to_fields(sprintf(__("Dont't check comments for users with above", 'cleantalk') . $comments_check_number . __("comments.", 'cleantalk'), $ct_options['check_comments_number']));
1251
  }
1252
 
1253
  function ct_input_collect_details() {
1267
 
1268
  echo "<div id='cleantalk_anchor2' style='display:none'></div><input type=hidden name='cleantalk_settings[collect_details]' value='0' />";
1269
  echo "<input type='checkbox' id='collect_details1' name='cleantalk_settings[collect_details]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='collect_details1'> " . __('Collect details about browsers', 'cleantalk') . "</label>";
1270
+ ct_add_descriptions_to_fields(sprintf(__("Checking this box you allow plugin store information about screen size and browser plugins of website visitors. The option in a beta state.", 'cleantalk'), $ct_options['spam_firewall']));
1271
  echo "<script>
1272
  jQuery(document).ready(function(){
1273
  jQuery('#cleantalk_anchor2').parent().parent().children().first().hide();
1304
  echo "<input type='radio' id='cleantalk_check_messages_number1' name='cleantalk_settings[check_messages_number]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_check_messages_number1'> " . __('Yes') . "</label>";
1305
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1306
  echo "<input type='radio' id='cleantalk_check_messages_number0' name='cleantalk_settings[check_messages_number]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_check_messages_number0'> " . __('No') . "</label>";
1307
+ ct_add_descriptions_to_fields(sprintf(__("Dont't check messages for users with above $messages_check_number messages", 'cleantalk'), $ct_options['check_messages_number']));
1308
  }
1309
 
1310
  function ct_input_check_external() {
1324
  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>";
1325
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1326
  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>";
1327
+ ct_add_descriptions_to_fields(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']));
1328
  }
1329
 
1330
  function ct_input_check_internal() {
1344
  echo "<input type='radio' id='cleantalk_check_internal1' name='cleantalk_settings[check_internal]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_check_internal1'> " . __('Yes') . "</label>";
1345
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1346
  echo "<input type='radio' id='cleantalk_check_internal0' name='cleantalk_settings[check_internal]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_check_internal0'> " . __('No') . "</label>";
1347
+ ct_add_descriptions_to_fields(sprintf(__('This option will enable protection for custom (hand-made) AJAX forms with PHP scripts handlers on your WordPress.', 'cleantalk'), $ct_options['check_internal']));
1348
  }
1349
 
1350
  function ct_input_set_cookies() {
1356
  echo "<input type='radio' id='cleantalk_set_cookies1' name='cleantalk_settings[set_cookies]' value='1' " . (!empty($ct_options['set_cookies']) ? 'checked' : '') . " /><label for='cleantalk_set_cookies1'> " . __('Yes') . "</label>";
1357
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1358
  echo "<input type='radio' id='cleantalk_set_cookies0' name='cleantalk_settings[set_cookies]' value='0' " . (empty($ct_options['set_cookies']) ? 'checked' : '') . " /><label for='cleantalk_set_cookies0'> " . __('No') . "</label>";
1359
+ ct_add_descriptions_to_fields(sprintf(__('Turn this option off to deny plugin generates any cookies on website front-end. This option is helpful if you use Varnish. But most of contact forms will not be protected by CleanTalk if the option is turned off!', 'cleantalk')));
1360
  }
1361
 
1362
  function ct_input_ssl_on() {
1368
  echo "<input type='radio' id='cleantalk_ssl_on1' name='cleantalk_settings[ssl_on]' value='1' " . (!empty($ct_options['ssl_on']) ? 'checked' : '') . " /><label for='cleantalk_ssl_on1'> " . __('Yes') . "</label>";
1369
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1370
  echo "<input type='radio' id='cleantalk_ssl_on0' name='cleantalk_settings[ssl_on]' value='0' " . (empty($ct_options['ssl_on']) ? 'checked' : '') . " /><label for='cleantalk_ssl_on0'> " . __('No') . "</label>";
1371
+ ct_add_descriptions_to_fields(sprintf(__('Turn this option on to use encrypted (SSL) connection with CleanTalk servers.', 'cleantalk')));
1372
  }
1373
 
1374
  function ct_input_protect_logged_in() {
1380
  echo "<input type='radio' id='cleantalk_protect_logged_in1' name='cleantalk_settings[protect_logged_in]' value='1' " . (!empty($ct_options['protect_logged_in']) ? 'checked' : '') . " /><label for='cleantalk_protect_logged_in1'> " . __('Yes') . "</label>";
1381
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1382
  echo "<input type='radio' id='cleantalk_protect_logged_in0' name='cleantalk_settings[protect_logged_in]' value='0' " . (empty($ct_options['protect_logged_in']) ? 'checked' : '') . " /><label for='cleantalk_protect_logged_in0'> " . __('No') . "</label>";
1383
+ ct_add_descriptions_to_fields(sprintf(__('Turn this option on to check for spam any submissions (comments, contact forms and etc.) from registered Users.', 'cleantalk')));
1384
 
1385
  return null;
1386
  }
1397
 
1398
  echo "<div id='cleantalk_anchor' style='display:none'></div><input type=hidden name='cleantalk_settings[show_link]' value='0' />";
1399
  echo "<input type='checkbox' id='cleantalk_show_link1' name='cleantalk_settings[show_link]' value='1' " . (!empty($ct_options['show_link']) ? 'checked' : '') . " /><label for='cleantalk_show_link1'> " . __('Tell others about CleanTalk', 'cleantalk') . "</label>";
1400
+ ct_add_descriptions_to_fields(sprintf(__("Checking this box places a small link under the comment form that lets others know what anti-spam tool protects your site.", 'cleantalk'), $ct_options['show_link']));
1401
  echo "<script>
1402
  jQuery(document).ready(function(){
1403
  jQuery('#cleantalk_anchor').parent().parent().children().first().hide();
1414
 
1415
  echo "<div id='cleantalk_anchor1' style='display:none'></div><input type=hidden name='cleantalk_settings[spam_firewall]' value='0' />";
1416
  echo "<input type='checkbox' id='cleantalk_spam_firewall1' name='cleantalk_settings[spam_firewall]' value='1' " . (!empty($ct_options['spam_firewall']) ? 'checked' : '') . " /><label for='cleantalk_spam_firewall1'> " . __('SpamFireWall') . "</label>";
1417
+ ct_add_descriptions_to_fields(sprintf(__("This option allows to filter spam bots before they access website. Also reduces CPU usage on hosting server and accelerates pages load time.", 'cleantalk'), $ct_options['spam_firewall']) .
1418
  " " .
1419
  '<a href="https://cleantalk.org/cleantalk-spam-firewall" style="font-size: 10pt; color: #666 !important" target="_blank">' . __('Learn more', 'cleantalk') . '</a>.'
1420
  );
1660
  *
1661
  * Add descriptions for field
1662
  */
1663
+ function ct_add_descriptions_to_fields($descr = '') {
1664
  echo "<div style='font-size: 10pt; color: #666 !important'>$descr</div>";
1665
  }
1666
 
inc/cleantalk-ajax.php CHANGED
@@ -1,722 +1,722 @@
1
- <?php
2
- global $cleantalk_hooked_actions;
3
-
4
- /*
5
- AJAX functions
6
- */
7
-
8
- //$cleantalk_ajax_actions_to_check - array for POST 'actions' we should check.
9
-
10
- $cleantalk_ajax_actions_to_check[] = 'qcf_validate_form'; //Quick Contact Form
11
- $cleantalk_ajax_actions_to_check[] = 'amoforms_submit'; //amoForms
12
-
13
- //cleantalk_hooked_actions[] - array for POST 'actions' which were direct hooked.
14
-
15
- $cleantalk_hooked_actions[] = 'rwp_ajax_action_rating'; //Don't check Reviewer plugin
16
-
17
- $cleantalk_hooked_actions[] = 'ct_feedback_comment';
18
-
19
- /* MailChimp Premium*/
20
- add_filter('mc4wp_form_errors', 'ct_mc4wp_ajax_hook');
21
-
22
- /*hooks for Usernoise Form*/
23
- add_action('un_feedback_form_body', 'ct_add_hidden_fields',1);
24
- add_filter('un_validate_feedback', 'ct_ajax_hook', 1, 2);
25
-
26
- /*hooks for AJAX Login & Register email validation*/
27
- add_action( 'wp_ajax_nopriv_validate_email', 'ct_validate_email_ajaxlogin',1 );
28
- add_action( 'wp_ajax_validate_email', 'ct_validate_email_ajaxlogin',1 );
29
- $cleantalk_hooked_actions[]='validate_email';
30
-
31
- /*hooks for user registration*/
32
- add_action( 'user_register', 'ct_user_register_ajaxlogin',1 );
33
-
34
- /*hooks for WPUF pro */
35
- //add_action( 'wp_ajax_nopriv_wpuf_submit_register', 'ct_wpuf_submit_register',1 );
36
- //add_action( 'wp_ajax_wpuf_submit_register', 'ct_wpuf_submit_register',1 );
37
- add_action( 'wp_ajax_nopriv_wpuf_submit_register', 'ct_ajax_hook',1 );
38
- add_action( 'wp_ajax_wpuf_submit_register', 'ct_ajax_hook',1 );
39
- $cleantalk_hooked_actions[]='submit_register';
40
-
41
- /*hooks for MyMail */
42
- //add_action( 'wp_ajax_nopriv_mymail_form_submit', 'ct_mymail_form_submit',1 );
43
- //add_action( 'wp_ajax_mymail_form_submit', 'ct_mymail_form_submit',1 );
44
- add_action( 'wp_ajax_nopriv_mymail_form_submit', 'ct_ajax_hook',1 );
45
- add_action( 'wp_ajax_mymail_form_submit', 'ct_ajax_hook',1 );
46
- $cleantalk_hooked_actions[]='form_submit';
47
-
48
- /*hooks for MailPoet */
49
- //add_action( 'wp_ajax_nopriv_wysija_ajax', 'ct_wysija_ajax',1 );
50
- //add_action( 'wp_ajax_wysija_ajax', 'ct_wysija_ajax',1 );
51
- add_action( 'wp_ajax_nopriv_wysija_ajax', 'ct_ajax_hook',1 );
52
- add_action( 'wp_ajax_wysija_ajax', 'ct_ajax_hook',1 );
53
- $cleantalk_hooked_actions[]='wysija_ajax';
54
-
55
- /*hooks for cs_registration_validation */
56
- //add_action( 'wp_ajax_nopriv_cs_registration_validation', 'ct_cs_registration_validation',1 );
57
- //add_action( 'wp_ajax_cs_registration_validation', 'ct_cs_registration_validation',1 );
58
- add_action( 'wp_ajax_nopriv_cs_registration_validation', 'ct_ajax_hook',1 );
59
- add_action( 'wp_ajax_cs_registration_validation', 'ct_ajax_hook',1 );
60
- $cleantalk_hooked_actions[]='cs_registration_validation';
61
-
62
- /*hooks for send_message and request_appointment */
63
- //add_action( 'wp_ajax_nopriv_send_message', 'ct_sm_ra',1 );
64
- //add_action( 'wp_ajax_send_message', 'ct_sm_ra',1 );
65
- //add_action( 'wp_ajax_nopriv_request_appointment', 'ct_sm_ra',1 );
66
- //add_action( 'wp_ajax_request_appointment', 'ct_sm_ra',1 );
67
- add_action( 'wp_ajax_nopriv_send_message', 'ct_ajax_hook',1 );
68
- add_action( 'wp_ajax_send_message', 'ct_ajax_hook',1 );
69
- add_action( 'wp_ajax_nopriv_request_appointment', 'ct_ajax_hook',1 );
70
- add_action( 'wp_ajax_request_appointment', 'ct_ajax_hook',1 );
71
- $cleantalk_hooked_actions[]='send_message';
72
- $cleantalk_hooked_actions[]='request_appointment';
73
-
74
- /*hooks for zn_do_login */
75
- //add_action( 'wp_ajax_nopriv_zn_do_login', 'ct_zn_do_login',1 );
76
- //add_action( 'wp_ajax_zn_do_login', 'ct_zn_do_login',1 );
77
- add_action( 'wp_ajax_nopriv_zn_do_login', 'ct_ajax_hook',1 );
78
- add_action( 'wp_ajax_zn_do_login', 'ct_ajax_hook',1 );
79
- $cleantalk_hooked_actions[]='zn_do_login';
80
-
81
- /*hooks for zn_do_login */
82
- //add_action( 'wp_ajax_nopriv_cscf-submitform', 'ct_cscf_submitform',1 );
83
- //add_action( 'wp_ajax_cscf-submitform', 'ct_cscf_submitform',1 );
84
- if(isset($_POST['action']) && $_POST['action'] == 'cscf-submitform'){
85
- add_filter('preprocess_comment', 'ct_ajax_hook', 1);
86
- //add_action( 'wp_ajax_nopriv_cscf-submitform', 'ct_ajax_hook',1 );
87
- //add_action( 'wp_ajax_cscf-submitform', 'ct_ajax_hook',1 );
88
- $cleantalk_hooked_actions[]='cscf-submitform';
89
- }
90
-
91
-
92
- /*hooks for visual form builder */
93
- //add_action( 'wp_ajax_nopriv_vfb_submit', 'ct_vfb_submit',1 );
94
- //add_action( 'wp_ajax_vfb_submit', 'ct_vfb_submit',1 );
95
- add_action( 'wp_ajax_nopriv_vfb_submit', 'ct_ajax_hook',1 );
96
- add_action( 'wp_ajax_vfb_submit', 'ct_ajax_hook',1 );
97
- $cleantalk_hooked_actions[]='vfb_submit';
98
-
99
- /*hooks for woocommerce_checkout*/
100
- add_action( 'wp_ajax_nopriv_woocommerce_checkout', 'ct_ajax_hook',1 );
101
- add_action( 'wp_ajax_woocommerce_checkout', 'ct_ajax_hook',1 );
102
- $cleantalk_hooked_actions[]='woocommerce_checkout';
103
-
104
- /*hooks for frm_action*/
105
- add_action( 'wp_ajax_nopriv_frm_entries_create', 'ct_ajax_hook',1 );
106
- add_action( 'wp_ajax_frm_entries_create', 'ct_ajax_hook',1 );
107
- $cleantalk_hooked_actions[]='frm_entries_create';
108
-
109
- add_action( 'wp_ajax_nopriv_td_mod_register', 'ct_ajax_hook',1 );
110
- add_action( 'wp_ajax_td_mod_register', 'ct_ajax_hook',1 );
111
- $cleantalk_hooked_actions[]='td_mod_register';
112
-
113
- /*hooks for tevolution theme*/
114
- add_action( 'wp_ajax_nopriv_tmpl_ajax_check_user_email', 'ct_ajax_hook',1 );
115
- add_action( 'wp_ajax_tmpl_ajax_check_user_email', 'ct_ajax_hook',1 );
116
- add_action( 'wp_ajax_nopriv_tevolution_submit_from_preview', 'ct_ajax_hook',1 );
117
- add_action( 'wp_ajax_tevolution_submit_from_preview', 'ct_ajax_hook',1 );
118
- add_action( 'wp_ajax_nopriv_submit_form_recaptcha_validation', 'ct_ajax_hook',1 );
119
- add_action( 'wp_ajax_tmpl_submit_form_recaptcha_validation', 'ct_ajax_hook',1 );
120
- $cleantalk_hooked_actions[]='tmpl_ajax_check_user_email';
121
- $cleantalk_hooked_actions[]='tevolution_submit_from_preview';
122
- $cleantalk_hooked_actions[]='submit_form_recaptcha_validation';
123
-
124
- /**hooks for cm answers pro */
125
- add_action( 'template_redirect', 'ct_ajax_hook',1 );
126
-
127
- /* hooks for ninja forms ajax*/
128
- add_action( 'wp_ajax_nopriv_ninja_forms_ajax_submit', 'ct_ajax_hook',1 );
129
- add_action( 'wp_ajax_ninja_forms_ajax_submit', 'ct_ajax_hook',1 );
130
-
131
- add_action( 'ninja_forms_process', 'ct_ajax_hook',1 );
132
- $cleantalk_hooked_actions[]='ninja_forms_ajax_submit';
133
-
134
- /* hooks for contact forms by web settler ajax*/
135
- add_action( 'wp_ajax_nopriv_smuzform-storage', 'ct_ajax_hook',1 );
136
- $cleantalk_hooked_actions[]='smuzform_form_submit';
137
-
138
- /* hooks for reviewer plugin*/
139
- add_action( 'wp_ajax_nopriv_rwp_ajax_action_rating', 'ct_ajax_hook',1 );
140
- $cleantalk_hooked_actions[]='rwp-submit-wrap';
141
- function ct_validate_email_ajaxlogin($email=null, $is_ajax=true)
142
- {
143
- require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-public.php');
144
- 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, $ct_data;
145
-
146
- $ct_options = ct_get_options();
147
- $ct_data = ct_get_data();
148
-
149
- $email = is_null( $email ) ? $email : $_POST['email'];
150
- $email=sanitize_email($email);
151
- $is_good=true;
152
- if ( ! filter_var( $email, FILTER_VALIDATE_EMAIL )||email_exists( $email ) )
153
- {
154
- $is_good=false;
155
- }
156
-
157
- if(class_exists('AjaxLogin')&&isset($_POST['action'])&&$_POST['action']=='validate_email')
158
- {
159
-
160
- //$ct_options=ct_get_options();
161
- $checkjs = js_test('ct_checkjs', $_COOKIE, true);
162
- $submit_time = submit_time_test();
163
- $sender_info = get_sender_info();
164
- $sender_info['post_checkjs_passed']=$checkjs;
165
-
166
- if ($checkjs === null)
167
- {
168
- $checkjs = js_test('ct_checkjs', $_COOKIE, true);
169
- $sender_info['cookie_checkjs_passed'] = $checkjs;
170
- }
171
-
172
- $sender_info = json_encode($sender_info);
173
- if ($sender_info === false)
174
- {
175
- $sender_info= '';
176
- }
177
-
178
- require_once('cleantalk.class.php');
179
- $config = ct_get_server();
180
- $ct = new Cleantalk();
181
- $ct->work_url = $config['ct_work_url'];
182
- $ct->server_url = $ct_options['server'];
183
-
184
- $ct->server_ttl = $config['ct_server_ttl'];
185
- $ct->server_changed = $config['ct_server_changed'];
186
- $ct->ssl_on = $ct_options['ssl_on'];
187
-
188
- $ct_request = new CleantalkRequest();
189
- $ct_request->auth_key = $ct_options['apikey'];
190
- $ct_request->sender_email = $email;
191
- // $ct_request->sender_ip = $ct->ct_session_ip($_SERVER['REMOTE_ADDR']);
192
- $ct_request->sender_ip = cleantalk_get_real_ip();
193
- $ct_request->sender_nickname = '';
194
- $ct_request->agent = $ct_agent_version;
195
- $ct_request->sender_info = $sender_info;
196
- $ct_request->js_on = $checkjs;
197
- $ct_request->submit_time = $submit_time;
198
-
199
- $ct_result = $ct->isAllowUser($ct_request);
200
-
201
- if ($ct->server_change)
202
- {
203
- update_option(
204
- 'cleantalk_server', array(
205
- 'ct_work_url' => $ct->work_url,
206
- 'ct_server_ttl' => $ct->server_ttl,
207
- 'ct_server_changed' => time()
208
- )
209
- );
210
- }
211
- if ($ct_result->allow===0)
212
- {
213
- $is_good=false;
214
- }
215
- }
216
- if($is_good)
217
- {
218
- $ajaxresult=array(
219
- 'description' => null,
220
- 'cssClass' => 'noon',
221
- 'code' => 'success'
222
- );
223
- }
224
- else
225
- {
226
- $ajaxresult=array(
227
- 'description' => 'Invalid Email',
228
- 'cssClass' => 'error-container',
229
- 'code' => 'error'
230
- );
231
- }
232
- $ajaxresult=json_encode($ajaxresult);
233
- print $ajaxresult;
234
- wp_die();
235
- }
236
-
237
- function ct_user_register_ajaxlogin($user_id)
238
- {
239
- require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-public.php');
240
- 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, $ct_data;
241
-
242
- $ct_options = ct_get_options();
243
- $ct_data = ct_get_data();
244
-
245
- if(class_exists('AjaxLogin')&&isset($_POST['action'])&&$_POST['action']=='register_submit')
246
- {
247
- $checkjs = js_test('ct_checkjs', $_COOKIE, true);
248
- $submit_time = submit_time_test();
249
- $sender_info = get_sender_info();
250
- $sender_info['post_checkjs_passed']=$checkjs;
251
-
252
- if ($checkjs === null)
253
- {
254
- $checkjs = js_test('ct_checkjs', $_COOKIE, true);
255
- $sender_info['cookie_checkjs_passed'] = $checkjs;
256
- }
257
-
258
- $sender_info = json_encode($sender_info);
259
- if ($sender_info === false)
260
- {
261
- $sender_info= '';
262
- }
263
-
264
- require_once('cleantalk.class.php');
265
- $config = ct_get_server();
266
- $ct = new Cleantalk();
267
- $ct->work_url = $config['ct_work_url'];
268
- $ct->server_url = $ct_options['server'];
269
-
270
- $ct->server_ttl = $config['ct_server_ttl'];
271
- $ct->server_changed = $config['ct_server_changed'];
272
- $ct->ssl_on = $ct_options['ssl_on'];
273
-
274
- $ct_request = new CleantalkRequest();
275
- $ct_request->auth_key = $ct_options['apikey'];
276
- $ct_request->sender_email = sanitize_email($_POST['email']);
277
- // $ct_request->sender_ip = $ct->ct_session_ip($_SERVER['REMOTE_ADDR']);
278
- $ct_request->sender_ip = cleantalk_get_real_ip();
279
- $ct_request->sender_nickname = sanitize_email($_POST['login']); ;
280
- $ct_request->agent = $ct_agent_version;
281
- $ct_request->sender_info = $sender_info;
282
- $ct_request->js_on = $checkjs;
283
- $ct_request->submit_time = $submit_time;
284
-
285
- $ct_result = $ct->isAllowUser($ct_request);
286
-
287
- if ($ct->server_change)
288
- {
289
- update_option(
290
- 'cleantalk_server', array(
291
- 'ct_work_url' => $ct->work_url,
292
- 'ct_server_ttl' => $ct->server_ttl,
293
- 'ct_server_changed' => time()
294
- )
295
- );
296
- }
297
- if ($ct_result->allow===0)
298
- {
299
- wp_delete_user($user_id);
300
- }
301
- }
302
- return $user_id;
303
- }
304
-
305
- /**
306
- * Hook into MailChimp for WordPress `mc4wp_form_errors` filter.
307
- *
308
- * @param array $errors
309
- * @return array
310
- */
311
- function ct_mc4wp_ajax_hook( array $errors )
312
- {
313
- $result = ct_ajax_hook();
314
-
315
- // only return modified errors array when function returned a string value (the message key)
316
- if( is_string( $result ) ) {
317
- $errors[] = $result;
318
- }
319
-
320
- return $errors;
321
- }
322
-
323
- function ct_ajax_hook($message_obj = false, $additional = false)
324
- {
325
- require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-public.php');
326
- 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, $ct_data, $current_user;
327
-
328
- $ct_options = ct_get_options();
329
- $ct_data = ct_get_data();
330
- $sender_email = null;
331
- $message = '';
332
- $sender_nickname = null;
333
- $contact = true;
334
- $subject = '';
335
-
336
- //
337
- // Skip test if Custom contact forms is disabled.
338
- //
339
- if (intval($ct_options['general_contact_forms_test'])==0 ) {
340
- return false;
341
- }
342
-
343
- //
344
- // Go out because we call it on backend.
345
- //
346
- if( (ct_is_user_enable() === false || (function_exists('get_current_user_id') && get_current_user_id() != 0)) &&
347
- (strval(current_action()) != 'et_pre_insert_answer' && isset($message_obj['author']) && intval($message_obj['author']) == 0) //QAEngine Theme fix
348
- ){
349
- return false;
350
- }
351
-
352
- //
353
- // Go out because of not spam data
354
- //
355
- $skip_post = array(
356
- 'gmaps_display_info_window', // Geo My WP pop-up windows.
357
- 'gmw_ps_display_info_window', // Geo My WP pop-up windows.
358
- 'the_champ_user_auth', // Super Socializer
359
- );
360
-
361
- $checkjs = js_test('ct_checkjs', $_COOKIE, true);
362
- if ($checkjs && // Spammers usually fail the JS test
363
- (isset($_POST['action']) && in_array($_POST['action'], $skip_post))
364
- ) {
365
- return false;
366
- }
367
-
368
- if(isset($_POST['user_login']))
369
- $sender_nickname = $_POST['user_login'];
370
- else
371
- $sender_nickname = '';
372
-
373
- //QAEngine Theme answers
374
- if( !empty($message_obj) && isset($message_obj['post_type'], $message_obj['author'], $message_obj['post_content']) ){
375
- $curr_user = get_user_by('id', $message_obj['author']);
376
- $ct_post_temp['comment'] = $message_obj['post_content'];
377
- $ct_post_temp['email'] = $curr_user->data->user_email;
378
- $ct_post_temp['name'] = $curr_user->data->user_login;
379
- }
380
-
381
- //CSCF fix
382
- if(isset($_POST['action']) && $_POST['action']== 'cscf-submitform'){
383
- $ct_post_temp[] = $message_obj['comment_author'];
384
- $ct_post_temp[] = $message_obj['comment_author_email'];
385
- $ct_post_temp[] = $message_obj['comment_content'];
386
- }
387
-
388
- //??? fix
389
- if(isset($_POST['action'], $_POST['target']) && ($_POST['action']=='request_appointment'||$_POST['action']=='send_message')){
390
- $ct_post_temp=$_POST;
391
- $ct_post_temp['target']=1;
392
- }
393
-
394
- //UserPro fix
395
- if(isset($_POST['action'], $_POST['template']) && $_POST['action']=='userpro_process_form' && $_POST['template']=='register'){
396
- $ct_post_temp = $_POST;
397
- $ct_post_temp['shortcode'] = '';
398
- }
399
- //Reviewer fix
400
- if(isset($_POST['action']) && $_POST['action'] == 'rwp_ajax_action_rating')
401
- {
402
- $ct_post_temp['name'] = $_POST['user_name'];
403
- $ct_post_temp['email'] = $_POST['user_email'];
404
- $ct_post_temp['comment'] = $_POST['comment'];
405
- }
406
- if(isset($ct_post_temp))
407
- $ct_temp_msg_data = ct_get_fields_any($ct_post_temp);
408
- else
409
- $ct_temp_msg_data = ct_get_fields_any($_POST);
410
-
411
- $sender_email = ($ct_temp_msg_data['email'] ? $ct_temp_msg_data['email'] : '');
412
- $sender_nickname = ($ct_temp_msg_data['nickname'] ? $ct_temp_msg_data['nickname'] : '');
413
- $subject = ($ct_temp_msg_data['subject'] ? $ct_temp_msg_data['subject'] : '');
414
- $contact_form = ($ct_temp_msg_data['contact'] ? $ct_temp_msg_data['contact'] : true);
415
- $message = ($ct_temp_msg_data['message'] ? $ct_temp_msg_data['message'] : array());
416
-
417
- if ($subject != '') {
418
- $message = array_merge(array('subject' => $subject), $message);
419
- }
420
-
421
- $message = json_encode($message);
422
-
423
- if($sender_email!=null)
424
- {
425
- $submit_time = submit_time_test();
426
- $sender_info = get_sender_info();
427
- $sender_info['post_checkjs_passed']=$checkjs;
428
-
429
- $sender_info = json_encode($sender_info);
430
- if ($sender_info === false)
431
- {
432
- $sender_info= '';
433
- }
434
-
435
- $post_info['comment_type'] = 'feedback_ajax';
436
- $post_info = json_encode($post_info);
437
- if ($post_info === false)
438
- $post_info = '';
439
-
440
-
441
- $ct_base_call_result = ct_base_call(
442
- array(
443
- 'message' => $message,
444
- 'example' => null,
445
- 'sender_email' => $sender_email,
446
- 'sender_nickname' => $sender_nickname,
447
- 'sender_info' => $sender_info,
448
- 'post_info'=> $post_info,
449
- 'checkjs' => $checkjs
450
- )
451
- );
452
-
453
- $ct = $ct_base_call_result['ct'];
454
- $ct_result = $ct_base_call_result['ct_result'];
455
- if ($ct_result->allow == 0)
456
- {
457
- if(isset($_POST['action']) && $_POST['action']=='wpuf_submit_register'){
458
- $result=Array('success'=>false,'error'=>$ct_result->comment);
459
- @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
460
- print json_encode($result);
461
- die();
462
- }
463
- else if(isset($_POST['action']) && $_POST['action']=='mymail_form_submit')
464
- {
465
- $result=Array('success'=>false,'html'=>$ct_result->comment);
466
- @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
467
- print json_encode($result);
468
- die();
469
- }
470
- else if(isset($_POST['action'], $_POST['task']) && $_POST['action'] == 'wysija_ajax' && $_POST['task'] != 'send_preview')
471
- {
472
- $result=Array('result'=>false,'msgs'=>Array('updated'=>Array($ct_result->comment)));
473
- //@header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
474
- print $_GET['callback'].'('.json_encode($result).');';
475
- die();
476
- }
477
- else if(isset($_POST['action']) && $_POST['action']=='cs_registration_validation')
478
- {
479
- $result=Array("type"=>"error","message"=>$ct_result->comment);
480
- print json_encode($result);
481
- die();
482
- }
483
- else if(isset($_POST['action']) && ($_POST['action']=='request_appointment' || $_POST['action']=='send_message'))
484
- {
485
- print $ct_result->comment;
486
- die();
487
- }
488
- else if(isset($_POST['action']) && $_POST['action']=='zn_do_login')
489
- {
490
- print '<div id="login_error">'.$ct_result->comment.'</div>';
491
- die();
492
- }
493
- else if(isset($_POST['action']) && $_POST['action']=='vfb_submit')
494
- {
495
- $result=Array('result'=>false,'message'=>$ct_result->comment);
496
- @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
497
- print json_encode($result);
498
- die();
499
- }
500
- else if(isset($_POST['action']) && $_POST['action']== 'cscf-submitform')
501
- {
502
- $message_obj['akismet_result'] = 'true';
503
- $result = array(
504
- 'sent' => false,
505
- 'valid' => 1,
506
- 'errorlist' => array('confirm-email'=>$ct_result->comment)
507
- );
508
- $result = json_encode($result);
509
- echo $result;
510
- return $message_obj;
511
- }
512
- else if(isset($_POST['action']) && $_POST['action']=='woocommerce_checkout')
513
- {
514
- print $ct_result->comment;
515
- die();
516
- }
517
- else if(isset($_POST['action']) && $_POST['action']=='frm_entries_create')
518
- {
519
- $result=Array('112'=>$ct_result->comment);
520
- print json_encode($result);
521
- die();
522
- }
523
- else if(isset($_POST['cma-action']) && $_POST['cma-action']=='add')
524
- {
525
- $result=Array('success'=>0, 'thread_id'=>null,'messages'=>Array($ct_result->comment));
526
- print json_encode($result);
527
- die();
528
- }
529
- else if(isset($_POST['action']) && $_POST['action']=='td_mod_register')
530
- {
531
- print json_encode(array('register', 0, $ct_result->comment));
532
- die();
533
- }
534
- else if(isset($_POST['action']) && $_POST['action']=='tmpl_ajax_check_user_email')
535
- {
536
- print "17,email";
537
- die();
538
- }
539
- else if(isset($_POST['action']) && ($_POST['action']=='tevolution_submit_from_preview' || $_POST['action']=='submit_form_recaptcha_validation'))
540
- {
541
- print $ct_result->comment;
542
- die();
543
- }
544
- else if(isset($_POST['action']) && $_POST['action']=='ninja_forms_ajax_submit')
545
- {
546
- print '{"form_id":'.$_POST['_form_id'].',"errors":false,"success":{"success_msg-Success":"'.$ct_result->comment.'"}}';
547
- die();
548
- }
549
- else if(isset($_POST['action']) && $_POST['action']=='nf_ajax_submit')
550
- {
551
- $nf_data = json_decode($_POST['formData'], true);
552
- // print '{data:{{"form_id":'.$nf_data['id'].',"errors":false,"success":{"success_msg-Success":"'.$ct_result->comment.'"}}}}'; \\Old version
553
- print '{"data":{"form_id":"'.$nf_data['id'].'","settings":{},"extra":[],"fields":{},"processed_actions":[],"actions":{"success_message": "<font style=\"color: red\">'.$ct_result->comment.'</font><br><br>"}},"errors":[],"debug":[]}';
554
- die();
555
- }
556
-
557
- // WooWaitList
558
- // http://codecanyon.net/item/woowaitlist-woocommerce-back-in-stock-notifier/7103373
559
- else if(isset($_POST['action']) && $_POST['action']=='wew_save_to_db_callback')
560
- {
561
- $result = array();
562
- $result['error'] = 1;
563
- $result['message'] = $ct_result->comment;
564
- $result['code'] = 5; // Unused code number in WooWaitlist
565
- print json_encode($result);
566
- die();
567
- }
568
- // UserPro
569
- else if(isset($_POST['action'], $_POST['template']) && $_POST['action']=='userpro_process_form' && $_POST['template']=='register')
570
- {
571
- foreach($_POST as $key => $value){
572
- $output[$key]=$value;
573
- }unset($key, $value);
574
- $output['template'] = $ct_result->comment;
575
- $output=json_encode($output);
576
- print_r($output);
577
- die;
578
- }
579
- // Quick event manager
580
- else if(isset($_POST['action']) && $_POST['action']=='qem_validate_form'){
581
- $errors[] = 'registration_forbidden';
582
- $result = Array(
583
- 'success' => 'false',
584
- 'errors' => $errors,
585
- 'title' => $ct_result->comment
586
- );
587
- print json_encode($result);
588
- die();
589
- }
590
- // Quick Contact Form
591
- elseif(isset($_POST['action']) && $_POST['action'] == 'qcf_validate_form')
592
- {
593
- $result = Array(
594
- 'blurb' => "<h1>".$ct_result->comment."</h1>",
595
- 'display' => "Oops, got a few problems here",
596
- 'errors' => array(
597
- 0 => array(
598
- error => 'error',
599
- name => 'name'
600
- ),
601
- ),
602
- 'success' => 'false',
603
- );
604
- print json_encode($result);
605
- die();
606
- }
607
- // Usernoise Contact Form
608
- elseif(isset($_POST['title'], $_POST['email'], $_POST['type'], $_POST['ct_checkjs']))
609
- {
610
- return array($ct_result->comment);
611
- die();
612
- }
613
- // amoForms
614
- elseif(isset($_POST['action']) && $_POST['action'] == 'amoforms_submit')
615
- {
616
- $result = Array(
617
- 'result' => true,
618
- 'type' => "html",
619
- 'value' => "<h1 style='font-size: 25px; color: red;'>".$ct_result->comment."</h1>",
620
- 'fast' => false
621
- );
622
- print json_encode($result);
623
- die();
624
- }
625
- // MailChimp for Wordpress Premium
626
- elseif(!empty($_POST['_mc4wp_form_id']))
627
- {
628
- return 'ct_mc4wp_response';
629
- }
630
- // QAEngine Theme answers
631
- elseif ( !empty($message_obj) && isset($message_obj['post_type'], $message_obj['author'], $message_obj['post_content']) ){
632
- return new WP_Error('Spam comment', $ct_result->comment);
633
- }
634
- //Convertplug. Strpos because action value dynamically changes and depends on mailing service
635
- elseif (isset($_POST['action']) && strpos($_POST['action'], '_add_subscriber') !== false){
636
- $result = Array(
637
- 'action' => "message",
638
- 'detailed_msg' => "",
639
- 'email_status' => false,
640
- 'message' => "<h1 style='font-size: 25px; color: red;'>".$ct_result->comment."</h1>",
641
- 'status' => "error",
642
- 'url' => "none"
643
- );
644
- print json_encode($result);
645
- die();
646
- }
647
- // Ultimate Form Builder
648
- elseif (isset($_POST['action']) && $_POST['action'] == 'ufbl_front_form_action'){
649
- $result = Array(
650
- 'error_keys' => array(),
651
- 'error_flag' => 1,
652
- 'response_message' => $ct_result->comment
653
- );
654
- print json_encode($result);
655
- die();
656
- }
657
- // Smart Forms
658
- elseif (isset($_POST['action']) && $_POST['action'] == 'rednao_smart_forms_save_form_values'){
659
- $result = Array(
660
- 'message' => $ct_result->comment,
661
- 'refreshCaptcha' => 'n',
662
- 'success' => 'n'
663
- );
664
- print json_encode($result);
665
- die();
666
- }
667
- //cFormsII
668
- elseif(isset($_POST['action']) && $_POST['action'] == 'submitcform')
669
- {
670
- header('Content-Type: application/json');
671
- $result = Array(
672
- 'no' => "",
673
- 'result' => "failure",
674
- 'html' =>$ct_result->comment,
675
- 'hide' => false,
676
- 'redirection' => null
677
-
678
- );
679
- print json_encode($result);
680
- die();
681
- }
682
- //Contact Form by Web-Settler
683
- elseif(isset($_POST['smFieldData']))
684
- {
685
- $result = Array(
686
- 'signal' => true,
687
- 'code' => 0,
688
- 'thanksMsg' => $ct_result->comment,
689
- 'errors' => array(),
690
- 'isMsg' => true,
691
- 'redirectUrl' => null
692
- );
693
- print json_encode($result);
694
- die();
695
- }
696
- //Reviewer
697
- elseif(isset($_POST['action']) && $_POST['action'] == 'rwp_ajax_action_rating')
698
- {
699
- $result = Array(
700
- 'success' => false,
701
- 'data' => array(0=>$ct_result->comment)
702
- );
703
- print json_encode($result);
704
- die();
705
- }
706
- else
707
- {
708
- print $ct_result->comment;
709
- die();
710
- }
711
- }
712
- //Allow == 1
713
- else{
714
- //QAEngine Theme answers
715
- if ( !empty($message_obj) && isset($message_obj['post_type'], $message_obj['author'], $message_obj['post_content']) ){
716
- return $message_obj;
717
- }
718
- }
719
- }
720
- }
721
-
722
  ?>
1
+ <?php
2
+ global $cleantalk_hooked_actions;
3
+
4
+ /*
5
+ AJAX functions
6
+ */
7
+
8
+ //$cleantalk_ajax_actions_to_check - array for POST 'actions' we should check.
9
+
10
+ $cleantalk_ajax_actions_to_check[] = 'qcf_validate_form'; //Quick Contact Form
11
+ $cleantalk_ajax_actions_to_check[] = 'amoforms_submit'; //amoForms
12
+
13
+ //cleantalk_hooked_actions[] - array for POST 'actions' which were direct hooked.
14
+
15
+ $cleantalk_hooked_actions[] = 'rwp_ajax_action_rating'; //Don't check Reviewer plugin
16
+
17
+ $cleantalk_hooked_actions[] = 'ct_feedback_comment';
18
+
19
+ /* MailChimp Premium*/
20
+ add_filter('mc4wp_form_errors', 'ct_mc4wp_ajax_hook');
21
+
22
+ /*hooks for Usernoise Form*/
23
+ add_action('un_feedback_form_body', 'ct_add_hidden_fields',1);
24
+ add_filter('un_validate_feedback', 'ct_ajax_hook', 1, 2);
25
+
26
+ /*hooks for AJAX Login & Register email validation*/
27
+ add_action( 'wp_ajax_nopriv_validate_email', 'ct_validate_email_ajaxlogin',1 );
28
+ add_action( 'wp_ajax_validate_email', 'ct_validate_email_ajaxlogin',1 );
29
+ $cleantalk_hooked_actions[]='validate_email';
30
+
31
+ /*hooks for user registration*/
32
+ add_action( 'user_register', 'ct_user_register_ajaxlogin',1 );
33
+
34
+ /*hooks for WPUF pro */
35
+ //add_action( 'wp_ajax_nopriv_wpuf_submit_register', 'ct_wpuf_submit_register',1 );
36
+ //add_action( 'wp_ajax_wpuf_submit_register', 'ct_wpuf_submit_register',1 );
37
+ add_action( 'wp_ajax_nopriv_wpuf_submit_register', 'ct_ajax_hook',1 );
38
+ add_action( 'wp_ajax_wpuf_submit_register', 'ct_ajax_hook',1 );
39
+ $cleantalk_hooked_actions[]='submit_register';
40
+
41
+ /*hooks for MyMail */
42
+ //add_action( 'wp_ajax_nopriv_mymail_form_submit', 'ct_mymail_form_submit',1 );
43
+ //add_action( 'wp_ajax_mymail_form_submit', 'ct_mymail_form_submit',1 );
44
+ add_action( 'wp_ajax_nopriv_mymail_form_submit', 'ct_ajax_hook',1 );
45
+ add_action( 'wp_ajax_mymail_form_submit', 'ct_ajax_hook',1 );
46
+ $cleantalk_hooked_actions[]='form_submit';
47
+
48
+ /*hooks for MailPoet */
49
+ //add_action( 'wp_ajax_nopriv_wysija_ajax', 'ct_wysija_ajax',1 );
50
+ //add_action( 'wp_ajax_wysija_ajax', 'ct_wysija_ajax',1 );
51
+ add_action( 'wp_ajax_nopriv_wysija_ajax', 'ct_ajax_hook',1 );
52
+ add_action( 'wp_ajax_wysija_ajax', 'ct_ajax_hook',1 );
53
+ $cleantalk_hooked_actions[]='wysija_ajax';
54
+
55
+ /*hooks for cs_registration_validation */
56
+ //add_action( 'wp_ajax_nopriv_cs_registration_validation', 'ct_cs_registration_validation',1 );
57
+ //add_action( 'wp_ajax_cs_registration_validation', 'ct_cs_registration_validation',1 );
58
+ add_action( 'wp_ajax_nopriv_cs_registration_validation', 'ct_ajax_hook',1 );
59
+ add_action( 'wp_ajax_cs_registration_validation', 'ct_ajax_hook',1 );
60
+ $cleantalk_hooked_actions[]='cs_registration_validation';
61
+
62
+ /*hooks for send_message and request_appointment */
63
+ //add_action( 'wp_ajax_nopriv_send_message', 'ct_sm_ra',1 );
64
+ //add_action( 'wp_ajax_send_message', 'ct_sm_ra',1 );
65
+ //add_action( 'wp_ajax_nopriv_request_appointment', 'ct_sm_ra',1 );
66
+ //add_action( 'wp_ajax_request_appointment', 'ct_sm_ra',1 );
67
+ add_action( 'wp_ajax_nopriv_send_message', 'ct_ajax_hook',1 );
68
+ add_action( 'wp_ajax_send_message', 'ct_ajax_hook',1 );
69
+ add_action( 'wp_ajax_nopriv_request_appointment', 'ct_ajax_hook',1 );
70
+ add_action( 'wp_ajax_request_appointment', 'ct_ajax_hook',1 );
71
+ $cleantalk_hooked_actions[]='send_message';
72
+ $cleantalk_hooked_actions[]='request_appointment';
73
+
74
+ /*hooks for zn_do_login */
75
+ //add_action( 'wp_ajax_nopriv_zn_do_login', 'ct_zn_do_login',1 );
76
+ //add_action( 'wp_ajax_zn_do_login', 'ct_zn_do_login',1 );
77
+ add_action( 'wp_ajax_nopriv_zn_do_login', 'ct_ajax_hook',1 );
78
+ add_action( 'wp_ajax_zn_do_login', 'ct_ajax_hook',1 );
79
+ $cleantalk_hooked_actions[]='zn_do_login';
80
+
81
+ /*hooks for zn_do_login */
82
+ //add_action( 'wp_ajax_nopriv_cscf-submitform', 'ct_cscf_submitform',1 );
83
+ //add_action( 'wp_ajax_cscf-submitform', 'ct_cscf_submitform',1 );
84
+ if(isset($_POST['action']) && $_POST['action'] == 'cscf-submitform'){
85
+ add_filter('preprocess_comment', 'ct_ajax_hook', 1);
86
+ //add_action( 'wp_ajax_nopriv_cscf-submitform', 'ct_ajax_hook',1 );
87
+ //add_action( 'wp_ajax_cscf-submitform', 'ct_ajax_hook',1 );
88
+ $cleantalk_hooked_actions[]='cscf-submitform';
89
+ }
90
+
91
+
92
+ /*hooks for visual form builder */
93
+ //add_action( 'wp_ajax_nopriv_vfb_submit', 'ct_vfb_submit',1 );
94
+ //add_action( 'wp_ajax_vfb_submit', 'ct_vfb_submit',1 );
95
+ add_action( 'wp_ajax_nopriv_vfb_submit', 'ct_ajax_hook',1 );
96
+ add_action( 'wp_ajax_vfb_submit', 'ct_ajax_hook',1 );
97
+ $cleantalk_hooked_actions[]='vfb_submit';
98
+
99
+ /*hooks for woocommerce_checkout*/
100
+ add_action( 'wp_ajax_nopriv_woocommerce_checkout', 'ct_ajax_hook',1 );
101
+ add_action( 'wp_ajax_woocommerce_checkout', 'ct_ajax_hook',1 );
102
+ $cleantalk_hooked_actions[]='woocommerce_checkout';
103
+
104
+ /*hooks for frm_action*/
105
+ add_action( 'wp_ajax_nopriv_frm_entries_create', 'ct_ajax_hook',1 );
106
+ add_action( 'wp_ajax_frm_entries_create', 'ct_ajax_hook',1 );
107
+ $cleantalk_hooked_actions[]='frm_entries_create';
108
+
109
+ add_action( 'wp_ajax_nopriv_td_mod_register', 'ct_ajax_hook',1 );
110
+ add_action( 'wp_ajax_td_mod_register', 'ct_ajax_hook',1 );
111
+ $cleantalk_hooked_actions[]='td_mod_register';
112
+
113
+ /*hooks for tevolution theme*/
114
+ add_action( 'wp_ajax_nopriv_tmpl_ajax_check_user_email', 'ct_ajax_hook',1 );
115
+ add_action( 'wp_ajax_tmpl_ajax_check_user_email', 'ct_ajax_hook',1 );
116
+ add_action( 'wp_ajax_nopriv_tevolution_submit_from_preview', 'ct_ajax_hook',1 );
117
+ add_action( 'wp_ajax_tevolution_submit_from_preview', 'ct_ajax_hook',1 );
118
+ add_action( 'wp_ajax_nopriv_submit_form_recaptcha_validation', 'ct_ajax_hook',1 );
119
+ add_action( 'wp_ajax_tmpl_submit_form_recaptcha_validation', 'ct_ajax_hook',1 );
120
+ $cleantalk_hooked_actions[]='tmpl_ajax_check_user_email';
121
+ $cleantalk_hooked_actions[]='tevolution_submit_from_preview';
122
+ $cleantalk_hooked_actions[]='submit_form_recaptcha_validation';
123
+
124
+ /**hooks for cm answers pro */
125
+ add_action( 'template_redirect', 'ct_ajax_hook',1 );
126
+
127
+ /* hooks for ninja forms ajax*/
128
+ add_action( 'wp_ajax_nopriv_ninja_forms_ajax_submit', 'ct_ajax_hook',1 );
129
+ add_action( 'wp_ajax_ninja_forms_ajax_submit', 'ct_ajax_hook',1 );
130
+
131
+ add_action( 'ninja_forms_process', 'ct_ajax_hook',1 );
132
+ $cleantalk_hooked_actions[]='ninja_forms_ajax_submit';
133
+
134
+ /* hooks for contact forms by web settler ajax*/
135
+ add_action( 'wp_ajax_nopriv_smuzform-storage', 'ct_ajax_hook',1 );
136
+ $cleantalk_hooked_actions[]='smuzform_form_submit';
137
+
138
+ /* hooks for reviewer plugin*/
139
+ add_action( 'wp_ajax_nopriv_rwp_ajax_action_rating', 'ct_ajax_hook',1 );
140
+ $cleantalk_hooked_actions[]='rwp-submit-wrap';
141
+ function ct_validate_email_ajaxlogin($email=null, $is_ajax=true)
142
+ {
143
+ require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-public.php');
144
+ 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, $ct_data;
145
+
146
+ $ct_options = ct_get_options();
147
+ $ct_data = ct_get_data();
148
+
149
+ $email = is_null( $email ) ? $email : $_POST['email'];
150
+ $email=sanitize_email($email);
151
+ $is_good=true;
152
+ if ( ! filter_var( $email, FILTER_VALIDATE_EMAIL )||email_exists( $email ) )
153
+ {
154
+ $is_good=false;
155
+ }
156
+
157
+ if(class_exists('AjaxLogin')&&isset($_POST['action'])&&$_POST['action']=='validate_email')
158
+ {
159
+
160
+ //$ct_options=ct_get_options();
161
+ $checkjs = js_test('ct_checkjs', $_COOKIE, true);
162
+ $submit_time = submit_time_test();
163
+ $sender_info = get_sender_info();
164
+ $sender_info['post_checkjs_passed']=$checkjs;
165
+
166
+ if ($checkjs === null)
167
+ {
168
+ $checkjs = js_test('ct_checkjs', $_COOKIE, true);
169
+ $sender_info['cookie_checkjs_passed'] = $checkjs;
170
+ }
171
+
172
+ $sender_info = json_encode($sender_info);
173
+ if ($sender_info === false)
174
+ {
175
+ $sender_info= '';
176
+ }
177
+
178
+ require_once('cleantalk.class.php');
179
+ $config = ct_get_server();
180
+ $ct = new Cleantalk();
181
+ $ct->work_url = $config['ct_work_url'];
182
+ $ct->server_url = $ct_options['server'];
183
+
184
+ $ct->server_ttl = $config['ct_server_ttl'];
185
+ $ct->server_changed = $config['ct_server_changed'];
186
+ $ct->ssl_on = $ct_options['ssl_on'];
187
+
188
+ $ct_request = new CleantalkRequest();
189
+ $ct_request->auth_key = $ct_options['apikey'];
190
+ $ct_request->sender_email = $email;
191
+ // $ct_request->sender_ip = $ct->ct_session_ip($_SERVER['REMOTE_ADDR']);
192
+ $ct_request->sender_ip = cleantalk_get_real_ip();
193
+ $ct_request->sender_nickname = '';
194
+ $ct_request->agent = $ct_agent_version;
195
+ $ct_request->sender_info = $sender_info;
196
+ $ct_request->js_on = $checkjs;
197
+ $ct_request->submit_time = $submit_time;
198
+
199
+ $ct_result = $ct->isAllowUser($ct_request);
200
+
201
+ if ($ct->server_change)
202
+ {
203
+ update_option(
204
+ 'cleantalk_server', array(
205
+ 'ct_work_url' => $ct->work_url,
206
+ 'ct_server_ttl' => $ct->server_ttl,
207
+ 'ct_server_changed' => time()
208
+ )
209
+ );
210
+ }
211
+ if ($ct_result->allow===0)
212
+ {
213
+ $is_good=false;
214
+ }
215
+ }
216
+ if($is_good)
217
+ {
218
+ $ajaxresult=array(
219
+ 'description' => null,
220
+ 'cssClass' => 'noon',
221
+ 'code' => 'success'
222
+ );
223
+ }
224
+ else
225
+ {
226
+ $ajaxresult=array(
227
+ 'description' => 'Invalid Email',
228
+ 'cssClass' => 'error-container',
229
+ 'code' => 'error'
230
+ );
231
+ }
232
+ $ajaxresult=json_encode($ajaxresult);
233
+ print $ajaxresult;
234
+ wp_die();
235
+ }
236
+
237
+ function ct_user_register_ajaxlogin($user_id)
238
+ {
239
+ require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-public.php');
240
+ 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, $ct_data;
241
+
242
+ $ct_options = ct_get_options();
243
+ $ct_data = ct_get_data();
244
+
245
+ if(class_exists('AjaxLogin')&&isset($_POST['action'])&&$_POST['action']=='register_submit')
246
+ {
247
+ $checkjs = js_test('ct_checkjs', $_COOKIE, true);
248
+ $submit_time = submit_time_test();
249
+ $sender_info = get_sender_info();
250
+ $sender_info['post_checkjs_passed']=$checkjs;
251
+
252
+ if ($checkjs === null)
253
+ {
254
+ $checkjs = js_test('ct_checkjs', $_COOKIE, true);
255
+ $sender_info['cookie_checkjs_passed'] = $checkjs;
256
+ }
257
+
258
+ $sender_info = json_encode($sender_info);
259
+ if ($sender_info === false)
260
+ {
261
+ $sender_info= '';
262
+ }
263
+
264
+ require_once('cleantalk.class.php');
265
+ $config = ct_get_server();
266
+ $ct = new Cleantalk();
267
+ $ct->work_url = $config['ct_work_url'];
268
+ $ct->server_url = $ct_options['server'];
269
+
270
+ $ct->server_ttl = $config['ct_server_ttl'];
271
+ $ct->server_changed = $config['ct_server_changed'];
272
+ $ct->ssl_on = $ct_options['ssl_on'];
273
+
274
+ $ct_request = new CleantalkRequest();
275
+ $ct_request->auth_key = $ct_options['apikey'];
276
+ $ct_request->sender_email = sanitize_email($_POST['email']);
277
+ // $ct_request->sender_ip = $ct->ct_session_ip($_SERVER['REMOTE_ADDR']);
278
+ $ct_request->sender_ip = cleantalk_get_real_ip();
279
+ $ct_request->sender_nickname = sanitize_email($_POST['login']); ;
280
+ $ct_request->agent = $ct_agent_version;
281
+ $ct_request->sender_info = $sender_info;
282
+ $ct_request->js_on = $checkjs;
283
+ $ct_request->submit_time = $submit_time;
284
+
285
+ $ct_result = $ct->isAllowUser($ct_request);
286
+
287
+ if ($ct->server_change)
288
+ {
289
+ update_option(
290
+ 'cleantalk_server', array(
291
+ 'ct_work_url' => $ct->work_url,
292
+ 'ct_server_ttl' => $ct->server_ttl,
293
+ 'ct_server_changed' => time()
294
+ )
295
+ );
296
+ }
297
+ if ($ct_result->allow===0)
298
+ {
299
+ wp_delete_user($user_id);
300
+ }
301
+ }
302
+ return $user_id;
303
+ }
304
+
305
+ /**
306
+ * Hook into MailChimp for WordPress `mc4wp_form_errors` filter.
307
+ *
308
+ * @param array $errors
309
+ * @return array
310
+ */
311
+ function ct_mc4wp_ajax_hook( array $errors )
312
+ {
313
+ $result = ct_ajax_hook();
314
+
315
+ // only return modified errors array when function returned a string value (the message key)
316
+ if( is_string( $result ) ) {
317
+ $errors[] = $result;
318
+ }
319
+
320
+ return $errors;
321
+ }
322
+
323
+ function ct_ajax_hook($message_obj = false, $additional = false)
324
+ {
325
+ require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-public.php');
326
+ 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, $ct_data, $current_user;
327
+
328
+ $ct_options = ct_get_options();
329
+ $ct_data = ct_get_data();
330
+ $sender_email = null;
331
+ $message = '';
332
+ $sender_nickname = null;
333
+ $contact = true;
334
+ $subject = '';
335
+
336
+ //
337
+ // Skip test if Custom contact forms is disabled.
338
+ //
339
+ if (intval($ct_options['general_contact_forms_test'])==0 ) {
340
+ return false;
341
+ }
342
+
343
+ //
344
+ // Go out because we call it on backend.
345
+ //
346
+ if( (ct_is_user_enable() === false || (function_exists('get_current_user_id') && get_current_user_id() != 0)) &&
347
+ (strval(current_action()) != 'et_pre_insert_answer' && isset($message_obj['author']) && intval($message_obj['author']) == 0) //QAEngine Theme fix
348
+ ){
349
+ return false;
350
+ }
351
+
352
+ //
353
+ // Go out because of not spam data
354
+ //
355
+ $skip_post = array(
356
+ 'gmaps_display_info_window', // Geo My WP pop-up windows.
357
+ 'gmw_ps_display_info_window', // Geo My WP pop-up windows.
358
+ 'the_champ_user_auth', // Super Socializer
359
+ );
360
+
361
+ $checkjs = js_test('ct_checkjs', $_COOKIE, true);
362
+ if ($checkjs && // Spammers usually fail the JS test
363
+ (isset($_POST['action']) && in_array($_POST['action'], $skip_post))
364
+ ) {
365
+ return false;
366
+ }
367
+
368
+ if(isset($_POST['user_login']))
369
+ $sender_nickname = $_POST['user_login'];
370
+ else
371
+ $sender_nickname = '';
372
+
373
+ //QAEngine Theme answers
374
+ if( !empty($message_obj) && isset($message_obj['post_type'], $message_obj['author'], $message_obj['post_content']) ){
375
+ $curr_user = get_user_by('id', $message_obj['author']);
376
+ $ct_post_temp['comment'] = $message_obj['post_content'];
377
+ $ct_post_temp['email'] = $curr_user->data->user_email;
378
+ $ct_post_temp['name'] = $curr_user->data->user_login;
379
+ }
380
+
381
+ //CSCF fix
382
+ if(isset($_POST['action']) && $_POST['action']== 'cscf-submitform'){
383
+ $ct_post_temp[] = $message_obj['comment_author'];
384
+ $ct_post_temp[] = $message_obj['comment_author_email'];
385
+ $ct_post_temp[] = $message_obj['comment_content'];
386
+ }
387
+
388
+ //??? fix
389
+ if(isset($_POST['action'], $_POST['target']) && ($_POST['action']=='request_appointment'||$_POST['action']=='send_message')){
390
+ $ct_post_temp=$_POST;
391
+ $ct_post_temp['target']=1;
392
+ }
393
+
394
+ //UserPro fix
395
+ if(isset($_POST['action'], $_POST['template']) && $_POST['action']=='userpro_process_form' && $_POST['template']=='register'){
396
+ $ct_post_temp = $_POST;
397
+ $ct_post_temp['shortcode'] = '';
398
+ }
399
+ //Reviewer fix
400
+ if(isset($_POST['action']) && $_POST['action'] == 'rwp_ajax_action_rating')
401
+ {
402
+ $ct_post_temp['name'] = $_POST['user_name'];
403
+ $ct_post_temp['email'] = $_POST['user_email'];
404
+ $ct_post_temp['comment'] = $_POST['comment'];
405
+ }
406
+ if(isset($ct_post_temp))
407
+ $ct_temp_msg_data = ct_get_fields_any($ct_post_temp);
408
+ else
409
+ $ct_temp_msg_data = ct_get_fields_any($_POST);
410
+
411
+ $sender_email = ($ct_temp_msg_data['email'] ? $ct_temp_msg_data['email'] : '');
412
+ $sender_nickname = ($ct_temp_msg_data['nickname'] ? $ct_temp_msg_data['nickname'] : '');
413
+ $subject = ($ct_temp_msg_data['subject'] ? $ct_temp_msg_data['subject'] : '');
414
+ $contact_form = ($ct_temp_msg_data['contact'] ? $ct_temp_msg_data['contact'] : true);
415
+ $message = ($ct_temp_msg_data['message'] ? $ct_temp_msg_data['message'] : array());
416
+
417
+ if ($subject != '') {
418
+ $message = array_merge(array('subject' => $subject), $message);
419
+ }
420
+
421
+ $message = json_encode($message);
422
+
423
+ if($sender_email!=null)
424
+ {
425
+ $submit_time = submit_time_test();
426
+ $sender_info = get_sender_info();
427
+ $sender_info['post_checkjs_passed']=$checkjs;
428
+
429
+ $sender_info = json_encode($sender_info);
430
+ if ($sender_info === false)
431
+ {
432
+ $sender_info= '';
433
+ }
434
+
435
+ $post_info['comment_type'] = 'feedback_ajax';
436
+ $post_info = json_encode($post_info);
437
+ if ($post_info === false)
438
+ $post_info = '';
439
+
440
+
441
+ $ct_base_call_result = ct_base_call(
442
+ array(
443
+ 'message' => $message,
444
+ 'example' => null,
445
+ 'sender_email' => $sender_email,
446
+ 'sender_nickname' => $sender_nickname,
447
+ 'sender_info' => $sender_info,
448
+ 'post_info'=> $post_info,
449
+ 'checkjs' => $checkjs
450
+ )
451
+ );
452
+
453
+ $ct = $ct_base_call_result['ct'];
454
+ $ct_result = $ct_base_call_result['ct_result'];
455
+ if ($ct_result->allow == 0)
456
+ {
457
+ if(isset($_POST['action']) && $_POST['action']=='wpuf_submit_register'){
458
+ $result=Array('success'=>false,'error'=>$ct_result->comment);
459
+ @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
460
+ print json_encode($result);
461
+ die();
462
+ }
463
+ else if(isset($_POST['action']) && $_POST['action']=='mymail_form_submit')
464
+ {
465
+ $result=Array('success'=>false,'html'=>$ct_result->comment);
466
+ @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
467
+ print json_encode($result);
468
+ die();
469
+ }
470
+ else if(isset($_POST['action'], $_POST['task']) && $_POST['action'] == 'wysija_ajax' && $_POST['task'] != 'send_preview')
471
+ {
472
+ $result=Array('result'=>false,'msgs'=>Array('updated'=>Array($ct_result->comment)));
473
+ //@header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
474
+ print $_GET['callback'].'('.json_encode($result).');';
475
+ die();
476
+ }
477
+ else if(isset($_POST['action']) && $_POST['action']=='cs_registration_validation')
478
+ {
479
+ $result=Array("type"=>"error","message"=>$ct_result->comment);
480
+ print json_encode($result);
481
+ die();
482
+ }
483
+ else if(isset($_POST['action']) && ($_POST['action']=='request_appointment' || $_POST['action']=='send_message'))
484
+ {
485
+ print $ct_result->comment;
486
+ die();
487
+ }
488
+ else if(isset($_POST['action']) && $_POST['action']=='zn_do_login')
489
+ {
490
+ print '<div id="login_error">'.$ct_result->comment.'</div>';
491
+ die();
492
+ }
493
+ else if(isset($_POST['action']) && $_POST['action']=='vfb_submit')
494
+ {
495
+ $result=Array('result'=>false,'message'=>$ct_result->comment);
496
+ @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
497
+ print json_encode($result);
498
+ die();
499
+ }
500
+ else if(isset($_POST['action']) && $_POST['action']== 'cscf-submitform')
501
+ {
502
+ $message_obj['akismet_result'] = 'true';
503
+ $result = array(
504
+ 'sent' => false,
505
+ 'valid' => 1,
506
+ 'errorlist' => array('confirm-email'=>$ct_result->comment)
507
+ );
508
+ $result = json_encode($result);
509
+ echo $result;
510
+ return $message_obj;
511
+ }
512
+ else if(isset($_POST['action']) && $_POST['action']=='woocommerce_checkout')
513
+ {
514
+ print $ct_result->comment;
515
+ die();
516
+ }
517
+ else if(isset($_POST['action']) && $_POST['action']=='frm_entries_create')
518
+ {
519
+ $result=Array('112'=>$ct_result->comment);
520
+ print json_encode($result);
521
+ die();
522
+ }
523
+ else if(isset($_POST['cma-action']) && $_POST['cma-action']=='add')
524
+ {
525
+ $result=Array('success'=>0, 'thread_id'=>null,'messages'=>Array($ct_result->comment));
526
+ print json_encode($result);
527
+ die();
528
+ }
529
+ else if(isset($_POST['action']) && $_POST['action']=='td_mod_register')
530
+ {
531
+ print json_encode(array('register', 0, $ct_result->comment));
532
+ die();
533
+ }
534
+ else if(isset($_POST['action']) && $_POST['action']=='tmpl_ajax_check_user_email')
535
+ {
536
+ print "17,email";
537
+ die();
538
+ }
539
+ else if(isset($_POST['action']) && ($_POST['action']=='tevolution_submit_from_preview' || $_POST['action']=='submit_form_recaptcha_validation'))
540
+ {
541
+ print $ct_result->comment;
542
+ die();
543
+ }
544
+ else if(isset($_POST['action']) && $_POST['action']=='ninja_forms_ajax_submit')
545
+ {
546
+ print '{"form_id":'.$_POST['_form_id'].',"errors":false,"success":{"success_msg-Success":"'.$ct_result->comment.'"}}';
547
+ die();
548
+ }
549
+ else if(isset($_POST['action']) && $_POST['action']=='nf_ajax_submit')
550
+ {
551
+ $nf_data = json_decode($_POST['formData'], true);
552
+ // print '{data:{{"form_id":'.$nf_data['id'].',"errors":false,"success":{"success_msg-Success":"'.$ct_result->comment.'"}}}}'; \\Old version
553
+ print '{"data":{"form_id":"'.$nf_data['id'].'","settings":{},"extra":[],"fields":{},"processed_actions":[],"actions":{"success_message": "<font style=\"color: red\">'.$ct_result->comment.'</font><br><br>"}},"errors":[],"debug":[]}';
554
+ die();
555
+ }
556
+
557
+ // WooWaitList
558
+ // http://codecanyon.net/item/woowaitlist-woocommerce-back-in-stock-notifier/7103373
559
+ else if(isset($_POST['action']) && $_POST['action']=='wew_save_to_db_callback')
560
+ {
561
+ $result = array();
562
+ $result['error'] = 1;
563
+ $result['message'] = $ct_result->comment;
564
+ $result['code'] = 5; // Unused code number in WooWaitlist
565
+ print json_encode($result);
566
+ die();
567
+ }
568
+ // UserPro
569
+ else if(isset($_POST['action'], $_POST['template']) && $_POST['action']=='userpro_process_form' && $_POST['template']=='register')
570
+ {
571
+ foreach($_POST as $key => $value){
572
+ $output[$key]=$value;
573
+ }unset($key, $value);
574
+ $output['template'] = $ct_result->comment;
575
+ $output=json_encode($output);
576
+ print_r($output);
577
+ die;
578
+ }
579
+ // Quick event manager
580
+ else if(isset($_POST['action']) && $_POST['action']=='qem_validate_form'){
581
+ $errors[] = 'registration_forbidden';
582
+ $result = Array(
583
+ 'success' => 'false',
584
+ 'errors' => $errors,
585
+ 'title' => $ct_result->comment
586
+ );
587
+ print json_encode($result);
588
+ die();
589
+ }
590
+ // Quick Contact Form
591
+ elseif(isset($_POST['action']) && $_POST['action'] == 'qcf_validate_form')
592
+ {
593
+ $result = Array(
594
+ 'blurb' => "<h1>".$ct_result->comment."</h1>",
595
+ 'display' => "Oops, got a few problems here",
596
+ 'errors' => array(
597
+ 0 => array(
598
+ error => 'error',
599
+ name => 'name'
600
+ ),
601
+ ),
602
+ 'success' => 'false',
603
+ );
604
+ print json_encode($result);
605
+ die();
606
+ }
607
+ // Usernoise Contact Form
608
+ elseif(isset($_POST['title'], $_POST['email'], $_POST['type'], $_POST['ct_checkjs']))
609
+ {
610
+ return array($ct_result->comment);
611
+ die();
612
+ }
613
+ // amoForms
614
+ elseif(isset($_POST['action']) && $_POST['action'] == 'amoforms_submit')
615
+ {
616
+ $result = Array(
617
+ 'result' => true,
618
+ 'type' => "html",
619
+ 'value' => "<h1 style='font-size: 25px; color: red;'>".$ct_result->comment."</h1>",
620
+ 'fast' => false
621
+ );
622
+ print json_encode($result);
623
+ die();
624
+ }
625
+ // MailChimp for Wordpress Premium
626
+ elseif(!empty($_POST['_mc4wp_form_id']))
627
+ {
628
+ return 'ct_mc4wp_response';
629
+ }
630
+ // QAEngine Theme answers
631
+ elseif ( !empty($message_obj) && isset($message_obj['post_type'], $message_obj['author'], $message_obj['post_content']) ){
632
+ return new WP_Error('Spam comment', $ct_result->comment);
633
+ }
634
+ //Convertplug. Strpos because action value dynamically changes and depends on mailing service
635
+ elseif (isset($_POST['action']) && strpos($_POST['action'], '_add_subscriber') !== false){
636
+ $result = Array(
637
+ 'action' => "message",
638
+ 'detailed_msg' => "",
639
+ 'email_status' => false,
640
+ 'message' => "<h1 style='font-size: 25px; color: red;'>".$ct_result->comment."</h1>",
641
+ 'status' => "error",
642
+ 'url' => "none"
643
+ );
644
+ print json_encode($result);
645
+ die();
646
+ }
647
+ // Ultimate Form Builder
648
+ elseif (isset($_POST['action']) && $_POST['action'] == 'ufbl_front_form_action'){
649
+ $result = Array(
650
+ 'error_keys' => array(),
651
+ 'error_flag' => 1,
652
+ 'response_message' => $ct_result->comment
653
+ );
654
+ print json_encode($result);
655
+ die();
656
+ }
657
+ // Smart Forms
658
+ elseif (isset($_POST['action']) && $_POST['action'] == 'rednao_smart_forms_save_form_values'){
659
+ $result = Array(
660
+ 'message' => $ct_result->comment,
661
+ 'refreshCaptcha' => 'n',
662
+ 'success' => 'n'
663
+ );
664
+ print json_encode($result);
665
+ die();
666
+ }
667
+ //cFormsII
668
+ elseif(isset($_POST['action']) && $_POST['action'] == 'submitcform')
669
+ {
670
+ header('Content-Type: application/json');
671
+ $result = Array(
672
+ 'no' => "",
673
+ 'result' => "failure",
674
+ 'html' =>$ct_result->comment,
675
+ 'hide' => false,
676
+ 'redirection' => null
677
+
678
+ );
679
+ print json_encode($result);
680
+ die();
681
+ }
682
+ //Contact Form by Web-Settler
683
+ elseif(isset($_POST['smFieldData']))
684
+ {
685
+ $result = Array(
686
+ 'signal' => true,
687
+ 'code' => 0,
688
+ 'thanksMsg' => $ct_result->comment,
689
+ 'errors' => array(),
690
+ 'isMsg' => true,
691
+ 'redirectUrl' => null
692
+ );
693
+ print json_encode($result);
694
+ die();
695
+ }
696
+ //Reviewer
697
+ elseif(isset($_POST['action']) && $_POST['action'] == 'rwp_ajax_action_rating')
698
+ {
699
+ $result = Array(
700
+ 'success' => false,
701
+ 'data' => array(0=>$ct_result->comment)
702
+ );
703
+ print json_encode($result);
704
+ die();
705
+ }
706
+ else
707
+ {
708
+ print $ct_result->comment;
709
+ die();
710
+ }
711
+ }
712
+ //Allow == 1
713
+ else{
714
+ //QAEngine Theme answers
715
+ if ( !empty($message_obj) && isset($message_obj['post_type'], $message_obj['author'], $message_obj['post_content']) ){
716
+ return $message_obj;
717
+ }
718
+ }
719
+ }
720
+ }
721
+
722
  ?>
inc/cleantalk-public.php CHANGED
@@ -45,18 +45,20 @@ function ct_init() {
45
  unset($_POST['cleantalk_hidden_action']);
46
  unset($_POST['cleantalk_hidden_method']);
47
  ct_contact_form_validate();
48
- print "<html><body><form method='$method' action='$action'>";
49
- ct_print_form($_POST,'');
50
- print "</form><center>Redirecting to ".$action."... Anti-spam by CleanTalk.</center></body></html>";
51
- print "<script>
52
- if(document.forms[0].submit != 'undefined'){
53
- var objects = document.getElementsByName('submit');
54
- if(objects.length > 0)
55
- document.forms[0].removeChild(objects[0]);
56
- }
57
- document.forms[0].submit();
58
- </script>";
59
- die();
 
 
60
  }
61
 
62
  if(isset($ct_options['general_postdata_test']) && $ct_options['general_postdata_test'] == 1 && !@isset($_POST['ct_checkjs_cf7']))
@@ -2842,7 +2844,7 @@ function ct_enqueue_scripts_public($hook){
2842
  wp_enqueue_script('ct_nocache', plugins_url('/cleantalk-spam-protect/inc/cleantalk_nocache.js'), array(), $cleantalk_plugin_version, 'in_footer');
2843
 
2844
  if(!empty($ct_options['check_external']))
2845
- wp_enqueue_script('ct_external', plugins_url('/cleantalk-spam-protect/inc/cleantalk_external.js'), array(), $cleantalk_plugin_version, 'in_footer');
2846
 
2847
  if(!empty($ct_options['check_internal']))
2848
  wp_enqueue_script('ct_internal', plugins_url('/cleantalk-spam-protect/inc/cleantalk_internal.js'), array('jquery'), $cleantalk_plugin_version, 'in_footer');
@@ -2851,7 +2853,7 @@ function ct_enqueue_scripts_public($hook){
2851
  'ajaxurl' => admin_url('admin-ajax.php'),
2852
  'info_flag' => !empty($ct_options['collect_details']) && !empty($ct_options['set_cookies']) ? true : false,
2853
  'set_cookies_flag' => empty($ct_options['set_cookies']) ? false : true,
2854
- 'blog_home' => get_home_url(),
2855
  ));
2856
  }
2857
  }
45
  unset($_POST['cleantalk_hidden_action']);
46
  unset($_POST['cleantalk_hidden_method']);
47
  ct_contact_form_validate();
48
+ if(empty($_POST['cleantalk_hidden_ajax'])){
49
+ print "<html><body><form method='$method' action='$action'>";
50
+ ct_print_form($_POST,'');
51
+ print "</form><center>Redirecting to ".$action."... Anti-spam by CleanTalk.</center></body></html>";
52
+ print "<script>
53
+ if(document.forms[0].submit != 'undefined'){
54
+ var objects = document.getElementsByName('submit');
55
+ if(objects.length > 0)
56
+ document.forms[0].removeChild(objects[0]);
57
+ }
58
+ document.forms[0].submit();
59
+ </script>";
60
+ die();
61
+ }
62
  }
63
 
64
  if(isset($ct_options['general_postdata_test']) && $ct_options['general_postdata_test'] == 1 && !@isset($_POST['ct_checkjs_cf7']))
2844
  wp_enqueue_script('ct_nocache', plugins_url('/cleantalk-spam-protect/inc/cleantalk_nocache.js'), array(), $cleantalk_plugin_version, 'in_footer');
2845
 
2846
  if(!empty($ct_options['check_external']))
2847
+ wp_enqueue_script('ct_external', plugins_url('/cleantalk-spam-protect/inc/cleantalk_external.js'), array('jquery'), $cleantalk_plugin_version, 'in_footer');
2848
 
2849
  if(!empty($ct_options['check_internal']))
2850
  wp_enqueue_script('ct_internal', plugins_url('/cleantalk-spam-protect/inc/cleantalk_internal.js'), array('jquery'), $cleantalk_plugin_version, 'in_footer');
2853
  'ajaxurl' => admin_url('admin-ajax.php'),
2854
  'info_flag' => !empty($ct_options['collect_details']) && !empty($ct_options['set_cookies']) ? true : false,
2855
  'set_cookies_flag' => empty($ct_options['set_cookies']) ? false : true,
2856
+ 'blog_home' => get_home_url().'/',
2857
  ));
2858
  }
2859
  }
inc/cleantalk-updater.php CHANGED
@@ -1,82 +1,82 @@
1
- <?php
2
-
3
- function ct_run_update_actions($current_version, $new_version){
4
-
5
- global $ct_data, $wpdb;
6
-
7
- $current_version = ct_version_standartization($current_version);
8
- $new_version = ct_version_standartization($new_version);
9
-
10
- //Update actions
11
- if($current_version[0] <= 5){
12
- if($current_version[1] <= 49){
13
- if($current_version[2] <= 1){
14
- $wpdb->query("CREATE TABLE IF NOT EXISTS `".$wpdb->base_prefix."cleantalk_sfw` (
15
- `network` int(11) unsigned NOT NULL,
16
- `mask` int(11) unsigned NOT NULL,
17
- INDEX ( `network` , `mask` )
18
- ) ENGINE = MYISAM ;");
19
-
20
- $wpdb->query("CREATE TABLE IF NOT EXISTS `".$wpdb->base_prefix."cleantalk_sfw_logs` (
21
- `ip` VARCHAR(15) NOT NULL ,
22
- `all` INT NOT NULL ,
23
- `blocked` INT NOT NULL ,
24
- `timestamp` INT NOT NULL ,
25
- PRIMARY KEY (`ip`))
26
- ENGINE = MYISAM;");
27
- }
28
- }
29
- if($current_version[1] <= 55){
30
- if (!wp_next_scheduled('cleantalk_update_sfw_hook'))
31
- wp_schedule_event(time()+1800, 'daily', 'cleantalk_update_sfw_hook' );
32
- }
33
- if($current_version[1] <= 69){
34
-
35
- if(!in_array('all_entries', $wpdb->get_col("DESC " . $wpdb->base_prefix."cleantalk_sfw_logs", 0))){
36
- $wpdb->query("ALTER TABLE `".$wpdb->base_prefix."cleantalk_sfw_logs`
37
- CHANGE `all` `all_entries` INT(11) NOT NULL,
38
- CHANGE `blocked` `blocked_entries` INT(11) NOT NULL,
39
- CHANGE `timestamp` `entries_timestamp` INT(11) NOT NULL;"
40
- );
41
- }
42
-
43
- // Deleting usless data
44
- unset($ct_data['db_refreshed'], $ct_data['last_sfw_send'], $ct_data['next_account_status_check']);
45
- update_option('cleantalk_data', $ct_data);
46
- delete_option('cleantalk_sends_reports_till');
47
- delete_option('cleantalk_activation_timestamp');
48
-
49
- // Disabling WP_Cron tasks
50
- wp_clear_scheduled_hook('cleantalk_send_daily_report_hook');
51
- wp_clear_scheduled_hook('ct_hourly_event_hook');
52
- wp_clear_scheduled_hook('ct_send_sfw_log');
53
- wp_clear_scheduled_hook('cleantalk_update_sfw_hook');
54
- wp_clear_scheduled_hook('cleantalk_get_brief_data_hook');
55
-
56
- // Adding Self cron system tasks
57
- cleantalk\antispam\CleantalkCron::addTask('check_account_status', 'ct_account_status_check', 3600, time()+1800); // New
58
- cleantalk\antispam\CleantalkCron::addTask('delete_spam_comments', 'ct_delete_spam_comments', 3600, time()+3500);
59
- cleantalk\antispam\CleantalkCron::addTask('send_feedback', 'ct_send_feedback', 3600, time()+3500);
60
- cleantalk\antispam\CleantalkCron::addTask('sfw_update', 'ct_sfw_update', 86400, time()+43200);
61
- cleantalk\antispam\CleantalkCron::addTask('send_sfw_logs', 'ct_sfw_send_logs', 3600, time()+1800); // New
62
- cleantalk\antispam\CleantalkCron::addTask('get_brief_data', 'cleantalk_get_brief_data', 86400, time()+3500);
63
- }
64
- }
65
-
66
- return true;
67
-
68
- }
69
-
70
- function ct_version_standartization($version){
71
-
72
- $version = explode('.', $version);
73
- $version = !empty($version) ? $version : array();
74
-
75
- $version[0] = !empty($version[0]) ? (int)$version[0] : 0;
76
- $version[1] = !empty($version[1]) ? (int)$version[1] : 0;
77
- $version[2] = !empty($version[2]) ? (int)$version[2] : 0;
78
-
79
- return $version;
80
- }
81
-
82
  ?>
1
+ <?php
2
+
3
+ function ct_run_update_actions($current_version, $new_version){
4
+
5
+ global $ct_data, $wpdb;
6
+
7
+ $current_version = ct_version_standartization($current_version);
8
+ $new_version = ct_version_standartization($new_version);
9
+
10
+ //Update actions
11
+ if($current_version[0] <= 5){
12
+ if($current_version[1] <= 49){
13
+ if($current_version[2] <= 1){
14
+ $wpdb->query("CREATE TABLE IF NOT EXISTS `".$wpdb->base_prefix."cleantalk_sfw` (
15
+ `network` int(11) unsigned NOT NULL,
16
+ `mask` int(11) unsigned NOT NULL,
17
+ INDEX ( `network` , `mask` )
18
+ ) ENGINE = MYISAM ;");
19
+
20
+ $wpdb->query("CREATE TABLE IF NOT EXISTS `".$wpdb->base_prefix."cleantalk_sfw_logs` (
21
+ `ip` VARCHAR(15) NOT NULL ,
22
+ `all` INT NOT NULL ,
23
+ `blocked` INT NOT NULL ,
24
+ `timestamp` INT NOT NULL ,
25
+ PRIMARY KEY (`ip`))
26
+ ENGINE = MYISAM;");
27
+ }
28
+ }
29
+ if($current_version[1] <= 55){
30
+ if (!wp_next_scheduled('cleantalk_update_sfw_hook'))
31
+ wp_schedule_event(time()+1800, 'daily', 'cleantalk_update_sfw_hook' );
32
+ }
33
+ if($current_version[1] <= 69){
34
+
35
+ if(!in_array('all_entries', $wpdb->get_col("DESC " . $wpdb->base_prefix."cleantalk_sfw_logs", 0))){
36
+ $wpdb->query("ALTER TABLE `".$wpdb->base_prefix."cleantalk_sfw_logs`
37
+ CHANGE `all` `all_entries` INT(11) NOT NULL,
38
+ CHANGE `blocked` `blocked_entries` INT(11) NOT NULL,
39
+ CHANGE `timestamp` `entries_timestamp` INT(11) NOT NULL;"
40
+ );
41
+ }
42
+
43
+ // Deleting usless data
44
+ unset($ct_data['db_refreshed'], $ct_data['last_sfw_send'], $ct_data['next_account_status_check']);
45
+ update_option('cleantalk_data', $ct_data);
46
+ delete_option('cleantalk_sends_reports_till');
47
+ delete_option('cleantalk_activation_timestamp');
48
+
49
+ // Disabling WP_Cron tasks
50
+ wp_clear_scheduled_hook('cleantalk_send_daily_report_hook');
51
+ wp_clear_scheduled_hook('ct_hourly_event_hook');
52
+ wp_clear_scheduled_hook('ct_send_sfw_log');
53
+ wp_clear_scheduled_hook('cleantalk_update_sfw_hook');
54
+ wp_clear_scheduled_hook('cleantalk_get_brief_data_hook');
55
+
56
+ // Adding Self cron system tasks
57
+ CleantalkCron::addTask('check_account_status', 'ct_account_status_check', 3600, time()+1800); // New
58
+ CleantalkCron::addTask('delete_spam_comments', 'ct_delete_spam_comments', 3600, time()+3500);
59
+ CleantalkCron::addTask('send_feedback', 'ct_send_feedback', 3600, time()+3500);
60
+ CleantalkCron::addTask('sfw_update', 'ct_sfw_update', 86400, time()+43200);
61
+ CleantalkCron::addTask('send_sfw_logs', 'ct_sfw_send_logs', 3600, time()+1800); // New
62
+ CleantalkCron::addTask('get_brief_data', 'cleantalk_get_brief_data', 86400, time()+3500);
63
+ }
64
+ }
65
+
66
+ return true;
67
+
68
+ }
69
+
70
+ function ct_version_standartization($version){
71
+
72
+ $version = explode('.', $version);
73
+ $version = !empty($version) ? $version : array();
74
+
75
+ $version[0] = !empty($version[0]) ? (int)$version[0] : 0;
76
+ $version[1] = !empty($version[1]) ? (int)$version[1] : 0;
77
+ $version[2] = !empty($version[2]) ? (int)$version[2] : 0;
78
+
79
+ return $version;
80
+ }
81
+
82
  ?>
inc/cleantalk-users.php CHANGED
@@ -1,605 +1,605 @@
1
- <?php
2
- add_action('admin_menu', 'ct_add_users_menu');
3
- add_action( 'wp_ajax_ajax_check_users', 'ct_ajax_check_users' );
4
- add_action( 'wp_ajax_ajax_info_users', 'ct_ajax_info_users' );
5
- add_action( 'wp_ajax_ajax_insert_users', 'ct_ajax_insert_users' );
6
- add_action( 'wp_ajax_ajax_delete_checked_users', 'ct_ajax_delete_checked_users' );
7
- add_action( 'wp_ajax_ajax_delete_all_users', 'ct_ajax_delete_all_users' );
8
- add_action( 'wp_ajax_ajax_clear_users', 'ct_ajax_clear_users' );
9
- add_action( 'wp_ajax_ajax_ct_approve_user', 'ct_usercheck_approve_user' );
10
- add_action( 'wp_ajax_ajax_ct_get_csv_file', 'ct_usercheck_get_csv_file' );
11
-
12
- function ct_add_users_menu(){
13
- if(current_user_can('activate_plugins'))
14
- add_users_page( __("Check for spam", 'cleantalk'), __("Check for spam", 'cleantalk'), 'read', 'ct_check_users', 'ct_show_users_page');
15
- }
16
-
17
- function ct_show_users_page(){
18
- global $ct_plugin_name, $wpdb;
19
-
20
- // Getting total spam users
21
- $r = $wpdb->get_results("
22
- SELECT
23
- DISTINCT COUNT($wpdb->users.ID) AS cnt
24
- FROM $wpdb->users
25
- INNER JOIN $wpdb->usermeta
26
- ON $wpdb->users.ID = $wpdb->usermeta.user_id
27
- WHERE $wpdb->usermeta.meta_key='ct_marked_as_spam';"
28
- , ARRAY_A);
29
- $cnt_spam1=$r[0]['cnt'];
30
-
31
- ?>
32
- <div class="wrap">
33
- <h2><?php echo $ct_plugin_name; ?></h2><br />
34
-
35
- <!-- AJAX error message -->
36
- <div id="ct_error_message" style="display:none">
37
- <h3 style="text-align: center;width:90%;">
38
- <?php _e("Ajax error. Process will be automatically restarted in 3 seconds. Status: ", 'cleantalk'); ?><span id="cleantalk_ajax_error"></span> (<span id="cleantalk_js_func"></span>)
39
- </h3>
40
- <h4 style="text-align:center;width:90%;">Please, check for JavaScript errors in your dashboard and and repair it.</h4>
41
- </div>
42
-
43
- <!-- Deleting message -->
44
- <div id="ct_deleting_message" style="display:none">
45
- <?php _e("Please wait for a while. CleanTalk is deleting spam users. Users left: ", 'cleantalk'); ?> <span id="cleantalk_users_left">
46
- <?php echo $cnt_spam1;?>
47
- </span>
48
- </div>
49
-
50
- <!-- Main info -->
51
- <h3 id="ct_checking_users_status" style="text-align:center;width:90%;"><?php echo ct_ajax_info_users(true); ?></h3>
52
-
53
- <!-- Cooling notice -->
54
- <h3 id="ct_cooling_notice" style="text-align:center;width:90%;"></h3>
55
-
56
- <!-- Preloader and working message -->
57
- <div id="ct_preloader">
58
- <img border=0 src="<?php print plugin_dir_url(__FILE__); ?>images/preloader.gif" />
59
- </div>
60
- <div id="ct_working_message">
61
- <?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'); ?>
62
- </div>
63
-
64
- <?php
65
- // Pagination
66
- $page = !empty($_GET['spam_page']) ? intval($_GET['spam_page']) : 1;
67
- $on_page = 20;
68
- $args_spam = array(
69
- 'meta_query' => array(
70
- Array(
71
- 'key' => 'ct_marked_as_spam',
72
- 'value' => '1',
73
- 'compare' => 'NUMERIC'
74
- )
75
- ),
76
- 'number'=>$on_page,
77
- 'offset'=>($page-1)*$on_page
78
- );
79
-
80
- $c_spam=get_users($args_spam);
81
- if($cnt_spam1 > 0){
82
-
83
- $pages = ceil(intval($cnt_spam1)/$on_page);
84
- if($pages && $pages != 1){
85
- echo "<div class='pagination'>"
86
- ."<b>Pages:</b>"
87
- ."<ul class='pagination'>";
88
- for($i = 1; $i <= $pages; $i++){
89
- echo "<li class='pagination'>"
90
- ."<a href='users.php?page=ct_check_users&spam_page=$i&ct_worked=1'>"
91
- .($i == $page ? "<span class='current_page'>$i</span>" : $i)
92
- ."</a>"
93
- ."</li>";
94
- }
95
- echo "</ul>";
96
- echo "</div>";
97
- }
98
- ?>
99
- <table class="widefat fixed comments" id="ct_check_users_table">
100
- <thead>
101
- <th scope="col" id="cb" class="manage-column column-cb check-column">
102
- <label class="screen-reader-text" for="cb-select-all-1">Select All</label>
103
- <input id="cb-select-all-1" type="checkbox"/>
104
- </th>
105
- <th scope="col" id="author" class="manage-column column-slug"><?php _e('Username');?></th>
106
- <th scope="col" id="comment" class="manage-column column-comment"><?php _e('Name');?></th>
107
- <th scope="col" id="response" class="manage-column column-comment"><?php _e('E-mail');?></th>
108
- <th scope="col" id="role" class="manage-column column-response sortable desc"><?php _e('Role');?></th>
109
- <th scope="col" id="posts" class="manage-column column-response sortable desc"><?php _e('Posts');?></th>
110
- </thead>
111
- <tbody id="the-comment-list" data-wp-lists="list:comment">
112
- <?php
113
- for($i=0;$i<sizeof($c_spam);$i++){
114
- $id = $c_spam[$i]->ID;
115
- $login = $c_spam[$i]->data->user_login;
116
- $email = $c_spam[$i]->data->user_email;
117
-
118
- echo "<tr id='comment-$id' class='comment even thread-even depth-1 approved cleantalk_user' data-id='$id'>"
119
- ."<th scope='row' class='check-column'>"
120
- ."<label class='screen-reader-text' for='cb-select-$id'>Select user</label>"
121
- ."<input id='cb-select-$id' type='checkbox' name='del_comments[]' />"
122
- ."</th>"
123
- ."<td class='author column-author' nowrap>"
124
- ."<strong>"
125
- .get_avatar( $c_spam[$i]->data->ID , 32)
126
- .$login
127
- ."</strong>"
128
- ."<br/>"
129
- ."<br/>";
130
-
131
- // Outputs email if exists
132
- if(!empty($email)){
133
- echo "<a href='mailto:$email'>$email</a>"
134
- ."<a href='https://cleantalk.org/blacklists/$email' target='_blank'>"
135
- ."&nbsp;<img src='".plugin_dir_url(__FILE__)."images/new_window.gif' border='0' style='float:none' />"
136
- ."</a>";
137
- }else{
138
- echo "No email";
139
- }
140
- echo "<br/>";
141
-
142
- // Outputs IP if exists
143
- $user_meta = get_user_meta($id, 'session_tokens', true);
144
- if(!empty($user_meta) && is_array($user_meta)){
145
- $user_meta=array_values($user_meta);
146
- if(!empty($user_meta[0]['ip'])){
147
- $ip = $user_meta[0]['ip'];
148
- echo "<a href='user-edit.php?user_id=$id'>$ip</a>"
149
- ."<a href='https://cleantalk.org/blacklists/$ip' target='_blank'>"
150
- ."&nbsp;<img src='".plugin_dir_url(__FILE__)."images/new_window.gif' border='0' style='float:none' />"
151
- ."</a>";
152
- }else
153
- echo "No IP adress";
154
- }else
155
- echo "No IP adress";
156
- echo "</td>";
157
- ?>
158
-
159
-
160
- <td class="comment column-comment">
161
- <div class="submitted-on">
162
- <?php print $c_spam[$i]->data->display_name; ?>
163
- <div style="height:16px; display: none;" id="cleantalk_button_set_<?php print $id; ?>">
164
- <a href="#" class="cleantalk_delete_from_list_button" data-id="<?php print $id; ?>" style="color:#0a0;" onclick="return false;" onmouseover="this.style.textDecoration='underline';" onmouseout="this.style.textDecoration='none';"><?php _e("Approve", "cleantalk"); ?></a>
165
- &nbsp;|&nbsp;
166
- <a href="#" class="cleantalk_delete_user_button" id="cleantalk_delete_user_<?php print $id; ?>" data-id="<?php print $id; ?>" style="color:#a00;display:none;" onclick="return false;" onmouseover="this.style.textDecoration='underline';" onmouseout="this.style.textDecoration='none';"><?php _e("Delete", "cleantalk"); ?></a>
167
- </div>
168
- </div>
169
- </td>
170
- <td class="comment column-comment">
171
- <?php print $email; ?>
172
- </td>
173
- <td class="comment column-comment">
174
- <?php
175
- $info=get_userdata( $id );
176
- print implode(', ', $info->roles);
177
- ?>
178
- </td>
179
- <td class="comment column-comment">
180
- <?php
181
- print count_user_posts($id);
182
- ?>
183
- </td>
184
- </tr>
185
- <?php
186
- }
187
- ?>
188
- </tbody>
189
- </table>
190
- <?php
191
- // Pagination
192
- if($pages && $pages != 1){
193
- echo "<div class='pagination'>"
194
- ."<b>Pages:</b>"
195
- ."<ul class='pagination'>";
196
- for($i = 1; $i <= $pages; $i++){
197
- echo "<li class='pagination'>"
198
- ."<a href='users.php?page=ct_check_users&spam_page=$i&ct_worked=1'>"
199
- .($i == $page ? "<span class='current_page'>$i</span>" : $i)
200
- ."</a>"
201
- ."</li>";
202
- }
203
- echo "</ul>";
204
- echo "</div>";
205
- }
206
- ?>
207
- <div id="ct_tools_buttons" style="margin-top: 10px;">
208
- <button class="button" id="ct_delete_all_users"><?php _e('Delete all users from list', 'cleantalk'); ?></button>
209
- <button class="button" id="ct_delete_checked_users"><?php _e('Delete selected', 'cleantalk'); ?></button>
210
- <button class="button" id="ct_get_csv_file"><?php _e('Download results in CSV', 'cleantalk'); ?></button>
211
- </div>
212
- <?php
213
- }
214
- echo $_SERVER['REMOTE_ADDR']=='127.0.0.1' ? '<br /><button class="button" id="ct_insert_users">'. __('Insert accounts', 'cleantalk'). '</button><br />' : '';
215
- ?>
216
- <br />
217
- <br />
218
- <table>
219
- <tr>
220
- <td>
221
- <button class="button" id="ct_check_users_button"><?php _e("Check for spam", 'cleantalk'); ?></button>
222
- </td>
223
- <td style="padding-left: 2em;">
224
- <div id="ct_info_message" class="wrap">
225
- <?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'); ?>
226
- </div>
227
- </td>
228
- </tr>
229
- </table>
230
- <?php
231
- if($cnt_spam1 > 0)
232
- echo "<div id='ct_search_info'>"
233
- ."<br />"
234
- .__("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.", 'cleantalk')
235
- ."</div>";
236
- ?>
237
- <div>
238
- <button class="button" id="ct_stop_deletion" style="display:none;"><?php _e("Stop deletion", 'cleantalk'); ?></button>
239
- </div>
240
- <div id='ct_csv_wrapper' style="display: none;"></div>
241
- </div>
242
- <?php
243
- }
244
-
245
- function ct_ajax_check_users(){
246
-
247
- global $ct_options,$ct_ip_penalty_days;
248
-
249
- check_ajax_referer('ct_secret_nonce', 'security');
250
-
251
- $ct_options = ct_get_options();
252
-
253
- $skip_roles = array(
254
- 'administrator'
255
- );
256
-
257
- $args_unchecked = array(
258
- 'meta_query' => array(
259
- array(
260
- 'key' => 'ct_checked',
261
- 'value' => '1',
262
- 'compare' => 'NOT EXISTS'
263
- ),
264
- array(
265
- 'key' => 'ct_bad',
266
- 'value' => '1',
267
- 'compare' => 'NOT EXISTS'
268
- ),
269
- ),
270
- 'orderby' => 'registered',
271
- 'order' => 'ASC',
272
- 'number' => 100
273
- );
274
- $u = get_users($args_unchecked);
275
-
276
- $check_result = array(
277
- 'end' => 0,
278
- 'checked' => 0,
279
- 'spam' => 0,
280
- 'bad' => 0,
281
- 'error' => 0
282
- );
283
-
284
- if(count($u) > 0){
285
-
286
- foreach($u as $user_index => $user){
287
-
288
- if(!isset($curr_date))
289
- $curr_date = (substr($user->data->user_registered, 0, 10) ? substr($user->data->user_registered, 0, 10) : '');
290
-
291
- if(substr($user->data->user_registered, 0, 10) != $curr_date)
292
- unset($u[$user_index]);
293
-
294
- }
295
- unset($user_index, $user);
296
-
297
- $data=Array();
298
- for($i=0; $i < count($u); $i++){
299
-
300
- $user_meta = get_user_meta($u[$i]->ID, 'session_tokens', true);
301
- if(is_array($user_meta))
302
- $user_meta = array_values($user_meta);
303
-
304
- $curr_ip = !empty($user_meta[0]['ip']) ? trim($user_meta[0]['ip']) : '';
305
- $curr_email = !empty($u[$i]->data->user_email) ? trim($u[$i]->data->user_email) : '';
306
-
307
- // Check for identity
308
- $curr_ip = preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $curr_ip) === 1 ? $curr_ip : null;
309
- $curr_email = preg_match('/^\S+@\S+\.\S+$/', $curr_email) === 1 ? $curr_email : null;
310
-
311
- if(empty($curr_ip) && empty($curr_email)){
312
- $check_result['bad']++;
313
- update_user_meta($u[$i]->ID,'ct_bad','1',true);
314
- unset($u[$i]);
315
- $u = array_values($u);
316
- }else{
317
- if(!empty($curr_ip))
318
- $data[] = $curr_ip;
319
- if(!empty($curr_email))
320
- $data[] = $curr_email;
321
- $u[$i]->data->user_ip = empty($curr_ip) ? 'none' : $curr_ip;
322
- $u[$i]->data->user_email = empty($curr_email) ? 'none' : $curr_email;
323
- }
324
- }
325
-
326
- // Drop if data empty and there's no users to check
327
- if(count($data) == 0){
328
-
329
- if($_POST['unchecked'] === 0)
330
- $check_result['end'] = 1;
331
-
332
- print json_encode($check_result);
333
- die();
334
- }
335
-
336
- $data=implode(',',$data);
337
-
338
- $request=Array();
339
- $request['method_name'] = 'spam_check_cms';
340
- $request['auth_key'] = $ct_options['apikey'];
341
- $request['data'] = $data;
342
- $request['date'] = $curr_date;
343
- $url='https://api.cleantalk.org';
344
- if(!function_exists('sendRawRequest'))
345
- require_once('cleantalk.class.php');
346
-
347
- $result=sendRawRequest($url, $request, false, 5);
348
-
349
- if(empty($result)){
350
- $check_result['error'] = 1;
351
- $check_result['error_message'] = __('Connection error', 'cleantalk');
352
- print json_encode($check_result);
353
- }else{
354
-
355
- $result = json_decode($result);
356
-
357
- if(isset($result->error_message)){
358
- $check_result['error'] = 1;
359
- $check_result['error_message'] = __('Server response: ', 'cleantalk').$result->error_message;
360
- print "Server response: ".$result->error_message;
361
- }else{
362
-
363
- // Opening CSV file
364
- $current_user = wp_get_current_user();
365
- $filename = WP_PLUGIN_DIR."/cleantalk-spam-protect/check-results/user_check_by_{$current_user->user_login}.csv";
366
- $text = "";
367
-
368
- if(isset($_POST['new_check']) && $_POST['new_check'] == 'true'){
369
- $file_desc = fopen($filename, 'w');
370
- $text .= "login,email,ip".PHP_EOL;
371
- }else
372
- $file_desc = fopen($filename, 'a+');
373
- // End of Opening CSV
374
-
375
- for($i=0;$i<sizeof($u);$i++){
376
-
377
- $check_result['checked']++;
378
- update_user_meta($u[$i]->ID,'ct_checked',date("Y-m-d H:m:s"),true);
379
-
380
- // Do not display forbidden roles.
381
- foreach ($skip_roles as $role) {
382
- if (in_array($role, $u[$i]->roles)){
383
- delete_user_meta($u[$i]->ID, 'ct_marked_as_spam');
384
- continue 2;
385
- }
386
- }
387
-
388
- $mark_spam_ip = false;
389
- $mark_spam_email = false;
390
-
391
- $uip = $u[$i]->data->user_ip;
392
- $uim = $u[$i]->data->user_email;
393
-
394
- if(isset($result->data->$uip) && $result->data->$uip->appears == 1)
395
- $mark_spam_ip = true;
396
-
397
- if(isset($result->data->$uim) && $result->data->$uim->appears==1)
398
- $mark_spam_email = true;
399
-
400
- if ($mark_spam_ip || $mark_spam_email){
401
- $check_result['spam']++;
402
- update_user_meta($u[$i]->ID,'ct_marked_as_spam','1',true);
403
- $text .= $u[$i]->user_login.',';
404
- $text .= ($mark_spam_email ? $uim : '').',';
405
- $text .= ($mark_spam_ip ? $uip : '').PHP_EOL;
406
- }
407
-
408
- }
409
- fwrite($file_desc, $text);
410
- fclose($file_desc);
411
- print json_encode($check_result);
412
- }
413
- }
414
- }else{
415
- $check_result['end'] = 1;
416
- print json_encode($check_result);
417
- }
418
- die;
419
- }
420
-
421
- function ct_ajax_info_users($direct_call = false)
422
- {
423
- if (!$direct_call)
424
- check_ajax_referer( 'ct_secret_nonce', 'security' );
425
-
426
- global $wpdb;
427
-
428
- // All users
429
- $r=$wpdb->get_results("
430
- SELECT
431
- COUNT(ID) AS cnt
432
- FROM $wpdb->users
433
- ");
434
- $cnt = $r[0]->cnt;
435
-
436
- // Checked
437
- $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';");
438
- $cnt_checked = $r[0]->cnt;
439
-
440
- //Spam
441
- $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);
442
- $cnt_spam = $r[0]['cnt'];
443
-
444
- //Bad
445
- $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_bad';", ARRAY_A);
446
- $cnt_bad = $r[0]['cnt'];
447
-
448
- $return = array(
449
- 'message' => '',
450
- 'total' => $cnt
451
- );
452
-
453
- $return['message'] .= sprintf (__("Total users %s, checked %s, found %s spam users and %s bad users (without IP or email)", 'cleantalk'), $cnt, $cnt_checked, $cnt_spam, $cnt_bad);
454
-
455
- $backup_notice = '&nbsp;';
456
- if ($cnt_spam > 0) {
457
- $backup_notice = __("Please do backup of WordPress database before delete any accounts!", 'cleantalk');
458
- }
459
- $return['message'] .= "<p>$backup_notice</p>";
460
-
461
- if($direct_call){
462
- return $return['message'];
463
- }else{
464
- echo json_encode($return);
465
- die();
466
- }
467
-
468
- return null;
469
- }
470
-
471
- function ct_ajax_insert_users()
472
- {
473
- check_ajax_referer( 'ct_secret_nonce', 'security' );
474
- global $wpdb;
475
-
476
- $to_insert = 20;
477
-
478
- /* DELETION
479
- $users = get_users(array('search' => '*user_*', 'search_columns' => array('login', 'nicename')));
480
- $inserted = 0;
481
- $amount_to_delete = 0;
482
- foreach($users as $user){
483
- if($inserted >= $amount_to_delete)
484
- break;
485
- if(wp_delete_user($user->ID))
486
- $inserted++;
487
- }
488
- //*/
489
-
490
- $result = $wpdb->get_results("SELECT network FROM `".$wpdb->base_prefix."cleantalk_sfw` LIMIT $to_insert;", ARRAY_A);
491
-
492
- if($result){
493
- $ip = array();
494
- foreach($result as $value){
495
- $ips[] = long2ip($value['network']);
496
- }
497
- unset($value);
498
-
499
- $inserted = 0;
500
- for($i=0; $i<$to_insert; $i++){
501
- $rnd=mt_rand(1,10000000);
502
-
503
- $user_name = "user_$rnd";
504
- $email="stop_email_$rnd@example.com";
505
-
506
- $user_id = wp_create_user(
507
- $user_name,
508
- rand(),
509
- $email
510
- );
511
-
512
- $curr_user = get_user_by('email', $email);
513
-
514
- update_user_meta($curr_user->ID, 'session_tokens', array($rnd => array('ip' => $ips[$i])));
515
-
516
- if (is_int($user_id))
517
- $inserted++;
518
-
519
- }
520
- }else{
521
- $inserted = '0';
522
- }
523
-
524
- print "$inserted";
525
- die();
526
- }
527
-
528
- function ct_ajax_delete_checked_users()
529
- {
530
- check_ajax_referer( 'ct_secret_nonce', 'security' );
531
- foreach($_POST['ids'] as $key=>$value)
532
- {
533
- wp_delete_user($value);
534
- }
535
- die();
536
- }
537
-
538
- function ct_ajax_delete_all_users()
539
- {
540
- check_ajax_referer( 'ct_secret_nonce', 'security' );
541
-
542
- global $wpdb;
543
-
544
- $r = $wpdb->get_results("select count(*) as cnt from $wpdb->usermeta where meta_key='ct_marked_as_spam';");
545
- $count_all = $r ? $r[0]->cnt : 0;
546
-
547
- $args = array(
548
- 'meta_key' => 'ct_marked_as_spam',
549
- 'meta_value' => '1',
550
- 'fields' => array('ID'),
551
- 'number' => 10
552
- );
553
- $users = get_users($args);
554
-
555
- if ($users){
556
- foreach($users as $user){
557
- wp_delete_user($user->ID);
558
- usleep(5000);
559
- }
560
- }
561
-
562
- print $count_all;
563
- die();
564
- }
565
-
566
- function ct_ajax_clear_users()
567
- {
568
- check_ajax_referer( 'ct_secret_nonce', 'security' );
569
- global $wpdb;
570
- $wpdb->query("delete from $wpdb->usermeta where meta_key='ct_checked' or meta_key='ct_marked_as_spam' or meta_key='ct_bad';");
571
- die();
572
- }
573
-
574
- /**
575
- * Admin action 'user_unapproved_to_approved' - Approve user, delete from the deleting list
576
- */
577
- function ct_usercheck_approve_user() {
578
-
579
- check_ajax_referer( 'ct_secret_nonce', 'security' );
580
-
581
- delete_metadata('user', $_POST['id'], 'ct_marked_as_spam');
582
-
583
- die();
584
- }
585
-
586
- /**
587
- * Admin action 'wp_ajax_ajax_ct_get_csv_file' - prints CSV file to AJAX
588
- */
589
- function ct_usercheck_get_csv_file() {
590
-
591
- check_ajax_referer( 'ct_secret_nonce', 'security' );
592
-
593
- $filename = !empty($_POST['filename']) ? $_POST['filename'] : false;
594
-
595
- if($filename !== false && file_exists(WP_PLUGIN_DIR."/cleantalk-spam-protect/check-results/{$filename}.csv"))
596
- $output = 1;
597
- else
598
- $output = 0;
599
-
600
- echo $output;
601
-
602
- die();
603
- }
604
-
605
  ?>
1
+ <?php
2
+ add_action('admin_menu', 'ct_add_users_menu');
3
+ add_action( 'wp_ajax_ajax_check_users', 'ct_ajax_check_users' );
4
+ add_action( 'wp_ajax_ajax_info_users', 'ct_ajax_info_users' );
5
+ add_action( 'wp_ajax_ajax_insert_users', 'ct_ajax_insert_users' );
6
+ add_action( 'wp_ajax_ajax_delete_checked_users', 'ct_ajax_delete_checked_users' );
7
+ add_action( 'wp_ajax_ajax_delete_all_users', 'ct_ajax_delete_all_users' );
8
+ add_action( 'wp_ajax_ajax_clear_users', 'ct_ajax_clear_users' );
9
+ add_action( 'wp_ajax_ajax_ct_approve_user', 'ct_usercheck_approve_user' );
10
+ add_action( 'wp_ajax_ajax_ct_get_csv_file', 'ct_usercheck_get_csv_file' );
11
+
12
+ function ct_add_users_menu(){
13
+ if(current_user_can('activate_plugins'))
14
+ add_users_page( __("Check for spam", 'cleantalk'), __("Check for spam", 'cleantalk'), 'read', 'ct_check_users', 'ct_show_users_page');
15
+ }
16
+
17
+ function ct_show_users_page(){
18
+ global $ct_plugin_name, $wpdb;
19
+
20
+ // Getting total spam users
21
+ $r = $wpdb->get_results("
22
+ SELECT
23
+ DISTINCT COUNT($wpdb->users.ID) AS cnt
24
+ FROM $wpdb->users
25
+ INNER JOIN $wpdb->usermeta
26
+ ON $wpdb->users.ID = $wpdb->usermeta.user_id
27
+ WHERE $wpdb->usermeta.meta_key='ct_marked_as_spam';"
28
+ , ARRAY_A);
29
+ $cnt_spam1=$r[0]['cnt'];
30
+
31
+ ?>
32
+ <div class="wrap">
33
+ <h2><?php echo $ct_plugin_name; ?></h2><br />
34
+
35
+ <!-- AJAX error message -->
36
+ <div id="ct_error_message" style="display:none">
37
+ <h3 style="text-align: center;width:90%;">
38
+ <?php _e("Ajax error. Process will be automatically restarted in 3 seconds. Status: ", 'cleantalk'); ?><span id="cleantalk_ajax_error"></span> (<span id="cleantalk_js_func"></span>)
39
+ </h3>
40
+ <h4 style="text-align:center;width:90%;">Please, check for JavaScript errors in your dashboard and and repair it.</h4>
41
+ </div>
42
+
43
+ <!-- Deleting message -->
44
+ <div id="ct_deleting_message" style="display:none">
45
+ <?php _e("Please wait for a while. CleanTalk is deleting spam users. Users left: ", 'cleantalk'); ?> <span id="cleantalk_users_left">
46
+ <?php echo $cnt_spam1;?>
47
+ </span>
48
+ </div>
49
+
50
+ <!-- Main info -->
51
+ <h3 id="ct_checking_users_status" style="text-align:center;width:90%;"><?php echo ct_ajax_info_users(true); ?></h3>
52
+
53
+ <!-- Cooling notice -->
54
+ <h3 id="ct_cooling_notice" style="text-align:center;width:90%;"></h3>
55
+
56
+ <!-- Preloader and working message -->
57
+ <div id="ct_preloader">
58
+ <img border=0 src="<?php print plugin_dir_url(__FILE__); ?>images/preloader.gif" />
59
+ </div>
60
+ <div id="ct_working_message">
61
+ <?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'); ?>
62
+ </div>
63
+
64
+ <?php
65
+ // Pagination
66
+ $page = !empty($_GET['spam_page']) ? intval($_GET['spam_page']) : 1;
67
+ $on_page = 20;
68
+ $args_spam = array(
69
+ 'meta_query' => array(
70
+ Array(
71
+ 'key' => 'ct_marked_as_spam',
72
+ 'value' => '1',
73
+ 'compare' => 'NUMERIC'
74
+ )
75
+ ),
76
+ 'number'=>$on_page,
77
+ 'offset'=>($page-1)*$on_page
78
+ );
79
+
80
+ $c_spam=get_users($args_spam);
81
+ if($cnt_spam1 > 0){
82
+
83
+ $pages = ceil(intval($cnt_spam1)/$on_page);
84
+ if($pages && $pages != 1){
85
+ echo "<div class='pagination'>"
86
+ ."<b>Pages:</b>"
87
+ ."<ul class='pagination'>";
88
+ for($i = 1; $i <= $pages; $i++){
89
+ echo "<li class='pagination'>"
90
+ ."<a href='users.php?page=ct_check_users&spam_page=$i&ct_worked=1'>"
91
+ .($i == $page ? "<span class='current_page'>$i</span>" : $i)
92
+ ."</a>"
93
+ ."</li>";
94
+ }
95
+ echo "</ul>";
96
+ echo "</div>";
97
+ }
98
+ ?>
99
+ <table class="widefat fixed comments" id="ct_check_users_table">
100
+ <thead>
101
+ <th scope="col" id="cb" class="manage-column column-cb check-column">
102
+ <label class="screen-reader-text" for="cb-select-all-1">Select All</label>
103
+ <input id="cb-select-all-1" type="checkbox"/>
104
+ </th>
105
+ <th scope="col" id="author" class="manage-column column-slug"><?php _e('Username');?></th>
106
+ <th scope="col" id="comment" class="manage-column column-comment"><?php _e('Name');?></th>
107
+ <th scope="col" id="response" class="manage-column column-comment"><?php _e('E-mail');?></th>
108
+ <th scope="col" id="role" class="manage-column column-response sortable desc"><?php _e('Role');?></th>
109
+ <th scope="col" id="posts" class="manage-column column-response sortable desc"><?php _e('Posts');?></th>
110
+ </thead>
111
+ <tbody id="the-comment-list" data-wp-lists="list:comment">
112
+ <?php
113
+ for($i=0;$i<sizeof($c_spam);$i++){
114
+ $id = $c_spam[$i]->ID;
115
+ $login = $c_spam[$i]->data->user_login;
116
+ $email = $c_spam[$i]->data->user_email;
117
+
118
+ echo "<tr id='comment-$id' class='comment even thread-even depth-1 approved cleantalk_user' data-id='$id'>"
119
+ ."<th scope='row' class='check-column'>"
120
+ ."<label class='screen-reader-text' for='cb-select-$id'>Select user</label>"
121
+ ."<input id='cb-select-$id' type='checkbox' name='del_comments[]' />"
122
+ ."</th>"
123
+ ."<td class='author column-author' nowrap>"
124
+ ."<strong>"
125
+ .get_avatar( $c_spam[$i]->data->ID , 32)
126
+ .$login
127
+ ."</strong>"
128
+ ."<br/>"
129
+ ."<br/>";
130
+
131
+ // Outputs email if exists
132
+ if(!empty($email)){
133
+ echo "<a href='mailto:$email'>$email</a>"
134
+ ."<a href='https://cleantalk.org/blacklists/$email' target='_blank'>"
135
+ ."&nbsp;<img src='".plugin_dir_url(__FILE__)."images/new_window.gif' border='0' style='float:none' />"
136
+ ."</a>";
137
+ }else{
138
+ echo "No email";
139
+ }
140
+ echo "<br/>";
141
+
142
+ // Outputs IP if exists
143
+ $user_meta = get_user_meta($id, 'session_tokens', true);
144
+ if(!empty($user_meta) && is_array($user_meta)){
145
+ $user_meta=array_values($user_meta);
146
+ if(!empty($user_meta[0]['ip'])){
147
+ $ip = $user_meta[0]['ip'];
148
+ echo "<a href='user-edit.php?user_id=$id'>$ip</a>"
149
+ ."<a href='https://cleantalk.org/blacklists/$ip' target='_blank'>"
150
+ ."&nbsp;<img src='".plugin_dir_url(__FILE__)."images/new_window.gif' border='0' style='float:none' />"
151
+ ."</a>";
152
+ }else
153
+ echo "No IP adress";
154
+ }else
155
+ echo "No IP adress";
156
+ echo "</td>";
157
+ ?>
158
+
159
+
160
+ <td class="comment column-comment">
161
+ <div class="submitted-on">
162
+ <?php print $c_spam[$i]->data->display_name; ?>
163
+ <div style="height:16px; display: none;" id="cleantalk_button_set_<?php print $id; ?>">
164
+ <a href="#" class="cleantalk_delete_from_list_button" data-id="<?php print $id; ?>" style="color:#0a0;" onclick="return false;" onmouseover="this.style.textDecoration='underline';" onmouseout="this.style.textDecoration='none';"><?php _e("Approve", "cleantalk"); ?></a>
165
+ &nbsp;|&nbsp;
166
+ <a href="#" class="cleantalk_delete_user_button" id="cleantalk_delete_user_<?php print $id; ?>" data-id="<?php print $id; ?>" style="color:#a00;display:none;" onclick="return false;" onmouseover="this.style.textDecoration='underline';" onmouseout="this.style.textDecoration='none';"><?php _e("Delete", "cleantalk"); ?></a>
167
+ </div>
168
+ </div>
169
+ </td>
170
+ <td class="comment column-comment">
171
+ <?php print $email; ?>
172
+ </td>
173
+ <td class="comment column-comment">
174
+ <?php
175
+ $info=get_userdata( $id );
176
+ print implode(', ', $info->roles);
177
+ ?>
178
+ </td>
179
+ <td class="comment column-comment">
180
+ <?php
181
+ print count_user_posts($id);
182
+ ?>
183
+ </td>
184
+ </tr>
185
+ <?php
186
+ }
187
+ ?>
188
+ </tbody>
189
+ </table>
190
+ <?php
191
+ // Pagination
192
+ if($pages && $pages != 1){
193
+ echo "<div class='pagination'>"
194
+ ."<b>Pages:</b>"
195
+ ."<ul class='pagination'>";
196
+ for($i = 1; $i <= $pages; $i++){
197
+ echo "<li class='pagination'>"
198
+ ."<a href='users.php?page=ct_check_users&spam_page=$i&ct_worked=1'>"
199
+ .($i == $page ? "<span class='current_page'>$i</span>" : $i)
200
+ ."</a>"
201
+ ."</li>";
202
+ }
203
+ echo "</ul>";
204
+ echo "</div>";
205
+ }
206
+ ?>
207
+ <div id="ct_tools_buttons" style="margin-top: 10px;">
208
+ <button class="button" id="ct_delete_all_users"><?php _e('Delete all users from list', 'cleantalk'); ?></button>
209
+ <button class="button" id="ct_delete_checked_users"><?php _e('Delete selected', 'cleantalk'); ?></button>
210
+ <button class="button" id="ct_get_csv_file"><?php _e('Download results in CSV', 'cleantalk'); ?></button>
211
+ </div>
212
+ <?php
213
+ }
214
+ echo $_SERVER['REMOTE_ADDR']=='127.0.0.1' ? '<br /><button class="button" id="ct_insert_users">'. __('Insert accounts', 'cleantalk'). '</button><br />' : '';
215
+ ?>
216
+ <br />
217
+ <br />
218
+ <table>
219
+ <tr>
220
+ <td>
221
+ <button class="button" id="ct_check_users_button"><?php _e("Check for spam", 'cleantalk'); ?></button>
222
+ </td>
223
+ <td style="padding-left: 2em;">
224
+ <div id="ct_info_message" class="wrap">
225
+ <?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'); ?>
226
+ </div>
227
+ </td>
228
+ </tr>
229
+ </table>
230
+ <?php
231
+ if($cnt_spam1 > 0)
232
+ echo "<div id='ct_search_info'>"
233
+ ."<br />"
234
+ .__("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.", 'cleantalk')
235
+ ."</div>";
236
+ ?>
237
+ <div>
238
+ <button class="button" id="ct_stop_deletion" style="display:none;"><?php _e("Stop deletion", 'cleantalk'); ?></button>
239
+ </div>
240
+ <div id='ct_csv_wrapper' style="display: none;"></div>
241
+ </div>
242
+ <?php
243
+ }
244
+
245
+ function ct_ajax_check_users(){
246
+
247
+ global $ct_options,$ct_ip_penalty_days;
248
+
249
+ check_ajax_referer('ct_secret_nonce', 'security');
250
+
251
+ $ct_options = ct_get_options();
252
+
253
+ $skip_roles = array(
254
+ 'administrator'
255
+ );
256
+
257
+ $args_unchecked = array(
258
+ 'meta_query' => array(
259
+ array(
260
+ 'key' => 'ct_checked',
261
+ 'value' => '1',
262
+ 'compare' => 'NOT EXISTS'
263
+ ),
264
+ array(
265
+ 'key' => 'ct_bad',
266
+ 'value' => '1',
267
+ 'compare' => 'NOT EXISTS'
268
+ ),
269
+ ),
270
+ 'orderby' => 'registered',
271
+ 'order' => 'ASC',
272
+ 'number' => 100
273
+ );
274
+ $u = get_users($args_unchecked);
275
+
276
+ $check_result = array(
277
+ 'end' => 0,
278
+ 'checked' => 0,
279
+ 'spam' => 0,
280
+ 'bad' => 0,
281
+ 'error' => 0
282
+ );
283
+
284
+ if(count($u) > 0){
285
+
286
+ foreach($u as $user_index => $user){
287
+
288
+ if(!isset($curr_date))
289
+ $curr_date = (substr($user->data->user_registered, 0, 10) ? substr($user->data->user_registered, 0, 10) : '');
290
+
291
+ if(substr($user->data->user_registered, 0, 10) != $curr_date)
292
+ unset($u[$user_index]);
293
+
294
+ }
295
+ unset($user_index, $user);
296
+
297
+ $data=Array();
298
+ for($i=0; $i < count($u); $i++){
299
+
300
+ $user_meta = get_user_meta($u[$i]->ID, 'session_tokens', true);
301
+ if(is_array($user_meta))
302
+ $user_meta = array_values($user_meta);
303
+
304
+ $curr_ip = !empty($user_meta[0]['ip']) ? trim($user_meta[0]['ip']) : '';
305
+ $curr_email = !empty($u[$i]->data->user_email) ? trim($u[$i]->data->user_email) : '';
306
+
307
+ // Check for identity
308
+ $curr_ip = preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $curr_ip) === 1 ? $curr_ip : null;
309
+ $curr_email = preg_match('/^\S+@\S+\.\S+$/', $curr_email) === 1 ? $curr_email : null;
310
+
311
+ if(empty($curr_ip) && empty($curr_email)){
312
+ $check_result['bad']++;
313
+ update_user_meta($u[$i]->ID,'ct_bad','1',true);
314
+ unset($u[$i]);
315
+ $u = array_values($u);
316
+ }else{
317
+ if(!empty($curr_ip))
318
+ $data[] = $curr_ip;
319
+ if(!empty($curr_email))
320
+ $data[] = $curr_email;
321
+ $u[$i]->data->user_ip = empty($curr_ip) ? 'none' : $curr_ip;
322
+ $u[$i]->data->user_email = empty($curr_email) ? 'none' : $curr_email;
323
+ }
324
+ }
325
+
326
+ // Drop if data empty and there's no users to check
327
+ if(count($data) == 0){
328
+
329
+ if($_POST['unchecked'] === 0)
330
+ $check_result['end'] = 1;
331
+
332
+ print json_encode($check_result);
333
+ die();
334
+ }
335
+
336
+ $data=implode(',',$data);
337
+
338
+ $request=Array();
339
+ $request['method_name'] = 'spam_check_cms';
340
+ $request['auth_key'] = $ct_options['apikey'];
341
+ $request['data'] = $data;
342
+ $request['date'] = $curr_date;
343
+ $url='https://api.cleantalk.org';
344
+ if(!function_exists('sendRawRequest'))
345
+ require_once('cleantalk.class.php');
346
+
347
+ $result=sendRawRequest($url, $request, false, 5);
348
+
349
+ if(empty($result)){
350
+ $check_result['error'] = 1;
351
+ $check_result['error_message'] = __('Connection error', 'cleantalk');
352
+ print json_encode($check_result);
353
+ }else{
354
+
355
+ $result = json_decode($result);
356
+
357
+ if(isset($result->error_message)){
358
+ $check_result['error'] = 1;
359
+ $check_result['error_message'] = __('Server response: ', 'cleantalk').$result->error_message;
360
+ print "Server response: ".$result->error_message;
361
+ }else{
362
+
363
+ // Opening CSV file
364
+ $current_user = wp_get_current_user();
365
+ $filename = WP_PLUGIN_DIR."/cleantalk-spam-protect/check-results/user_check_by_{$current_user->user_login}.csv";
366
+ $text = "";
367
+
368
+ if(isset($_POST['new_check']) && $_POST['new_check'] == 'true'){
369
+ $file_desc = fopen($filename, 'w');
370
+ $text .= "login,email,ip".PHP_EOL;
371
+ }else
372
+ $file_desc = fopen($filename, 'a+');
373
+ // End of Opening CSV
374
+
375
+ for($i=0;$i<sizeof($u);$i++){
376
+
377
+ $check_result['checked']++;
378
+ update_user_meta($u[$i]->ID,'ct_checked',date("Y-m-d H:m:s"),true);
379
+
380
+ // Do not display forbidden roles.
381
+ foreach ($skip_roles as $role) {
382
+ if (in_array($role, $u[$i]->roles)){
383
+ delete_user_meta($u[$i]->ID, 'ct_marked_as_spam');
384
+ continue 2;
385
+ }
386
+ }
387
+
388
+ $mark_spam_ip = false;
389
+ $mark_spam_email = false;
390
+
391
+ $uip = $u[$i]->data->user_ip;
392
+ $uim = $u[$i]->data->user_email;
393
+
394
+ if(isset($result->data->$uip) && $result->data->$uip->appears == 1)
395
+ $mark_spam_ip = true;
396
+
397
+ if(isset($result->data->$uim) && $result->data->$uim->appears==1)
398
+ $mark_spam_email = true;
399
+
400
+ if ($mark_spam_ip || $mark_spam_email){
401
+ $check_result['spam']++;
402
+ update_user_meta($u[$i]->ID,'ct_marked_as_spam','1',true);
403
+ $text .= $u[$i]->user_login.',';
404
+ $text .= ($mark_spam_email ? $uim : '').',';
405
+ $text .= ($mark_spam_ip ? $uip : '').PHP_EOL;
406
+ }
407
+
408
+ }
409
+ fwrite($file_desc, $text);
410
+ fclose($file_desc);
411
+ print json_encode($check_result);
412
+ }
413
+ }
414
+ }else{
415
+ $check_result['end'] = 1;
416
+ print json_encode($check_result);
417
+ }
418
+ die;
419
+ }
420
+
421
+ function ct_ajax_info_users($direct_call = false)
422
+ {
423
+ if (!$direct_call)
424
+ check_ajax_referer( 'ct_secret_nonce', 'security' );
425
+
426
+ global $wpdb;
427
+
428
+ // All users
429
+ $r=$wpdb->get_results("
430
+ SELECT
431
+ COUNT(ID) AS cnt
432
+ FROM $wpdb->users
433
+ ");
434
+ $cnt = $r[0]->cnt;
435
+
436
+ // Checked
437
+ $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';");
438
+ $cnt_checked = $r[0]->cnt;
439
+
440
+ //Spam
441
+ $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);
442
+ $cnt_spam = $r[0]['cnt'];
443
+
444
+ //Bad
445
+ $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_bad';", ARRAY_A);
446
+ $cnt_bad = $r[0]['cnt'];
447
+
448
+ $return = array(
449
+ 'message' => '',
450
+ 'total' => $cnt
451
+ );
452
+
453
+ $return['message'] .= sprintf (__("Total users %s, checked %s, found %s spam users and %s bad users (without IP or email)", 'cleantalk'), $cnt, $cnt_checked, $cnt_spam, $cnt_bad);
454
+
455
+ $backup_notice = '&nbsp;';
456
+ if ($cnt_spam > 0) {
457
+ $backup_notice = __("Please do backup of WordPress database before delete any accounts!", 'cleantalk');
458
+ }
459
+ $return['message'] .= "<p>$backup_notice</p>";
460
+
461
+ if($direct_call){
462
+ return $return['message'];
463
+ }else{
464
+ echo json_encode($return);
465
+ die();
466
+ }
467
+
468
+ return null;
469
+ }
470
+
471
+ function ct_ajax_insert_users()
472
+ {
473
+ check_ajax_referer( 'ct_secret_nonce', 'security' );
474
+ global $wpdb;
475
+
476
+ $to_insert = 20;
477
+
478
+ /* DELETION
479
+ $users = get_users(array('search' => '*user_*', 'search_columns' => array('login', 'nicename')));
480
+ $inserted = 0;
481
+ $amount_to_delete = 0;
482
+ foreach($users as $user){
483
+ if($inserted >= $amount_to_delete)
484
+ break;
485
+ if(wp_delete_user($user->ID))
486
+ $inserted++;
487
+ }
488
+ //*/
489
+
490
+ $result = $wpdb->get_results("SELECT network FROM `".$wpdb->base_prefix."cleantalk_sfw` LIMIT $to_insert;", ARRAY_A);
491
+
492
+ if($result){
493
+ $ip = array();
494
+ foreach($result as $value){
495
+ $ips[] = long2ip($value['network']);
496
+ }
497
+ unset($value);
498
+
499
+ $inserted = 0;
500
+ for($i=0; $i<$to_insert; $i++){
501
+ $rnd=mt_rand(1,10000000);
502
+
503
+ $user_name = "user_$rnd";
504
+ $email="stop_email_$rnd@example.com";
505
+
506
+ $user_id = wp_create_user(
507
+ $user_name,
508
+ rand(),
509
+ $email
510
+ );
511
+
512
+ $curr_user = get_user_by('email', $email);
513
+
514
+ update_user_meta($curr_user->ID, 'session_tokens', array($rnd => array('ip' => $ips[$i])));
515
+
516
+ if (is_int($user_id))
517
+ $inserted++;
518
+
519
+ }
520
+ }else{
521
+ $inserted = '0';
522
+ }
523
+
524
+ print "$inserted";
525
+ die();
526
+ }
527
+
528
+ function ct_ajax_delete_checked_users()
529
+ {
530
+ check_ajax_referer( 'ct_secret_nonce', 'security' );
531
+ foreach($_POST['ids'] as $key=>$value)
532
+ {
533
+ wp_delete_user($value);
534
+ }
535
+ die();
536
+ }
537
+
538
+ function ct_ajax_delete_all_users()
539
+ {
540
+ check_ajax_referer( 'ct_secret_nonce', 'security' );
541
+
542
+ global $wpdb;
543
+
544
+ $r = $wpdb->get_results("select count(*) as cnt from $wpdb->usermeta where meta_key='ct_marked_as_spam';");
545
+ $count_all = $r ? $r[0]->cnt : 0;
546
+
547
+ $args = array(
548
+ 'meta_key' => 'ct_marked_as_spam',
549
+ 'meta_value' => '1',
550
+ 'fields' => array('ID'),
551
+ 'number' => 10
552
+ );
553
+ $users = get_users($args);
554
+
555
+ if ($users){
556
+ foreach($users as $user){
557
+ wp_delete_user($user->ID);
558
+ usleep(5000);
559
+ }
560
+ }
561
+
562
+ print $count_all;
563
+ die();
564
+ }
565
+
566
+ function ct_ajax_clear_users()
567
+ {
568
+ check_ajax_referer( 'ct_secret_nonce', 'security' );
569
+ global $wpdb;
570
+ $wpdb->query("delete from $wpdb->usermeta where meta_key='ct_checked' or meta_key='ct_marked_as_spam' or meta_key='ct_bad';");
571
+ die();
572
+ }
573
+
574
+ /**
575
+ * Admin action 'user_unapproved_to_approved' - Approve user, delete from the deleting list
576
+ */
577
+ function ct_usercheck_approve_user() {
578
+
579
+ check_ajax_referer( 'ct_secret_nonce', 'security' );
580
+
581
+ delete_metadata('user', $_POST['id'], 'ct_marked_as_spam');
582
+
583
+ die();
584
+ }
585
+
586
+ /**
587
+ * Admin action 'wp_ajax_ajax_ct_get_csv_file' - prints CSV file to AJAX
588
+ */
589
+ function ct_usercheck_get_csv_file() {
590
+
591
+ check_ajax_referer( 'ct_secret_nonce', 'security' );
592
+
593
+ $filename = !empty($_POST['filename']) ? $_POST['filename'] : false;
594
+
595
+ if($filename !== false && file_exists(WP_PLUGIN_DIR."/cleantalk-spam-protect/check-results/{$filename}.csv"))
596
+ $output = 1;
597
+ else
598
+ $output = 0;
599
+
600
+ echo $output;
601
+
602
+ die();
603
+ }
604
+
605
  ?>
inc/cleantalk-widget.php CHANGED
@@ -1,87 +1,87 @@
1
- <?php
2
-
3
- class cleantalk_widget extends WP_Widget
4
- {
5
-
6
- function __construct()
7
- {
8
- parent::__construct(
9
- // Base ID of your widget
10
- 'cleantalk_widget',
11
-
12
- // Widget name will appear in UI
13
- __('CleanTalk Widget', 'cleantalk'),
14
-
15
- // Widget description
16
- array( 'description' => __( 'CleanTalk widget', 'cleantalk' ), )
17
- );
18
- }
19
-
20
- // Creating widget front-end
21
- // This is where the action happens
22
- public function widget( $args, $instance )
23
- {
24
- $title = apply_filters( 'widget_title', $instance['title'] );
25
- // before and after widget arguments are defined by themes
26
- echo $args['before_widget'];
27
- if ( ! empty( $title ) )
28
- {
29
- echo $args['before_title'] . $title . $args['after_title'];
30
- }
31
- global $ct_data;
32
- $ct_data=ct_get_data();
33
- if(!isset($ct_data['admin_blocked']))
34
- {
35
- $blocked=0;
36
- }
37
- else
38
- {
39
- $blocked=$ct_data['admin_blocked'];
40
- }
41
- $blocked = number_format($blocked, 0, ',', ' ');
42
-
43
- // This is where you run the code and display the output
44
- ?>
45
- <div style="width:auto;">
46
- <a href="http://cleantalk.org" target="_blank" title="" style="background: #3090C7; background-image: -moz-linear-gradient(0% 100% 90deg,#2060a7,#3090C7); background-image: -webkit-gradient(linear,0% 0,0% 100%,from(#3090C7),to(#2060A7)); border: 1px solid #33eeee; border-radius: 5px; color: #AFCA63; cursor: pointer; display: block; font-weight: normal; height: 100%; -moz-border-radius: 5px; padding: 5px 0 5px; text-align: center; text-decoration: none; -webkit-border-radius: 5px; width: 100%;"><strong style="color: #FFF;display: block;font-size: 15px; line-height: 16px; padding: 0 13px; white-space: nowrap;"><b><?php print $blocked; ?></b> spam</strong> blocked by <strong>CleanTalk</strong></a>
47
- </div>
48
- <?php
49
- echo $args['after_widget'];
50
- }
51
-
52
- // Widget Backend
53
- public function form( $instance )
54
- {
55
- if ( isset( $instance[ 'title' ] ) )
56
- {
57
- $title = $instance[ 'title' ];
58
- }
59
- else
60
- {
61
- $title = __( 'Spam blocked', 'cleantalk' );
62
- }
63
- // Widget admin form
64
- ?>
65
- <p>
66
- <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
67
- <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
68
- </p>
69
- <?php
70
- }
71
-
72
- // Updating widget replacing old instances with new
73
- public function update( $new_instance, $old_instance )
74
- {
75
- $instance = array();
76
- $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
77
- return $instance;
78
- }
79
- } // Class cleantalk_widget ends here
80
-
81
- // Register and load the widget
82
- function cleantalk_load_widget()
83
- {
84
- register_widget( 'cleantalk_widget' );
85
- }
86
- add_action( 'widgets_init', 'cleantalk_load_widget' );
87
  ?>
1
+ <?php
2
+
3
+ class cleantalk_widget extends WP_Widget
4
+ {
5
+
6
+ function __construct()
7
+ {
8
+ parent::__construct(
9
+ // Base ID of your widget
10
+ 'cleantalk_widget',
11
+
12
+ // Widget name will appear in UI
13
+ __('CleanTalk Widget', 'cleantalk'),
14
+
15
+ // Widget description
16
+ array( 'description' => __( 'CleanTalk widget', 'cleantalk' ), )
17
+ );
18
+ }
19
+
20
+ // Creating widget front-end
21
+ // This is where the action happens
22
+ public function widget( $args, $instance )
23
+ {
24
+ $title = apply_filters( 'widget_title', $instance['title'] );
25
+ // before and after widget arguments are defined by themes
26
+ echo $args['before_widget'];
27
+ if ( ! empty( $title ) )
28
+ {
29
+ echo $args['before_title'] . $title . $args['after_title'];
30
+ }
31
+ global $ct_data;
32
+ $ct_data=ct_get_data();
33
+ if(!isset($ct_data['admin_blocked']))
34
+ {
35
+ $blocked=0;
36
+ }
37
+ else
38
+ {
39
+ $blocked=$ct_data['admin_blocked'];
40
+ }
41
+ $blocked = number_format($blocked, 0, ',', ' ');
42
+
43
+ // This is where you run the code and display the output
44
+ ?>
45
+ <div style="width:auto;">
46
+ <a href="http://cleantalk.org" target="_blank" title="" style="background: #3090C7; background-image: -moz-linear-gradient(0% 100% 90deg,#2060a7,#3090C7); background-image: -webkit-gradient(linear,0% 0,0% 100%,from(#3090C7),to(#2060A7)); border: 1px solid #33eeee; border-radius: 5px; color: #AFCA63; cursor: pointer; display: block; font-weight: normal; height: 100%; -moz-border-radius: 5px; padding: 5px 0 5px; text-align: center; text-decoration: none; -webkit-border-radius: 5px; width: 100%;"><strong style="color: #FFF;display: block;font-size: 15px; line-height: 16px; padding: 0 13px; white-space: nowrap;"><b><?php print $blocked; ?></b> spam</strong> blocked by <strong>CleanTalk</strong></a>
47
+ </div>
48
+ <?php
49
+ echo $args['after_widget'];
50
+ }
51
+
52
+ // Widget Backend
53
+ public function form( $instance )
54
+ {
55
+ if ( isset( $instance[ 'title' ] ) )
56
+ {
57
+ $title = $instance[ 'title' ];
58
+ }
59
+ else
60
+ {
61
+ $title = __( 'Spam blocked', 'cleantalk' );
62
+ }
63
+ // Widget admin form
64
+ ?>
65
+ <p>
66
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
67
+ <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
68
+ </p>
69
+ <?php
70
+ }
71
+
72
+ // Updating widget replacing old instances with new
73
+ public function update( $new_instance, $old_instance )
74
+ {
75
+ $instance = array();
76
+ $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
77
+ return $instance;
78
+ }
79
+ } // Class cleantalk_widget ends here
80
+
81
+ // Register and load the widget
82
+ function cleantalk_load_widget()
83
+ {
84
+ register_widget( 'cleantalk_widget' );
85
+ }
86
+ add_action( 'widgets_init', 'cleantalk_load_widget' );
87
  ?>
inc/cleantalk.class.php CHANGED
@@ -1,1252 +1,1252 @@
1
- <?php
2
- /**
3
- * Cleantalk base class
4
- *
5
- * @version 2.1.4
6
- * @package Cleantalk
7
- * @subpackage Base
8
- * @author Cleantalk team (welcome@cleantalk.org)
9
- * @copyright (C) 2014 CleanTalk team (http://cleantalk.org)
10
- * @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
11
- * @see https://github.com/CleanTalk/php-antispam
12
- *
13
- */
14
-
15
- /**
16
- * Response class
17
- */
18
- class CleantalkResponse {
19
-
20
- /**
21
- * Received feedback nubmer
22
- * @var int
23
- */
24
- public $received = null;
25
-
26
- /**
27
- * Is stop words
28
- * @var int
29
- */
30
- public $stop_words = null;
31
-
32
- /**
33
- * Cleantalk comment
34
- * @var string
35
- */
36
- public $comment = null;
37
-
38
- /**
39
- * Is blacklisted
40
- * @var int
41
- */
42
- public $blacklisted = null;
43
-
44
- /**
45
- * Is allow, 1|0
46
- * @var int
47
- */
48
- public $allow = null;
49
-
50
- /**
51
- * Request ID
52
- * @var int
53
- */
54
- public $id = null;
55
-
56
- /**
57
- * Request errno
58
- * @var int
59
- */
60
- public $errno = null;
61
-
62
- /**
63
- * Error string
64
- * @var string
65
- */
66
- public $errstr = null;
67
-
68
- /**
69
- * Is fast submit, 1|0
70
- * @var string
71
- */
72
- public $fast_submit = null;
73
-
74
- /**
75
- * Is spam comment
76
- * @var string
77
- */
78
- public $spam = null;
79
-
80
- /**
81
- * Is JS
82
- * @var type
83
- */
84
- public $js_disabled = null;
85
-
86
- /**
87
- * Sms check
88
- * @var type
89
- */
90
- public $sms_allow = null;
91
-
92
- /**
93
- * Sms code result
94
- * @var type
95
- */
96
- public $sms = null;
97
-
98
- /**
99
- * Sms error code
100
- * @var type
101
- */
102
- public $sms_error_code = null;
103
-
104
- /**
105
- * Sms error code
106
- * @var type
107
- */
108
- public $sms_error_text = null;
109
-
110
- /**
111
- * Stop queue message, 1|0
112
- * @var int
113
- */
114
- public $stop_queue = null;
115
-
116
- /**
117
- * Account shuld by deactivated after registration, 1|0
118
- * @var int
119
- */
120
- public $inactive = null;
121
-
122
- /**
123
- * Account status
124
- * @var int
125
- */
126
- public $account_status = -1;
127
-
128
- /**
129
- * Create server response
130
- *
131
- * @param type $response
132
- * @param type $obj
133
- */
134
- function __construct($response = null, $obj = null) {
135
- if ($response && is_array($response) && count($response) > 0) {
136
- foreach ($response as $param => $value) {
137
- $this->{$param} = $value;
138
- }
139
- } else {
140
- $this->errno = $obj->errno;
141
- $this->errstr = $obj->errstr;
142
-
143
- $this->errstr = preg_replace("/.+(\*\*\*.+\*\*\*).+/", "$1", $this->errstr);
144
-
145
- $this->stop_words = isset($obj->stop_words) ? utf8_decode($obj->stop_words) : null;
146
- $this->comment = isset($obj->comment) ? utf8_decode($obj->comment) : null;
147
- $this->blacklisted = (isset($obj->blacklisted)) ? $obj->blacklisted : null;
148
- $this->allow = (isset($obj->allow)) ? $obj->allow : 0;
149
- $this->id = (isset($obj->id)) ? $obj->id : null;
150
- $this->fast_submit = (isset($obj->fast_submit)) ? $obj->fast_submit : 0;
151
- $this->spam = (isset($obj->spam)) ? $obj->spam : 0;
152
- $this->js_disabled = (isset($obj->js_disabled)) ? $obj->js_disabled : 0;
153
- $this->sms_allow = (isset($obj->sms_allow)) ? $obj->sms_allow : null;
154
- $this->sms = (isset($obj->sms)) ? $obj->sms : null;
155
- $this->sms_error_code = (isset($obj->sms_error_code)) ? $obj->sms_error_code : null;
156
- $this->sms_error_text = (isset($obj->sms_error_text)) ? $obj->sms_error_text : null;
157
- $this->stop_queue = (isset($obj->stop_queue)) ? $obj->stop_queue : 0;
158
- $this->inactive = (isset($obj->inactive)) ? $obj->inactive : 0;
159
- $this->account_status = (isset($obj->account_status)) ? $obj->account_status : -1;
160
- $this->received = (isset($obj->received)) ? $obj->received : -1;
161
-
162
- if ($this->errno !== 0 && $this->errstr !== null && $this->comment === null)
163
- $this->comment = '*** ' . $this->errstr . ' Antispam service cleantalk.org ***';
164
- }
165
- }
166
-
167
- }
168
-
169
- /**
170
- * Request class
171
- */
172
- class CleantalkRequest {
173
-
174
- /**
175
- * All http request headers
176
- * @var string
177
- */
178
- public $all_headers = null;
179
-
180
- /**
181
- * IP address of connection
182
- * @var string
183
- */
184
- //public $remote_addr = null;
185
-
186
- /**
187
- * Last error number
188
- * @var integer
189
- */
190
- public $last_error_no = null;
191
-
192
- /**
193
- * Last error time
194
- * @var integer
195
- */
196
- public $last_error_time = null;
197
-
198
- /**
199
- * Last error text
200
- * @var string
201
- */
202
- public $last_error_text = null;
203
-
204
- /**
205
- * User message
206
- * @var string
207
- */
208
- public $message = null;
209
-
210
- /**
211
- * Post example with last comments
212
- * @var string
213
- */
214
- public $example = null;
215
-
216
- /**
217
- * Auth key
218
- * @var string
219
- */
220
- public $auth_key = null;
221
-
222
- /**
223
- * Engine
224
- * @var string
225
- */
226
- public $agent = null;
227
-
228
- /**
229
- * Is check for stoplist,
230
- * valid are 0|1
231
- * @var int
232
- */
233
- public $stoplist_check = null;
234
-
235
- /**
236
- * Language server response,
237
- * valid are 'en' or 'ru'
238
- * @var string
239
- */
240
- public $response_lang = null;
241
-
242
- /**
243
- * User IP
244
- * @var strings
245
- */
246
- public $sender_ip = null;
247
-
248
- /**
249
- * User email
250
- * @var strings
251
- */
252
- public $sender_email = null;
253
-
254
- /**
255
- * User nickname
256
- * @var string
257
- */
258
- public $sender_nickname = null;
259
-
260
- /**
261
- * Sender info JSON string
262
- * @var string
263
- */
264
- public $sender_info = null;
265
-
266
- /**
267
- * Post info JSON string
268
- * @var string
269
- */
270
- public $post_info = null;
271
-
272
- /**
273
- * Is allow links, email and icq,
274
- * valid are 1|0
275
- * @var int
276
- */
277
- public $allow_links = null;
278
-
279
- /**
280
- * Time form filling
281
- * @var int
282
- */
283
- public $submit_time = null;
284
-
285
- public $x_forwarded_for = '';
286
- public $x_real_ip = '';
287
-
288
- /**
289
- * Is enable Java Script,
290
- * valid are 0|1|2
291
- * Status:
292
- * null - JS html code not inserted into phpBB templates
293
- * 0 - JS disabled at the client browser
294
- * 1 - JS enabled at the client broswer
295
- * @var int
296
- */
297
- public $js_on = null;
298
-
299
- /**
300
- * user time zone
301
- * @var string
302
- */
303
- public $tz = null;
304
-
305
- /**
306
- * Feedback string,
307
- * valid are 'requset_id:(1|0)'
308
- * @var string
309
- */
310
- public $feedback = null;
311
-
312
- /**
313
- * Phone number
314
- * @var type
315
- */
316
- public $phone = null;
317
-
318
- /**
319
- * Method name
320
- * @var string
321
- */
322
- public $method_name = 'check_message';
323
-
324
- /**
325
- * Fill params with constructor
326
- * @param type $params
327
- */
328
- public function __construct($params = null) {
329
- if (is_array($params) && count($params) > 0) {
330
- foreach ($params as $param => $value) {
331
- $this->{$param} = $value;
332
- }
333
- }
334
- }
335
-
336
- }
337
-
338
- /**
339
- * Cleantalk class create request
340
- */
341
- class Cleantalk {
342
-
343
- /**
344
- * Debug level
345
- * @var int
346
- */
347
- public $debug = 0;
348
-
349
- /**
350
- * Maximum data size in bytes
351
- * @var int
352
- */
353
- private $dataMaxSise = 32768;
354
-
355
- /**
356
- * Data compression rate
357
- * @var int
358
- */
359
- private $compressRate = 6;
360
-
361
- /**
362
- * Server connection timeout in seconds
363
- * @var int
364
- */
365
- private $server_timeout = 15;
366
-
367
- /**
368
- * Cleantalk server url
369
- * @var string
370
- */
371
- public $server_url = null;
372
-
373
- /**
374
- * Last work url
375
- * @var string
376
- */
377
- public $work_url = null;
378
-
379
- /**
380
- * WOrk url ttl
381
- * @var int
382
- */
383
- public $server_ttl = null;
384
-
385
- /**
386
- * Time wotk_url changer
387
- * @var int
388
- */
389
- public $server_changed = null;
390
-
391
- /**
392
- * Flag is change server url
393
- * @var bool
394
- */
395
- public $server_change = false;
396
-
397
- /**
398
- * Use TRUE when need stay on server. Example: send feedback
399
- * @var bool
400
- */
401
- public $stay_on_server = false;
402
-
403
- /**
404
- * Codepage of the data
405
- * @var bool
406
- */
407
- public $data_codepage = null;
408
-
409
- /**
410
- * API version to use
411
- * @var string
412
- */
413
- public $api_version = '/api2.0';
414
-
415
- /**
416
- * Use https connection to servers
417
- * @var bool
418
- */
419
- public $ssl_on = false;
420
-
421
- /**
422
- * Path to SSL certificate
423
- * @var string
424
- */
425
- public $ssl_path = '';
426
-
427
- /**
428
- * Minimal server response in miliseconds to catch the server
429
- *
430
- */
431
- public $min_server_timeout = 50;
432
-
433
- /**
434
- * Function checks whether it is possible to publish the message
435
- * @param CleantalkRequest $request
436
- * @return type
437
- */
438
- public function isAllowMessage(CleantalkRequest $request) {
439
- $request = $this->filterRequest($request);
440
- $msg = $this->createMsg('check_message', $request);
441
- return $this->httpRequest($msg);
442
- }
443
-
444
- /**
445
- * Function checks whether it is possible to publish the message
446
- * @param CleantalkRequest $request
447
- * @return type
448
- */
449
- public function isAllowUser(CleantalkRequest $request) {
450
- $request = $this->filterRequest($request);
451
- $msg = $this->createMsg('check_newuser', $request);
452
- return $this->httpRequest($msg);
453
- }
454
-
455
- /**
456
- * Function sends the results of manual moderation
457
- *
458
- * @param CleantalkRequest $request
459
- * @return type
460
- */
461
- public function sendFeedback(CleantalkRequest $request) {
462
- $request = $this->filterRequest($request);
463
- $msg = $this->createMsg('send_feedback', $request);
464
- return $this->httpRequest($msg);
465
- }
466
-
467
- /**
468
- * Filter request params
469
- * @param CleantalkRequest $request
470
- * @return type
471
- */
472
- private function filterRequest(CleantalkRequest $request) {
473
- // general and optional
474
- foreach ($request as $param => $value) {
475
- if (in_array($param, array('message', 'example', 'agent',
476
- 'sender_info', 'sender_nickname', 'post_info', 'phone')) && !empty($value)) {
477
- if (!is_string($value) && !is_integer($value)) {
478
- $request->$param = NULL;
479
- }
480
- }
481
-
482
- if (in_array($param, array('stoplist_check', 'allow_links')) && !empty($value)) {
483
- if (!in_array($value, array(1, 2))) {
484
- $request->$param = NULL;
485
- }
486
- }
487
-
488
- if (in_array($param, array('js_on')) && !empty($value)) {
489
- if (!is_integer($value)) {
490
- $request->$param = NULL;
491
- }
492
- }
493
-
494
- if ($param == 'sender_ip' && !empty($value)) {
495
- if (!is_string($value)) {
496
- $request->$param = NULL;
497
- }
498
- }
499
-
500
- if ($param == 'sender_email' && !empty($value)) {
501
- if (!is_string($value)) {
502
- $request->$param = NULL;
503
- }
504
- }
505
-
506
- if ($param == 'submit_time' && !empty($value)) {
507
- if (!is_int($value)) {
508
- $request->$param = NULL;
509
- }
510
- }
511
- }
512
- return $request;
513
- }
514
-
515
- /**
516
- * Compress data and encode to base64
517
- * @param type string
518
- * @return string
519
- */
520
- private function compressData($data = null){
521
-
522
- if (strlen($data) > $this->dataMaxSise && function_exists('gzencode') && function_exists('base64_encode')){
523
-
524
- $localData = gzencode($data, $this->compressRate, FORCE_GZIP);
525
-
526
- if ($localData === false)
527
- return $data;
528
-
529
- $localData = base64_encode($localData);
530
-
531
- if ($localData === false)
532
- return $data;
533
-
534
- return $localData;
535
- }
536
-
537
- return $data;
538
- }
539
-
540
- /**
541
- * Create msg for cleantalk server
542
- * @param type $method
543
- * @param CleantalkRequest $request
544
- * @return \xmlrpcmsg
545
- */
546
- private function createMsg($method, CleantalkRequest $request) {
547
- switch ($method) {
548
- case 'check_message':
549
- // Convert strings to UTF8
550
- $request->message = $this->stringToUTF8($request->message, $this->data_codepage);
551
- $request->example = $this->stringToUTF8($request->example, $this->data_codepage);
552
- $request->sender_email = $this->stringToUTF8($request->sender_email, $this->data_codepage);
553
- $request->sender_nickname = $this->stringToUTF8($request->sender_nickname, $this->data_codepage);
554
-
555
- $request->message = $this->compressData($request->message);
556
- $request->example = $this->compressData($request->example);
557
- break;
558
-
559
- case 'check_newuser':
560
- // Convert strings to UTF8
561
- $request->sender_email = $this->stringToUTF8($request->sender_email, $this->data_codepage);
562
- $request->sender_nickname = $this->stringToUTF8($request->sender_nickname, $this->data_codepage);
563
- break;
564
-
565
- case 'send_feedback':
566
- if (is_array($request->feedback)) {
567
- $request->feedback = implode(';', $request->feedback);
568
- }
569
- break;
570
- }
571
-
572
- $request->method_name = $method;
573
-
574
- //
575
- // Removing non UTF8 characters from request, because non UTF8 or malformed characters break json_encode().
576
- //
577
- foreach ($request as $param => $value) {
578
- if (!preg_match('//u', $value))
579
- $request->{$param} = 'Nulled. Not UTF8 encoded or malformed.';
580
- }
581
-
582
- return $request;
583
- }
584
-
585
- /**
586
- * Send JSON request to servers
587
- * @param $msg
588
- * @return boolean|\CleantalkResponse
589
- */
590
- private function sendRequest($data = null, $url, $server_timeout = 3) {
591
- // Convert to array
592
- $data = (array)json_decode(json_encode($data), true);
593
-
594
- $original_url = $url;
595
- $original_data = $data;
596
-
597
- //Cleaning from 'null' values
598
- $tmp_data = array();
599
- foreach($data as $key => $value){
600
- if($value !== null)
601
- $tmp_data[$key] = $value;
602
- }
603
- $data = $tmp_data;
604
- unset($key, $value, $tmp_data);
605
-
606
- // Convert to JSON
607
- $data = json_encode($data);
608
-
609
- if (isset($this->api_version)) {
610
- $url = $url . $this->api_version;
611
- }
612
-
613
- // Switching to secure connection
614
- if ($this->ssl_on && !preg_match("/^https:/", $url)) {
615
- $url = preg_replace("/^(http)/i", "$1s", $url);
616
- }
617
-
618
- $result = false;
619
- $curl_error = null;
620
- if(function_exists('curl_init')) {
621
- $ch = curl_init();
622
- curl_setopt($ch, CURLOPT_URL, $url);
623
- curl_setopt($ch, CURLOPT_TIMEOUT, $server_timeout);
624
- curl_setopt($ch, CURLOPT_POST, 1);
625
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
626
- // receive server response ...
627
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
628
- // resolve 'Expect: 100-continue' issue
629
- curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
630
- // see http://stackoverflow.com/a/23322368
631
- curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
632
-
633
- // Disabling CA cert verivication
634
- // Disabling common name verification
635
- if ($this->ssl_on && $this->ssl_path=='') {
636
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
637
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
638
- }
639
- else if ($this->ssl_on && $this->ssl_path!='') {
640
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
641
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
642
- curl_setopt($ch, CURLOPT_CAINFO, $this->ssl_path);
643
- }
644
-
645
- $result = curl_exec($ch);
646
- if (!$result) {
647
- $curl_error = curl_error($ch);
648
- // Use SSL next time, if error occurs.
649
- if(!$this->ssl_on){
650
- $this->ssl_on = true;
651
- return $this->sendRequest($original_data, $original_url, $server_timeout);
652
- }
653
- }
654
-
655
- curl_close($ch);
656
- }
657
-
658
- if (!$result) {
659
- $allow_url_fopen = ini_get('allow_url_fopen');
660
- if (function_exists('file_get_contents') && isset($allow_url_fopen) && $allow_url_fopen == '1') {
661
- $opts = array('http' =>
662
- array(
663
- 'method' => 'POST',
664
- 'header' => "Content-Type: text/html\r\n",
665
- 'content' => $data,
666
- 'timeout' => $server_timeout
667
- )
668
- );
669
-
670
- $context = stream_context_create($opts);
671
- $result = @file_get_contents($url, false, $context);
672
- }
673
- }
674
-
675
- if (!$result || !cleantalk_is_JSON($result)) {
676
- $response = null;
677
- $response['errno'] = 1;
678
- if ($curl_error) {
679
- $response['errstr'] = sprintf("CURL error: '%s'", $curl_error);
680
- } else {
681
- $response['errstr'] = 'No CURL support compiled in';
682
- }
683
- $response['errstr'] .= ' or disabled allow_url_fopen in php.ini.';
684
- $response = json_decode(json_encode($response));
685
-
686
- return $response;
687
- }
688
-
689
- $errstr = null;
690
- $response = json_decode($result);
691
- if ($result !== false && is_object($response)) {
692
- $response->errno = 0;
693
- $response->errstr = $errstr;
694
- } else {
695
- $errstr = 'Unknown response from ' . $url . '.' . ' ' . $result;
696
-
697
- $response = null;
698
- $response['errno'] = 1;
699
- $response['errstr'] = $errstr;
700
- $response = json_decode(json_encode($response));
701
- }
702
-
703
-
704
- return $response;
705
- }
706
-
707
- /**
708
- * httpRequest
709
- * @param $msg
710
- * @return boolean|\CleantalkResponse
711
- */
712
- private function httpRequest($msg) {
713
- $result = false;
714
-
715
- if($msg->method_name != 'send_feedback'){
716
- $ct_tmp = apache_request_headers();
717
-
718
- if(isset($ct_tmp['Cookie']))
719
- $cookie_name = 'Cookie';
720
- elseif(isset($ct_tmp['cookie']))
721
- $cookie_name = 'cookie';
722
- else
723
- $cookie_name = 'COOKIE';
724
-
725
- $ct_tmp[$cookie_name] = preg_replace(array(
726
- '/\s{0,1}ct_checkjs=[a-z0-9]*[;|$]{0,1}/',
727
- '/\s{0,1}ct_timezone=.{0,1}\d{1,2}[;|$]/',
728
- '/\s{0,1}ct_pointer_data=.*5D[;|$]{0,1}/',
729
- '/;{0,1}\s{0,3}$/'
730
- ), '', $ct_tmp[$cookie_name]);
731
- $msg->all_headers=json_encode($ct_tmp);
732
- }
733
-
734
- $si=(array)json_decode($msg->sender_info,true);
735
-
736
- $si['remote_addr'] = $_SERVER['REMOTE_ADDR'];
737
- $msg->x_forwarded_for = @$_SERVER['X_FORWARDED_FOR'];
738
- $msg->x_real_ip = @$_SERVER['X_REAL_IP'];
739
-
740
- $msg->sender_info=json_encode($si);
741
- if (((isset($this->work_url) && $this->work_url !== '') && ($this->server_changed + $this->server_ttl > time()))
742
- || $this->stay_on_server == true) {
743
-
744
- $url = (!empty($this->work_url)) ? $this->work_url : $this->server_url;
745
-
746
- $result = $this->sendRequest($msg, $url, $this->server_timeout);
747
- }
748
-
749
- if (($result === false || $result->errno != 0) && $this->stay_on_server == false) {
750
- // Split server url to parts
751
- preg_match("@^(https?://)([^/:]+)(.*)@i", $this->server_url, $matches);
752
- $url_prefix = '';
753
- if (isset($matches[1]))
754
- $url_prefix = $matches[1];
755
-
756
- $pool = null;
757
- if (isset($matches[2]))
758
- $pool = $matches[2];
759
-
760
- $url_suffix = '';
761
- if (isset($matches[3]))
762
- $url_suffix = $matches[3];
763
-
764
- if ($url_prefix === '')
765
- $url_prefix = 'http://';
766
-
767
- if (empty($pool)) {
768
- return false;
769
- } else {
770
- // Loop until find work server
771
- foreach ($this->get_servers_ip($pool) as $server) {
772
- if ($server['host'] === 'localhost' || $server['ip'] === null) {
773
- $work_url = $server['host'];
774
- } else {
775
- $server_host = $server['ip'];
776
- $work_url = $server_host;
777
- }
778
- $work_url = $url_prefix . $work_url;
779
- if (isset($url_suffix))
780
- $work_url = $work_url . $url_suffix;
781
-
782
- $this->work_url = $work_url;
783
- $this->server_ttl = $server['ttl'];
784
-
785
- $result = $this->sendRequest($msg, $this->work_url, $this->server_timeout);
786
-
787
- if ($result !== false && $result->errno === 0) {
788
- $this->server_change = true;
789
- break;
790
- }
791
- }
792
- }
793
- }
794
-
795
- $response = new CleantalkResponse(null, $result);
796
-
797
- if (!empty($this->data_codepage) && $this->data_codepage !== 'UTF-8') {
798
- if (!empty($response->comment))
799
- $response->comment = $this->stringFromUTF8($response->comment, $this->data_codepage);
800
- if (!empty($response->errstr))
801
- $response->errstr = $this->stringFromUTF8($response->errstr, $this->data_codepage);
802
- if (!empty($response->sms_error_text))
803
- $response->sms_error_text = $this->stringFromUTF8($response->sms_error_text, $this->data_codepage);
804
- }
805
-
806
- return $response;
807
- }
808
-
809
- /**
810
- * Function DNS request
811
- * @param $host
812
- * @return array
813
- */
814
- public function get_servers_ip($host) {
815
- $response = null;
816
- if (!isset($host))
817
- return $response;
818
-
819
- if (function_exists('dns_get_record')) {
820
- $records = dns_get_record($host, DNS_A);
821
-
822
- if ($records !== FALSE) {
823
- foreach ($records as $server) {
824
- $response[] = $server;
825
- }
826
- }
827
- }
828
-
829
- if (count($response) == 0 && function_exists('gethostbynamel')) {
830
- $records = gethostbynamel($host);
831
-
832
- if ($records !== FALSE) {
833
- foreach ($records as $server) {
834
- $response[] = array(
835
- "ip" => $server,
836
- "host" => $host,
837
- "ttl" => $this->server_ttl
838
- );
839
- }
840
- }
841
- }
842
-
843
- if (count($response) == 0) {
844
- $response[] = array("ip" => null,
845
- "host" => $host,
846
- "ttl" => $this->server_ttl
847
- );
848
- } else {
849
- // $i - to resolve collisions with localhost
850
- $i = 0;
851
- $r_temp = null;
852
- $fast_server_found = false;
853
- foreach ($response as $server) {
854
-
855
- // Do not test servers because fast work server found
856
- if ($fast_server_found) {
857
- $ping = $this->min_server_timeout;
858
- } else {
859
- $ping = $this->httpPing($server['ip']);
860
- $ping = $ping * 1000;
861
- }
862
-
863
- // -1 server is down, skips not reachable server
864
- if ($ping != -1) {
865
- $r_temp[$ping + $i] = $server;
866
- }
867
- $i++;
868
-
869
- if ($ping < $this->min_server_timeout) {
870
- $fast_server_found = true;
871
- }
872
- }
873
- if (count($r_temp)){
874
- ksort($r_temp);
875
- $response = $r_temp;
876
- }
877
- }
878
-
879
- return $response;
880
- }
881
-
882
- /**
883
- * Function to get the message hash from Cleantalk.ru comment
884
- * @param $message
885
- * @return null
886
- */
887
- public function getCleantalkCommentHash($message) {
888
- $matches = array();
889
- if (preg_match('/\n\n\*\*\*.+([a-z0-9]{32}).+\*\*\*$/', $message, $matches))
890
- return $matches[1];
891
- else if (preg_match('/\<br.*\>[\n]{0,1}\<br.*\>[\n]{0,1}\*\*\*.+([a-z0-9]{32}).+\*\*\*$/', $message, $matches))
892
- return $matches[1];
893
-
894
- return NULL;
895
- }
896
-
897
- /**
898
- * Function adds to the post comment Cleantalk.ru
899
- * @param $message
900
- * @param $comment
901
- * @return string
902
- */
903
- public function addCleantalkComment($message, $comment) {
904
- $comment = preg_match('/\*\*\*(.+)\*\*\*/', $comment, $matches) ? $comment : '*** ' . $comment . ' ***';
905
- return $message . "\n\n" . $comment;
906
- }
907
-
908
- /**
909
- * Function deletes the comment Cleantalk.ru
910
- * @param $message
911
- * @return mixed
912
- */
913
- public function delCleantalkComment($message) {
914
- $message = preg_replace('/\n\n\*\*\*.+\*\*\*$/', '', $message);
915
-
916
- // DLE sign cut
917
- $message = preg_replace('/<br\s?\/><br\s?\/>\*\*\*.+\*\*\*$/', '', $message);
918
-
919
- $message = preg_replace('/\<br.*\>[\n]{0,1}\<br.*\>[\n]{0,1}\*\*\*.+\*\*\*$/', '', $message);
920
-
921
- return $message;
922
- }
923
-
924
- /**
925
- * Get user IP behind proxy server
926
- */
927
- public function ct_session_ip( $data_ip ) {
928
- // Return FALSE if FALSE !?
929
- // if (!preg_match("/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/", $data_ip)) {
930
- // error_log(__FUNCTION__ . " " . "condition");
931
- // return $data_ip;
932
- // }
933
- return cleantalk_get_real_ip();
934
- }
935
-
936
- /**
937
- * From http://php.net/manual/en/function.ip2long.php#82397
938
- */
939
- public function net_match($CIDR,$IP) {
940
- list ($net, $mask) = explode ('/', $CIDR);
941
- return ( ip2long ($IP) & ~((1 << (32 - $mask)) - 1) ) == ip2long ($net);
942
- }
943
-
944
- /**
945
- * Function to check response time
946
- * param string
947
- * @return int
948
- */
949
- function httpPing($host){
950
-
951
- // Skip localhost ping cause it raise error at fsockopen.
952
- // And return minimun value
953
- if ($host == 'localhost')
954
- return 0.001;
955
-
956
- $starttime = microtime(true);
957
- $file = @fsockopen ($host, 80, $errno, $errstr, $this->server_timeout);
958
- $stoptime = microtime(true);
959
- $status = 0;
960
- if (!$file) {
961
- $status = -1; // Site is down
962
- } else {
963
- fclose($file);
964
- $status = ($stoptime - $starttime);
965
- $status = round($status, 4);
966
- }
967
-
968
- return $status;
969
- }
970
-
971
- /**
972
- * Function convert string to UTF8 and removes non UTF8 characters
973
- * param string
974
- * param string
975
- * @return string
976
- */
977
- function stringToUTF8($str, $data_codepage = null){
978
- if (!preg_match('//u', $str) && function_exists('mb_detect_encoding') && function_exists('mb_convert_encoding'))
979
- {
980
-
981
- if ($data_codepage !== null)
982
- return mb_convert_encoding($str, 'UTF-8', $data_codepage);
983
-
984
- $encoding = mb_detect_encoding($str);
985
- if ($encoding)
986
- return mb_convert_encoding($str, 'UTF-8', $encoding);
987
- }
988
-
989
- return $str;
990
- }
991
-
992
- /**
993
- * Function convert string from UTF8
994
- * param string
995
- * param string
996
- * @return string
997
- */
998
- function stringFromUTF8($str, $data_codepage = null){
999
- if (preg_match('//u', $str) && function_exists('mb_convert_encoding') && $data_codepage !== null)
1000
- {
1001
- return mb_convert_encoding($str, $data_codepage, 'UTF-8');
1002
- }
1003
-
1004
- return $str;
1005
- }
1006
-
1007
- /**
1008
- * Function gets information about spam active networks
1009
- *
1010
- * @param string api_key
1011
- * @return JSON/array
1012
- */
1013
- public function get_2s_blacklists_db ($api_key) {
1014
- $request=array();
1015
- $request['method_name'] = '2s_blacklists_db';
1016
- $request['auth_key'] = $api_key;
1017
- $url='https://api.cleantalk.org';
1018
- $result=sendRawRequest($url,$request);
1019
- return $result;
1020
- }
1021
- }
1022
-
1023
- /**
1024
- * Function gets access key automatically
1025
- *
1026
- * @param string website admin email
1027
- * @param string website host
1028
- * @param string website platform
1029
- * @return type
1030
- */
1031
-
1032
- if(!function_exists('getAutoKey'))
1033
- {
1034
- function getAutoKey($email, $host, $platform, $timezone = null)
1035
- {
1036
- $request=array();
1037
- $request['method_name'] = 'get_api_key';
1038
- $request['email'] = $email;
1039
- $request['website'] = $host;
1040
- $request['platform'] = $platform;
1041
- $request['timezone'] = $timezone;
1042
- $request['product_name'] = 'antispam';
1043
- $url='https://api.cleantalk.org';
1044
- $result=sendRawRequest($url,$request);
1045
- return $result;
1046
- }
1047
- }
1048
-
1049
- /**
1050
- * Function gets information about renew notice
1051
- *
1052
- * @param string api_key
1053
- * @return type
1054
- */
1055
-
1056
- function noticePaidTill($api_key)
1057
- {
1058
- $request=array();
1059
- $request['method_name'] = 'notice_paid_till';
1060
- $request['auth_key'] = $api_key;
1061
- $url='https://api.cleantalk.org';
1062
- $result=sendRawRequest($url,$request);
1063
- return $result;
1064
- }
1065
-
1066
- /**
1067
- * Function gets spam report
1068
- *
1069
- * @param string website host
1070
- * @param integer report days
1071
- * @return type
1072
- */
1073
-
1074
- if(!function_exists('getAntispamReport'))
1075
- {
1076
- function getAntispamReport($host, $period = 1)
1077
- {
1078
- $url='https://api.cleantalk.org';
1079
- $request=Array(
1080
- 'method_name' => 'get_antispam_report',
1081
- 'hostname' => $host,
1082
- 'period' => $period
1083
- );
1084
- $result=sendRawRequest($url,$request);
1085
- return $result;
1086
- }
1087
- }
1088
-
1089
- /**
1090
- * Function gets spam statistics
1091
- *
1092
- * @param string website host
1093
- * @param integer report days
1094
- * @return type
1095
- */
1096
-
1097
- if(!function_exists('getAntispamReportBreif'))
1098
- {
1099
- function getAntispamReportBreif($key='')
1100
- {
1101
-
1102
- $url="https://api.cleantalk.org?auth_key=$key";
1103
- $request=Array(
1104
- 'method_name' => 'get_antispam_report_breif'
1105
- );
1106
- $result = sendRawRequest($url,$request);
1107
-
1108
- if($result === false)
1109
- return "Network error. Please, check <a target='_blank' href='https://cleantalk.org/help/faq-setup#hosting'>this article</a>.";
1110
-
1111
- $result = !empty($result) ? json_decode($result, true) : false;
1112
-
1113
- if(!empty($result['error_message']))
1114
- return $result['error_message'];
1115
- else{
1116
- $tmp = array();
1117
- for($i=0; $i<7; $i++)
1118
- $tmp[date("Y-m-d", time()-86400*7+86400*$i)] = 0;
1119
- $result['data']['spam_stat'] = array_merge($tmp, $result['data']['spam_stat']);
1120
- return $result['data'];
1121
- }
1122
- }
1123
- }
1124
-
1125
- /**
1126
- * Function sends raw request to API server
1127
- *
1128
- * @param string url of API server
1129
- * @param array data to send
1130
- * @param boolean is data have to be JSON encoded or not
1131
- * @param integer connect timeout
1132
- * @return type
1133
- */
1134
-
1135
- function sendRawRequest($url,$data,$isJSON=false,$timeout=3)
1136
- {
1137
- $result=null;
1138
- if(!$isJSON)
1139
- {
1140
- $data=http_build_query($data);
1141
- $data=str_replace("&amp;", "&", $data);
1142
- }
1143
- else
1144
- {
1145
- $data= json_encode($data);
1146
- }
1147
- $curl_exec=false;
1148
- if (function_exists('curl_init') && function_exists('json_decode'))
1149
- {
1150
-
1151
- $ch = curl_init();
1152
- curl_setopt($ch, CURLOPT_URL, $url);
1153
- curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
1154
- curl_setopt($ch, CURLOPT_POST, true);
1155
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
1156
-
1157
- // receive server response ...
1158
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1159
- // resolve 'Expect: 100-continue' issue
1160
- curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
1161
-
1162
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
1163
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
1164
-
1165
- $result = @curl_exec($ch);
1166
- if($result!==false)
1167
- {
1168
- $curl_exec=true;
1169
- }
1170
- @curl_close($ch);
1171
- }
1172
- if(!$curl_exec)
1173
- {
1174
- $opts = array(
1175
- 'http'=>array(
1176
- 'method' => "POST",
1177
- 'timeout'=> $timeout,
1178
- 'content' => $data
1179
- )
1180
- );
1181
- $context = stream_context_create($opts);
1182
- $result = @file_get_contents($url, 0, $context);
1183
- }
1184
- return $result;
1185
- }
1186
-
1187
- // Creating apache_request_headers() if not exists
1188
- if(!function_exists('apache_request_headers')){
1189
- function apache_request_headers(){
1190
- $arh = array();
1191
- $rx_http = '/\AHTTP_/';
1192
- foreach($_SERVER as $key => $val){
1193
- if(preg_match($rx_http, $key)){
1194
- $arh_key = preg_replace($rx_http, '', $key);
1195
- // do some nasty string manipulations to restore the original letter case
1196
- // this should work in most cases
1197
- $rx_matches = array();
1198
- $rx_matches = explode('_', $arh_key);
1199
- if( count($rx_matches) > 0 and strlen($arh_key) > 2 ){
1200
- foreach($rx_matches as $ak_key => $ak_val) $rx_matches[$ak_key] = ucfirst($ak_val);
1201
- $arh_key = implode('-', $rx_matches);
1202
- }
1203
- $arh[$arh_key] = $val;
1204
- }
1205
- }
1206
- return( $arh );
1207
- }
1208
- }
1209
-
1210
- function cleantalk_get_real_ip(){
1211
-
1212
- // Getting headers
1213
- $headers = function_exists('apache_request_headers') ? apache_request_headers() : $_SERVER;
1214
-
1215
- // Getting IP for validating
1216
- if (array_key_exists( 'X-Forwarded-For', $headers )){
1217
- $ip = explode(",", trim($headers['X-Forwarded-For']));
1218
- $ip = trim($ip[0]);
1219
- }elseif(array_key_exists( 'HTTP_X_FORWARDED_FOR', $headers)){
1220
- $ip = explode(",", trim($headers['HTTP_X_FORWARDED_FOR']));
1221
- $ip = trim($ip[0]);
1222
- }else{
1223
- $ip = $_SERVER['REMOTE_ADDR'];
1224
- }
1225
-
1226
- // Validating IP
1227
- // IPv4
1228
- if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)){
1229
- $the_ip = $ip;
1230
- // IPv6
1231
- }elseif(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)){
1232
- $the_ip = $ip;
1233
- // Unknown
1234
- }else{
1235
- $the_ip = null;
1236
- }
1237
-
1238
- return $the_ip;
1239
- }
1240
-
1241
- function cleantalk_is_JSON($string)
1242
- {
1243
- return ((is_string($string) && (is_object(json_decode($string)) || is_array(json_decode($string))))) ? true : false;
1244
- }
1245
-
1246
- // Patch for locale_get_display_region() for old PHP versions
1247
- if( !function_exists('locale_get_display_region') ){
1248
- function locale_get_display_region($locale){
1249
- return $locale;
1250
- }
1251
- }
1252
-
1
+ <?php
2
+ /**
3
+ * Cleantalk base class
4
+ *
5
+ * @version 2.1.4
6
+ * @package Cleantalk
7
+ * @subpackage Base
8
+ * @author Cleantalk team (welcome@cleantalk.org)
9
+ * @copyright (C) 2014 CleanTalk team (http://cleantalk.org)
10
+ * @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
11
+ * @see https://github.com/CleanTalk/php-antispam
12
+ *
13
+ */
14
+
15
+ /**
16
+ * Response class
17
+ */
18
+ class CleantalkResponse {
19
+
20
+ /**
21
+ * Received feedback nubmer
22
+ * @var int
23
+ */
24
+ public $received = null;
25
+
26
+ /**
27
+ * Is stop words
28
+ * @var int
29
+ */
30
+ public $stop_words = null;
31
+
32
+ /**
33
+ * Cleantalk comment
34
+ * @var string
35
+ */
36
+ public $comment = null;
37
+
38
+ /**
39
+ * Is blacklisted
40
+ * @var int
41
+ */
42
+ public $blacklisted = null;
43
+
44
+ /**
45
+ * Is allow, 1|0
46
+ * @var int
47
+ */
48
+ public $allow = null;
49
+
50
+ /**
51
+ * Request ID
52
+ * @var int
53
+ */
54
+ public $id = null;
55
+
56
+ /**
57
+ * Request errno
58
+ * @var int
59
+ */
60
+ public $errno = null;
61
+
62
+ /**
63
+ * Error string
64
+ * @var string
65
+ */
66
+ public $errstr = null;
67
+
68
+ /**
69
+ * Is fast submit, 1|0
70
+ * @var string
71
+ */
72
+ public $fast_submit = null;
73
+
74
+ /**
75
+ * Is spam comment
76
+ * @var string
77
+ */
78
+ public $spam = null;
79
+
80
+ /**
81
+ * Is JS
82
+ * @var type
83
+ */
84
+ public $js_disabled = null;
85
+
86
+ /**
87
+ * Sms check
88
+ * @var type
89
+ */
90
+ public $sms_allow = null;
91
+
92
+ /**
93
+ * Sms code result
94
+ * @var type
95
+ */
96
+ public $sms = null;
97
+
98
+ /**
99
+ * Sms error code
100
+ * @var type
101
+ */
102
+ public $sms_error_code = null;
103
+
104
+ /**
105
+ * Sms error code
106
+ * @var type
107
+ */
108
+ public $sms_error_text = null;
109
+
110
+ /**
111
+ * Stop queue message, 1|0
112
+ * @var int
113
+ */
114
+ public $stop_queue = null;
115
+
116
+ /**
117
+ * Account shuld by deactivated after registration, 1|0
118
+ * @var int
119
+ */
120
+ public $inactive = null;
121
+
122
+ /**
123
+ * Account status
124
+ * @var int
125
+ */
126
+ public $account_status = -1;
127
+
128
+ /**
129
+ * Create server response
130
+ *
131
+ * @param type $response
132
+ * @param type $obj
133
+ */
134
+ function __construct($response = null, $obj = null) {
135
+ if ($response && is_array($response) && count($response) > 0) {
136
+ foreach ($response as $param => $value) {
137
+ $this->{$param} = $value;
138
+ }
139
+ } else {
140
+ $this->errno = $obj->errno;
141
+ $this->errstr = $obj->errstr;
142
+
143
+ $this->errstr = preg_replace("/.+(\*\*\*.+\*\*\*).+/", "$1", $this->errstr);
144
+
145
+ $this->stop_words = isset($obj->stop_words) ? utf8_decode($obj->stop_words) : null;
146
+ $this->comment = isset($obj->comment) ? utf8_decode($obj->comment) : null;
147
+ $this->blacklisted = (isset($obj->blacklisted)) ? $obj->blacklisted : null;
148
+ $this->allow = (isset($obj->allow)) ? $obj->allow : 0;
149
+ $this->id = (isset($obj->id)) ? $obj->id : null;
150
+ $this->fast_submit = (isset($obj->fast_submit)) ? $obj->fast_submit : 0;
151
+ $this->spam = (isset($obj->spam)) ? $obj->spam : 0;
152
+ $this->js_disabled = (isset($obj->js_disabled)) ? $obj->js_disabled : 0;
153
+ $this->sms_allow = (isset($obj->sms_allow)) ? $obj->sms_allow : null;
154
+ $this->sms = (isset($obj->sms)) ? $obj->sms : null;
155
+ $this->sms_error_code = (isset($obj->sms_error_code)) ? $obj->sms_error_code : null;
156
+ $this->sms_error_text = (isset($obj->sms_error_text)) ? $obj->sms_error_text : null;
157
+ $this->stop_queue = (isset($obj->stop_queue)) ? $obj->stop_queue : 0;
158
+ $this->inactive = (isset($obj->inactive)) ? $obj->inactive : 0;
159
+ $this->account_status = (isset($obj->account_status)) ? $obj->account_status : -1;
160
+ $this->received = (isset($obj->received)) ? $obj->received : -1;
161
+
162
+ if ($this->errno !== 0 && $this->errstr !== null && $this->comment === null)
163
+ $this->comment = '*** ' . $this->errstr . ' Antispam service cleantalk.org ***';
164
+ }
165
+ }
166
+
167
+ }
168
+
169
+ /**
170
+ * Request class
171
+ */
172
+ class CleantalkRequest {
173
+
174
+ /**
175
+ * All http request headers
176
+ * @var string
177
+ */
178
+ public $all_headers = null;
179
+
180
+ /**
181
+ * IP address of connection
182
+ * @var string
183
+ */
184
+ //public $remote_addr = null;
185
+
186
+ /**
187
+ * Last error number
188
+ * @var integer
189
+ */
190
+ public $last_error_no = null;
191
+
192
+ /**
193
+ * Last error time
194
+ * @var integer
195
+ */
196
+ public $last_error_time = null;
197
+
198
+ /**
199
+ * Last error text
200
+ * @var string
201
+ */
202
+ public $last_error_text = null;
203
+
204
+ /**
205
+ * User message
206
+ * @var string
207
+ */
208
+ public $message = null;
209
+
210
+ /**
211
+ * Post example with last comments
212
+ * @var string
213
+ */
214
+ public $example = null;
215
+
216
+ /**
217
+ * Auth key
218
+ * @var string
219
+ */
220
+ public $auth_key = null;
221
+
222
+ /**
223
+ * Engine
224
+ * @var string
225
+ */
226
+ public $agent = null;
227
+
228
+ /**
229
+ * Is check for stoplist,
230
+ * valid are 0|1
231
+ * @var int
232
+ */
233
+ public $stoplist_check = null;
234
+
235
+ /**
236
+ * Language server response,
237
+ * valid are 'en' or 'ru'
238
+ * @var string
239
+ */
240
+ public $response_lang = null;
241
+
242
+ /**
243
+ * User IP
244
+ * @var strings
245
+ */
246
+ public $sender_ip = null;
247
+
248
+ /**
249
+ * User email
250
+ * @var strings
251
+ */
252
+ public $sender_email = null;
253
+
254
+ /**
255
+ * User nickname
256
+ * @var string
257
+ */
258
+ public $sender_nickname = null;
259
+
260
+ /**
261
+ * Sender info JSON string
262
+ * @var string
263
+ */
264
+ public $sender_info = null;
265
+
266
+ /**
267
+ * Post info JSON string
268
+ * @var string
269
+ */
270
+ public $post_info = null;
271
+
272
+ /**
273
+ * Is allow links, email and icq,
274
+ * valid are 1|0
275
+ * @var int
276
+ */
277
+ public $allow_links = null;
278
+
279
+ /**
280
+ * Time form filling
281
+ * @var int
282
+ */
283
+ public $submit_time = null;
284
+
285
+ public $x_forwarded_for = '';
286
+ public $x_real_ip = '';
287
+
288
+ /**
289
+ * Is enable Java Script,
290
+ * valid are 0|1|2
291
+ * Status:
292
+ * null - JS html code not inserted into phpBB templates
293
+ * 0 - JS disabled at the client browser
294
+ * 1 - JS enabled at the client broswer
295
+ * @var int
296
+ */
297
+ public $js_on = null;
298
+
299
+ /**
300
+ * user time zone
301
+ * @var string
302
+ */
303
+ public $tz = null;
304
+
305
+ /**
306
+ * Feedback string,
307
+ * valid are 'requset_id:(1|0)'
308
+ * @var string
309
+ */
310
+ public $feedback = null;
311
+
312
+ /**
313
+ * Phone number
314
+ * @var type
315
+ */
316
+ public $phone = null;
317
+
318
+ /**
319
+ * Method name
320
+ * @var string
321
+ */
322
+ public $method_name = 'check_message';
323
+
324
+ /**
325
+ * Fill params with constructor
326
+ * @param type $params
327
+ */
328
+ public function __construct($params = null) {
329
+ if (is_array($params) && count($params) > 0) {
330
+ foreach ($params as $param => $value) {
331
+ $this->{$param} = $value;
332
+ }
333
+ }
334
+ }
335
+
336
+ }
337
+
338
+ /**
339
+ * Cleantalk class create request
340
+ */
341
+ class Cleantalk {
342
+
343
+ /**
344
+ * Debug level
345
+ * @var int
346
+ */
347
+ public $debug = 0;
348
+
349
+ /**
350
+ * Maximum data size in bytes
351
+ * @var int
352
+ */
353
+ private $dataMaxSise = 32768;
354
+
355
+ /**
356
+ * Data compression rate
357
+ * @var int
358
+ */
359
+ private $compressRate = 6;
360
+
361
+ /**
362
+ * Server connection timeout in seconds
363
+ * @var int
364
+ */
365
+ private $server_timeout = 15;
366
+
367
+ /**
368
+ * Cleantalk server url
369
+ * @var string
370
+ */
371
+ public $server_url = null;
372
+
373
+ /**
374
+ * Last work url
375
+ * @var string
376
+ */
377
+ public $work_url = null;
378
+
379
+ /**
380
+ * WOrk url ttl
381
+ * @var int
382
+ */
383
+ public $server_ttl = null;
384
+
385
+ /**
386
+ * Time wotk_url changer
387
+ * @var int
388
+ */
389
+ public $server_changed = null;
390
+
391
+ /**
392
+ * Flag is change server url
393
+ * @var bool
394
+ */
395
+ public $server_change = false;
396
+
397
+ /**
398
+ * Use TRUE when need stay on server. Example: send feedback
399
+ * @var bool
400
+ */
401
+ public $stay_on_server = false;
402
+
403
+ /**
404
+ * Codepage of the data
405
+ * @var bool
406
+ */
407
+ public $data_codepage = null;
408
+
409
+ /**
410
+ * API version to use
411
+ * @var string
412
+ */
413
+ public $api_version = '/api2.0';
414
+
415
+ /**
416
+ * Use https connection to servers
417
+ * @var bool
418
+ */
419
+ public $ssl_on = false;
420
+
421
+ /**
422
+ * Path to SSL certificate
423
+ * @var string
424
+ */
425
+ public $ssl_path = '';
426
+
427
+ /**
428
+ * Minimal server response in miliseconds to catch the server
429
+ *
430
+ */
431
+ public $min_server_timeout = 50;
432
+
433
+ /**
434
+ * Function checks whether it is possible to publish the message
435
+ * @param CleantalkRequest $request
436
+ * @return type
437
+ */
438
+ public function isAllowMessage(CleantalkRequest $request) {
439
+ $request = $this->filterRequest($request);
440
+ $msg = $this->createMsg('check_message', $request);
441
+ return $this->httpRequest($msg);
442
+ }
443
+
444
+ /**
445
+ * Function checks whether it is possible to publish the message
446
+ * @param CleantalkRequest $request
447
+ * @return type
448
+ */
449
+ public function isAllowUser(CleantalkRequest $request) {
450
+ $request = $this->filterRequest($request);
451
+ $msg = $this->createMsg('check_newuser', $request);
452
+ return $this->httpRequest($msg);
453
+ }
454
+
455
+ /**
456
+ * Function sends the results of manual moderation
457
+ *
458
+ * @param CleantalkRequest $request
459
+ * @return type
460
+ */
461
+ public function sendFeedback(CleantalkRequest $request) {
462
+ $request = $this->filterRequest($request);
463
+ $msg = $this->createMsg('send_feedback', $request);
464
+ return $this->httpRequest($msg);
465
+ }
466
+
467
+ /**
468
+ * Filter request params
469
+ * @param CleantalkRequest $request
470
+ * @return type
471
+ */
472
+ private function filterRequest(CleantalkRequest $request) {
473
+ // general and optional
474
+ foreach ($request as $param => $value) {
475
+ if (in_array($param, array('message', 'example', 'agent',
476
+ 'sender_info', 'sender_nickname', 'post_info', 'phone')) && !empty($value)) {
477
+ if (!is_string($value) && !is_integer($value)) {
478
+ $request->$param = NULL;
479
+ }
480
+ }
481
+
482
+ if (in_array($param, array('stoplist_check', 'allow_links')) && !empty($value)) {
483
+ if (!in_array($value, array(1, 2))) {
484
+ $request->$param = NULL;
485
+ }
486
+ }
487
+
488
+ if (in_array($param, array('js_on')) && !empty($value)) {
489
+ if (!is_integer($value)) {
490
+ $request->$param = NULL;
491
+ }
492
+ }
493
+
494
+ if ($param == 'sender_ip' && !empty($value)) {
495
+ if (!is_string($value)) {
496
+ $request->$param = NULL;
497
+ }
498
+ }
499
+
500
+ if ($param == 'sender_email' && !empty($value)) {
501
+ if (!is_string($value)) {
502
+ $request->$param = NULL;
503
+ }
504
+ }
505
+
506
+ if ($param == 'submit_time' && !empty($value)) {
507
+ if (!is_int($value)) {
508
+ $request->$param = NULL;
509
+ }
510
+ }
511
+ }
512
+ return $request;
513
+ }
514
+
515
+ /**
516
+ * Compress data and encode to base64
517
+ * @param type string
518
+ * @return string
519
+ */
520
+ private function compressData($data = null){
521
+
522
+ if (strlen($data) > $this->dataMaxSise && function_exists('gzencode') && function_exists('base64_encode')){
523
+
524
+ $localData = gzencode($data, $this->compressRate, FORCE_GZIP);
525
+
526
+ if ($localData === false)
527
+ return $data;
528
+
529
+ $localData = base64_encode($localData);
530
+
531
+ if ($localData === false)
532
+ return $data;
533
+
534
+ return $localData;
535
+ }
536
+
537
+ return $data;
538
+ }
539
+
540
+ /**
541
+ * Create msg for cleantalk server
542
+ * @param type $method
543
+ * @param CleantalkRequest $request
544
+ * @return \xmlrpcmsg
545
+ */
546
+ private function createMsg($method, CleantalkRequest $request) {
547
+ switch ($method) {
548
+ case 'check_message':
549
+ // Convert strings to UTF8
550
+ $request->message = $this->stringToUTF8($request->message, $this->data_codepage);
551
+ $request->example = $this->stringToUTF8($request->example, $this->data_codepage);
552
+ $request->sender_email = $this->stringToUTF8($request->sender_email, $this->data_codepage);
553
+ $request->sender_nickname = $this->stringToUTF8($request->sender_nickname, $this->data_codepage);
554
+
555
+ $request->message = $this->compressData($request->message);
556
+ $request->example = $this->compressData($request->example);
557
+ break;
558
+
559
+ case 'check_newuser':
560
+ // Convert strings to UTF8
561
+ $request->sender_email = $this->stringToUTF8($request->sender_email, $this->data_codepage);
562
+ $request->sender_nickname = $this->stringToUTF8($request->sender_nickname, $this->data_codepage);
563
+ break;
564
+
565
+ case 'send_feedback':
566
+ if (is_array($request->feedback)) {
567
+ $request->feedback = implode(';', $request->feedback);
568
+ }
569
+ break;
570
+ }
571
+
572
+ $request->method_name = $method;
573
+
574
+ //
575
+ // Removing non UTF8 characters from request, because non UTF8 or malformed characters break json_encode().
576
+ //
577
+ foreach ($request as $param => $value) {
578
+ if (!preg_match('//u', $value))
579
+ $request->{$param} = 'Nulled. Not UTF8 encoded or malformed.';
580
+ }
581
+
582
+ return $request;
583
+ }
584
+
585
+ /**
586
+ * Send JSON request to servers
587
+ * @param $msg
588
+ * @return boolean|\CleantalkResponse
589
+ */
590
+ private function sendRequest($data = null, $url, $server_timeout = 3) {
591
+ // Convert to array
592
+ $data = (array)json_decode(json_encode($data), true);
593
+
594
+ $original_url = $url;
595
+ $original_data = $data;
596
+
597
+ //Cleaning from 'null' values
598
+ $tmp_data = array();
599
+ foreach($data as $key => $value){
600
+ if($value !== null)
601
+ $tmp_data[$key] = $value;
602
+ }
603
+ $data = $tmp_data;
604
+ unset($key, $value, $tmp_data);
605
+
606
+ // Convert to JSON
607
+ $data = json_encode($data);
608
+
609
+ if (isset($this->api_version)) {
610
+ $url = $url . $this->api_version;
611
+ }
612
+
613
+ // Switching to secure connection
614
+ if ($this->ssl_on && !preg_match("/^https:/", $url)) {
615
+ $url = preg_replace("/^(http)/i", "$1s", $url);
616
+ }
617
+
618
+ $result = false;
619
+ $curl_error = null;
620
+ if(function_exists('curl_init')) {
621
+ $ch = curl_init();
622
+ curl_setopt($ch, CURLOPT_URL, $url);
623
+ curl_setopt($ch, CURLOPT_TIMEOUT, $server_timeout);
624
+ curl_setopt($ch, CURLOPT_POST, 1);
625
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
626
+ // receive server response ...
627
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
628
+ // resolve 'Expect: 100-continue' issue
629
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
630
+ // see http://stackoverflow.com/a/23322368
631
+ curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
632
+
633
+ // Disabling CA cert verivication
634
+ // Disabling common name verification
635
+ if ($this->ssl_on && $this->ssl_path=='') {
636
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
637
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
638
+ }
639
+ else if ($this->ssl_on && $this->ssl_path!='') {
640
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
641
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
642
+ curl_setopt($ch, CURLOPT_CAINFO, $this->ssl_path);
643
+ }
644
+
645
+ $result = curl_exec($ch);
646
+ if (!$result) {
647
+ $curl_error = curl_error($ch);
648
+ // Use SSL next time, if error occurs.
649
+ if(!$this->ssl_on){
650
+ $this->ssl_on = true;
651
+ return $this->sendRequest($original_data, $original_url, $server_timeout);
652
+ }
653
+ }
654
+
655
+ curl_close($ch);
656
+ }
657
+
658
+ if (!$result) {
659
+ $allow_url_fopen = ini_get('allow_url_fopen');
660
+ if (function_exists('file_get_contents') && isset($allow_url_fopen) && $allow_url_fopen == '1') {
661
+ $opts = array('http' =>
662
+ array(
663
+ 'method' => 'POST',
664
+ 'header' => "Content-Type: text/html\r\n",
665
+ 'content' => $data,
666
+ 'timeout' => $server_timeout
667
+ )
668
+ );
669
+
670
+ $context = stream_context_create($opts);
671
+ $result = @file_get_contents($url, false, $context);
672
+ }
673
+ }
674
+
675
+ if (!$result || !cleantalk_is_JSON($result)) {
676
+ $response = null;
677
+ $response['errno'] = 1;
678
+ if ($curl_error) {
679
+ $response['errstr'] = sprintf("CURL error: '%s'", $curl_error);
680
+ } else {
681
+ $response['errstr'] = 'No CURL support compiled in';
682
+ }
683
+ $response['errstr'] .= ' or disabled allow_url_fopen in php.ini.';
684
+ $response = json_decode(json_encode($response));
685
+
686
+ return $response;
687
+ }
688
+
689
+ $errstr = null;
690
+ $response = json_decode($result);
691
+ if ($result !== false && is_object($response)) {
692
+ $response->errno = 0;
693
+ $response->errstr = $errstr;
694
+ } else {
695
+ $errstr = 'Unknown response from ' . $url . '.' . ' ' . $result;
696
+
697
+ $response = null;
698
+ $response['errno'] = 1;
699
+ $response['errstr'] = $errstr;
700
+ $response = json_decode(json_encode($response));
701
+ }
702
+
703
+
704
+ return $response;
705
+ }
706
+
707
+ /**
708
+ * httpRequest
709
+ * @param $msg
710
+ * @return boolean|\CleantalkResponse
711
+ */
712
+ private function httpRequest($msg) {
713
+ $result = false;
714
+
715
+ if($msg->method_name != 'send_feedback'){
716
+ $ct_tmp = apache_request_headers();
717
+
718
+ if(isset($ct_tmp['Cookie']))
719
+ $cookie_name = 'Cookie';
720
+ elseif(isset($ct_tmp['cookie']))
721
+ $cookie_name = 'cookie';
722
+ else
723
+ $cookie_name = 'COOKIE';
724
+
725
+ $ct_tmp[$cookie_name] = preg_replace(array(
726
+ '/\s{0,1}ct_checkjs=[a-z0-9]*[;|$]{0,1}/',
727
+ '/\s{0,1}ct_timezone=.{0,1}\d{1,2}[;|$]/',
728
+ '/\s{0,1}ct_pointer_data=.*5D[;|$]{0,1}/',
729
+ '/;{0,1}\s{0,3}$/'
730
+ ), '', $ct_tmp[$cookie_name]);
731
+ $msg->all_headers=json_encode($ct_tmp);
732
+ }
733
+
734
+ $si=(array)json_decode($msg->sender_info,true);
735
+
736
+ $si['remote_addr'] = $_SERVER['REMOTE_ADDR'];
737
+ $msg->x_forwarded_for = @$_SERVER['X_FORWARDED_FOR'];
738
+ $msg->x_real_ip = @$_SERVER['X_REAL_IP'];
739
+
740
+ $msg->sender_info=json_encode($si);
741
+ if (((isset($this->work_url) && $this->work_url !== '') && ($this->server_changed + $this->server_ttl > time()))
742
+ || $this->stay_on_server == true) {
743
+
744
+ $url = (!empty($this->work_url)) ? $this->work_url : $this->server_url;
745
+
746
+ $result = $this->sendRequest($msg, $url, $this->server_timeout);
747
+ }
748
+
749
+ if (($result === false || $result->errno != 0) && $this->stay_on_server == false) {
750
+ // Split server url to parts
751
+ preg_match("@^(https?://)([^/:]+)(.*)@i", $this->server_url, $matches);
752
+ $url_prefix = '';
753
+ if (isset($matches[1]))
754
+ $url_prefix = $matches[1];
755
+
756
+ $pool = null;
757
+ if (isset($matches[2]))
758
+ $pool = $matches[2];
759
+
760
+ $url_suffix = '';
761
+ if (isset($matches[3]))
762
+ $url_suffix = $matches[3];
763
+
764
+ if ($url_prefix === '')
765
+ $url_prefix = 'http://';
766
+
767
+ if (empty($pool)) {
768
+ return false;
769
+ } else {
770
+ // Loop until find work server
771
+ foreach ($this->get_servers_ip($pool) as $server) {
772
+ if ($server['host'] === 'localhost' || $server['ip'] === null) {
773
+ $work_url = $server['host'];
774
+ } else {
775
+ $server_host = $server['ip'];
776
+ $work_url = $server_host;
777
+ }
778
+ $work_url = $url_prefix . $work_url;
779
+ if (isset($url_suffix))
780
+ $work_url = $work_url . $url_suffix;
781
+
782
+ $this->work_url = $work_url;
783
+ $this->server_ttl = $server['ttl'];
784
+
785
+ $result = $this->sendRequest($msg, $this->work_url, $this->server_timeout);
786
+
787
+ if ($result !== false && $result->errno === 0) {
788
+ $this->server_change = true;
789
+ break;
790
+ }
791
+ }
792
+ }
793
+ }
794
+
795
+ $response = new CleantalkResponse(null, $result);
796
+
797
+ if (!empty($this->data_codepage) && $this->data_codepage !== 'UTF-8') {
798
+ if (!empty($response->comment))
799
+ $response->comment = $this->stringFromUTF8($response->comment, $this->data_codepage);
800
+ if (!empty($response->errstr))
801
+ $response->errstr = $this->stringFromUTF8($response->errstr, $this->data_codepage);
802
+ if (!empty($response->sms_error_text))
803
+ $response->sms_error_text = $this->stringFromUTF8($response->sms_error_text, $this->data_codepage);
804
+ }
805
+
806
+ return $response;
807
+ }
808
+
809
+ /**
810
+ * Function DNS request
811
+ * @param $host
812
+ * @return array
813
+ */
814
+ public function get_servers_ip($host) {
815
+ $response = null;
816
+ if (!isset($host))
817
+ return $response;
818
+
819
+ if (function_exists('dns_get_record')) {
820
+ $records = dns_get_record($host, DNS_A);
821
+
822
+ if ($records !== FALSE) {
823
+ foreach ($records as $server) {
824
+ $response[] = $server;
825
+ }
826
+ }
827
+ }
828
+
829
+ if (count($response) == 0 && function_exists('gethostbynamel')) {
830
+ $records = gethostbynamel($host);
831
+
832
+ if ($records !== FALSE) {
833
+ foreach ($records as $server) {
834
+ $response[] = array(
835
+ "ip" => $server,
836
+ "host" => $host,
837
+ "ttl" => $this->server_ttl
838
+ );
839
+ }
840
+ }
841
+ }
842
+
843
+ if (count($response) == 0) {
844
+ $response[] = array("ip" => null,
845
+ "host" => $host,
846
+ "ttl" => $this->server_ttl
847
+ );
848
+ } else {
849
+ // $i - to resolve collisions with localhost
850
+ $i = 0;
851
+ $r_temp = null;
852
+ $fast_server_found = false;
853
+ foreach ($response as $server) {
854
+
855
+ // Do not test servers because fast work server found
856
+ if ($fast_server_found) {
857
+ $ping = $this->min_server_timeout;
858
+ } else {
859
+ $ping = $this->httpPing($server['ip']);
860
+ $ping = $ping * 1000;
861
+ }
862
+
863
+ // -1 server is down, skips not reachable server
864
+ if ($ping != -1) {
865
+ $r_temp[$ping + $i] = $server;
866
+ }
867
+ $i++;
868
+
869
+ if ($ping < $this->min_server_timeout) {
870
+ $fast_server_found = true;
871
+ }
872
+ }
873
+ if (count($r_temp)){
874
+ ksort($r_temp);
875
+ $response = $r_temp;
876
+ }
877
+ }
878
+
879
+ return $response;
880
+ }
881
+
882
+ /**
883
+ * Function to get the message hash from Cleantalk.ru comment
884
+ * @param $message
885
+ * @return null
886
+ */
887
+ public function getCleantalkCommentHash($message) {
888
+ $matches = array();
889
+ if (preg_match('/\n\n\*\*\*.+([a-z0-9]{32}).+\*\*\*$/', $message, $matches))
890
+ return $matches[1];
891
+ else if (preg_match('/\<br.*\>[\n]{0,1}\<br.*\>[\n]{0,1}\*\*\*.+([a-z0-9]{32}).+\*\*\*$/', $message, $matches))
892
+ return $matches[1];
893
+
894
+ return NULL;
895
+ }
896
+
897
+ /**
898
+ * Function adds to the post comment Cleantalk.ru
899
+ * @param $message
900
+ * @param $comment
901
+ * @return string
902
+ */
903
+ public function addCleantalkComment($message, $comment) {
904
+ $comment = preg_match('/\*\*\*(.+)\*\*\*/', $comment, $matches) ? $comment : '*** ' . $comment . ' ***';
905
+ return $message . "\n\n" . $comment;
906
+ }
907
+
908
+ /**
909
+ * Function deletes the comment Cleantalk.ru
910
+ * @param $message
911
+ * @return mixed
912
+ */
913
+ public function delCleantalkComment($message) {
914
+ $message = preg_replace('/\n\n\*\*\*.+\*\*\*$/', '', $message);
915
+
916
+ // DLE sign cut
917
+ $message = preg_replace('/<br\s?\/><br\s?\/>\*\*\*.+\*\*\*$/', '', $message);
918
+
919
+ $message = preg_replace('/\<br.*\>[\n]{0,1}\<br.*\>[\n]{0,1}\*\*\*.+\*\*\*$/', '', $message);
920
+
921
+ return $message;
922
+ }
923
+
924
+ /**
925
+ * Get user IP behind proxy server
926
+ */
927
+ public function ct_session_ip( $data_ip ) {
928
+ // Return FALSE if FALSE !?
929
+ // if (!preg_match("/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/", $data_ip)) {
930
+ // error_log(__FUNCTION__ . " " . "condition");
931
+ // return $data_ip;
932
+ // }
933
+ return cleantalk_get_real_ip();
934
+ }
935
+
936
+ /**
937
+ * From http://php.net/manual/en/function.ip2long.php#82397
938
+ */
939
+ public function net_match($CIDR,$IP) {
940
+ list ($net, $mask) = explode ('/', $CIDR);
941
+ return ( ip2long ($IP) & ~((1 << (32 - $mask)) - 1) ) == ip2long ($net);
942
+ }
943
+
944
+ /**
945
+ * Function to check response time
946
+ * param string
947
+ * @return int
948
+ */
949
+ function httpPing($host){
950
+
951
+ // Skip localhost ping cause it raise error at fsockopen.
952
+ // And return minimun value
953
+ if ($host == 'localhost')
954
+ return 0.001;
955
+
956
+ $starttime = microtime(true);
957
+ $file = @fsockopen ($host, 80, $errno, $errstr, $this->server_timeout);
958
+ $stoptime = microtime(true);
959
+ $status = 0;
960
+ if (!$file) {
961
+ $status = -1; // Site is down
962
+ } else {
963
+ fclose($file);
964
+ $status = ($stoptime - $starttime);
965
+ $status = round($status, 4);
966
+ }
967
+
968
+ return $status;
969
+ }
970
+
971
+ /**
972
+ * Function convert string to UTF8 and removes non UTF8 characters
973
+ * param string
974
+ * param string
975
+ * @return string
976
+ */
977
+ function stringToUTF8($str, $data_codepage = null){
978
+ if (!preg_match('//u', $str) && function_exists('mb_detect_encoding') && function_exists('mb_convert_encoding'))
979
+ {
980
+
981
+ if ($data_codepage !== null)
982
+ return mb_convert_encoding($str, 'UTF-8', $data_codepage);
983
+
984
+ $encoding = mb_detect_encoding($str);
985
+ if ($encoding)
986
+ return mb_convert_encoding($str, 'UTF-8', $encoding);
987
+ }
988
+
989
+ return $str;
990
+ }
991
+
992
+ /**
993
+ * Function convert string from UTF8
994
+ * param string
995
+ * param string
996
+ * @return string
997
+ */
998
+ function stringFromUTF8($str, $data_codepage = null){
999
+ if (preg_match('//u', $str) && function_exists('mb_convert_encoding') && $data_codepage !== null)
1000
+ {
1001
+ return mb_convert_encoding($str, $data_codepage, 'UTF-8');
1002
+ }
1003
+
1004
+ return $str;
1005
+ }
1006
+
1007
+ /**
1008
+ * Function gets information about spam active networks
1009
+ *
1010
+ * @param string api_key
1011
+ * @return JSON/array
1012
+ */
1013
+ public function get_2s_blacklists_db ($api_key) {
1014
+ $request=array();
1015
+ $request['method_name'] = '2s_blacklists_db';
1016
+ $request['auth_key'] = $api_key;
1017
+ $url='https://api.cleantalk.org';
1018
+ $result=sendRawRequest($url,$request);
1019
+ return $result;
1020
+ }
1021
+ }
1022
+
1023
+ /**
1024
+ * Function gets access key automatically
1025
+ *
1026
+ * @param string website admin email
1027
+ * @param string website host
1028
+ * @param string website platform
1029
+ * @return type
1030
+ */
1031
+
1032
+ if(!function_exists('getAutoKey'))
1033
+ {
1034
+ function getAutoKey($email, $host, $platform, $timezone = null)
1035
+ {
1036
+ $request=array();
1037
+ $request['method_name'] = 'get_api_key';
1038
+ $request['email'] = $email;
1039
+ $request['website'] = $host;
1040
+ $request['platform'] = $platform;
1041
+ $request['timezone'] = $timezone;
1042
+ $request['product_name'] = 'antispam';
1043
+ $url='https://api.cleantalk.org';
1044
+ $result=sendRawRequest($url,$request);
1045
+ return $result;
1046
+ }
1047
+ }
1048
+
1049
+ /**
1050
+ * Function gets information about renew notice
1051
+ *
1052
+ * @param string api_key
1053
+ * @return type
1054
+ */
1055
+
1056
+ function noticePaidTill($api_key)
1057
+ {
1058
+ $request=array();
1059
+ $request['method_name'] = 'notice_paid_till';
1060
+ $request['auth_key'] = $api_key;
1061
+ $url='https://api.cleantalk.org';
1062
+ $result=sendRawRequest($url,$request);
1063
+ return $result;
1064
+ }
1065
+
1066
+ /**
1067
+ * Function gets spam report
1068
+ *
1069
+ * @param string website host
1070
+ * @param integer report days
1071
+ * @return type
1072
+ */
1073
+
1074
+ if(!function_exists('getAntispamReport'))
1075
+ {
1076
+ function getAntispamReport($host, $period = 1)
1077
+ {
1078
+ $url='https://api.cleantalk.org';
1079
+ $request=Array(
1080
+ 'method_name' => 'get_antispam_report',
1081
+ 'hostname' => $host,
1082
+ 'period' => $period
1083
+ );
1084
+ $result=sendRawRequest($url,$request);
1085
+ return $result;
1086
+ }
1087
+ }
1088
+
1089
+ /**
1090
+ * Function gets spam statistics
1091
+ *
1092
+ * @param string website host
1093
+ * @param integer report days
1094
+ * @return type
1095
+ */
1096
+
1097
+ if(!function_exists('getAntispamReportBreif'))
1098
+ {
1099
+ function getAntispamReportBreif($key='')
1100
+ {
1101
+
1102
+ $url="https://api.cleantalk.org?auth_key=$key";
1103
+ $request=Array(
1104
+ 'method_name' => 'get_antispam_report_breif'
1105
+ );
1106
+ $result = sendRawRequest($url,$request);
1107
+
1108
+ if($result === false)
1109
+ return "Network error. Please, check <a target='_blank' href='https://cleantalk.org/help/faq-setup#hosting'>this article</a>.";
1110
+
1111
+ $result = !empty($result) ? json_decode($result, true) : false;
1112
+
1113
+ if(!empty($result['error_message']))
1114
+ return $result['error_message'];
1115
+ else{
1116
+ $tmp = array();
1117
+ for($i=0; $i<7; $i++)
1118
+ $tmp[date("Y-m-d", time()-86400*7+86400*$i)] = 0;
1119
+ $result['data']['spam_stat'] = array_merge($tmp, $result['data']['spam_stat']);
1120
+ return $result['data'];
1121
+ }
1122
+ }
1123
+ }
1124
+
1125
+ /**
1126
+ * Function sends raw request to API server
1127
+ *
1128
+ * @param string url of API server
1129
+ * @param array data to send
1130
+ * @param boolean is data have to be JSON encoded or not
1131
+ * @param integer connect timeout
1132
+ * @return type
1133
+ */
1134
+
1135
+ function sendRawRequest($url,$data,$isJSON=false,$timeout=3)
1136
+ {
1137
+ $result=null;
1138
+ if(!$isJSON)
1139
+ {
1140
+ $data=http_build_query($data);
1141
+ $data=str_replace("&amp;", "&", $data);
1142
+ }
1143
+ else
1144
+ {
1145
+ $data= json_encode($data);
1146
+ }
1147
+ $curl_exec=false;
1148
+ if (function_exists('curl_init') && function_exists('json_decode'))
1149
+ {
1150
+
1151
+ $ch = curl_init();
1152
+ curl_setopt($ch, CURLOPT_URL, $url);
1153
+ curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
1154
+ curl_setopt($ch, CURLOPT_POST, true);
1155
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
1156
+
1157
+ // receive server response ...
1158
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1159
+ // resolve 'Expect: 100-continue' issue
1160
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
1161
+
1162
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
1163
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
1164
+
1165
+ $result = @curl_exec($ch);
1166
+ if($result!==false)
1167
+ {
1168
+ $curl_exec=true;
1169
+ }
1170
+ @curl_close($ch);
1171
+ }
1172
+ if(!$curl_exec)
1173
+ {
1174
+ $opts = array(
1175
+ 'http'=>array(
1176
+ 'method' => "POST",
1177
+ 'timeout'=> $timeout,
1178
+ 'content' => $data
1179
+ )
1180
+ );
1181
+ $context = stream_context_create($opts);
1182
+ $result = @file_get_contents($url, 0, $context);
1183
+ }
1184
+ return $result;
1185
+ }
1186
+
1187
+ // Creating apache_request_headers() if not exists
1188
+ if(!function_exists('apache_request_headers')){
1189
+ function apache_request_headers(){
1190
+ $arh = array();
1191
+ $rx_http = '/\AHTTP_/';
1192
+ foreach($_SERVER as $key => $val){
1193
+ if(preg_match($rx_http, $key)){
1194
+ $arh_key = preg_replace($rx_http, '', $key);
1195
+ // do some nasty string manipulations to restore the original letter case
1196
+ // this should work in most cases
1197
+ $rx_matches = array();
1198
+ $rx_matches = explode('_', $arh_key);
1199
+ if( count($rx_matches) > 0 and strlen($arh_key) > 2 ){
1200
+ foreach($rx_matches as $ak_key => $ak_val) $rx_matches[$ak_key] = ucfirst($ak_val);
1201
+ $arh_key = implode('-', $rx_matches);
1202
+ }
1203
+ $arh[$arh_key] = $val;
1204
+ }
1205
+ }
1206
+ return( $arh );
1207
+ }
1208
+ }
1209
+
1210
+ function cleantalk_get_real_ip(){
1211
+
1212
+ // Getting headers
1213
+ $headers = function_exists('apache_request_headers') ? apache_request_headers() : $_SERVER;
1214
+
1215
+ // Getting IP for validating
1216
+ if (array_key_exists( 'X-Forwarded-For', $headers )){
1217
+ $ip = explode(",", trim($headers['X-Forwarded-For']));
1218
+ $ip = trim($ip[0]);
1219
+ }elseif(array_key_exists( 'HTTP_X_FORWARDED_FOR', $headers)){
1220
+ $ip = explode(",", trim($headers['HTTP_X_FORWARDED_FOR']));
1221
+ $ip = trim($ip[0]);
1222
+ }else{
1223
+ $ip = $_SERVER['REMOTE_ADDR'];
1224
+ }
1225
+
1226
+ // Validating IP
1227
+ // IPv4
1228
+ if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)){
1229
+ $the_ip = $ip;
1230
+ // IPv6
1231
+ }elseif(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)){
1232
+ $the_ip = $ip;
1233
+ // Unknown
1234
+ }else{
1235
+ $the_ip = null;
1236
+ }
1237
+
1238
+ return $the_ip;
1239
+ }
1240
+
1241
+ function cleantalk_is_JSON($string)
1242
+ {
1243
+ return ((is_string($string) && (is_object(json_decode($string)) || is_array(json_decode($string))))) ? true : false;
1244
+ }
1245
+
1246
+ // Patch for locale_get_display_region() for old PHP versions
1247
+ if( !function_exists('locale_get_display_region') ){
1248
+ function locale_get_display_region($locale){
1249
+ return $locale;
1250
+ }
1251
+ }
1252
+
inc/cleantalk_external.js CHANGED
@@ -1,34 +1,44 @@
1
- if(ct_external_executed==undefined)
2
- {
3
- var ct_external_executed=true;
4
- for(i=0;i<document.forms.length;i++)
5
- {
6
- if(typeof(document.forms[i].action)=='string')
7
- {
8
- action=document.forms[i].action;
9
- if(action.indexOf('http://')!=-1||action.indexOf('https://')!=-1)
10
- {
11
- tmp=action.split('//');
12
- tmp=tmp[1].split('/');
13
- host=tmp[0].toLowerCase();
14
- if(host!=location.hostname.toLowerCase())
15
- {
16
- var ct_action = document.createElement("input");
17
- ct_action.name='cleantalk_hidden_action';
18
- ct_action.value=action;
19
- ct_action.type='hidden';
20
- document.forms[i].appendChild(ct_action);
21
-
22
- var ct_method = document.createElement("input");
23
- ct_method.name='cleantalk_hidden_method';
24
- ct_method.value=document.forms[i].method;
25
- ct_method.type='hidden';
26
- document.forms[i].method='POST';
27
- document.forms[i].appendChild(ct_method);
28
-
29
- document.forms[i].action=ctNocache.blog_home;
30
- }
31
- }
32
- }
33
- }
34
- }
 
 
 
 
 
 
 
 
 
 
1
+ function ct_protect_external(){
2
+
3
+ for(i=0;i<document.forms.length;i++){
4
+
5
+ if(typeof(document.forms[i].action)=='string'){
6
+
7
+ action=document.forms[i].action;
8
+ if(action.indexOf('http://')!=-1||action.indexOf('https://')!=-1){
9
+
10
+ tmp=action.split('//');
11
+ tmp=tmp[1].split('/');
12
+ host=tmp[0].toLowerCase();
13
+ if(host!=location.hostname.toLowerCase()){
14
+
15
+ var ct_action = document.createElement("input");
16
+ ct_action.name='cleantalk_hidden_action';
17
+ ct_action.value=action;
18
+ ct_action.type='hidden';
19
+ document.forms[i].appendChild(ct_action);
20
+
21
+ var ct_method = document.createElement("input");
22
+ ct_method.name='cleantalk_hidden_method';
23
+ ct_method.value=document.forms[i].method;
24
+ ct_method.type='hidden';
25
+
26
+ document.forms[i].method='POST';
27
+ document.forms[i].appendChild(ct_method);
28
+
29
+ document.forms[i].action=ctNocache.blog_home;
30
+ }
31
+ }
32
+ }
33
+ }
34
+ }
35
+
36
+ jQuery(document).ready(function(){
37
+
38
+ // Aigle CRM subscription form
39
+ if(typeof _agile == 'object'){
40
+ window.onload = function(){ setTimeout(function(){ ct_protect_external() }, 1500); };
41
+ }else{
42
+ ct_protect_external();
43
+ }
44
+ });
inc/cleantalk_internal.js CHANGED
@@ -1,54 +1,54 @@
1
- function ct_check_internal(currForm){
2
-
3
- //Gathering data
4
- var ct_data = {},
5
- elems = currForm.elements;
6
-
7
- for (var key in elems) {
8
- if(elems[key].type == 'submit' || elems[key].value == undefined || elems[key].value == '')
9
- continue;
10
- ct_data[elems[key].name] = currForm.elements[key].value;
11
- }
12
- ct_data['action'] = 'ct_check_internal';
13
-
14
- //AJAX Request
15
- jQuery.ajax({
16
- type: 'POST',
17
- url: ctNocache.blog_home,
18
- datatype : 'text',
19
- data: ct_data,
20
- success: function(data){
21
- if(data == 'true'){
22
- currForm.submit();
23
- }else{
24
- alert(data);
25
- return false;
26
- }
27
- },
28
- error: function(){
29
- currForm.submit();
30
- }
31
- });
32
- }
33
-
34
- jQuery(document).ready( function(){
35
- var ct_currAction = '',
36
- ct_currForm = '';
37
- for(i=0;i<document.forms.length;i++){
38
- if(typeof(document.forms[i].action)=='string'){
39
- ct_currForm = document.forms[i];
40
- ct_currAction = ct_currForm.action;
41
- if(ct_currAction.indexOf('http://')!=-1||ct_currAction.indexOf('https://')!=-1){
42
- if(ct_currAction.search(/\/wp-content\/themes.*\.php$/) != (-1) && ct_currAction.indexOf(ctNocache.blog_home) != (-1)){
43
- ctPrevHandler = ct_currForm.click;
44
- jQuery(ct_currForm).off('**');
45
- jQuery(ct_currForm).off();
46
- jQuery(ct_currForm).on('submit', function(){
47
- ct_check_internal(ct_currForm);
48
- return false;
49
- });
50
- }
51
- }
52
- }
53
- }
54
  });
1
+ function ct_check_internal(currForm){
2
+
3
+ //Gathering data
4
+ var ct_data = {},
5
+ elems = currForm.elements;
6
+
7
+ for (var key in elems) {
8
+ if(elems[key].type == 'submit' || elems[key].value == undefined || elems[key].value == '')
9
+ continue;
10
+ ct_data[elems[key].name] = currForm.elements[key].value;
11
+ }
12
+ ct_data['action'] = 'ct_check_internal';
13
+
14
+ //AJAX Request
15
+ jQuery.ajax({
16
+ type: 'POST',
17
+ url: ctNocache.blog_home,
18
+ datatype : 'text',
19
+ data: ct_data,
20
+ success: function(data){
21
+ if(data == 'true'){
22
+ currForm.submit();
23
+ }else{
24
+ alert(data);
25
+ return false;
26
+ }
27
+ },
28
+ error: function(){
29
+ currForm.submit();
30
+ }
31
+ });
32
+ }
33
+
34
+ jQuery(document).ready( function(){
35
+ var ct_currAction = '',
36
+ ct_currForm = '';
37
+ for(i=0;i<document.forms.length;i++){
38
+ if(typeof(document.forms[i].action)=='string'){
39
+ ct_currForm = document.forms[i];
40
+ ct_currAction = ct_currForm.action;
41
+ if(ct_currAction.indexOf('http://')!=-1||ct_currAction.indexOf('https://')!=-1){
42
+ if(ct_currAction.search(/\/wp-content\/themes.*\.php$/) != (-1) && ct_currAction.indexOf(ctNocache.blog_home) != (-1)){
43
+ ctPrevHandler = ct_currForm.click;
44
+ jQuery(ct_currForm).off('**');
45
+ jQuery(ct_currForm).off();
46
+ jQuery(ct_currForm).on('submit', function(){
47
+ ct_check_internal(ct_currForm);
48
+ return false;
49
+ });
50
+ }
51
+ }
52
+ }
53
+ }
54
  });
inc/cleantalk_nocache.js CHANGED
@@ -1,216 +1,217 @@
1
- /*
2
- Assign default values for backend variables.
3
- */
4
- if (typeof ctNocache.set_cookies_flag === 'undefined') {
5
- ctNocache.set_cookies_flag = true;
6
- }
7
-
8
- if (typeof ctNocache.ajaxurl === 'undefined') {
9
- ctNocache.ajaxurl = '/wp-admin/admin-ajax.php';
10
- }
11
-
12
- function sendRequest(url,callback,postData) {
13
- var req = createXMLHTTPObject();
14
- if (!req) return;
15
- var method = (postData) ? "POST" : "GET";
16
-
17
- var protocol = location.protocol;
18
- if (protocol === 'https:') {
19
- url = url.replace('http:', 'https:');
20
- } else {
21
- url = url.replace('https:', 'http:');
22
- }
23
-
24
- req.open(method,url,true);
25
- if (postData)
26
- req.setRequestHeader('Content-type','application/x-www-form-urlencoded');
27
- req.onreadystatechange = function () {
28
- if (req.readyState != 4) return;
29
- if (req.status != 200 && req.status != 304) {
30
- // alert('HTTP error ' + req.status);
31
- return;
32
- }
33
- callback(req);
34
- };
35
- if (req.readyState == 4) return;
36
- req.send(postData);
37
- }
38
-
39
- var XMLHttpFactories = [
40
- function () {return new XMLHttpRequest()},
41
- function () {return new ActiveXObject("Msxml2.XMLHTTP")},
42
- function () {return new ActiveXObject("Msxml3.XMLHTTP")},
43
- function () {return new ActiveXObject("Microsoft.XMLHTTP")}
44
- ];
45
-
46
- function createXMLHTTPObject() {
47
- var xmlhttp = false;
48
- for (var i=0;i<XMLHttpFactories.length;i++) {
49
- try {
50
- xmlhttp = XMLHttpFactories[i]();
51
- }
52
- catch (e) {
53
- continue;
54
- }
55
- break;
56
- }
57
- return xmlhttp;
58
- }
59
-
60
- function ct_getCookie(name) {
61
- var matches = document.cookie.match(new RegExp(
62
- "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
63
- ));
64
- return matches ? decodeURIComponent(matches[1]) : undefined;
65
- }
66
-
67
- function ct_setCookie(name, value)
68
- {
69
- if (ctNocache.set_cookies_flag) {
70
- document.cookie = name+" =; expires=Thu, 01 Jan 1970 00:00:01 GMT; path = /";
71
- document.cookie = name+" =; expires=Thu, 01 Jan 1970 00:00:01 GMT";
72
-
73
- var date = new Date;
74
- date.setDate(date.getDate() + 1);
75
- setTimeout(function() { document.cookie = name+"=" + value + "; expires=" + date.toUTCString() + "; path = /;"}, 500);
76
- }
77
-
78
- return null;
79
- }
80
-
81
- function ct_callback(req)
82
- {
83
- ct_cookie = req.responseText.trim();
84
- //alert('Key value: ' + ct_cookie);
85
-
86
- ct_setCookie('ct_checkjs', ct_cookie);
87
-
88
- for(i=0;i<document.forms.length;i++)
89
- {
90
- f=document.forms[i];
91
- for(j=0;j<f.elements.length;j++)
92
- {
93
- e=f.elements[j];
94
- if(e.name!==undefined&&e.name.indexOf('ct_checkjs')!=-1)
95
- {
96
- e.value=ct_cookie;
97
- //alert('Form #' + i + ', field ' + e.name + ' = ' + ct_cookie);
98
- }
99
- }
100
- }
101
-
102
- //alert('Set cookie: \n' + document.cookie);
103
- }
104
-
105
- if (!Date.now) {
106
- Date.now = function() { return new Date().getTime(); }
107
- }
108
-
109
- if(ct_nocache_executed==undefined)
110
- {
111
- var ct_nocache_executed=true;
112
- var new_timestamp=Math.floor(Date.now() / 1000);
113
-
114
- var old_timestamp=ct_getCookie('ct_timestamp');
115
-
116
- var checkjs_cookie=ct_getCookie('ct_checkjs');
117
-
118
- if(checkjs_cookie!=undefined)
119
- {
120
- for(i=0;i<document.forms.length;i++)
121
- {
122
- f=document.forms[i];
123
- for(j=0;j<f.elements.length;j++)
124
- {
125
- e=f.elements[j];
126
- if(e.name!==undefined&&e.name.indexOf('ct_checkjs')!=-1)
127
- {
128
- e.value=checkjs_cookie;
129
- //alert('Form #' + i + ', field ' + e.name + ' = ' + ct_cookie);
130
- }
131
- }
132
- }
133
- }
134
-
135
- if((old_timestamp==undefined||new_timestamp-old_timestamp>86400||checkjs_cookie==undefined)) //86400 is 24 hours
136
- {
137
- ct_setCookie('ct_timestamp', new_timestamp);
138
- sendRequest(ctNocache.ajaxurl+'?'+Math.random(),ct_callback,'action=ct_get_cookie');
139
- }
140
-
141
- if(typeof ctNocache.info_flag !== 'undefined' && ctNocache.info_flag)
142
- {
143
-
144
- var cleantalk_user_info={};
145
-
146
- var cleantalk_screen_info={};
147
- for(var prop in screen)
148
- {
149
- if (navigator[prop] instanceof Object || screen[prop]==='') continue
150
- cleantalk_screen_info[prop]=screen[prop];
151
- }
152
-
153
- cleantalk_user_info.screen=cleantalk_screen_info;
154
-
155
- var cleantalk_plugins=Array();
156
- var prev
157
- var cnt=0;
158
- for(var i=0;i<navigator.plugins.length;i++)
159
- {
160
- var plugin = navigator.plugins[i];
161
- var plugin = plugin.name+" "+(plugin.version || '')
162
- if (prev == plugin ) continue;
163
- cleantalk_plugins[cnt]=plugin;
164
- cnt++;
165
- prev = plugin
166
- }
167
- cleantalk_user_info.plugins=cleantalk_plugins;
168
-
169
- cleantalk_user_info.timezone_offset = -new Date().getTimezoneOffset()/60;
170
- cleantalk_user_info.datetime = Math.round((new Date().getTime())/1000);
171
-
172
- cleantalk_user_info.browser_x=document.documentElement.clientWidth;
173
- cleantalk_user_info.browser_y=document.documentElement.clientHeight;
174
-
175
- var ua = navigator.userAgent.toLowerCase();
176
- var flashInstalled = 0;
177
- if (typeof(navigator.plugins)!="undefined"&&typeof(navigator.plugins["Shockwave Flash"])=="object")
178
- {
179
- flashInstalled = 1;
180
- }
181
- else if (typeof window.ActiveXObject != "undefined")
182
- {
183
- try
184
- {
185
- if (new ActiveXObject("ShockwaveFlash.ShockwaveFlash"))
186
- {
187
- flashInstalled = 1;
188
- }
189
- } catch(e) {};
190
- };
191
-
192
- cleantalk_user_info.is_flash=flashInstalled;
193
-
194
- isVisitedMain=-1;
195
- if(location.href=='http://'+location.hostname+'/' || location.href=='https://'+location.hostname+'/')
196
- {
197
- isVisitedMain=1;
198
- setTimeout(function() { document.cookie = "ct_visited_main = 1; path = /;"}, 500);
199
- }
200
-
201
-
202
- ct_visited_main = ct_getCookie('ct_visited_main');
203
- if(ct_visited_main==undefined && isVisitedMain==-1)
204
- {
205
- isVisitedMain=0;
206
- }
207
- else
208
- {
209
- isVisitedMain=1;
210
- }
211
-
212
- cleantalk_user_info.is_main=isVisitedMain;
213
-
214
- setTimeout(function() { document.cookie = "ct_user_info = "+escape(JSON.stringify(cleantalk_user_info))+"; path = /;"}, 500);
215
- }
 
216
  }
1
+ /*
2
+ Assign default values for backend variables.
3
+ */
4
+ if (typeof ctNocache.set_cookies_flag === 'undefined') {
5
+ ctNocache.set_cookies_flag = true;
6
+ }
7
+
8
+ if (typeof ctNocache.ajaxurl === 'undefined') {
9
+ ctNocache.ajaxurl = '/wp-admin/admin-ajax.php';
10
+ }
11
+
12
+ function sendRequest(url,callback,postData) {
13
+ var req = createXMLHTTPObject();
14
+ if (!req) return;
15
+ var method = (postData) ? "POST" : "GET";
16
+
17
+ var protocol = location.protocol;
18
+ if (protocol === 'https:') {
19
+ url = url.replace('http:', 'https:');
20
+ } else {
21
+ url = url.replace('https:', 'http:');
22
+ }
23
+
24
+ req.open(method,url,true);
25
+ if (postData)
26
+ req.setRequestHeader('Content-type','application/x-www-form-urlencoded');
27
+ req.onreadystatechange = function () {
28
+ if (req.readyState != 4) return;
29
+ if (req.status != 200 && req.status != 304) {
30
+ // alert('HTTP error ' + req.status);
31
+ return;
32
+ }
33
+ callback(req);
34
+ };
35
+ if (req.readyState == 4) return;
36
+ req.send(postData);
37
+ }
38
+
39
+ var XMLHttpFactories = [
40
+ function () {return new XMLHttpRequest()},
41
+ function () {return new ActiveXObject("Msxml2.XMLHTTP")},
42
+ function () {return new ActiveXObject("Msxml3.XMLHTTP")},
43
+ function () {return new ActiveXObject("Microsoft.XMLHTTP")}
44
+ ];
45
+
46
+ function createXMLHTTPObject() {
47
+ var xmlhttp = false;
48
+ for (var i=0;i<XMLHttpFactories.length;i++) {
49
+ try {
50
+ xmlhttp = XMLHttpFactories[i]();
51
+ }
52
+ catch (e) {
53
+ continue;
54
+ }
55
+ break;
56
+ }
57
+ return xmlhttp;
58
+ }
59
+
60
+ function ct_getCookie(name) {
61
+ var matches = document.cookie.match(new RegExp(
62
+ "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
63
+ ));
64
+ return matches ? decodeURIComponent(matches[1]) : undefined;
65
+ }
66
+
67
+ function ct_setCookie(name, value)
68
+ {
69
+ if (ctNocache.set_cookies_flag) {
70
+ document.cookie = name+" =; expires=Thu, 01 Jan 1970 00:00:01 GMT; path = /";
71
+ document.cookie = name+" =; expires=Thu, 01 Jan 1970 00:00:01 GMT";
72
+
73
+ var date = new Date;
74
+ date.setDate(date.getDate() + 1);
75
+ setTimeout(function() { document.cookie = name+"=" + value + "; expires=" + date.toUTCString() + "; path = /;"}, 500);
76
+ }
77
+
78
+ return null;
79
+ }
80
+
81
+ function ct_callback(req)
82
+ {
83
+ ct_cookie = req.responseText.trim();
84
+ //alert('Key value: ' + ct_cookie);
85
+
86
+ ct_setCookie('ct_checkjs', ct_cookie);
87
+
88
+ for(i=0;i<document.forms.length;i++)
89
+ {
90
+ f=document.forms[i];
91
+ for(j=0;j<f.elements.length;j++)
92
+ {
93
+ e=f.elements[j];
94
+ if(e.name!==undefined&&e.name.indexOf('ct_checkjs')!=-1)
95
+ {
96
+ e.value=ct_cookie;
97
+ //alert('Form #' + i + ', field ' + e.name + ' = ' + ct_cookie);
98
+ }
99
+ }
100
+ }
101
+
102
+ //alert('Set cookie: \n' + document.cookie);
103
+ }
104
+
105
+ if (!Date.now) {
106
+ Date.now = function() { return new Date().getTime(); }
107
+ }
108
+
109
+ if(ct_nocache_executed==undefined)
110
+ {
111
+ var ct_nocache_executed=true;
112
+ var new_timestamp=Math.floor(Date.now() / 1000);
113
+
114
+ var old_timestamp=ct_getCookie('ct_timestamp');
115
+
116
+ var checkjs_cookie=ct_getCookie('ct_checkjs');
117
+
118
+ if(checkjs_cookie!=undefined)
119
+ {
120
+ for(i=0;i<document.forms.length;i++)
121
+ {
122
+ f=document.forms[i];
123
+ for(j=0;j<f.elements.length;j++)
124
+ {
125
+ e=f.elements[j];
126
+ if(e.name!==undefined&&e.name.indexOf('ct_checkjs')!=-1)
127
+ {
128
+ e.value=checkjs_cookie;
129
+ //alert('Form #' + i + ', field ' + e.name + ' = ' + ct_cookie);
130
+ }
131
+ }
132
+ }
133
+ }
134
+
135
+ if((old_timestamp==undefined||new_timestamp-old_timestamp>86400||checkjs_cookie==undefined)) //86400 is 24 hours
136
+ {
137
+ ct_setCookie('ct_timestamp', new_timestamp);
138
+ sendRequest(ctNocache.ajaxurl+'?'+Math.random(),ct_callback,'action=ct_get_cookie');
139
+ }
140
+
141
+ if(typeof ctNocache.info_flag !== 'undefined' && ctNocache.info_flag)
142
+ {
143
+
144
+ var cleantalk_user_info={};
145
+
146
+ var cleantalk_screen_info={};
147
+ for(var prop in screen)
148
+ {
149
+ if (navigator[prop] instanceof Object || screen[prop]==='')
150
+ continue;
151
+ cleantalk_screen_info[prop]=screen[prop];
152
+ }
153
+
154
+ cleantalk_user_info.screen=cleantalk_screen_info;
155
+
156
+ var cleantalk_plugins=Array();
157
+ var prev;
158
+ var cnt=0;
159
+ for(var i=0;i<navigator.plugins.length;i++)
160
+ {
161
+ var plugin = navigator.plugins[i];
162
+ var plugin = plugin.name+" "+(plugin.version || '')
163
+ if (prev == plugin ) continue;
164
+ cleantalk_plugins[cnt]=plugin;
165
+ cnt++;
166
+ prev = plugin;
167
+ }
168
+ cleantalk_user_info.plugins=cleantalk_plugins;
169
+
170
+ cleantalk_user_info.timezone_offset = -new Date().getTimezoneOffset()/60;
171
+ cleantalk_user_info.datetime = Math.round((new Date().getTime())/1000);
172
+
173
+ cleantalk_user_info.browser_x=document.documentElement.clientWidth;
174
+ cleantalk_user_info.browser_y=document.documentElement.clientHeight;
175
+
176
+ var ua = navigator.userAgent.toLowerCase();
177
+ var flashInstalled = 0;
178
+ if (typeof(navigator.plugins)!="undefined"&&typeof(navigator.plugins["Shockwave Flash"])=="object")
179
+ {
180
+ flashInstalled = 1;
181
+ }
182
+ else if (typeof window.ActiveXObject != "undefined")
183
+ {
184
+ try
185
+ {
186
+ if (new ActiveXObject("ShockwaveFlash.ShockwaveFlash"))
187
+ {
188
+ flashInstalled = 1;
189
+ }
190
+ } catch(e) {};
191
+ };
192
+
193
+ cleantalk_user_info.is_flash=flashInstalled;
194
+
195
+ isVisitedMain=-1;
196
+ if(location.href=='http://'+location.hostname+'/' || location.href=='https://'+location.hostname+'/')
197
+ {
198
+ isVisitedMain=1;
199
+ setTimeout(function() { document.cookie = "ct_visited_main = 1; path = /;"}, 500);
200
+ }
201
+
202
+
203
+ ct_visited_main = ct_getCookie('ct_visited_main');
204
+ if(ct_visited_main==undefined && isVisitedMain==-1)
205
+ {
206
+ isVisitedMain=0;
207
+ }
208
+ else
209
+ {
210
+ isVisitedMain=1;
211
+ }
212
+
213
+ cleantalk_user_info.is_main=isVisitedMain;
214
+
215
+ setTimeout(function() { document.cookie = "ct_user_info = "+escape(JSON.stringify(cleantalk_user_info))+"; path = /;"}, 500);
216
+ }
217
  }
inc/sfw_die_page.html CHANGED
@@ -1,73 +1,73 @@
1
- <!doctype html>
2
-
3
- <html lang='en'>
4
- <head>
5
- <meta charset='utf-8' />
6
- <meta name='viewport' content='width=device-width, initial-scale=1' />
7
- <meta http-equiv='сache-сontrol' content='no-cache'>
8
- <meta http-equiv='сache-сontrol' content='private'>
9
- <meta http-equiv='сache-сontrol' content='max-age=0, must-revalidate'>
10
- <meta http-equiv='сache-сontrol' content='max-age=0, proxy-revalidate'>
11
- <meta http-equiv='expires' content='0' />
12
- <meta http-equiv='expires' content='Tue, 01 Jan 1980 1:00:00 GMT' />
13
- <meta http-equiv='pragma' content='no-cache' />
14
-
15
- <!--[if lt IE 9]>
16
- <script src='http://html5shiv.googlecode.com/svn/trunk/html5.js'></script>
17
- <![endif]-->
18
- <style>
19
- html{font-size: 14pt;}
20
- h1{text-align:center}
21
- h1.main{margin-top: 1em;margin-bottom: 3em;}
22
- div.container {text-align:center;}
23
- div.container p.js_notice{width: 60%; display: inline-block;}
24
- div.footer {color: #666; position: absolute; bottom: 1em; text-align: center; width: 100%;}
25
- div.footer a {color: #666; vertical-align:bottom; text-align: center;}
26
- div#js_passed {display:none;}
27
-
28
- @media (max-width: 600px) {
29
- }
30
- </style>
31
- <script>
32
- var reload_timeout = 3000;
33
- function set_spamFireWallCookie(cookie_name, cookie_value) {
34
- document.cookie = cookie_name + '=' + escape(cookie_value) + '; path=/;{COOKIE_DOMAIN}';
35
- return null;
36
- }
37
- function get_current_url() {
38
- document.write(window.location.href);
39
- return null;
40
- }
41
- </script>
42
- </head>
43
-
44
- <body>
45
- <div class='container'>
46
- <h1 class='main'>{SFW_DIE_NOTICE_IP}<a href='https://cleantalk.org/blacklists/{REMOTE_ADDRESS}' target='_blank'>{REMOTE_ADDRESS}</a></h1>
47
-
48
- <div id='js_info'><br />{SFW_DIE_MAKE_SURE_JS_ENABLED}</div>
49
-
50
- <div id='js_passed'>
51
- <h3>{SFW_DIE_CLICK_TO_PASS}</h3>
52
- <a href='{REQUEST_URI}'><script>get_current_url();</script></a>
53
- {GENERATED}
54
- <br /><br /><br />
55
- <p class='js_notice'>{SFW_DIE_YOU_WILL_BE_REDIRECTED}</p>
56
- </div>
57
- </div>
58
- <div class='footer'>
59
- <a href='https://cleantalk.org' target='_blank'>{CLEANTALK_TITLE}</a>
60
- </div>
61
- <script type='text/javascript'>
62
- document.getElementById('js_info').style.display = 'none';
63
- document.getElementById('js_passed').style.display = 'block';
64
- setTimeout(function(){
65
- set_spamFireWallCookie('{COOKIE_PREFIX}ct_sfw_pass_key','{SFW_COOKIE}');
66
- set_spamFireWallCookie('{COOKIE_PREFIX}ct_sfw_passed','1');
67
- }, 2000);
68
- setTimeout(function(){
69
- window.location.reload(1);
70
- }, reload_timeout);
71
- </script>
72
- </body>
73
- </html>
1
+ <!doctype html>
2
+
3
+ <html lang='en'>
4
+ <head>
5
+ <meta charset='utf-8' />
6
+ <meta name='viewport' content='width=device-width, initial-scale=1' />
7
+ <meta http-equiv='сache-сontrol' content='no-cache'>
8
+ <meta http-equiv='сache-сontrol' content='private'>
9
+ <meta http-equiv='сache-сontrol' content='max-age=0, must-revalidate'>
10
+ <meta http-equiv='сache-сontrol' content='max-age=0, proxy-revalidate'>
11
+ <meta http-equiv='expires' content='0' />
12
+ <meta http-equiv='expires' content='Tue, 01 Jan 1980 1:00:00 GMT' />
13
+ <meta http-equiv='pragma' content='no-cache' />
14
+
15
+ <!--[if lt IE 9]>
16
+ <script src='http://html5shiv.googlecode.com/svn/trunk/html5.js'></script>
17
+ <![endif]-->
18
+ <style>
19
+ html{font-size: 14pt;}
20
+ h1{text-align:center}
21
+ h1.main{margin-top: 1em;margin-bottom: 3em;}
22
+ div.container {text-align:center;}
23
+ div.container p.js_notice{width: 60%; display: inline-block;}
24
+ div.footer {color: #666; position: absolute; bottom: 1em; text-align: center; width: 100%;}
25
+ div.footer a {color: #666; vertical-align:bottom; text-align: center;}
26
+ div#js_passed {display:none;}
27
+
28
+ @media (max-width: 600px) {
29
+ }
30
+ </style>
31
+ <script>
32
+ var reload_timeout = 3000;
33
+ function set_spamFireWallCookie(cookie_name, cookie_value) {
34
+ document.cookie = cookie_name + '=' + escape(cookie_value) + '; path=/;{COOKIE_DOMAIN}';
35
+ return null;
36
+ }
37
+ function get_current_url() {
38
+ document.write(window.location.href);
39
+ return null;
40
+ }
41
+ </script>
42
+ </head>
43
+
44
+ <body>
45
+ <div class='container'>
46
+ <h1 class='main'>{SFW_DIE_NOTICE_IP}<a href='https://cleantalk.org/blacklists/{REMOTE_ADDRESS}' target='_blank'>{REMOTE_ADDRESS}</a></h1>
47
+
48
+ <div id='js_info'><br />{SFW_DIE_MAKE_SURE_JS_ENABLED}</div>
49
+
50
+ <div id='js_passed'>
51
+ <h3>{SFW_DIE_CLICK_TO_PASS}</h3>
52
+ <a href='{REQUEST_URI}'><script>get_current_url();</script></a>
53
+ {GENERATED}
54
+ <br /><br /><br />
55
+ <p class='js_notice'>{SFW_DIE_YOU_WILL_BE_REDIRECTED}</p>
56
+ </div>
57
+ </div>
58
+ <div class='footer'>
59
+ <a href='https://cleantalk.org' target='_blank'>{CLEANTALK_TITLE}</a>
60
+ </div>
61
+ <script type='text/javascript'>
62
+ document.getElementById('js_info').style.display = 'none';
63
+ document.getElementById('js_passed').style.display = 'block';
64
+ setTimeout(function(){
65
+ set_spamFireWallCookie('{COOKIE_PREFIX}ct_sfw_pass_key','{SFW_COOKIE}');
66
+ set_spamFireWallCookie('{COOKIE_PREFIX}ct_sfw_passed','1');
67
+ }, 2000);
68
+ setTimeout(function(){
69
+ window.location.reload(1);
70
+ }, reload_timeout);
71
+ </script>
72
+ </body>
73
+ </html>
lib/CleantalkCron.php CHANGED
@@ -5,8 +5,6 @@
5
  * Version 1.0
6
  */
7
 
8
- namespace cleantalk\antispam;
9
-
10
  class CleantalkCron
11
  {
12
  public $tasks = array(); // Array with tasks
5
  * Version 1.0
6
  */
7
 
 
 
8
  class CleantalkCron
9
  {
10
  public $tasks = array(); // Array with tasks
lib/CleantalkSFW.php CHANGED
@@ -6,8 +6,6 @@
6
  * Compatible only with Wordpress.
7
  */
8
 
9
- namespace cleantalk\antispam;
10
-
11
  class CleantalkSFW
12
  {
13
  public $ip = 0;
6
  * Compatible only with Wordpress.
7
  */
8
 
 
 
9
  class CleantalkSFW
10
  {
11
  public $ip = 0;
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: znaeff, shagimuratov, serge00, sartemd174, amagsumov
3
  Tags: antispam, protection, contact form, comments, spam
4
  Requires at least: 3.0
5
  Tested up to: 4.8
6
- Stable tag: 5.70.2
7
  License: GPLv2
8
 
9
  Spam protection, antispam, all-in-one, premium plugin. No spam comments & users, no spam contact form & WooCommerce spam. Forget spam.
@@ -504,6 +504,11 @@ We develop plugin to do it as optimized as possible, CleanTalk doesn't downgrade
504
  1. The Dashboard with a map of most spam active countries per your account.
505
 
506
  == Changelog ==
 
 
 
 
 
507
  = 5.70.2 July 17 2017 =
508
  * Fix for SpamFireWall for Multisite.
509
 
@@ -1399,6 +1404,11 @@ We develop plugin to do it as optimized as possible, CleanTalk doesn't downgrade
1399
  * First version
1400
 
1401
  == Upgrade Notice ==
 
 
 
 
 
1402
  = 5.70.2 July 17 2017 =
1403
  * Fix for SpamFireWall for Multisite.
1404
 
3
  Tags: antispam, protection, contact form, comments, spam
4
  Requires at least: 3.0
5
  Tested up to: 4.8
6
+ Stable tag: 5.71
7
  License: GPLv2
8
 
9
  Spam protection, antispam, all-in-one, premium plugin. No spam comments & users, no spam contact form & WooCommerce spam. Forget spam.
504
  1. The Dashboard with a map of most spam active countries per your account.
505
 
506
  == Changelog ==
507
+ = 5.71 July 20 2017 =
508
+ * Improved spam protection for external forms.
509
+ * Optimization.
510
+ * Minor fixes.
511
+
512
  = 5.70.2 July 17 2017 =
513
  * Fix for SpamFireWall for Multisite.
514
 
1404
  * First version
1405
 
1406
  == Upgrade Notice ==
1407
+ = 5.71 July 20 2017 =
1408
+ * Improved spam protection for external forms.
1409
+ * Optimization.
1410
+ * Minor fixes.
1411
+
1412
  = 5.70.2 July 17 2017 =
1413
  * Fix for SpamFireWall for Multisite.
1414