Spam protection, AntiSpam, FireWall by CleanTalk - Version 2.50-profiling

Version Description

Download this release

Release Info

Developer shagimuratov
Plugin Icon 128x128 Spam protection, AntiSpam, FireWall by CleanTalk
Version 2.50-profiling
Comparing to
See all releases

Code changes from version 2.46 to 2.50-profiling

Files changed (3) hide show
  1. cleantalk-admin.php +52 -15
  2. cleantalk.php +149 -13
  3. readme.txt +18 -6
cleantalk-admin.php CHANGED
@@ -7,6 +7,7 @@ $ct_plugin_basename = 'cleantalk-spam-protect/cleantalk.php';
7
  * @param string $hook URL of hooked page
8
  */
9
  function ct_enqueue_scripts($hook) {
 
10
  if ($hook == 'edit-comments.php')
11
  wp_enqueue_script('ct_reload_script', plugins_url('/cleantalk-rel.js', __FILE__));
12
  }
@@ -15,6 +16,7 @@ function ct_enqueue_scripts($hook) {
15
  * Admin action 'admin_menu' - Add the admin options page
16
  */
17
  function ct_admin_add_page() {
 
18
  add_options_page(__('CleanTalk settings', 'cleantalk'), '<b style="color: #49C73B;">Clean</b><b style="color: #349ebf;">Talk</b>', 'manage_options', 'cleantalk', 'ct_settings_page');
19
  }
20
 
@@ -22,17 +24,26 @@ function ct_admin_add_page() {
22
  * Admin action 'admin_init' - Add the admin settings and such
23
  */
24
  function ct_admin_init() {
25
- global $show_ct_notice_trial, $ct_notice_trial_label, $show_ct_notice_online, $ct_notice_online_label, $trial_notice_check_timeout;
26
-
 
27
  $show_ct_notice_trial = false;
28
  if (isset($_COOKIE[$ct_notice_trial_label])) {
29
  if ($_COOKIE[$ct_notice_trial_label] == 1)
30
  $show_ct_notice_trial = true;
31
  } else {
 
 
 
 
 
 
 
32
  $options = ct_get_options();
33
- if (function_exists('curl_init') && function_exists('json_decode') && ct_valid_key($options['apikey'])) {
 
34
  $url = 'https://cleantalk.org/app_notice';
35
- $server_timeout = 1;
36
  $data['auth_key'] = $options['apikey'];
37
  $data['param'] = 'notice_paid_till';
38
 
@@ -62,8 +73,10 @@ function ct_admin_init() {
62
  }
63
  }
64
  }
65
-
66
- setcookie($ct_notice_trial_label, (int) $show_ct_notice_trial, strtotime("+$trial_notice_check_timeout minutes"), '/');
 
 
67
  }
68
 
69
  $show_ct_notice_online = '';
@@ -74,17 +87,20 @@ function ct_admin_init() {
74
  $show_ct_notice_online = 'N';
75
  }
76
  }
 
77
 
78
  ct_init_session();
79
 
80
  register_setting('cleantalk_settings', 'cleantalk_settings', 'ct_settings_validate');
81
- add_settings_section('cleantalk_settings_main', __('Anti-spam by CleanTalk', 'cleantalk'), 'ct_section_settings_main', 'cleantalk');
82
  add_settings_section('cleantalk_settings_anti_spam', __('Anti-spam settings', 'cleantalk'), 'ct_section_settings_anti_spam', 'cleantalk');
83
  add_settings_field('cleantalk_apikey', __('Access key', 'cleantalk'), 'ct_input_apikey', 'cleantalk', 'cleantalk_settings_main');
84
  add_settings_field('cleantalk_autoPubRevelantMess', __('Publish relevant comments', 'cleantalk'), 'ct_input_autoPubRevelantMess', 'cleantalk', 'cleantalk_settings_main');
85
  add_settings_field('cleantalk_registrations_test', __('Registration forms', 'cleantalk'), 'ct_input_registrations_test', 'cleantalk', 'cleantalk_settings_anti_spam');
86
  add_settings_field('cleantalk_comments_test', __('Comments form', 'cleantalk'), 'ct_input_comments_test', 'cleantalk', 'cleantalk_settings_anti_spam');
87
  add_settings_field('cleantalk_contact_forms_test', __('Contact forms', 'cleantalk'), 'ct_input_contact_forms_test', 'cleantalk', 'cleantalk_settings_anti_spam');
 
 
88
  }
89
 
90
  /**
@@ -108,6 +124,7 @@ function ct_section_settings_anti_spam() {
108
  * @return null
109
  */
110
  function ct_input_autoPubRevelantMess () {
 
111
  $options = ct_get_options();
112
  $value = $options['autoPubRevelantMess'];
113
  echo "<input type='radio' id='cleantalk_autoPubRevelantMess1' name='cleantalk_settings[autoPubRevelantMess]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_autoPubRevelantMess1'> " . __('Yes') . "</label>";
@@ -122,6 +139,7 @@ function ct_input_autoPubRevelantMess () {
122
  * @return null
123
  */
124
  function ct_input_remove_old_spam() {
 
125
  $options = ct_get_options();
126
  $value = $options['remove_old_spam'];
127
  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>";
@@ -134,6 +152,7 @@ function ct_input_remove_old_spam() {
134
  * Admin callback function - Displays inputs of 'apikey' plugin parameter
135
  */
136
  function ct_input_apikey() {
 
137
  $options = ct_get_options();
138
  $value = $options['apikey'];
139
 
@@ -148,6 +167,7 @@ function ct_input_apikey() {
148
  * Admin callback function - Displays inputs of 'comments_test' plugin parameter
149
  */
150
  function ct_input_comments_test() {
 
151
  $options = ct_get_options();
152
  $value = $options['comments_test'];
153
  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>";
@@ -160,6 +180,7 @@ function ct_input_comments_test() {
160
  * Admin callback function - Displays inputs of 'comments_test' plugin parameter
161
  */
162
  function ct_input_registrations_test() {
 
163
  $options = ct_get_options();
164
  $value = $options['registrations_test'];
165
  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>";
@@ -172,6 +193,7 @@ function ct_input_registrations_test() {
172
  * Admin callback function - Displays inputs of 'contact_forms_test' plugin parameter
173
  */
174
  function ct_input_contact_forms_test() {
 
175
  $options = ct_get_options();
176
  $value = $options['contact_forms_test'];
177
  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>";
@@ -184,6 +206,7 @@ function ct_input_contact_forms_test() {
184
  * Admin callback function - Plugin parameters validator
185
  */
186
  function ct_settings_validate($input) {
 
187
  return $input;
188
  }
189
 
@@ -192,6 +215,7 @@ function ct_settings_validate($input) {
192
  * Admin callback function - Displays plugin options page
193
  */
194
  function ct_settings_page() {
 
195
  ?>
196
  <style type="text/css">
197
  input[type=submit] {padding: 10px; background: #3399FF; color: #fff; border:0 none;
@@ -229,17 +253,23 @@ input[type=submit] {padding: 10px; background: #3399FF; color: #fff; border:0 no
229
  * @return bool
230
  */
231
  function admin_notice_message(){
232
- global $show_ct_notice_trial, $show_ct_notice_online;
 
233
 
234
  if (ct_active() === false)
235
  return false;
236
-
237
  $options = ct_get_options();
238
  $show_notice = true;
239
  if ($show_notice && ct_valid_key($options['apikey']) === false) {
240
  echo '<div class="updated"><h3>' . __("Please enter the Access Key in <a href=\"options-general.php?page=cleantalk\">CleanTalk plugin</a> settings to enable protection from spam!", 'cleantalk') . '</h3></div>';
241
  }
242
 
 
 
 
 
 
243
  if ($show_notice && !empty($show_ct_notice_online)) {
244
  echo '<div class="updated"><h3><b>';
245
  if($show_ct_notice_online === 'Y'){
@@ -250,11 +280,6 @@ function admin_notice_message(){
250
  echo '</b></h3></div>';
251
  }
252
 
253
- if ($show_notice && $show_ct_notice_trial) {
254
- echo '<div class="updated"><h3>' . __("CleanTalk anti-spam trial period will end soon, please upgrade to <a href=\"http://cleantalk.org/my\" target=\"_blank\"><b>premium version</b></a>!", 'cleantalk') . '</h3></div>';
255
- $show_notice = false;
256
- }
257
-
258
  ct_send_feedback();
259
 
260
  delete_spam_comments();
@@ -268,6 +293,7 @@ function admin_notice_message(){
268
  * Add descriptions for field
269
  */
270
  function admin_addDescriptionsFields($descr = '') {
 
271
  echo "<div style='color: #666 !important'>$descr</div>";
272
  }
273
 
@@ -275,6 +301,7 @@ function admin_addDescriptionsFields($descr = '') {
275
  * Test API key
276
  */
277
  function ct_valid_key($apikey = null) {
 
278
  if ($apikey === null) {
279
  $options = ct_get_options();
280
  $apikey = $options['apikey'];
@@ -289,6 +316,7 @@ function ct_valid_key($apikey = null) {
289
  * @return boolean TRUE
290
  */
291
  function ct_comment_approved($comment_object) {
 
292
  $comment = get_comment($comment_object->comment_ID, 'ARRAY_A');
293
  $hash = get_comment_meta($comment_object->comment_ID, 'ct_hash', true);
294
  $comment['comment_content'] = ct_unmark_red($comment['comment_content']);
@@ -305,6 +333,7 @@ function ct_comment_approved($comment_object) {
305
  * @return boolean TRUE
306
  */
307
  function ct_comment_unapproved($comment_object) {
 
308
  $comment = get_comment($comment_object->comment_ID, 'ARRAY_A');
309
  $hash = get_comment_meta($comment_object->comment_ID, 'ct_hash', true);
310
  ct_feedback($hash, $comment['comment_content'], 0);
@@ -320,6 +349,7 @@ function ct_comment_unapproved($comment_object) {
320
  * @return boolean TRUE
321
  */
322
  function ct_comment_spam($comment_object) {
 
323
  $comment = get_comment($comment_object->comment_ID, 'ARRAY_A');
324
  $hash = get_comment_meta($comment_object->comment_ID, 'ct_hash', true);
325
  ct_feedback($hash, $comment['comment_content'], 0);
@@ -335,6 +365,7 @@ function ct_comment_spam($comment_object) {
335
  * @param type $comment_id
336
  */
337
  function ct_unspam_comment($comment_id) {
 
338
  update_comment_meta($comment_id, '_wp_trash_meta_status', 1);
339
  $comment = get_comment($comment_id, 'ARRAY_A');
340
  $hash = get_comment_meta($comment_id, 'ct_hash', true);
@@ -350,6 +381,7 @@ function ct_unspam_comment($comment_id) {
350
  * @return string New comment text
351
  */
352
  function ct_get_comment_text($current_text) {
 
353
  global $comment;
354
  $new_text = $current_text;
355
  if (isset($comment) && is_object($comment)) {
@@ -366,6 +398,7 @@ function ct_get_comment_text($current_text) {
366
  * @return null
367
  */
368
  function ct_delete_user($user_id) {
 
369
  $hash = get_user_meta($user_id, 'ct_hash', true);
370
  if ($hash !== '') {
371
  ct_feedback($hash, null, 0);
@@ -378,6 +411,7 @@ function ct_delete_user($user_id) {
378
  */
379
  if (!function_exists ( 'ct_register_plugin_links')) {
380
  function ct_register_plugin_links($links, $file) {
 
381
  global $ct_plugin_basename;
382
 
383
  if ($file == $ct_plugin_basename) {
@@ -395,6 +429,7 @@ if (!function_exists ( 'ct_register_plugin_links')) {
395
  */
396
  if (!function_exists ( 'ct_plugin_action_links')) {
397
  function ct_plugin_action_links($links, $file) {
 
398
  global $ct_plugin_basename;
399
 
400
  if ($file == $ct_plugin_basename) {
@@ -410,7 +445,8 @@ if (!function_exists ( 'ct_plugin_action_links')) {
410
  * @return array
411
  */
412
  function ct_update_option($option_name) {
413
- global $show_ct_notice_online, $ct_notice_online_label;
 
414
  if($option_name !== 'cleantalk_settings')
415
  return;
416
  $ct_base_call_result = ct_base_call(array(
@@ -428,6 +464,7 @@ function ct_update_option($option_name) {
428
  setcookie($ct_notice_online_label, 0, null, '/');
429
  }else{
430
  setcookie($ct_notice_online_label, 1, strtotime("+5 seconds"), '/');
 
431
  }
432
  }
433
 
7
  * @param string $hook URL of hooked page
8
  */
9
  function ct_enqueue_scripts($hook) {
10
+ ct_profiler(__FILE__, __LINE__);
11
  if ($hook == 'edit-comments.php')
12
  wp_enqueue_script('ct_reload_script', plugins_url('/cleantalk-rel.js', __FILE__));
13
  }
16
  * Admin action 'admin_menu' - Add the admin options page
17
  */
18
  function ct_admin_add_page() {
19
+ ct_profiler(__FILE__, __LINE__);
20
  add_options_page(__('CleanTalk settings', 'cleantalk'), '<b style="color: #49C73B;">Clean</b><b style="color: #349ebf;">Talk</b>', 'manage_options', 'cleantalk', 'ct_settings_page');
21
  }
22
 
24
  * Admin action 'admin_init' - Add the admin settings and such
25
  */
26
  function ct_admin_init() {
27
+ ct_profiler(__FILE__, __LINE__);
28
+ global $show_ct_notice_trial, $ct_notice_trial_label, $show_ct_notice_online, $ct_notice_online_label, $trial_notice_check_timeout, $pagenow, $ct_plugin_name;
29
+
30
  $show_ct_notice_trial = false;
31
  if (isset($_COOKIE[$ct_notice_trial_label])) {
32
  if ($_COOKIE[$ct_notice_trial_label] == 1)
33
  $show_ct_notice_trial = true;
34
  } else {
35
+ // Run function only on special pages
36
+ $working_pages = array("plugins.php", "options-general.php");
37
+ $do_request = false;
38
+ if (in_array($pagenow, $working_pages)) {
39
+ $do_request = true;
40
+ }
41
+
42
  $options = ct_get_options();
43
+ $result = false;
44
+ if (function_exists('curl_init') && function_exists('json_decode') && ct_valid_key($options['apikey']) && $do_request) {
45
  $url = 'https://cleantalk.org/app_notice';
46
+ $server_timeout = 2;
47
  $data['auth_key'] = $options['apikey'];
48
  $data['param'] = 'notice_paid_till';
49
 
73
  }
74
  }
75
  }
76
+
77
+ if ($result) {
78
+ setcookie($ct_notice_trial_label, (int) $show_ct_notice_trial, strtotime("+$trial_notice_check_timeout minutes"), '/');
79
+ }
80
  }
81
 
82
  $show_ct_notice_online = '';
87
  $show_ct_notice_online = 'N';
88
  }
89
  }
90
+ ct_profiler(__FILE__, __LINE__);
91
 
92
  ct_init_session();
93
 
94
  register_setting('cleantalk_settings', 'cleantalk_settings', 'ct_settings_validate');
95
+ add_settings_section('cleantalk_settings_main', __($ct_plugin_name, 'cleantalk'), 'ct_section_settings_main', 'cleantalk');
96
  add_settings_section('cleantalk_settings_anti_spam', __('Anti-spam settings', 'cleantalk'), 'ct_section_settings_anti_spam', 'cleantalk');
97
  add_settings_field('cleantalk_apikey', __('Access key', 'cleantalk'), 'ct_input_apikey', 'cleantalk', 'cleantalk_settings_main');
98
  add_settings_field('cleantalk_autoPubRevelantMess', __('Publish relevant comments', 'cleantalk'), 'ct_input_autoPubRevelantMess', 'cleantalk', 'cleantalk_settings_main');
99
  add_settings_field('cleantalk_registrations_test', __('Registration forms', 'cleantalk'), 'ct_input_registrations_test', 'cleantalk', 'cleantalk_settings_anti_spam');
100
  add_settings_field('cleantalk_comments_test', __('Comments form', 'cleantalk'), 'ct_input_comments_test', 'cleantalk', 'cleantalk_settings_anti_spam');
101
  add_settings_field('cleantalk_contact_forms_test', __('Contact forms', 'cleantalk'), 'ct_input_contact_forms_test', 'cleantalk', 'cleantalk_settings_anti_spam');
102
+
103
+ ct_profiler(__FILE__, __LINE__);
104
  }
105
 
106
  /**
124
  * @return null
125
  */
126
  function ct_input_autoPubRevelantMess () {
127
+ ct_profiler(__FILE__, __LINE__);
128
  $options = ct_get_options();
129
  $value = $options['autoPubRevelantMess'];
130
  echo "<input type='radio' id='cleantalk_autoPubRevelantMess1' name='cleantalk_settings[autoPubRevelantMess]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_autoPubRevelantMess1'> " . __('Yes') . "</label>";
139
  * @return null
140
  */
141
  function ct_input_remove_old_spam() {
142
+ ct_profiler(__FILE__, __LINE__);
143
  $options = ct_get_options();
144
  $value = $options['remove_old_spam'];
145
  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>";
152
  * Admin callback function - Displays inputs of 'apikey' plugin parameter
153
  */
154
  function ct_input_apikey() {
155
+ ct_profiler(__FILE__, __LINE__);
156
  $options = ct_get_options();
157
  $value = $options['apikey'];
158
 
167
  * Admin callback function - Displays inputs of 'comments_test' plugin parameter
168
  */
169
  function ct_input_comments_test() {
170
+ ct_profiler(__FILE__, __LINE__);
171
  $options = ct_get_options();
172
  $value = $options['comments_test'];
173
  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>";
180
  * Admin callback function - Displays inputs of 'comments_test' plugin parameter
181
  */
182
  function ct_input_registrations_test() {
183
+ ct_profiler(__FILE__, __LINE__);
184
  $options = ct_get_options();
185
  $value = $options['registrations_test'];
186
  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>";
193
  * Admin callback function - Displays inputs of 'contact_forms_test' plugin parameter
194
  */
195
  function ct_input_contact_forms_test() {
196
+ ct_profiler(__FILE__, __LINE__);
197
  $options = ct_get_options();
198
  $value = $options['contact_forms_test'];
199
  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>";
206
  * Admin callback function - Plugin parameters validator
207
  */
208
  function ct_settings_validate($input) {
209
+ ct_profiler(__FILE__, __LINE__);
210
  return $input;
211
  }
212
 
215
  * Admin callback function - Displays plugin options page
216
  */
217
  function ct_settings_page() {
218
+ ct_profiler(__FILE__, __LINE__);
219
  ?>
220
  <style type="text/css">
221
  input[type=submit] {padding: 10px; background: #3399FF; color: #fff; border:0 none;
253
  * @return bool
254
  */
255
  function admin_notice_message(){
256
+ ct_profiler(__FILE__, __LINE__);
257
+ global $show_ct_notice_trial, $show_ct_notice_online, $ct_plugin_name;
258
 
259
  if (ct_active() === false)
260
  return false;
261
+
262
  $options = ct_get_options();
263
  $show_notice = true;
264
  if ($show_notice && ct_valid_key($options['apikey']) === false) {
265
  echo '<div class="updated"><h3>' . __("Please enter the Access Key in <a href=\"options-general.php?page=cleantalk\">CleanTalk plugin</a> settings to enable protection from spam!", 'cleantalk') . '</h3></div>';
266
  }
267
 
268
+ if ($show_notice && $show_ct_notice_trial) {
269
+ echo '<div class="updated"><h3>' . __("<a href=\"options-general.php?page=cleantalk\">$ct_plugin_name</a> trial period will end soon, please upgrade to <a href=\"http://cleantalk.org/my\" target=\"_blank\"><b>premium version</b></a>!", 'cleantalk') . '</h3></div>';
270
+ $show_notice = false;
271
+ }
272
+
273
  if ($show_notice && !empty($show_ct_notice_online)) {
274
  echo '<div class="updated"><h3><b>';
275
  if($show_ct_notice_online === 'Y'){
280
  echo '</b></h3></div>';
281
  }
282
 
 
 
 
 
 
283
  ct_send_feedback();
284
 
285
  delete_spam_comments();
293
  * Add descriptions for field
294
  */
295
  function admin_addDescriptionsFields($descr = '') {
296
+ ct_profiler(__FILE__, __LINE__);
297
  echo "<div style='color: #666 !important'>$descr</div>";
298
  }
299
 
301
  * Test API key
302
  */
303
  function ct_valid_key($apikey = null) {
304
+ ct_profiler(__FILE__, __LINE__);
305
  if ($apikey === null) {
306
  $options = ct_get_options();
307
  $apikey = $options['apikey'];
316
  * @return boolean TRUE
317
  */
318
  function ct_comment_approved($comment_object) {
319
+ ct_profiler(__FILE__, __LINE__);
320
  $comment = get_comment($comment_object->comment_ID, 'ARRAY_A');
321
  $hash = get_comment_meta($comment_object->comment_ID, 'ct_hash', true);
322
  $comment['comment_content'] = ct_unmark_red($comment['comment_content']);
333
  * @return boolean TRUE
334
  */
335
  function ct_comment_unapproved($comment_object) {
336
+ ct_profiler(__FILE__, __LINE__);
337
  $comment = get_comment($comment_object->comment_ID, 'ARRAY_A');
338
  $hash = get_comment_meta($comment_object->comment_ID, 'ct_hash', true);
339
  ct_feedback($hash, $comment['comment_content'], 0);
349
  * @return boolean TRUE
350
  */
351
  function ct_comment_spam($comment_object) {
352
+ ct_profiler(__FILE__, __LINE__);
353
  $comment = get_comment($comment_object->comment_ID, 'ARRAY_A');
354
  $hash = get_comment_meta($comment_object->comment_ID, 'ct_hash', true);
355
  ct_feedback($hash, $comment['comment_content'], 0);
365
  * @param type $comment_id
366
  */
367
  function ct_unspam_comment($comment_id) {
368
+ ct_profiler(__FILE__, __LINE__);
369
  update_comment_meta($comment_id, '_wp_trash_meta_status', 1);
370
  $comment = get_comment($comment_id, 'ARRAY_A');
371
  $hash = get_comment_meta($comment_id, 'ct_hash', true);
381
  * @return string New comment text
382
  */
383
  function ct_get_comment_text($current_text) {
384
+ ct_profiler(__FILE__, __LINE__);
385
  global $comment;
386
  $new_text = $current_text;
387
  if (isset($comment) && is_object($comment)) {
398
  * @return null
399
  */
400
  function ct_delete_user($user_id) {
401
+ ct_profiler(__FILE__, __LINE__);
402
  $hash = get_user_meta($user_id, 'ct_hash', true);
403
  if ($hash !== '') {
404
  ct_feedback($hash, null, 0);
411
  */
412
  if (!function_exists ( 'ct_register_plugin_links')) {
413
  function ct_register_plugin_links($links, $file) {
414
+ ct_profiler(__FILE__, __LINE__);
415
  global $ct_plugin_basename;
416
 
417
  if ($file == $ct_plugin_basename) {
429
  */
430
  if (!function_exists ( 'ct_plugin_action_links')) {
431
  function ct_plugin_action_links($links, $file) {
432
+ ct_profiler(__FILE__, __LINE__);
433
  global $ct_plugin_basename;
434
 
435
  if ($file == $ct_plugin_basename) {
445
  * @return array
446
  */
447
  function ct_update_option($option_name) {
448
+ ct_profiler(__FILE__, __LINE__);
449
+ global $show_ct_notice_online, $ct_notice_online_label, $ct_notice_trial_label, $trial_notice_check_timeout;
450
  if($option_name !== 'cleantalk_settings')
451
  return;
452
  $ct_base_call_result = ct_base_call(array(
464
  setcookie($ct_notice_online_label, 0, null, '/');
465
  }else{
466
  setcookie($ct_notice_online_label, 1, strtotime("+5 seconds"), '/');
467
+ setcookie($ct_notice_trial_label, (int) 0, strtotime("+$trial_notice_check_timeout minutes"), '/');
468
  }
469
  }
470
 
cleantalk.php CHANGED
@@ -1,16 +1,16 @@
1
  <?php
2
  /*
3
- Plugin Name: Anti-spam by CleanTalk
4
  Plugin URI: http://cleantalk.org
5
  Description: Cloud antispam for comments, registrations and contacts. The plugin doesn't use CAPTCHA, Q&A, math, counting animals or quiz to stop spam bots.
6
- Version: 2.46
7
  Author: СleanTalk <welcome@cleantalk.ru>
8
  Author URI: http://cleantalk.org
9
  */
10
 
11
  define('CLEANTALK_PLUGIN_DIR', plugin_dir_path(__FILE__));
12
 
13
- $ct_agent_version = 'wordpress-246';
14
  $ct_plugin_name = 'Anti-spam by CleanTalk';
15
  $ct_checkjs_frm = 'ct_checkjs_frm';
16
  $ct_checkjs_register_form = 'ct_checkjs_register_form';
@@ -27,6 +27,9 @@ $ct_jpcf_fields = array('name', 'email');
27
  // Comment already proccessed
28
  $ct_comment_done = false;
29
 
 
 
 
30
  // Default value for JS test
31
  $ct_checkjs_def = 0;
32
 
@@ -57,11 +60,23 @@ $ct_wplp_result_label = 'ct_wplp_result';
57
  // Flag indicates active JetPack comments
58
  $ct_jp_comments = false;
59
 
60
- // S2member post data label
61
  $ct_post_data_label = 's2member_pro_paypal_registration';
62
 
 
 
 
63
  // Form time load label
64
- $ct_formtime_label = 'formtime';
 
 
 
 
 
 
 
 
 
65
 
66
  // Init action.
67
  add_action('init', 'ct_init', 1);
@@ -82,6 +97,10 @@ add_action('register_form','ct_register_form');
82
  add_filter('registration_errors', 'ct_registration_errors', 10, 3);
83
  add_action('user_register', 'ct_user_register');
84
 
 
 
 
 
85
  // BuddyPress
86
  add_action('bp_before_registration_submit_buttons','ct_register_form');
87
  add_filter('bp_signup_validate', 'ct_registration_errors');
@@ -100,8 +119,8 @@ add_filter('si_contact_form_validate', 'ct_si_contact_form_validate');
100
 
101
  // Login form - for notifications only
102
  add_filter('login_message', 'ct_login_message');
103
-
104
- if (is_admin()) {
105
  require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-admin.php');
106
 
107
  add_action('admin_init', 'ct_admin_init', 1);
@@ -125,7 +144,7 @@ if (is_admin()) {
125
  * @return mixed[] Array of options
126
  */
127
  function ct_init() {
128
- global $ct_wplp_result_label, $ct_jp_comments, $ct_post_data_label;
129
 
130
  ct_init_session();
131
 
@@ -155,9 +174,18 @@ function ct_init() {
155
  }
156
 
157
  // intercept S2member POST
158
- if (defined('WS_PLUGIN__S2MEMBER_PRO_VERSION') && isset($_POST[$ct_post_data_label]['email'])){
159
  ct_s2member_registration_test();
160
  }
 
 
 
 
 
 
 
 
 
161
  }
162
 
163
  /**
@@ -185,7 +213,7 @@ function ct_get_options() {
185
  function ct_def_options() {
186
  $lang = get_bloginfo('language');
187
  return array(
188
- 'server' => 'http://moderate.cleantalk.ru',
189
  'apikey' => __('enter key', 'cleantalk'),
190
  'autoPubRevelantMess' => '1',
191
  'registrations_test' => '1',
@@ -959,13 +987,63 @@ function ct_login_message($message) {
959
  return $message;
960
  }
961
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
962
  /**
963
  * Test users registration
964
  * @return array with errors
965
  */
966
  function ct_registration_errors($errors, $sanitized_user_login = null, $user_email = null) {
967
- global $ct_agent_version, $ct_checkjs_register_form, $ct_session_request_id_label, $ct_session_register_ok_label, $bp;
968
-
 
 
 
 
 
 
 
 
 
969
  //
970
  // BuddyPress actions
971
  //
@@ -1031,6 +1109,8 @@ function ct_registration_errors($errors, $sanitized_user_login = null, $user_ema
1031
  )
1032
  );
1033
  }
 
 
1034
 
1035
  if ($ct_result->errno != 0) {
1036
  return $errors;
@@ -1405,7 +1485,7 @@ function ct_check_wplp(){
1405
  * @return array with errors
1406
  */
1407
  function ct_s2member_registration_test() {
1408
- global $ct_agent_version, $ct_post_data_label;
1409
 
1410
  $options = ct_get_options();
1411
  if ($options['registrations_test'] == 0) {
@@ -1431,10 +1511,16 @@ function ct_s2member_registration_test() {
1431
  $sender_email = null;
1432
  if (isset($_POST[$ct_post_data_label]['email']))
1433
  $sender_email = $_POST[$ct_post_data_label]['email'];
 
 
 
1434
 
1435
  $sender_nickname = null;
1436
  if (isset($_POST[$ct_post_data_label]['username']))
1437
  $sender_nickname = $_POST[$ct_post_data_label]['username'];
 
 
 
1438
 
1439
  $config = get_option('cleantalk_server');
1440
 
@@ -1476,4 +1562,54 @@ function ct_s2member_registration_test() {
1476
  return true;
1477
  }
1478
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1479
  ?>
1
  <?php
2
  /*
3
+ Plugin Name: Anti-spam by CleanTalk
4
  Plugin URI: http://cleantalk.org
5
  Description: Cloud antispam for comments, registrations and contacts. The plugin doesn't use CAPTCHA, Q&A, math, counting animals or quiz to stop spam bots.
6
+ Version: 2.50
7
  Author: СleanTalk <welcome@cleantalk.ru>
8
  Author URI: http://cleantalk.org
9
  */
10
 
11
  define('CLEANTALK_PLUGIN_DIR', plugin_dir_path(__FILE__));
12
 
13
+ $ct_agent_version = 'wordpress-250';
14
  $ct_plugin_name = 'Anti-spam by CleanTalk';
15
  $ct_checkjs_frm = 'ct_checkjs_frm';
16
  $ct_checkjs_register_form = 'ct_checkjs_register_form';
27
  // Comment already proccessed
28
  $ct_comment_done = false;
29
 
30
+ // Comment already proccessed
31
+ $ct_signup_done = false;
32
+
33
  // Default value for JS test
34
  $ct_checkjs_def = 0;
35
 
60
  // Flag indicates active JetPack comments
61
  $ct_jp_comments = false;
62
 
63
+ // S2member PayPal post data label
64
  $ct_post_data_label = 's2member_pro_paypal_registration';
65
 
66
+ // S2member Auth.Net post data label
67
+ $ct_post_data_authnet_label = 's2member_pro_authnet_registration';
68
+
69
  // Form time load label
70
+ $ct_formtime_label = 'formtime';
71
+
72
+ // Profiler proccess ID
73
+ $ct_profiler_proccess_id = null;
74
+
75
+ // Profiler last execution time
76
+ $ct_profiler_last_run = null;
77
+
78
+ // Enable code profiler
79
+ $ct_enable_profiler = true;
80
 
81
  // Init action.
82
  add_action('init', 'ct_init', 1);
97
  add_filter('registration_errors', 'ct_registration_errors', 10, 3);
98
  add_action('user_register', 'ct_user_register');
99
 
100
+ // Multisite registrations
101
+ add_action('signup_extra_fields','ct_register_form');
102
+ add_filter('wpmu_validate_user_signup', 'ct_registration_errors_wpmu', 10, 3);
103
+
104
  // BuddyPress
105
  add_action('bp_before_registration_submit_buttons','ct_register_form');
106
  add_filter('bp_signup_validate', 'ct_registration_errors');
119
 
120
  // Login form - for notifications only
121
  add_filter('login_message', 'ct_login_message');
122
+
123
+ if (is_admin() && !(defined( 'DOING_AJAX' ) && DOING_AJAX)) {
124
  require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-admin.php');
125
 
126
  add_action('admin_init', 'ct_admin_init', 1);
144
  * @return mixed[] Array of options
145
  */
146
  function ct_init() {
147
+ global $ct_wplp_result_label, $ct_jp_comments, $ct_post_data_label, $ct_post_data_authnet_label;
148
 
149
  ct_init_session();
150
 
174
  }
175
 
176
  // intercept S2member POST
177
+ if (defined('WS_PLUGIN__S2MEMBER_PRO_VERSION') && (isset($_POST[$ct_post_data_label]['email']) || isset($_POST[$ct_post_data_authnet_label]['email']))){
178
  ct_s2member_registration_test();
179
  }
180
+
181
+ //
182
+ // New user approve hack
183
+ // https://wordpress.org/plugins/new-user-approve/
184
+ //
185
+ if (ct_plugin_active('new-user-approve/new-user-approve.php')) {
186
+ add_action('register_post', 'ct_register_post', 1, 3);
187
+ }
188
+
189
  }
190
 
191
  /**
213
  function ct_def_options() {
214
  $lang = get_bloginfo('language');
215
  return array(
216
+ 'server' => 'http://moderate.cleantalk.org',
217
  'apikey' => __('enter key', 'cleantalk'),
218
  'autoPubRevelantMess' => '1',
219
  'registrations_test' => '1',
987
  return $message;
988
  }
989
 
990
+ /**
991
+ * Test users registration for multisite enviroment
992
+ * @return array with errors
993
+ */
994
+ function ct_registration_errors_wpmu($errors) {
995
+ //
996
+ // Multisite actions
997
+ //
998
+ $sanitized_user_login = null;
999
+ if (isset($errors['user_name'])) {
1000
+ $sanitized_user_login = $errors['user_name'];
1001
+ $wpmu = true;
1002
+ }
1003
+ $user_email = null;
1004
+ if (isset($errors['user_email'])) {
1005
+ $user_email = $errors['user_email'];
1006
+ $wpmu = true;
1007
+ }
1008
+
1009
+ if ($wpmu && isset($errors['errors']->errors) && count($errors['errors']->errors) > 0) {
1010
+ return $errors;
1011
+ }
1012
+ $errors['errors'] = ct_registration_errors($errors['errors'], $sanitized_user_login, $user_email);
1013
+
1014
+ // Show CleanTalk errors in user_name field
1015
+ if (isset($errors['errors']->errors['ct_error'])) {
1016
+ $errors['errors']->errors['user_name'] = $errors['errors']->errors['ct_error'];
1017
+ unset($errors['errors']->errors['ct_error']);
1018
+ }
1019
+
1020
+ return $errors;
1021
+ }
1022
+
1023
+ /**
1024
+ * Shell for action register_post
1025
+ * @return array with errors
1026
+ */
1027
+ function ct_register_post($sanitized_user_login = null, $user_email = null, $errors) {
1028
+ return ct_registration_errors($errors, $sanitized_user_login, $user_email);
1029
+ }
1030
+
1031
  /**
1032
  * Test users registration
1033
  * @return array with errors
1034
  */
1035
  function ct_registration_errors($errors, $sanitized_user_login = null, $user_email = null) {
1036
+ global $ct_agent_version, $ct_checkjs_register_form, $ct_session_request_id_label, $ct_session_register_ok_label, $bp, $ct_signup_done;
1037
+
1038
+ // If there is an error already, let it do it's thing
1039
+ if ($errors->get_error_code()) {
1040
+ return $errors;
1041
+ }
1042
+
1043
+ // The function already executed
1044
+ if ($ct_signup_done) {
1045
+ return $errors;
1046
+ }
1047
  //
1048
  // BuddyPress actions
1049
  //
1109
  )
1110
  );
1111
  }
1112
+
1113
+ $ct_signup_done = true;
1114
 
1115
  if ($ct_result->errno != 0) {
1116
  return $errors;
1485
  * @return array with errors
1486
  */
1487
  function ct_s2member_registration_test() {
1488
+ global $ct_agent_version, $ct_post_data_label, $ct_post_data_authnet_label;
1489
 
1490
  $options = ct_get_options();
1491
  if ($options['registrations_test'] == 0) {
1511
  $sender_email = null;
1512
  if (isset($_POST[$ct_post_data_label]['email']))
1513
  $sender_email = $_POST[$ct_post_data_label]['email'];
1514
+
1515
+ if (isset($_POST[$ct_post_data_authnet_label]['email']))
1516
+ $sender_email = $_POST[$ct_post_data_authnet_label]['email'];
1517
 
1518
  $sender_nickname = null;
1519
  if (isset($_POST[$ct_post_data_label]['username']))
1520
  $sender_nickname = $_POST[$ct_post_data_label]['username'];
1521
+
1522
+ if (isset($_POST[$ct_post_data_authnet_label]['username']))
1523
+ $sender_nickname = $_POST[$ct_post_data_authnet_label]['username'];
1524
 
1525
  $config = get_option('cleantalk_server');
1526
 
1562
  return true;
1563
  }
1564
 
1565
+ /**
1566
+ * Writes to log execution time CleanTalk's functions
1567
+ * @return null
1568
+ */
1569
+ function ct_profiler ($file, $line) {
1570
+ global $ct_profiler_proccess_id, $ct_profiler_last_run, $ct_enable_profiler;
1571
+
1572
+ if (!$ct_enable_profiler) {
1573
+ return null;
1574
+ }
1575
+
1576
+ if ($ct_profiler_proccess_id === null) {
1577
+ $ct_profiler_proccess_id = md5(time() . rand(0, 10000));
1578
+ }
1579
+
1580
+ $warning_label = '';
1581
+ if ($ct_profiler_last_run === null) {
1582
+ $ct_profiler_last_run = microtime();
1583
+ } else {
1584
+ $ct_profiler_last_run = microtime() - $ct_profiler_last_run;
1585
+
1586
+ $max_execute_time = 1.0;
1587
+ if ((float) $ct_profiler_last_run >= $max_execute_time) {
1588
+ $warning_label = 'WARNING!!!';
1589
+ }
1590
+ }
1591
+
1592
+ $file = preg_replace("/^.+\/(.+)$/", "$1", $file);
1593
+
1594
+ $log_file = CLEANTALK_PLUGIN_DIR . 'ct-profiler.php';
1595
+ $fp = fopen($log_file, 'a+') or error_log('Could not open file:' . $file);
1596
+
1597
+ //
1598
+ // PROFILE_ID FILE LINE_NUM CURRENT_TIME MILLISECONDS_FROM_LAST_RUN
1599
+ //
1600
+ $to_file = sprintf("%s\t%s\t%d\t%s\t%.3f\t%s\n",
1601
+ $ct_profiler_proccess_id,
1602
+ $file,
1603
+ $line,
1604
+ date("Y-m-d H:i:s"),
1605
+ $ct_profiler_last_run,
1606
+ $warning_label
1607
+ );
1608
+
1609
+ fwrite($fp, $to_file);
1610
+ fclose($fp);
1611
+
1612
+ return null;
1613
+ }
1614
+
1615
  ?>
readme.txt CHANGED
@@ -1,13 +1,13 @@
1
- === SPAM defender ===
2
  Contributors: znaeff, shagimuratov
3
- Tags: antispam, anti-spam, anti spam, spam, spammers, captcha, comments, registration, contact form, blacklist, math, signup, formidable, bot, spam bots, quiz, spammy, s2member, wordpress, support, BuddyPress, bbpress, landing pages, fast secure contact form, WooCommerce, jetpack, cache, question
4
  Requires at least: 3.0
5
  Tested up to: 3.9.1
6
- Stable tag: 2.46
7
  License: GPLv2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
- SPAM defender for WordPress - no spam comments, no spam registrations, no spam contact emails. It's robutst anti-spam without CAPTCHAs.
11
 
12
  == Description ==
13
  No CAPTCHA, no questions, no counting animals, no puzzles, no math and no spam bots.
@@ -27,6 +27,8 @@ No CAPTCHA, no questions, no counting animals, no puzzles, no math and no spam b
27
  * WordPress Landing Pages.
28
 
29
  = Anti spam plugin info =
 
 
30
  CleanTalk is an antispam protection **4 in 1 for WordPress** that protects login, comment, contact and WooCommerce forms all at once. You don't need to install separate antispam plugins for each form. This allows your blog to work faster and save resources. After installation **you will forget about spam**, CleanTalk plugin will do all the work. You won't have to deal with spam, CleanTalk will do this for you automatically.
31
 
32
  CleanTalk is a transparent antispam protection, we provide detailed statistics of all entering comments and logins. You can always be sure that **there are no errors**. We have developed a mobile app for you to see antispam statistics wherever whenever.
@@ -140,7 +142,12 @@ WordPress 3.0 at least. PHP 4, 5 with CURL or file_get_contents() function and e
140
  1. Anti spam stopped spam bot at the registration form.
141
 
142
  == Changelog ==
143
- = 2.44 2014-05-19 =
 
 
 
 
 
144
  * Added: HTML notice about the need to enable JavaScript.
145
  * Fixed: Fixed pingbacks anti-spam test.
146
 
@@ -325,7 +332,12 @@ WordPress 3.0 at least. PHP 4, 5 with CURL or file_get_contents() function and e
325
  * First version
326
 
327
  == Upgrade Notice ==
328
- = 2.44 2014-05-19 =
 
 
 
 
 
329
  * Added: HTML notice about the need to enable JavaScript.
330
  * Fixed: Fixed pingbacks anti-spam test.
331
 
1
+ === Anti-spam by CleanTalk ===
2
  Contributors: znaeff, shagimuratov
3
+ Tags: antispam, anti-spam, anti spam, spam, spammers, captcha, comments, registration, contact form, blacklist, math, signup, formidable, bot, spam bots, quiz, spammy, s2member, wordpress, support, BuddyPress, bbpress, landing pages, fast secure contact form, WooCommerce, jetpack, cache
4
  Requires at least: 3.0
5
  Tested up to: 3.9.1
6
+ Stable tag: 2.49
7
  License: GPLv2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
+ SPAM defender for WordPress - no spam comments, no spam registrations, no spam contact emails, no spam trackbacks.
11
 
12
  == Description ==
13
  No CAPTCHA, no questions, no counting animals, no puzzles, no math and no spam bots.
27
  * WordPress Landing Pages.
28
 
29
  = Anti spam plugin info =
30
+ Spam is one of the most irritating factors. Spam become every year more and conventional anti spam can no longer handle all the spam bots. CleanTalk prevents spam and automatically blocks it. You'll be surprised of effective protection against spam.
31
+
32
  CleanTalk is an antispam protection **4 in 1 for WordPress** that protects login, comment, contact and WooCommerce forms all at once. You don't need to install separate antispam plugins for each form. This allows your blog to work faster and save resources. After installation **you will forget about spam**, CleanTalk plugin will do all the work. You won't have to deal with spam, CleanTalk will do this for you automatically.
33
 
34
  CleanTalk is a transparent antispam protection, we provide detailed statistics of all entering comments and logins. You can always be sure that **there are no errors**. We have developed a mobile app for you to see antispam statistics wherever whenever.
142
  1. Anti spam stopped spam bot at the registration form.
143
 
144
  == Changelog ==
145
+ = 2.49 2014-06-10 =
146
+ * Added spam protection for S2Member Auth.net forms.
147
+ * Added spam protection for multisite signup form.
148
+ * Optimized account status check function.
149
+
150
+ = 2.46 2014-05-19 =
151
  * Added: HTML notice about the need to enable JavaScript.
152
  * Fixed: Fixed pingbacks anti-spam test.
153
 
332
  * First version
333
 
334
  == Upgrade Notice ==
335
+ = 2.49 2014-06-10 =
336
+ * Added spam protection for S2Member Auth.net forms.
337
+ * Added spam protection for multisite signup form.
338
+ * Optimized account status check function.
339
+
340
+ = 2.46 2014-05-19 =
341
  * Added: HTML notice about the need to enable JavaScript.
342
  * Fixed: Fixed pingbacks anti-spam test.
343