Spam protection, AntiSpam, FireWall by CleanTalk - Version 4.24

Version Description

2015-03-20 = * Added immediate spam protection activation.

Download this release

Release Info

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

Code changes from version ajax-devel to 4.24

Files changed (6) hide show
  1. cleantalk-admin.php +33 -29
  2. cleantalk-ajax.php +0 -175
  3. cleantalk-common.php +238 -10
  4. cleantalk-public.php +19 -224
  5. cleantalk.php +1 -7
  6. readme.txt +7 -1
cleantalk-admin.php CHANGED
@@ -25,9 +25,10 @@ function ct_admin_add_page() {
25
  * Admin action 'admin_init' - Add the admin settings and such
26
  */
27
  function ct_admin_init() {
28
- global $ct_server_timeout, $show_ct_notice_autokey, $ct_notice_autokey_label, $ct_notice_autokey_value, $show_ct_notice_renew, $ct_notice_renew_label, $show_ct_notice_trial, $ct_notice_trial_label, $show_ct_notice_online, $ct_notice_online_label, $renew_notice_showtime, $trial_notice_showtime, $ct_plugin_name, $ct_options, $trial_notice_check_timeout, $account_notice_check_timeout, $ct_user_token_label, $ct_account_status_check;
29
 
30
  $ct_options = ct_get_options();
 
31
 
32
  $show_ct_notice_trial = false;
33
  if (isset($_COOKIE[$ct_notice_trial_label])) {
@@ -90,7 +91,7 @@ function ct_admin_init() {
90
  }
91
  }
92
 
93
- if (time() > $ct_options['next_account_status_check']) {
94
  $result = false;
95
  if (function_exists('curl_init') && function_exists('json_decode') && ct_valid_key($ct_options['apikey'])) {
96
  $url = 'https://api.cleantalk.org';
@@ -137,14 +138,13 @@ function ct_admin_init() {
137
  }
138
 
139
  if (isset($result['user_token'])) {
140
- $ct_options['user_token'] = $result['user_token'];
141
  }
142
  }
143
 
144
  // Save next status request time
145
- $ct_options['next_account_status_check'] = strtotime("+$notice_check_timeout hours", time());
146
- $ct_account_status_check = time();
147
- update_option('cleantalk_settings', $ct_options);
148
  }
149
 
150
  if ($result) {
@@ -198,7 +198,7 @@ function ct_section_settings_anti_spam() {
198
  * Admin callback function - Displays inputs of 'apikey' plugin parameter
199
  */
200
  function ct_input_apikey() {
201
- global $ct_options, $ct_notice_online_label;
202
 
203
  $value = $ct_options['apikey'];
204
  $def_value = '';
@@ -221,7 +221,7 @@ function ct_input_apikey() {
221
  * Admin callback function - Displays inputs of 'comments_test' plugin parameter
222
  */
223
  function ct_input_comments_test() {
224
- global $ct_options;
225
 
226
  $value = $ct_options['comments_test'];
227
  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>";
@@ -234,7 +234,7 @@ function ct_input_comments_test() {
234
  * Admin callback function - Displays inputs of 'comments_test' plugin parameter
235
  */
236
  function ct_input_registrations_test() {
237
- global $ct_options;
238
 
239
  $value = $ct_options['registrations_test'];
240
  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>";
@@ -247,7 +247,7 @@ function ct_input_registrations_test() {
247
  * Admin callback function - Displays inputs of 'contact_forms_test' plugin parameter
248
  */
249
  function ct_input_contact_forms_test() {
250
- global $ct_options;
251
 
252
  $value = $ct_options['contact_forms_test'];
253
  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>";
@@ -260,7 +260,7 @@ function ct_input_contact_forms_test() {
260
  * Admin callback function - Displays inputs of 'general_contact_forms_test' plugin parameter
261
  */
262
  function ct_input_general_contact_forms_test() {
263
- global $ct_options;
264
 
265
  $value = $ct_options['general_contact_forms_test'];
266
  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>";
@@ -276,7 +276,7 @@ function ct_input_general_contact_forms_test() {
276
  * @return null
277
  */
278
  function ct_input_remove_old_spam() {
279
- global $ct_options;
280
 
281
  $value = $ct_options['remove_old_spam'];
282
  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>";
@@ -334,11 +334,11 @@ input[type=submit] {padding: 10px; background: #3399FF; color: #fff; border:0 no
334
  * @return bool
335
  */
336
  function admin_notice_message(){
337
- global $show_ct_notice_trial, $show_ct_notice_renew, $show_ct_notice_online, $show_ct_notice_autokey, $ct_notice_autokey_value, $ct_plugin_name, $ct_options;
338
 
339
  $user_token = '';
340
- if (isset($ct_options['user_token']) && $ct_options['user_token'] != '') {
341
- $user_token = '&user_token=' . $ct_options['user_token'];
342
  }
343
 
344
  $show_notice = true;
@@ -396,7 +396,7 @@ function admin_addDescriptionsFields($descr = '') {
396
  * Test API key
397
  */
398
  function ct_valid_key($apikey = null) {
399
- global $ct_options;
400
  if ($apikey === null) {
401
  $apikey = $ct_options['apikey'];
402
  }
@@ -532,29 +532,33 @@ if (!function_exists ( 'ct_plugin_action_links')) {
532
  * @return array
533
  */
534
  function ct_update_option($option_name) {
535
- global $show_ct_notice_online, $ct_notice_online_label, $ct_notice_trial_label, $trial_notice_showtime, $ct_account_status_check, $ct_options, $ct_server_timeout;
536
 
537
  if($option_name !== 'cleantalk_settings') {
538
  return;
539
  }
540
 
541
- // Skip test call if the function executet during account status check
542
- if ($ct_account_status_check > 0 && time() - $ct_account_status_check < 5) {
 
 
 
 
543
  return;
544
  }
545
-
 
 
 
 
 
 
 
 
 
546
  $key_valid = true;
547
  $app_server_error = false;
548
  if (function_exists('curl_init') && function_exists('json_decode')) {
549
- $api_key = $ct_options['apikey'];
550
- if (isset($_POST['cleantalk_settings']['apikey'])) {
551
- $api_key = trim($_POST['cleantalk_settings']['apikey']);
552
- }
553
-
554
- if (!ct_valid_key($api_key)) {
555
- return null;
556
- }
557
-
558
  $url = 'https://cleantalk.org/app_notice';
559
  $data['auth_key'] = $api_key;
560
  $data['param'] = 'notice_validate_key';
25
  * Admin action 'admin_init' - Add the admin settings and such
26
  */
27
  function ct_admin_init() {
28
+ global $ct_server_timeout, $show_ct_notice_autokey, $ct_notice_autokey_label, $ct_notice_autokey_value, $show_ct_notice_renew, $ct_notice_renew_label, $show_ct_notice_trial, $ct_notice_trial_label, $show_ct_notice_online, $ct_notice_online_label, $renew_notice_showtime, $trial_notice_showtime, $ct_plugin_name, $ct_options, $ct_data, $trial_notice_check_timeout, $account_notice_check_timeout, $ct_user_token_label;
29
 
30
  $ct_options = ct_get_options();
31
+ $ct_data = ct_get_data();
32
 
33
  $show_ct_notice_trial = false;
34
  if (isset($_COOKIE[$ct_notice_trial_label])) {
91
  }
92
  }
93
 
94
+ if (time() > $ct_data['next_account_status_check']) {
95
  $result = false;
96
  if (function_exists('curl_init') && function_exists('json_decode') && ct_valid_key($ct_options['apikey'])) {
97
  $url = 'https://api.cleantalk.org';
138
  }
139
 
140
  if (isset($result['user_token'])) {
141
+ $ct_data['user_token'] = $result['user_token'];
142
  }
143
  }
144
 
145
  // Save next status request time
146
+ $ct_data['next_account_status_check'] = strtotime("+$notice_check_timeout hours", time());
147
+ update_option('cleantalk_data', $ct_data);
 
148
  }
149
 
150
  if ($result) {
198
  * Admin callback function - Displays inputs of 'apikey' plugin parameter
199
  */
200
  function ct_input_apikey() {
201
+ global $ct_options, $ct_data, $ct_notice_online_label;
202
 
203
  $value = $ct_options['apikey'];
204
  $def_value = '';
221
  * Admin callback function - Displays inputs of 'comments_test' plugin parameter
222
  */
223
  function ct_input_comments_test() {
224
+ global $ct_options, $ct_data;
225
 
226
  $value = $ct_options['comments_test'];
227
  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>";
234
  * Admin callback function - Displays inputs of 'comments_test' plugin parameter
235
  */
236
  function ct_input_registrations_test() {
237
+ global $ct_options, $ct_data;
238
 
239
  $value = $ct_options['registrations_test'];
240
  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>";
247
  * Admin callback function - Displays inputs of 'contact_forms_test' plugin parameter
248
  */
249
  function ct_input_contact_forms_test() {
250
+ global $ct_options, $ct_data;
251
 
252
  $value = $ct_options['contact_forms_test'];
253
  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>";
260
  * Admin callback function - Displays inputs of 'general_contact_forms_test' plugin parameter
261
  */
262
  function ct_input_general_contact_forms_test() {
263
+ global $ct_options, $ct_data;
264
 
265
  $value = $ct_options['general_contact_forms_test'];
266
  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>";
276
  * @return null
277
  */
278
  function ct_input_remove_old_spam() {
279
+ global $ct_options, $ct_data;
280
 
281
  $value = $ct_options['remove_old_spam'];
282
  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>";
334
  * @return bool
335
  */
336
  function admin_notice_message(){
337
+ global $show_ct_notice_trial, $show_ct_notice_renew, $show_ct_notice_online, $show_ct_notice_autokey, $ct_notice_autokey_value, $ct_plugin_name, $ct_options, $ct_data;
338
 
339
  $user_token = '';
340
+ if (isset($ct_data['user_token']) && $ct_data['user_token'] != '') {
341
+ $user_token = '&user_token=' . $ct_data['user_token'];
342
  }
343
 
344
  $show_notice = true;
396
  * Test API key
397
  */
398
  function ct_valid_key($apikey = null) {
399
+ global $ct_options, $ct_data;
400
  if ($apikey === null) {
401
  $apikey = $ct_options['apikey'];
402
  }
532
  * @return array
533
  */
534
  function ct_update_option($option_name) {
535
+ global $show_ct_notice_online, $ct_notice_online_label, $ct_notice_trial_label, $trial_notice_showtime, $ct_options, $ct_data, $ct_server_timeout;
536
 
537
  if($option_name !== 'cleantalk_settings') {
538
  return;
539
  }
540
 
541
+ $api_key = $ct_options['apikey'];
542
+ if (isset($_POST['cleantalk_settings']['apikey'])) {
543
+ $api_key = trim($_POST['cleantalk_settings']['apikey']);
544
+ $ct_options['apikey'] = $api_key;
545
+ }
546
+ if (!ct_valid_key($api_key)) {
547
  return;
548
  }
549
+
550
+ $ct_base_call_result = ct_base_call(array(
551
+ 'message' => 'CleanTalk connection test',
552
+ 'example' => null,
553
+ 'sender_email' => 'stop_email@example.com',
554
+ 'sender_nickname' => 'CleanTalk',
555
+ 'post_info' => '',
556
+ 'checkjs' => 1
557
+ ));
558
+
559
  $key_valid = true;
560
  $app_server_error = false;
561
  if (function_exists('curl_init') && function_exists('json_decode')) {
 
 
 
 
 
 
 
 
 
562
  $url = 'https://cleantalk.org/app_notice';
563
  $data['auth_key'] = $api_key;
564
  $data['param'] = 'notice_validate_key';
cleantalk-ajax.php DELETED
@@ -1,175 +0,0 @@
1
- <?
2
-
3
- /*
4
- AJAX functions
5
- */
6
-
7
- /*hooks for AJAX Login & Register email validation*/
8
- add_action( 'wp_ajax_nopriv_validate_email', 'ct_validate_email_ajaxlogin',1 );
9
- add_action( 'wp_ajax_validate_email', 'ct_validate_email_ajaxlogin',1 );
10
-
11
- /*hooks for user registration*/
12
- add_action( 'user_register', 'ct_user_register_ajaxlogin',1 );
13
-
14
-
15
- function ct_validate_email_ajaxlogin($email=null, $is_ajax=true)
16
- {
17
- require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-public.php');
18
- global $ct_agent_version, $ct_checkjs_register_form, $ct_session_request_id_label, $ct_session_register_ok_label, $bp, $ct_signup_done, $ct_formtime_label, $ct_negative_comment, $ct_options;
19
-
20
- $ct_options=ct_get_options();
21
-
22
- $email = is_null( $email ) ? $email : $_POST['email'];
23
- $email=sanitize_email($email);
24
- $is_good=true;
25
- if ( ! filter_var( $email, FILTER_VALIDATE_EMAIL )||email_exists( $email ) )
26
- {
27
- $is_good=false;
28
- }
29
-
30
- if(class_exists('AjaxLogin')&&isset($_POST['action'])&&$_POST['action']=='validate_email')
31
- {
32
-
33
- $ct_options=ct_get_options();
34
- $checkjs = js_test('ct_checkjs', $_COOKIE, true);
35
- $submit_time = submit_time_test();
36
- $sender_info = get_sender_info();
37
- $sender_info['post_checkjs_passed']=$checkjs;
38
-
39
- if ($checkjs === null)
40
- {
41
- $checkjs = js_test('ct_checkjs', $_COOKIE, true);
42
- $sender_info['cookie_checkjs_passed'] = $checkjs;
43
- }
44
-
45
- $sender_info = json_encode($sender_info);
46
- if ($sender_info === false)
47
- {
48
- $sender_info= '';
49
- }
50
-
51
- require_once('cleantalk.class.php');
52
- $config = get_option('cleantalk_server');
53
- $ct = new Cleantalk();
54
- $ct->work_url = $config['ct_work_url'];
55
- $ct->server_url = $ct_options['server'];
56
-
57
- $ct->server_ttl = $config['ct_server_ttl'];
58
- $ct->server_changed = $config['ct_server_changed'];
59
- $ct->ssl_on = $ct_options['ssl_on'];
60
-
61
- $ct_request = new CleantalkRequest();
62
- $ct_request->auth_key = $ct_options['apikey'];
63
- $ct_request->sender_email = $email;
64
- $ct_request->sender_ip = $ct->ct_session_ip($_SERVER['REMOTE_ADDR']);
65
- $ct_request->sender_nickname = '';
66
- $ct_request->agent = $ct_agent_version;
67
- $ct_request->sender_info = $sender_info;
68
- $ct_request->js_on = $checkjs;
69
- $ct_request->submit_time = $submit_time;
70
-
71
- $ct_result = $ct->isAllowUser($ct_request);
72
-
73
- if ($ct->server_change)
74
- {
75
- update_option(
76
- 'cleantalk_server', array(
77
- 'ct_work_url' => $ct->work_url,
78
- 'ct_server_ttl' => $ct->server_ttl,
79
- 'ct_server_changed' => time()
80
- )
81
- );
82
- }
83
- if ($ct_result->allow===0)
84
- {
85
- $is_good=false;
86
- }
87
- }
88
- if($is_good)
89
- {
90
- $ajaxresult=array(
91
- 'description' => null,
92
- 'cssClass' => 'noon',
93
- 'code' => 'success'
94
- );
95
- }
96
- else
97
- {
98
- $ajaxresult=array(
99
- 'description' => 'Invalid Email',
100
- 'cssClass' => 'error-container',
101
- 'code' => 'error'
102
- );
103
- }
104
- $ajaxresult=json_encode($ajaxresult);
105
- print $ajaxresult;
106
- wp_die();
107
- }
108
-
109
- function ct_user_register_ajaxlogin($user_id)
110
- {
111
- require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-public.php');
112
- global $ct_agent_version, $ct_checkjs_register_form, $ct_session_request_id_label, $ct_session_register_ok_label, $bp, $ct_signup_done, $ct_formtime_label, $ct_negative_comment, $ct_options;
113
-
114
- $ct_options=ct_get_options();
115
-
116
- if(class_exists('AjaxLogin')&&isset($_POST['action'])&&$_POST['action']=='register_submit')
117
- {
118
- $checkjs = js_test('ct_checkjs', $_COOKIE, true);
119
- $submit_time = submit_time_test();
120
- $sender_info = get_sender_info();
121
- $sender_info['post_checkjs_passed']=$checkjs;
122
-
123
- if ($checkjs === null)
124
- {
125
- $checkjs = js_test('ct_checkjs', $_COOKIE, true);
126
- $sender_info['cookie_checkjs_passed'] = $checkjs;
127
- }
128
-
129
- $sender_info = json_encode($sender_info);
130
- if ($sender_info === false)
131
- {
132
- $sender_info= '';
133
- }
134
-
135
- require_once('cleantalk.class.php');
136
- $config = get_option('cleantalk_server');
137
- $ct = new Cleantalk();
138
- $ct->work_url = $config['ct_work_url'];
139
- $ct->server_url = $ct_options['server'];
140
-
141
- $ct->server_ttl = $config['ct_server_ttl'];
142
- $ct->server_changed = $config['ct_server_changed'];
143
- $ct->ssl_on = $ct_options['ssl_on'];
144
-
145
- $ct_request = new CleantalkRequest();
146
- $ct_request->auth_key = $ct_options['apikey'];
147
- $ct_request->sender_email = sanitize_email($_POST['email']);
148
- $ct_request->sender_ip = $ct->ct_session_ip($_SERVER['REMOTE_ADDR']);
149
- $ct_request->sender_nickname = sanitize_email($_POST['login']); ;
150
- $ct_request->agent = $ct_agent_version;
151
- $ct_request->sender_info = $sender_info;
152
- $ct_request->js_on = $checkjs;
153
- $ct_request->submit_time = $submit_time;
154
-
155
- $ct_result = $ct->isAllowUser($ct_request);
156
-
157
- if ($ct->server_change)
158
- {
159
- update_option(
160
- 'cleantalk_server', array(
161
- 'ct_work_url' => $ct->work_url,
162
- 'ct_server_ttl' => $ct->server_ttl,
163
- 'ct_server_changed' => time()
164
- )
165
- );
166
- }
167
- if ($ct_result->allow===0)
168
- {
169
- wp_delete_user($user_id);
170
- }
171
- }
172
- return $user_id;
173
- }
174
-
175
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cleantalk-common.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- $ct_agent_version = 'wordpress-422';
4
  $ct_plugin_name = 'Anti-spam by CleanTalk';
5
  $ct_checkjs_frm = 'ct_checkjs_frm';
6
  $ct_checkjs_register_form = 'ct_checkjs_register_form';
@@ -75,10 +75,10 @@ $ct_post_data_authnet_label = 's2member_pro_authnet_registration';
75
  $ct_formtime_label = 'ct_formtime';
76
 
77
  // Plugin's options
78
- $ct_options = null;
79
 
80
- // Account status check last time
81
- $ct_account_status_check = 0;
82
 
83
  // Post without page load
84
  $ct_direct_post = 0;
@@ -118,6 +118,210 @@ function ct_init_session() {
118
  return null;
119
  }
120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  /**
122
  * Inner function - Current Cleantalk options
123
  * @return mixed[] Array of options
@@ -149,10 +353,31 @@ function ct_def_options() {
149
  'remove_old_spam' => '0',
150
  'spam_store_days' => '15', // Days before delete comments from folder Spam
151
  'ssl_on' => 0, // Secure connection to servers
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  'next_account_status_check' => 0, // Time label when the plugin should check account status
153
  'user_token' => '', // User token
154
- 'relevance_test' => 0, // Test comment for relevance
155
- 'notice_api_errors' => 0, // Send API error notices to WP admin
156
  'js_keys' => array(), // Keys to do JavaScript antispam test
157
  'js_keys_store_days' => 8, // JavaScript keys store days - 8 days now
158
  'js_key_lifetime' => 86400, // JavaScript key life time in seconds - 1 day now
@@ -184,7 +409,7 @@ function ct_hash($new_hash = '') {
184
  * @return string comment_content w\o cleantalk resume
185
  */
186
  function ct_feedback($hash, $message = null, $allow) {
187
- global $ct_options;
188
 
189
  require_once('cleantalk.class.php');
190
 
@@ -221,7 +446,7 @@ function ct_feedback($hash, $message = null, $allow) {
221
  * @return bool
222
  */
223
  function ct_send_feedback($feedback_request = null) {
224
- global $ct_options;
225
 
226
  if (empty($feedback_request) && isset($_SESSION['feedback_request']) && preg_match("/^[a-z0-9\;\:]+$/", $_SESSION['feedback_request'])) {
227
  $feedback_request = $_SESSION['feedback_request'];
@@ -263,12 +488,15 @@ function ct_send_feedback($feedback_request = null) {
263
  * On the scheduled action hook, run the function.
264
  */
265
  function ct_do_this_hourly() {
266
- global $ct_options;
267
  // do something every hour
268
 
269
  if (!isset($ct_options))
270
  $ct_options = ct_get_options();
271
 
 
 
 
272
  delete_spam_comments();
273
  ct_send_feedback();
274
  }
@@ -278,7 +506,7 @@ function ct_do_this_hourly() {
278
  * @return null
279
  */
280
  function delete_spam_comments() {
281
- global $pagenow, $ct_options;
282
 
283
  if ($ct_options['remove_old_spam'] == 1) {
284
  $last_comments = get_comments(array('status' => 'spam', 'number' => 1000, 'order' => 'ASC'));
1
  <?php
2
 
3
+ $ct_agent_version = 'wordpress-424';
4
  $ct_plugin_name = 'Anti-spam by CleanTalk';
5
  $ct_checkjs_frm = 'ct_checkjs_frm';
6
  $ct_checkjs_register_form = 'ct_checkjs_register_form';
75
  $ct_formtime_label = 'ct_formtime';
76
 
77
  // Plugin's options
78
+ $ct_options = null;
79
 
80
+ // Plugin's data
81
+ $ct_data = null;
82
 
83
  // Post without page load
84
  $ct_direct_post = 0;
118
  return null;
119
  }
120
 
121
+ /**
122
+ * Inner function - Common part of request sending
123
+ * @param array Array of parameters:
124
+ * 'message' - string
125
+ * 'example' - string
126
+ * 'checkjs' - int
127
+ * 'sender_email' - string
128
+ * 'sender_nickname' - string
129
+ * 'sender_info' - array
130
+ * 'post_info' - string
131
+ * @return array array('ct'=> Cleantalk, 'ct_result' => CleantalkResponse)
132
+ */
133
+ function ct_base_call($params = array()) {
134
+ global $wpdb, $ct_agent_version, $ct_formtime_label, $ct_options, $ct_data;
135
+
136
+ require_once('cleantalk.class.php');
137
+
138
+ $submit_time = submit_time_test();
139
+
140
+ $sender_info = get_sender_info();
141
+ if (array_key_exists('sender_info', $params)) {
142
+ $sender_info = array_merge($sender_info, (array) $params['sender_info']);
143
+ }
144
+ $sender_info = json_encode($sender_info);
145
+ if ($sender_info === false)
146
+ $sender_info = '';
147
+
148
+ $config = get_option('cleantalk_server');
149
+
150
+ $ct = new Cleantalk();
151
+ $ct->work_url = $config['ct_work_url'];
152
+ $ct->server_url = $ct_options['server'];
153
+ $ct->server_ttl = $config['ct_server_ttl'];
154
+ $ct->server_changed = $config['ct_server_changed'];
155
+ $ct->ssl_on = $ct_options['ssl_on'];
156
+
157
+ $ct_request = new CleantalkRequest();
158
+
159
+ $ct_request->auth_key = $ct_options['apikey'];
160
+ $ct_request->message = $params['message'];
161
+ $ct_request->example = $params['example'];
162
+ $ct_request->sender_email = $params['sender_email'];
163
+ $ct_request->sender_nickname = $params['sender_nickname'];
164
+ $ct_request->sender_ip = $ct->ct_session_ip($_SERVER['REMOTE_ADDR']);
165
+ $ct_request->agent = $ct_agent_version;
166
+ $ct_request->sender_info = $sender_info;
167
+ $ct_request->js_on = $params['checkjs'];
168
+ $ct_request->submit_time = $submit_time;
169
+ $ct_request->post_info = $params['post_info'];
170
+
171
+ $ct_result = $ct->isAllowMessage($ct_request);
172
+ if ($ct->server_change) {
173
+ update_option(
174
+ 'cleantalk_server', array(
175
+ 'ct_work_url' => $ct->work_url,
176
+ 'ct_server_ttl' => $ct->server_ttl,
177
+ 'ct_server_changed' => time()
178
+ )
179
+ );
180
+ }
181
+
182
+ // Restart submit form counter for failed requests
183
+ if ($ct_result->allow == 0) {
184
+ $_SESSION[$ct_formtime_label] = time();
185
+ }
186
+
187
+ return array('ct' => $ct, 'ct_result' => $ct_result);
188
+ }
189
+
190
+ /**
191
+ * Validate form submit time
192
+ *
193
+ */
194
+ function submit_time_test() {
195
+ global $ct_formtime_label;
196
+
197
+ $submit_time = null;
198
+ if (isset($_SESSION[$ct_formtime_label])) {
199
+ $submit_time = time() - (int) $_SESSION[$ct_formtime_label];
200
+ }
201
+
202
+ return $submit_time;
203
+ }
204
+
205
+ /**
206
+ * Inner function - Default data array for senders
207
+ * @return array
208
+ */
209
+ function get_sender_info() {
210
+ global $ct_direct_post, $ct_options, $ct_data;
211
+
212
+ $php_session = session_id() != '' ? 1 : 0;
213
+
214
+ // Raw data to validated JavaScript test in the cloud
215
+ $checkjs_data_cookies = null;
216
+ if (isset($_COOKIE['ct_checkjs'])) {
217
+ $checkjs_data_cookies = $_COOKIE['ct_checkjs'];
218
+ }
219
+
220
+ $checkjs_data_post = null;
221
+ if (count($_POST) > 0) {
222
+ foreach ($_POST as $k => $v) {
223
+ if (preg_match("/^ct_check.+/", $k)) {
224
+ $checkjs_data_post = $v;
225
+ }
226
+ }
227
+ }
228
+
229
+ $options2server = array( // Options for sending to server for support information
230
+ 'apikey' => $ct_options['apikey'],
231
+ 'registrations_test' => $ct_options['registrations_test'],
232
+ 'comments_test' => $ct_options['comments_test'],
233
+ 'contact_forms_test' => $ct_options['contact_forms_test'],
234
+ 'general_contact_forms_test' => $ct_options['general_contact_forms_test'],
235
+ 'remove_old_spam' => $ct_options['remove_old_spam'],
236
+ 'autoPubRevelantMess' => $ct_options['autoPubRevelantMess'],
237
+ 'spam_store_days' => $ct_options['spam_store_days'],
238
+ 'ssl_on' => $ct_options['ssl_on'],
239
+ );
240
+
241
+ return $sender_info = array(
242
+ 'page_url' => htmlspecialchars(@$_SERVER['SERVER_NAME'].@$_SERVER['REQUEST_URI']),
243
+ 'cms_lang' => substr(get_locale(), 0, 2),
244
+ 'REFFERRER' => htmlspecialchars(@$_SERVER['HTTP_REFERER']),
245
+ 'USER_AGENT' => htmlspecialchars(@$_SERVER['HTTP_USER_AGENT']),
246
+ 'php_session' => $php_session,
247
+ 'cookies_enabled' => ct_cookies_test(true),
248
+ 'direct_post' => $ct_direct_post,
249
+ 'checkjs_data_post' => $checkjs_data_post,
250
+ 'checkjs_data_cookies' => $checkjs_data_cookies,
251
+ 'ct_options' => json_encode($options2server),
252
+ );
253
+ }
254
+
255
+ /**
256
+ * Cookies test for sender
257
+ * @return null|0|1;
258
+ */
259
+ function ct_cookies_test ($test = false) {
260
+ $cookie_label = 'ct_cookies_test';
261
+ $secret_hash = ct_get_checkjs_value();
262
+
263
+ $result = null;
264
+ if (isset($_COOKIE[$cookie_label])) {
265
+ if ($_COOKIE[$cookie_label] == $secret_hash) {
266
+ $result = 1;
267
+ } else {
268
+ $result = 0;
269
+ }
270
+ } else {
271
+ @setcookie($cookie_label, $secret_hash, 0, '/');
272
+
273
+ if ($test) {
274
+ $result = 0;
275
+ }
276
+ }
277
+
278
+ return $result;
279
+ }
280
+
281
+ /**
282
+ * Get ct_get_checkjs_value
283
+ * @return string
284
+ */
285
+ function ct_get_checkjs_value($random_key = false) {
286
+ global $ct_options, $ct_data;
287
+
288
+ if ($random_key) {
289
+ $keys = $ct_data['js_keys'];
290
+ $keys_checksum = md5(json_encode($keys));
291
+
292
+ $key = null;
293
+ $latest_key_time = 0;
294
+ foreach ($keys as $k => $t) {
295
+
296
+ // Removing key if it's to old
297
+ if (time() - $t > $ct_data['js_keys_store_days'] * 86400) {
298
+ unset($keys[$k]);
299
+ continue;
300
+ }
301
+
302
+ if ($t > $latest_key_time) {
303
+ $latest_key_time = $t;
304
+ $key = $k;
305
+ }
306
+ }
307
+
308
+ // Get new key if the latest key is too old
309
+ if (time() - $latest_key_time > $ct_data['js_key_lifetime']) {
310
+ $key = rand();
311
+ $keys[$key] = time();
312
+ }
313
+
314
+ if (md5(json_encode($keys)) != $keys_checksum) {
315
+ $ct_data['js_keys'] = $keys;
316
+ update_option('cleantalk_data', $ct_data);
317
+ }
318
+ } else {
319
+ $key = md5($ct_options['apikey'] . '+' . get_option('admin_email'));
320
+ }
321
+
322
+ return $key;
323
+ }
324
+
325
  /**
326
  * Inner function - Current Cleantalk options
327
  * @return mixed[] Array of options
353
  'remove_old_spam' => '0',
354
  'spam_store_days' => '15', // Days before delete comments from folder Spam
355
  'ssl_on' => 0, // Secure connection to servers
356
+ 'relevance_test' => 0, // Test comment for relevance
357
+ 'notice_api_errors' => 0, // Send API error notices to WP admin
358
+ );
359
+ }
360
+
361
+ /**
362
+ * Inner function - Current Cleantalk data
363
+ * @return mixed[] Array of options
364
+ */
365
+ function ct_get_data() {
366
+ $data = get_option('cleantalk_data');
367
+ if (!is_array($data)){
368
+ $data = array();
369
+ }
370
+ return array_merge(ct_def_data(), (array) $data);
371
+ }
372
+
373
+ /**
374
+ * Inner function - Default Cleantalk data
375
+ * @return mixed[] Array of default options
376
+ */
377
+ function ct_def_data() {
378
+ return array(
379
  'next_account_status_check' => 0, // Time label when the plugin should check account status
380
  'user_token' => '', // User token
 
 
381
  'js_keys' => array(), // Keys to do JavaScript antispam test
382
  'js_keys_store_days' => 8, // JavaScript keys store days - 8 days now
383
  'js_key_lifetime' => 86400, // JavaScript key life time in seconds - 1 day now
409
  * @return string comment_content w\o cleantalk resume
410
  */
411
  function ct_feedback($hash, $message = null, $allow) {
412
+ global $ct_options, $ct_data;
413
 
414
  require_once('cleantalk.class.php');
415
 
446
  * @return bool
447
  */
448
  function ct_send_feedback($feedback_request = null) {
449
+ global $ct_options, $ct_data;
450
 
451
  if (empty($feedback_request) && isset($_SESSION['feedback_request']) && preg_match("/^[a-z0-9\;\:]+$/", $_SESSION['feedback_request'])) {
452
  $feedback_request = $_SESSION['feedback_request'];
488
  * On the scheduled action hook, run the function.
489
  */
490
  function ct_do_this_hourly() {
491
+ global $ct_options, $ct_data;
492
  // do something every hour
493
 
494
  if (!isset($ct_options))
495
  $ct_options = ct_get_options();
496
 
497
+ if (!isset($ct_data))
498
+ $ct_data = ct_get_data();
499
+
500
  delete_spam_comments();
501
  ct_send_feedback();
502
  }
506
  * @return null
507
  */
508
  function delete_spam_comments() {
509
+ global $pagenow, $ct_options, $ct_data;
510
 
511
  if ($ct_options['remove_old_spam'] == 1) {
512
  $last_comments = get_comments(array('status' => 'spam', 'number' => 1000, 'order' => 'ASC'));
cleantalk-public.php CHANGED
@@ -5,9 +5,10 @@
5
  * @return mixed[] Array of options
6
  */
7
  function ct_init() {
8
- global $ct_wplp_result_label, $ct_jp_comments, $ct_post_data_label, $ct_post_data_authnet_label, $ct_formtime_label, $ct_direct_post, $ct_options;
9
 
10
  $ct_options = ct_get_options();
 
11
 
12
  ct_init_session();
13
 
@@ -112,106 +113,11 @@ function ct_init() {
112
  }
113
  }
114
 
115
- /**
116
- * Cookies test for sender
117
- * @return null|0|1;
118
- */
119
- function ct_cookies_test ($test = false) {
120
- $cookie_label = 'ct_cookies_test';
121
- $secret_hash = ct_get_checkjs_value();
122
-
123
- $result = null;
124
- if (isset($_COOKIE[$cookie_label])) {
125
- if ($_COOKIE[$cookie_label] == $secret_hash) {
126
- $result = 1;
127
- } else {
128
- $result = 0;
129
- }
130
- } else {
131
- @setcookie($cookie_label, $secret_hash, 0, '/');
132
-
133
- if ($test) {
134
- $result = 0;
135
- }
136
- }
137
-
138
- return $result;
139
- }
140
-
141
- /**
142
- * Inner function - Common part of request sending
143
- * @param array Array of parameters:
144
- * 'message' - string
145
- * 'example' - string
146
- * 'checkjs' - int
147
- * 'sender_email' - string
148
- * 'sender_nickname' - string
149
- * 'sender_info' - array
150
- * 'post_info' - string
151
- * @return array array('ct'=> Cleantalk, 'ct_result' => CleantalkResponse)
152
- */
153
- function ct_base_call($params = array()) {
154
- global $wpdb, $ct_agent_version, $ct_formtime_label, $ct_options;
155
-
156
- require_once('cleantalk.class.php');
157
-
158
- $submit_time = submit_time_test();
159
-
160
- $sender_info = get_sender_info();
161
- if (array_key_exists('sender_info', $params)) {
162
- $sender_info = array_merge($sender_info, (array) $params['sender_info']);
163
- }
164
- $sender_info = json_encode($sender_info);
165
- if ($sender_info === false)
166
- $sender_info = '';
167
-
168
- $config = get_option('cleantalk_server');
169
-
170
- $ct = new Cleantalk();
171
- $ct->work_url = $config['ct_work_url'];
172
- $ct->server_url = $ct_options['server'];
173
- $ct->server_ttl = $config['ct_server_ttl'];
174
- $ct->server_changed = $config['ct_server_changed'];
175
- $ct->ssl_on = $ct_options['ssl_on'];
176
-
177
- $ct_request = new CleantalkRequest();
178
-
179
- $ct_request->auth_key = $ct_options['apikey'];
180
- $ct_request->message = $params['message'];
181
- $ct_request->example = $params['example'];
182
- $ct_request->sender_email = $params['sender_email'];
183
- $ct_request->sender_nickname = $params['sender_nickname'];
184
- $ct_request->sender_ip = $ct->ct_session_ip($_SERVER['REMOTE_ADDR']);
185
- $ct_request->agent = $ct_agent_version;
186
- $ct_request->sender_info = $sender_info;
187
- $ct_request->js_on = $params['checkjs'];
188
- $ct_request->submit_time = $submit_time;
189
- $ct_request->post_info = $params['post_info'];
190
-
191
- $ct_result = $ct->isAllowMessage($ct_request);
192
- if ($ct->server_change) {
193
- update_option(
194
- 'cleantalk_server', array(
195
- 'ct_work_url' => $ct->work_url,
196
- 'ct_server_ttl' => $ct->server_ttl,
197
- 'ct_server_changed' => time()
198
- )
199
- );
200
- }
201
-
202
- // Restart submit form counter for failed requests
203
- if ($ct_result->allow == 0) {
204
- $_SESSION[$ct_formtime_label] = time();
205
- }
206
-
207
- return array('ct' => $ct, 'ct_result' => $ct_result);
208
- }
209
-
210
  /**
211
  * Adds hidden filed to comment form
212
  */
213
  function ct_comment_form($post_id) {
214
- global $ct_options;
215
 
216
  if (ct_is_user_enable() === false) {
217
  return false;
@@ -308,7 +214,7 @@ function ct_is_user_enable() {
308
  * return null;
309
  */
310
  function ct_frm_entries_footer_scripts($fields, $form) {
311
- global $current_user, $ct_checkjs_frm, $ct_options;
312
 
313
  if ($ct_options['contact_forms_test'] == 0) {
314
  return false;
@@ -333,7 +239,7 @@ function ct_frm_entries_footer_scripts($fields, $form) {
333
  * return @array with errors if spam has found
334
  */
335
  function ct_frm_validate_entry ($errors, $values) {
336
- global $wpdb, $current_user, $ct_agent_version, $ct_checkjs_frm, $ct_options;
337
 
338
  if ($ct_options['contact_forms_test'] == 0) {
339
  return false;
@@ -380,7 +286,7 @@ function ct_frm_validate_entry ($errors, $values) {
380
  * @return mixed[] $comment Comment string
381
  */
382
  function ct_bbp_new_pre_content ($comment) {
383
- global $ct_options;
384
 
385
  if (ct_is_user_enable() === false || $ct_options['comments_test'] == 0 || is_user_logged_in()) {
386
  return $comment;
@@ -433,7 +339,7 @@ function ct_preprocess_comment($comment) {
433
  // this action is called just when WP process POST request (adds new comment)
434
  // this action is called by wp-comments-post.php
435
  // after processing WP makes redirect to post page with comment's form by GET request (see above)
436
- global $wpdb, $current_user, $comment_post_id, $ct_agent_version, $ct_comment_done, $ct_approved_request_id_label, $ct_jp_comments, $ct_options;
437
 
438
  if (ct_is_user_enable() === false || $ct_options['comments_test'] == 0 || $ct_comment_done) {
439
  return $comment;
@@ -592,7 +498,7 @@ function ct_die_extended($comment_body) {
592
  *
593
  */
594
  function js_test($field_name = 'ct_checkjs', $data = null, $random_key = false) {
595
- global $ct_options;
596
 
597
  $checkjs = null;
598
  $js_post_value = null;
@@ -608,7 +514,7 @@ function js_test($field_name = 'ct_checkjs', $data = null, $random_key = false)
608
  //
609
  if ($random_key) {
610
 
611
- $keys = $ct_options['js_keys'];
612
  if (isset($keys[$js_post_value])) {
613
  $checkjs = 1;
614
  } else {
@@ -630,21 +536,6 @@ function js_test($field_name = 'ct_checkjs', $data = null, $random_key = false)
630
  return $checkjs;
631
  }
632
 
633
- /**
634
- * Validate form submit time
635
- *
636
- */
637
- function submit_time_test() {
638
- global $ct_formtime_label;
639
-
640
- $submit_time = null;
641
- if (isset($_SESSION[$ct_formtime_label])) {
642
- $submit_time = time() - (int) $_SESSION[$ct_formtime_label];
643
- }
644
-
645
- return $submit_time;
646
- }
647
-
648
  /**
649
  * Get post url
650
  * @param int $comment_id
@@ -753,57 +644,12 @@ function ct_plugin_active($plugin_name){
753
  return false;
754
  }
755
 
756
- /**
757
- * Get ct_get_checkjs_value
758
- * @return string
759
- */
760
- function ct_get_checkjs_value($random_key = false) {
761
- global $ct_options;
762
-
763
- if ($random_key) {
764
- $keys = $ct_options['js_keys'];
765
- $keys_checksum = md5(json_encode($keys));
766
-
767
- $key = null;
768
- $latest_key_time = 0;
769
- foreach ($keys as $k => $t) {
770
-
771
- // Removing key if it's to old
772
- if (time() - $t > $ct_options['js_keys_store_days'] * 86400) {
773
- unset($keys[$k]);
774
- continue;
775
- }
776
-
777
- if ($t > $latest_key_time) {
778
- $latest_key_time = $t;
779
- $key = $k;
780
- }
781
- }
782
-
783
- // Get new key if the latest key is too old
784
- if (time() - $latest_key_time > $ct_options['js_key_lifetime']) {
785
- $key = rand();
786
- $keys[$key] = time();
787
- }
788
-
789
- if (md5(json_encode($keys)) != $keys_checksum) {
790
- $ct_options['js_keys'] = $keys;
791
- update_option('cleantalk_settings', $ct_options);
792
- }
793
- } else {
794
- $key = md5($ct_options['apikey'] . '+' . get_option('admin_email'));
795
- }
796
-
797
- return $key;
798
- }
799
-
800
-
801
  /**
802
  * Insert a hidden field to registration form
803
  * @return null
804
  */
805
  function ct_register_form() {
806
- global $ct_checkjs_register_form, $ct_options;
807
 
808
  if ($ct_options['registrations_test'] == 0) {
809
  return false;
@@ -819,7 +665,7 @@ function ct_register_form() {
819
  * @return null
820
  */
821
  function ct_login_message($message) {
822
- global $errors, $ct_session_register_ok_label, $ct_options;
823
 
824
  if ($ct_options['registrations_test'] != 0) {
825
  if( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] ) {
@@ -882,7 +728,7 @@ function ct_register_post($sanitized_user_login = null, $user_email = null, $err
882
  * @return array with errors
883
  */
884
  function ct_registration_errors($errors, $sanitized_user_login = null, $user_email = null) {
885
- 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;
886
 
887
  // Go out if a registrered user action
888
  if (ct_is_user_enable() === false) {
@@ -1027,7 +873,7 @@ function ct_user_register($user_id) {
1027
  * Test for JetPack contact form
1028
  */
1029
  function ct_grunion_contact_form_field_html($r, $field_label) {
1030
- global $ct_checkjs_jpcf, $ct_jpcf_patched, $ct_jpcf_fields, $ct_options;
1031
 
1032
  if ($ct_options['contact_forms_test'] == 1 && $ct_jpcf_patched === false && preg_match("/[text|email]/i", $r)) {
1033
 
@@ -1050,7 +896,7 @@ function ct_grunion_contact_form_field_html($r, $field_label) {
1050
  * Test for JetPack contact form
1051
  */
1052
  function ct_contact_form_is_spam($form) {
1053
- global $ct_checkjs_jpcf, $ct_options;
1054
 
1055
  if ($ct_options['contact_forms_test'] == 0) {
1056
  return null;
@@ -1112,7 +958,7 @@ function ct_contact_form_is_spam($form) {
1112
  * Inserts anti-spam hidden to CF7
1113
  */
1114
  function ct_wpcf7_form_elements($html) {
1115
- global $wpdb, $current_user, $ct_checkjs_cf7, $ct_options;
1116
 
1117
  if ($ct_options['contact_forms_test'] == 0) {
1118
  return $html;
@@ -1127,7 +973,7 @@ function ct_wpcf7_form_elements($html) {
1127
  * Test CF7 message for spam
1128
  */
1129
  function ct_wpcf7_spam($param) {
1130
- global $wpdb, $current_user, $ct_agent_version, $ct_checkjs_cf7, $ct_cf7_comment, $ct_options;
1131
 
1132
  if (WPCF7_VERSION >= '3.0.0') {
1133
  if($param === true)
@@ -1229,7 +1075,7 @@ function ct_si_contact_display_after_fields($string = '', $style = '', $form_err
1229
  * Test for Fast Secure contact form
1230
  */
1231
  function ct_si_contact_form_validate($form_errors = array(), $form_id_num = 0) {
1232
- global $ct_options;
1233
 
1234
  if (!empty($form_errors))
1235
  return $form_errors;
@@ -1305,7 +1151,7 @@ function ct_comment_text($comment_text) {
1305
  * Checks WordPress Landing Pages raw $_POST values
1306
  */
1307
  function ct_check_wplp(){
1308
- global $ct_wplp_result_label, $ct_options;
1309
  if (!isset($_COOKIE[$ct_wplp_result_label])) {
1310
  // First AJAX submit of WPLP form
1311
  if ($ct_options['contact_forms_test'] == 0)
@@ -1366,7 +1212,7 @@ function ct_check_wplp(){
1366
  * @return array with errors
1367
  */
1368
  function ct_s2member_registration_test() {
1369
- global $ct_agent_version, $ct_post_data_label, $ct_post_data_authnet_label, $ct_formtime_label, $ct_options;
1370
 
1371
  if ($ct_options['registrations_test'] == 0) {
1372
  return null;
@@ -1560,57 +1406,6 @@ function ct_get_data_from_submit($value = null, $field_name = null) {
1560
  }
1561
  }
1562
 
1563
-
1564
- /**
1565
- * Inner function - Default data array for senders
1566
- * @return array
1567
- */
1568
- function get_sender_info() {
1569
- global $ct_direct_post, $ct_options;
1570
-
1571
- $php_session = session_id() != '' ? 1 : 0;
1572
-
1573
- // Raw data to validated JavaScript test in the cloud
1574
- $checkjs_data_cookies = null;
1575
- if (isset($_COOKIE['ct_checkjs'])) {
1576
- $checkjs_data_cookies = $_COOKIE['ct_checkjs'];
1577
- }
1578
-
1579
- $checkjs_data_post = null;
1580
- if (count($_POST) > 0) {
1581
- foreach ($_POST as $k => $v) {
1582
- if (preg_match("/^ct_check.+/", $k)) {
1583
- $checkjs_data_post = $v;
1584
- }
1585
- }
1586
- }
1587
-
1588
- $options2server = array( // Options for sending to server for support information
1589
- 'apikey' => $ct_options['apikey'],
1590
- 'registrations_test' => $ct_options['registrations_test'],
1591
- 'comments_test' => $ct_options['comments_test'],
1592
- 'contact_forms_test' => $ct_options['contact_forms_test'],
1593
- 'general_contact_forms_test' => $ct_options['general_contact_forms_test'],
1594
- 'remove_old_spam' => $ct_options['remove_old_spam'],
1595
- 'autoPubRevelantMess' => $ct_options['autoPubRevelantMess'],
1596
- 'spam_store_days' => $ct_options['spam_store_days'],
1597
- 'ssl_on' => $ct_options['ssl_on'],
1598
- );
1599
-
1600
- return $sender_info = array(
1601
- 'page_url' => htmlspecialchars(@$_SERVER['SERVER_NAME'].@$_SERVER['REQUEST_URI']),
1602
- 'cms_lang' => substr(get_locale(), 0, 2),
1603
- 'REFFERRER' => htmlspecialchars(@$_SERVER['HTTP_REFERER']),
1604
- 'USER_AGENT' => htmlspecialchars(@$_SERVER['HTTP_USER_AGENT']),
1605
- 'php_session' => $php_session,
1606
- 'cookies_enabled' => ct_cookies_test(true),
1607
- 'direct_post' => $ct_direct_post,
1608
- 'checkjs_data_post' => $checkjs_data_post,
1609
- 'checkjs_data_cookies' => $checkjs_data_cookies,
1610
- 'ct_options' => json_encode($options2server),
1611
- );
1612
- }
1613
-
1614
  /**
1615
  * Sends error notice to admin
1616
  * @return null
5
  * @return mixed[] Array of options
6
  */
7
  function ct_init() {
8
+ global $ct_wplp_result_label, $ct_jp_comments, $ct_post_data_label, $ct_post_data_authnet_label, $ct_formtime_label, $ct_direct_post, $ct_options, $ct_data;
9
 
10
  $ct_options = ct_get_options();
11
+ $ct_data = ct_get_data();
12
 
13
  ct_init_session();
14
 
113
  }
114
  }
115
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  /**
117
  * Adds hidden filed to comment form
118
  */
119
  function ct_comment_form($post_id) {
120
+ global $ct_options, $ct_data;
121
 
122
  if (ct_is_user_enable() === false) {
123
  return false;
214
  * return null;
215
  */
216
  function ct_frm_entries_footer_scripts($fields, $form) {
217
+ global $current_user, $ct_checkjs_frm, $ct_options, $ct_data;
218
 
219
  if ($ct_options['contact_forms_test'] == 0) {
220
  return false;
239
  * return @array with errors if spam has found
240
  */
241
  function ct_frm_validate_entry ($errors, $values) {
242
+ global $wpdb, $current_user, $ct_agent_version, $ct_checkjs_frm, $ct_options, $ct_data;
243
 
244
  if ($ct_options['contact_forms_test'] == 0) {
245
  return false;
286
  * @return mixed[] $comment Comment string
287
  */
288
  function ct_bbp_new_pre_content ($comment) {
289
+ global $ct_options, $ct_data;
290
 
291
  if (ct_is_user_enable() === false || $ct_options['comments_test'] == 0 || is_user_logged_in()) {
292
  return $comment;
339
  // this action is called just when WP process POST request (adds new comment)
340
  // this action is called by wp-comments-post.php
341
  // after processing WP makes redirect to post page with comment's form by GET request (see above)
342
+ global $wpdb, $current_user, $comment_post_id, $ct_agent_version, $ct_comment_done, $ct_approved_request_id_label, $ct_jp_comments, $ct_options, $ct_data;
343
 
344
  if (ct_is_user_enable() === false || $ct_options['comments_test'] == 0 || $ct_comment_done) {
345
  return $comment;
498
  *
499
  */
500
  function js_test($field_name = 'ct_checkjs', $data = null, $random_key = false) {
501
+ global $ct_options, $ct_data;
502
 
503
  $checkjs = null;
504
  $js_post_value = null;
514
  //
515
  if ($random_key) {
516
 
517
+ $keys = $ct_data['js_keys'];
518
  if (isset($keys[$js_post_value])) {
519
  $checkjs = 1;
520
  } else {
536
  return $checkjs;
537
  }
538
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
539
  /**
540
  * Get post url
541
  * @param int $comment_id
644
  return false;
645
  }
646
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
647
  /**
648
  * Insert a hidden field to registration form
649
  * @return null
650
  */
651
  function ct_register_form() {
652
+ global $ct_checkjs_register_form, $ct_options, $ct_data;
653
 
654
  if ($ct_options['registrations_test'] == 0) {
655
  return false;
665
  * @return null
666
  */
667
  function ct_login_message($message) {
668
+ global $errors, $ct_session_register_ok_label, $ct_options, $ct_data;
669
 
670
  if ($ct_options['registrations_test'] != 0) {
671
  if( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] ) {
728
  * @return array with errors
729
  */
730
  function ct_registration_errors($errors, $sanitized_user_login = null, $user_email = null) {
731
+ 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;
732
 
733
  // Go out if a registrered user action
734
  if (ct_is_user_enable() === false) {
873
  * Test for JetPack contact form
874
  */
875
  function ct_grunion_contact_form_field_html($r, $field_label) {
876
+ global $ct_checkjs_jpcf, $ct_jpcf_patched, $ct_jpcf_fields, $ct_options, $ct_data;
877
 
878
  if ($ct_options['contact_forms_test'] == 1 && $ct_jpcf_patched === false && preg_match("/[text|email]/i", $r)) {
879
 
896
  * Test for JetPack contact form
897
  */
898
  function ct_contact_form_is_spam($form) {
899
+ global $ct_checkjs_jpcf, $ct_options, $ct_data;
900
 
901
  if ($ct_options['contact_forms_test'] == 0) {
902
  return null;
958
  * Inserts anti-spam hidden to CF7
959
  */
960
  function ct_wpcf7_form_elements($html) {
961
+ global $wpdb, $current_user, $ct_checkjs_cf7, $ct_options, $ct_data;
962
 
963
  if ($ct_options['contact_forms_test'] == 0) {
964
  return $html;
973
  * Test CF7 message for spam
974
  */
975
  function ct_wpcf7_spam($param) {
976
+ global $wpdb, $current_user, $ct_agent_version, $ct_checkjs_cf7, $ct_cf7_comment, $ct_options, $ct_data;
977
 
978
  if (WPCF7_VERSION >= '3.0.0') {
979
  if($param === true)
1075
  * Test for Fast Secure contact form
1076
  */
1077
  function ct_si_contact_form_validate($form_errors = array(), $form_id_num = 0) {
1078
+ global $ct_options, $ct_data;
1079
 
1080
  if (!empty($form_errors))
1081
  return $form_errors;
1151
  * Checks WordPress Landing Pages raw $_POST values
1152
  */
1153
  function ct_check_wplp(){
1154
+ global $ct_wplp_result_label, $ct_options, $ct_data;
1155
  if (!isset($_COOKIE[$ct_wplp_result_label])) {
1156
  // First AJAX submit of WPLP form
1157
  if ($ct_options['contact_forms_test'] == 0)
1212
  * @return array with errors
1213
  */
1214
  function ct_s2member_registration_test() {
1215
+ global $ct_agent_version, $ct_post_data_label, $ct_post_data_authnet_label, $ct_formtime_label, $ct_options, $ct_data;
1216
 
1217
  if ($ct_options['registrations_test'] == 0) {
1218
  return null;
1406
  }
1407
  }
1408
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1409
  /**
1410
  * Sends error notice to admin
1411
  * @return null
cleantalk.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Anti-spam by CleanTalk
4
  Plugin URI: http://cleantalk.org
5
  Description: Max power, all-in-one, captcha less, premium anti-spam plugin. No comment spam, no registration spam, no contact spam, protects any WordPress forms.
6
- Version: 4.22
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: http://cleantalk.org
9
  */
@@ -29,12 +29,6 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
29
  add_action('admin_menu', 'ct_admin_add_page');
30
  add_action('admin_notices', 'admin_notice_message');
31
  }
32
-
33
- if (defined( 'DOING_AJAX' ) && DOING_AJAX)
34
- {
35
- require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-public.php');
36
- require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-ajax.php');
37
- }
38
 
39
  add_action('admin_enqueue_scripts', 'ct_enqueue_scripts');
40
  add_action('comment_unapproved_to_approvecomment', 'ct_comment_approved'); // param - comment object
3
  Plugin Name: Anti-spam by CleanTalk
4
  Plugin URI: http://cleantalk.org
5
  Description: Max power, all-in-one, captcha less, premium anti-spam plugin. No comment spam, no registration spam, no contact spam, protects any WordPress forms.
6
+ Version: 4.24
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: http://cleantalk.org
9
  */
29
  add_action('admin_menu', 'ct_admin_add_page');
30
  add_action('admin_notices', 'admin_notice_message');
31
  }
 
 
 
 
 
 
32
 
33
  add_action('admin_enqueue_scripts', 'ct_enqueue_scripts');
34
  add_action('comment_unapproved_to_approvecomment', 'ct_comment_approved'); // param - comment object
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: znaeff, shagimuratov, vlad-cleantalk
3
  Tags: akismet, anti-spam, antispam, bbpress spam, buddypress spam, captcha antispam, cf7 spam, comments spam, contact form spam, fast secure contact form spam, form, Formidable spam, jetpack spam, landing pages, math, registration spam, s2member spam, signup spam, spam, spammers, spammy, WooCommerce spam, wordpress spam, booking spam, order spam, subscriptions spam, comments, gravity spam, gravity forms spam
4
  Requires at least: 3.0
5
  Tested up to: 4.1.1
6
- Stable tag: 4.22
7
  License: GPLv2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -175,6 +175,9 @@ WordPress 3.0 at least. PHP 5 with CURL or file_get_contents() function and enab
175
  1. Setup Android/iOS app to have push notices when new legitiamte comments/registrations or contactcs appears on the website.
176
 
177
  == Changelog ==
 
 
 
178
  = 4.22 2015-03-17 =
179
  * Added button for automatic spam protection key getting.
180
 
@@ -519,6 +522,9 @@ WordPress 3.0 at least. PHP 5 with CURL or file_get_contents() function and enab
519
  * First version
520
 
521
  == Upgrade Notice ==
 
 
 
522
  = 4.22 2015-03-17 =
523
  Added button for automatic spam protection key getting.
524
 
3
  Tags: akismet, anti-spam, antispam, bbpress spam, buddypress spam, captcha antispam, cf7 spam, comments spam, contact form spam, fast secure contact form spam, form, Formidable spam, jetpack spam, landing pages, math, registration spam, s2member spam, signup spam, spam, spammers, spammy, WooCommerce spam, wordpress spam, booking spam, order spam, subscriptions spam, comments, gravity spam, gravity forms spam
4
  Requires at least: 3.0
5
  Tested up to: 4.1.1
6
+ Stable tag: 4.24
7
  License: GPLv2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
175
  1. Setup Android/iOS app to have push notices when new legitiamte comments/registrations or contactcs appears on the website.
176
 
177
  == Changelog ==
178
+ = 4.24 2015-03-20 =
179
+ * Added immediate spam protection activation.
180
+
181
  = 4.22 2015-03-17 =
182
  * Added button for automatic spam protection key getting.
183
 
522
  * First version
523
 
524
  == Upgrade Notice ==
525
+ = 4.24 2015-03-20 =
526
+ Added immediate spam protection activation.
527
+
528
  = 4.22 2015-03-17 =
529
  Added button for automatic spam protection key getting.
530