Spam protection, AntiSpam, FireWall by CleanTalk - Version 2.34

Version Description

Download this release

Release Info

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

Code changes from version 2.35 to 2.34

Files changed (1) hide show
  1. cleantalk.php +50 -87
cleantalk.php CHANGED
@@ -3,16 +3,15 @@
3
  Plugin Name: Anti-spam by CleanTalk
4
  Plugin URI: http://cleantalk.org/my
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.35
7
  Author: СleanTalk <welcome@cleantalk.ru>
8
  Author URI: http://cleantalk.org
9
  */
10
 
11
- $ct_agent_version = 'wordpress-235';
12
  $ct_checkjs_frm = 'ct_checkjs_frm';
13
  $ct_checkjs_register_form = 'ct_checkjs_register_form';
14
  $ct_session_request_id_label = 'request_id';
15
- $ct_session_register_ok_label = 'register_ok';
16
 
17
  $ct_checkjs_cf7 = 'ct_checkjs_cf7';
18
  $ct_cf7_comment = 'This is a spam!';
@@ -45,12 +44,8 @@ $show_ct_notice_trial = false;
45
  // Timeout before new check for trial notice in minutes
46
  $trial_notice_check_timeout = 10;
47
 
48
- // Init action.
49
  add_action('init', 'ct_init');
50
 
51
- // After plugin loaded - to load locale as described in manual
52
- add_action( 'plugins_loaded', 'ct_plugin_loaded' );
53
-
54
  // Comments
55
  add_filter('preprocess_comment', 'ct_preprocess_comment'); // param - comment data array
56
  add_filter( 'comment_text', 'ct_comment_text' );
@@ -76,10 +71,6 @@ add_filter('wpcf7_spam', 'ct_wpcf7_spam');
76
  add_filter('grunion_contact_form_field_html', 'ct_grunion_contact_form_field_html', 10, 2);
77
  add_filter('contact_form_is_spam', 'ct_contact_form_is_spam');
78
 
79
- // Login form - for notifications only
80
- add_filter('login_message', 'ct_login_message');
81
-
82
-
83
  if (is_admin()) {
84
  add_action('admin_init', 'ct_admin_init', 1);
85
  add_action('admin_menu', 'ct_admin_add_page');
@@ -113,13 +104,6 @@ function ct_init() {
113
  }
114
  }
115
 
116
- /**
117
- * Public action 'plugins_loaded' - Loads locale, see http://codex.wordpress.org/Function_Reference/load_plugin_textdomain
118
- */
119
- function ct_plugin_loaded() {
120
- load_plugin_textdomain('cleantalk', false, basename(dirname(__FILE__)) . '/i18n');
121
- }
122
-
123
  /**
124
  * Inner function - Current Cleantalk options
125
  * @return mixed[] Array of options
@@ -194,7 +178,6 @@ function ct_feedback($hash, $message = null, $allow) {
194
  }
195
 
196
  $ct_feedback = $hash . ':' . $allow . ';';
197
- ct_init_session();
198
  if (empty($_SESSION['feedback_request'])) {
199
  $_SESSION['feedback_request'] = $ct_feedback;
200
  } else {
@@ -211,7 +194,6 @@ function ct_feedback($hash, $message = null, $allow) {
211
  */
212
  function ct_send_feedback($feedback_request = null) {
213
 
214
- ct_init_session();
215
  if (empty($feedback_request) && isset($_SESSION['feedback_request']) && preg_match("/^[a-z0-9\;\:]+$/", $_SESSION['feedback_request'])) {
216
  $feedback_request = $_SESSION['feedback_request'];
217
  unset($_SESSION['feedback_request']);
@@ -250,6 +232,13 @@ function ct_send_feedback($feedback_request = null) {
250
  return false;
251
  }
252
 
 
 
 
 
 
 
 
253
  /**
254
  * Session init
255
  * @return null;
@@ -268,10 +257,11 @@ function ct_init_session() {
268
  * @param array Array of parameters:
269
  * 'message' - string
270
  * 'example' - string
271
- * 'checkjs' - int
272
  * 'sender_email' - string
273
  * 'sender_nickname' - string
274
  * 'sender_info' - array
 
275
  * 'post_info' - string
276
  * @return array array('ct'=> Cleantalk, 'ct_result' => CleantalkResponse)
277
  */
@@ -318,7 +308,7 @@ function ct_base_call($params = array()) {
318
  $ct_request->sender_ip = $ct->ct_session_ip($_SERVER['REMOTE_ADDR']);
319
  $ct_request->agent = $ct_agent_version;
320
  $ct_request->sender_info = $sender_info;
321
- $ct_request->js_on = $params['checkjs'];
322
  $ct_request->submit_time = $submit_time;
323
  $ct_request->post_info = $params['post_info'];
324
 
@@ -340,6 +330,8 @@ function ct_base_call($params = array()) {
340
  * Adds hidden filed to comment form
341
  */
342
  function ct_comment_form() {
 
 
343
  if (ct_is_user_enable() === false) {
344
  return false;
345
  }
@@ -349,7 +341,7 @@ function ct_comment_form() {
349
  return false;
350
  }
351
 
352
- ct_add_hidden_fields(0, 'ct_checkjs', false);
353
 
354
  return null;
355
  }
@@ -358,14 +350,14 @@ function ct_comment_form() {
358
  * Adds hidden filed to define avaialbility of client's JavaScript
359
  * @param int $post_id Post ID, not used
360
  */
361
- function ct_add_hidden_fields($post_id = 0, $field_name = 'ct_checkjs', $return_string = false) {
362
  global $ct_jp_active, $ct_checkjs_def;
363
 
364
  $ct_checkjs_key = ct_get_checkjs_value();
365
  ct_init_session();
366
  $_SESSION['formtime'] = time();
367
 
368
- if ($ct_jp_active) {
369
  $html = '
370
  <script type="text/javascript">
371
  // <![CDATA[
@@ -386,7 +378,7 @@ function ct_add_hidden_fields($post_id = 0, $field_name = 'ct_checkjs', $return_
386
  <input type="hidden" id="%s" name="%s" value="0" />
387
  <script type="text/javascript">
388
  // <![CDATA[
389
- document.getElementById("%s").value = document.getElementById("%s").value.replace("%s", "%s");
390
  // ]]>
391
  </script>
392
  ';
@@ -457,14 +449,11 @@ function ct_frm_validate_entry ($errors, $values) {
457
  return false;
458
  }
459
 
460
- $checkjs = js_test($ct_checkjs_frm);
461
-
462
  $post_info['comment_type'] = 'feedback';
463
  $post_info = json_encode($post_info);
464
  if ($post_info === false)
465
  $post_info = '';
466
 
467
- $sender_email = null;
468
  $message = '';
469
  foreach ($values['item_meta'] as $v) {
470
  if (preg_match("/^\S+@\S+\.\S+$/", $v)) {
@@ -477,10 +466,10 @@ function ct_frm_validate_entry ($errors, $values) {
477
  $ct_base_call_result = ct_base_call(array(
478
  'message' => $message,
479
  'example' => null,
480
- 'sender_email' => $sender_email,
481
  'sender_nickname' => null,
482
  'post_info' => $post_info,
483
- 'checkjs' => $checkjs
484
  ));
485
  $ct = $ct_base_call_result['ct'];
486
  $ct_result = $ct_base_call_result['ct_result'];
@@ -541,8 +530,6 @@ function ct_preprocess_comment($comment) {
541
 
542
  $post = get_post($comment_post_id);
543
 
544
- $checkjs = js_test('ct_checkjs');
545
-
546
  $example = null;
547
 
548
  $post_info['comment_type'] = $comment['comment_type'];
@@ -577,7 +564,7 @@ function ct_preprocess_comment($comment) {
577
  'sender_email' => $comment['comment_author_email'],
578
  'sender_nickname' => $comment['comment_author'],
579
  'post_info' => $post_info,
580
- 'checkjs' => $checkjs
581
  ));
582
  $ct = $ct_base_call_result['ct'];
583
  $ct_result = $ct_base_call_result['ct_result'];
@@ -608,7 +595,7 @@ function ct_preprocess_comment($comment) {
608
  $approved_comments = get_comments(array('status' => 'approve', 'count' => true, 'author_email' => $comment['comment_author_email']));
609
 
610
  // Change comment flow only for new authors
611
- if ((int) $approved_comments == 0) {
612
 
613
  if ($ct_result->allow == 1 && $options['autoPubRevelantMess'] == 1) {
614
  add_filter('pre_comment_approved', 'ct_set_approved');
@@ -932,7 +919,8 @@ function ct_plugin_active($plugin_name){
932
  */
933
  function ct_get_checkjs_value() {
934
  $options = ct_get_options();
935
- return md5($options['apikey'] . '+' . get_option('admin_email'));
 
936
  }
937
 
938
  /**
@@ -973,33 +961,12 @@ function ct_register_form() {
973
  return null;
974
  }
975
 
976
- /**
977
- * Adds notification text to login form - to inform about approced registration
978
- * @return null
979
- */
980
- function ct_login_message($message) {
981
- global $errors, $ct_session_register_ok_label;
982
-
983
- $options = ct_get_options();
984
- if ($options['registrations_test'] != 0) {
985
- if( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] ) {
986
- ct_init_session();
987
- if (isset($_SESSION[$ct_session_register_ok_label])) {
988
- unset($_SESSION[$ct_session_register_ok_label]);
989
- if(is_wp_error($errors))
990
- $errors->add('ct_message','<br />' . sprintf(__('Registration is approved by %s.', 'cleantalk'), '<b style="color: #49C73B;">Clean</b><b style="color: #349ebf;">Talk</b>'), 'message');
991
- }
992
- }
993
- }
994
- return $message;
995
- }
996
-
997
  /**
998
  * Test users registration
999
  * @return array with errors
1000
  */
1001
  function ct_registration_errors($errors, $sanitized_user_login = null, $user_email = null) {
1002
- global $ct_agent_version, $ct_checkjs_register_form, $ct_session_request_id_label, $ct_session_register_ok_label, $bp;
1003
 
1004
  //
1005
  // BuddyPress actions
@@ -1019,7 +986,7 @@ function ct_registration_errors($errors, $sanitized_user_login = null, $user_ema
1019
  return $errors;
1020
  }
1021
 
1022
- $checkjs = js_test($ct_checkjs_register_form);
1023
 
1024
  require_once('cleantalk.class.php');
1025
 
@@ -1034,6 +1001,13 @@ function ct_registration_errors($errors, $sanitized_user_login = null, $user_ema
1034
  $user_info = '';
1035
 
1036
  $sender_email = $user_email;
 
 
 
 
 
 
 
1037
 
1038
  $config = get_option('cleantalk_server');
1039
 
@@ -1052,6 +1026,7 @@ function ct_registration_errors($errors, $sanitized_user_login = null, $user_ema
1052
  $ct_request->agent = $ct_agent_version;
1053
  $ct_request->sender_info = $user_info;
1054
  $ct_request->js_on = $checkjs;
 
1055
 
1056
  $ct_result = $ct->isAllowUser($ct_request);
1057
  if ($ct->server_change) {
@@ -1067,32 +1042,18 @@ function ct_registration_errors($errors, $sanitized_user_login = null, $user_ema
1067
  if ($ct_result->errno != 0) {
1068
  return $errors;
1069
  }
1070
-
1071
- if ($ct_result->inactive != 0) {
1072
- $timelabel_reg = intval( get_option('cleantalk_timelabel_reg') );
1073
- if(time() - 900 > $timelabel_reg){
1074
- update_option('cleantalk_timelabel_reg', time());
1075
-
1076
- $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
1077
- $message = __('Attention, please!', 'cleantalk') . "\r\n\r\n";
1078
- $message .= sprintf(__('"Anti-spam by CleanTalk" plugin error on your site %s:', 'cleantalk'), $blogname) . "\r\n\r\n";
1079
- $message .= $ct_result->comment . "\r\n\r\n";
1080
- @wp_mail(get_option('admin_email'), sprintf(__('[%s] Anti-spam by CleanTalk error!', 'cleantalk'), $blogname), $message);
1081
- }
1082
- return $errors;
1083
- }
1084
 
1085
  if ($ct_result->allow == 0) {
 
1086
  if ($buddypress === true) {
1087
  $bp->signup->errors['signup_username'] = $ct_result->comment;
1088
  } else {
1089
- $errors->add('ct_error', $ct_result->comment);
1090
  }
1091
  } else {
1092
  if ($ct_result->id !== null) {
1093
- ct_init_session();
1094
  $_SESSION[$ct_session_request_id_label] = $ct_result->id;
1095
- $_SESSION[$ct_session_register_ok_label] = $ct_result->id;
1096
  }
1097
  }
1098
 
@@ -1106,10 +1067,9 @@ function ct_registration_errors($errors, $sanitized_user_login = null, $user_ema
1106
  function ct_user_register($user_id) {
1107
  global $ct_session_request_id_label;
1108
 
1109
- ct_init_session();
1110
  if (isset($_SESSION[$ct_session_request_id_label])) {
1111
  update_user_meta($user_id, 'ct_hash', $_SESSION[$ct_session_request_id_label]);
1112
- unset($_SESSION[$ct_session_request_id_label]);
1113
  }
1114
  }
1115
 
@@ -1129,6 +1089,10 @@ function ct_delete_user($user_id) {
1129
  */
1130
  function ct_grunion_contact_form_field_html($r, $field_label) {
1131
  global $ct_checkjs_jpcf, $ct_jpcf_patched, $ct_jpcf_fields;
 
 
 
 
1132
 
1133
  $options = ct_get_options();
1134
  if ($options['contact_forms_test'] == 1 && $ct_jpcf_patched === false && preg_match("/[text|email]/i", $r)) {
@@ -1141,7 +1105,6 @@ function ct_grunion_contact_form_field_html($r, $field_label) {
1141
  $name_patched = true;
1142
  }
1143
  }
1144
-
1145
  $r .= ct_add_hidden_fields(0, $ct_checkjs_jpcf, true);
1146
  $ct_jpcf_patched = true;
1147
  }
@@ -1165,7 +1128,6 @@ function ct_contact_form_is_spam($form) {
1165
  if (preg_match("/^.+$ct_checkjs_jpcf$/", $k))
1166
  $js_field_name = $k;
1167
  }
1168
- $checkjs = js_test($js_field_name);
1169
 
1170
  $sender_info = array(
1171
  'sender_url' => @$form['comment_author_url']
@@ -1190,12 +1152,12 @@ function ct_contact_form_is_spam($form) {
1190
 
1191
  $ct_base_call_result = ct_base_call(array(
1192
  'message' => $message,
1193
- 'example' => null,
1194
  'sender_email' => $sender_email,
1195
  'sender_nickname' => $sender_nickname,
1196
  'post_info' => $post_info,
1197
  'sender_info' => $sender_info,
1198
- 'checkjs' => $checkjs
1199
  ));
1200
  $ct = $ct_base_call_result['ct'];
1201
  $ct_result = $ct_base_call_result['ct_result'];
@@ -1241,8 +1203,7 @@ function ct_wpcf7_spam($spam) {
1241
  return $spam;
1242
  }
1243
 
1244
- $checkjs = js_test($ct_checkjs_cf7);
1245
-
1246
  $post_info['comment_type'] = 'feedback';
1247
  $post_info = json_encode($post_info);
1248
  if ($post_info === false)
@@ -1265,11 +1226,11 @@ function ct_wpcf7_spam($spam) {
1265
 
1266
  $ct_base_call_result = ct_base_call(array(
1267
  'message' => $message,
1268
- 'example' => null,
1269
  'sender_email' => $sender_email,
1270
  'sender_nickname' => $sender_nickname,
1271
  'post_info' => $post_info,
1272
- 'checkjs' => $checkjs
1273
  ));
1274
  $ct = $ct_base_call_result['ct'];
1275
  $ct_result = $ct_base_call_result['ct_result'];
@@ -1360,6 +1321,7 @@ function ct_admin_init() {
1360
  setcookie($ct_notice_trial_label, (int) $show_ct_notice_trial, strtotime("+$trial_notice_check_timeout minutes"));
1361
  }
1362
 
 
1363
  ct_init_session();
1364
 
1365
  register_setting('cleantalk_settings', 'cleantalk_settings', 'ct_settings_validate');
@@ -1513,7 +1475,8 @@ function ct_comment_text($comment_text) {
1513
  $ct_hash = get_comment_meta($comment->comment_ID, 'ct_hash', true);
1514
 
1515
  if ($ct_hash !== '' && $_COOKIE[$ct_approved_request_id_label] == $ct_hash) {
1516
- $comment_text .= '<br /><br /> <em class="comment-awaiting-moderation">' . __('Comment is approved. Anti-spam by CleanTalk.', 'cleantalk') . '</em>';
 
1517
  }
1518
  }
1519
 
3
  Plugin Name: Anti-spam by CleanTalk
4
  Plugin URI: http://cleantalk.org/my
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.34
7
  Author: СleanTalk <welcome@cleantalk.ru>
8
  Author URI: http://cleantalk.org
9
  */
10
 
11
+ $ct_agent_version = 'wordpress-234';
12
  $ct_checkjs_frm = 'ct_checkjs_frm';
13
  $ct_checkjs_register_form = 'ct_checkjs_register_form';
14
  $ct_session_request_id_label = 'request_id';
 
15
 
16
  $ct_checkjs_cf7 = 'ct_checkjs_cf7';
17
  $ct_cf7_comment = 'This is a spam!';
44
  // Timeout before new check for trial notice in minutes
45
  $trial_notice_check_timeout = 10;
46
 
 
47
  add_action('init', 'ct_init');
48
 
 
 
 
49
  // Comments
50
  add_filter('preprocess_comment', 'ct_preprocess_comment'); // param - comment data array
51
  add_filter( 'comment_text', 'ct_comment_text' );
71
  add_filter('grunion_contact_form_field_html', 'ct_grunion_contact_form_field_html', 10, 2);
72
  add_filter('contact_form_is_spam', 'ct_contact_form_is_spam');
73
 
 
 
 
 
74
  if (is_admin()) {
75
  add_action('admin_init', 'ct_admin_init', 1);
76
  add_action('admin_menu', 'ct_admin_add_page');
104
  }
105
  }
106
 
 
 
 
 
 
 
 
107
  /**
108
  * Inner function - Current Cleantalk options
109
  * @return mixed[] Array of options
178
  }
179
 
180
  $ct_feedback = $hash . ':' . $allow . ';';
 
181
  if (empty($_SESSION['feedback_request'])) {
182
  $_SESSION['feedback_request'] = $ct_feedback;
183
  } else {
194
  */
195
  function ct_send_feedback($feedback_request = null) {
196
 
 
197
  if (empty($feedback_request) && isset($_SESSION['feedback_request']) && preg_match("/^[a-z0-9\;\:]+$/", $_SESSION['feedback_request'])) {
198
  $feedback_request = $_SESSION['feedback_request'];
199
  unset($_SESSION['feedback_request']);
232
  return false;
233
  }
234
 
235
+ /**
236
+ * Public action 'init' - Inits locale
237
+ */
238
+ function ct_init_locale() {
239
+ load_plugin_textdomain('cleantalk', false, basename(dirname(__FILE__)) . '/i18n');
240
+ }
241
+
242
  /**
243
  * Session init
244
  * @return null;
257
  * @param array Array of parameters:
258
  * 'message' - string
259
  * 'example' - string
260
+ * 'checkjs_field' -string
261
  * 'sender_email' - string
262
  * 'sender_nickname' - string
263
  * 'sender_info' - array
264
+ * 'checkjs_field' - string
265
  * 'post_info' - string
266
  * @return array array('ct'=> Cleantalk, 'ct_result' => CleantalkResponse)
267
  */
308
  $ct_request->sender_ip = $ct->ct_session_ip($_SERVER['REMOTE_ADDR']);
309
  $ct_request->agent = $ct_agent_version;
310
  $ct_request->sender_info = $sender_info;
311
+ $ct_request->js_on = js_test($params['checkjs_field']);
312
  $ct_request->submit_time = $submit_time;
313
  $ct_request->post_info = $params['post_info'];
314
 
330
  * Adds hidden filed to comment form
331
  */
332
  function ct_comment_form() {
333
+ global $ct_jp_active;
334
+
335
  if (ct_is_user_enable() === false) {
336
  return false;
337
  }
341
  return false;
342
  }
343
 
344
+ ct_add_hidden_fields(0, 'ct_checkjs', false, $ct_jp_active);
345
 
346
  return null;
347
  }
350
  * Adds hidden filed to define avaialbility of client's JavaScript
351
  * @param int $post_id Post ID, not used
352
  */
353
+ function ct_add_hidden_fields($post_id = 0, $field_name = 'ct_checkjs', $return_string = false, $cookie_check = false) {
354
  global $ct_jp_active, $ct_checkjs_def;
355
 
356
  $ct_checkjs_key = ct_get_checkjs_value();
357
  ct_init_session();
358
  $_SESSION['formtime'] = time();
359
 
360
+ if ($cookie_check) {
361
  $html = '
362
  <script type="text/javascript">
363
  // <![CDATA[
378
  <input type="hidden" id="%s" name="%s" value="0" />
379
  <script type="text/javascript">
380
  // <![CDATA[
381
+ document.getElementById("%s").value = document.getElementById("%s").value.replace(/^%s$/, "%s");
382
  // ]]>
383
  </script>
384
  ';
449
  return false;
450
  }
451
 
 
 
452
  $post_info['comment_type'] = 'feedback';
453
  $post_info = json_encode($post_info);
454
  if ($post_info === false)
455
  $post_info = '';
456
 
 
457
  $message = '';
458
  foreach ($values['item_meta'] as $v) {
459
  if (preg_match("/^\S+@\S+\.\S+$/", $v)) {
466
  $ct_base_call_result = ct_base_call(array(
467
  'message' => $message,
468
  'example' => null,
469
+ 'sender_email' => null,
470
  'sender_nickname' => null,
471
  'post_info' => $post_info,
472
+ 'checkjs_field' => $ct_checkjs_frm
473
  ));
474
  $ct = $ct_base_call_result['ct'];
475
  $ct_result = $ct_base_call_result['ct_result'];
530
 
531
  $post = get_post($comment_post_id);
532
 
 
 
533
  $example = null;
534
 
535
  $post_info['comment_type'] = $comment['comment_type'];
564
  'sender_email' => $comment['comment_author_email'],
565
  'sender_nickname' => $comment['comment_author'],
566
  'post_info' => $post_info,
567
+ 'checkjs_field' => 'ct_checkjs'
568
  ));
569
  $ct = $ct_base_call_result['ct'];
570
  $ct_result = $ct_base_call_result['ct_result'];
595
  $approved_comments = get_comments(array('status' => 'approve', 'count' => true, 'author_email' => $comment['comment_author_email']));
596
 
597
  // Change comment flow only for new authors
598
+ if ((int) $approved_comments == 0 || $ct_result->stop_words !== null) {
599
 
600
  if ($ct_result->allow == 1 && $options['autoPubRevelantMess'] == 1) {
601
  add_filter('pre_comment_approved', 'ct_set_approved');
919
  */
920
  function ct_get_checkjs_value() {
921
  $options = ct_get_options();
922
+
923
+ return md5($options['apikey'] . '+' . get_settings('admin_email'));
924
  }
925
 
926
  /**
961
  return null;
962
  }
963
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
964
  /**
965
  * Test users registration
966
  * @return array with errors
967
  */
968
  function ct_registration_errors($errors, $sanitized_user_login = null, $user_email = null) {
969
+ global $ct_agent_version, $ct_checkjs_register_form, $ct_session_request_id_label, $bp;
970
 
971
  //
972
  // BuddyPress actions
986
  return $errors;
987
  }
988
 
989
+ $checkjs = js_test($ct_checkjs_register_form);
990
 
991
  require_once('cleantalk.class.php');
992
 
1001
  $user_info = '';
1002
 
1003
  $sender_email = $user_email;
1004
+
1005
+ ct_init_session();
1006
+ if (array_key_exists('formtime', $_SESSION)) {
1007
+ $submit_time = time() - (int) $_SESSION['formtime'];
1008
+ } else {
1009
+ $submit_time = null;
1010
+ }
1011
 
1012
  $config = get_option('cleantalk_server');
1013
 
1026
  $ct_request->agent = $ct_agent_version;
1027
  $ct_request->sender_info = $user_info;
1028
  $ct_request->js_on = $checkjs;
1029
+ $ct_request->submit_time = $submit_time;
1030
 
1031
  $ct_result = $ct->isAllowUser($ct_request);
1032
  if ($ct->server_change) {
1042
  if ($ct_result->errno != 0) {
1043
  return $errors;
1044
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1045
 
1046
  if ($ct_result->allow == 0) {
1047
+ $wordpress_domain = preg_replace("/^https?:\/\//", "", site_url());
1048
  if ($buddypress === true) {
1049
  $bp->signup->errors['signup_username'] = $ct_result->comment;
1050
  } else {
1051
+ $errors->add('ct_error', __($ct_result->comment, $wordpress_domain));
1052
  }
1053
  } else {
1054
  if ($ct_result->id !== null) {
1055
+ ct_init_session();
1056
  $_SESSION[$ct_session_request_id_label] = $ct_result->id;
 
1057
  }
1058
  }
1059
 
1067
  function ct_user_register($user_id) {
1068
  global $ct_session_request_id_label;
1069
 
 
1070
  if (isset($_SESSION[$ct_session_request_id_label])) {
1071
  update_user_meta($user_id, 'ct_hash', $_SESSION[$ct_session_request_id_label]);
1072
+ unset($_SESSION[$ct_session_request_id_label]);
1073
  }
1074
  }
1075
 
1089
  */
1090
  function ct_grunion_contact_form_field_html($r, $field_label) {
1091
  global $ct_checkjs_jpcf, $ct_jpcf_patched, $ct_jpcf_fields;
1092
+
1093
+ // Skip proccessing if form submited
1094
+ if (count($_POST) > 0)
1095
+ return $r;
1096
 
1097
  $options = ct_get_options();
1098
  if ($options['contact_forms_test'] == 1 && $ct_jpcf_patched === false && preg_match("/[text|email]/i", $r)) {
1105
  $name_patched = true;
1106
  }
1107
  }
 
1108
  $r .= ct_add_hidden_fields(0, $ct_checkjs_jpcf, true);
1109
  $ct_jpcf_patched = true;
1110
  }
1128
  if (preg_match("/^.+$ct_checkjs_jpcf$/", $k))
1129
  $js_field_name = $k;
1130
  }
 
1131
 
1132
  $sender_info = array(
1133
  'sender_url' => @$form['comment_author_url']
1152
 
1153
  $ct_base_call_result = ct_base_call(array(
1154
  'message' => $message,
1155
+ 'example' => $example,
1156
  'sender_email' => $sender_email,
1157
  'sender_nickname' => $sender_nickname,
1158
  'post_info' => $post_info,
1159
  'sender_info' => $sender_info,
1160
+ 'checkjs_field' => $js_field_name
1161
  ));
1162
  $ct = $ct_base_call_result['ct'];
1163
  $ct_result = $ct_base_call_result['ct_result'];
1203
  return $spam;
1204
  }
1205
 
1206
+ $example = null;
 
1207
  $post_info['comment_type'] = 'feedback';
1208
  $post_info = json_encode($post_info);
1209
  if ($post_info === false)
1226
 
1227
  $ct_base_call_result = ct_base_call(array(
1228
  'message' => $message,
1229
+ 'example' => $example,
1230
  'sender_email' => $sender_email,
1231
  'sender_nickname' => $sender_nickname,
1232
  'post_info' => $post_info,
1233
+ 'checkjs_field' => $ct_checkjs_cf7
1234
  ));
1235
  $ct = $ct_base_call_result['ct'];
1236
  $ct_result = $ct_base_call_result['ct_result'];
1321
  setcookie($ct_notice_trial_label, (int) $show_ct_notice_trial, strtotime("+$trial_notice_check_timeout minutes"));
1322
  }
1323
 
1324
+ ct_init_locale();
1325
  ct_init_session();
1326
 
1327
  register_setting('cleantalk_settings', 'cleantalk_settings', 'ct_settings_validate');
1475
  $ct_hash = get_comment_meta($comment->comment_ID, 'ct_hash', true);
1476
 
1477
  if ($ct_hash !== '' && $_COOKIE[$ct_approved_request_id_label] == $ct_hash) {
1478
+ ct_init_locale();
1479
+ $comment_text .= '<br /><br /> <em class="comment-awaiting-moderation">' . __('Comment approved. Anti-spam by CleanTalk.', 'cleantalk') . '</em>';
1480
  }
1481
  }
1482