Version Description
Download this release
Release Info
Developer | shagimuratov |
Plugin | Spam protection, AntiSpam, FireWall by CleanTalk |
Version | 2.41 |
Comparing to | |
See all releases |
Code changes from version 2.40 to 2.41
- cleantalk.php +86 -49
cleantalk.php
CHANGED
@@ -3,12 +3,12 @@
|
|
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.
|
7 |
Author: СleanTalk <welcome@cleantalk.ru>
|
8 |
Author URI: http://cleantalk.org
|
9 |
*/
|
10 |
|
11 |
-
$ct_agent_version = 'wordpress-
|
12 |
$ct_checkjs_frm = 'ct_checkjs_frm';
|
13 |
$ct_checkjs_register_form = 'ct_checkjs_register_form';
|
14 |
$ct_session_request_id_label = 'request_id';
|
@@ -51,6 +51,9 @@ $trial_notice_check_timeout = 10;
|
|
51 |
// COOKIE label for WP Landing Page proccessing result
|
52 |
$ct_wplp_result_label = 'ct_wplp_result';
|
53 |
|
|
|
|
|
|
|
54 |
// Init action.
|
55 |
add_action('init', 'ct_init', 1);
|
56 |
|
@@ -120,7 +123,8 @@ function ct_init() {
|
|
120 |
(class_exists( 'Jetpack', false) && $jetpack_active_modules && in_array('comments', $jetpack_active_modules)) ||
|
121 |
(defined('LANDINGPAGES_CURRENT_VERSION'))
|
122 |
) {
|
123 |
-
|
|
|
124 |
}
|
125 |
|
126 |
//intercept WordPress Landing Pages POST
|
@@ -369,7 +373,10 @@ function ct_comment_form() {
|
|
369 |
return false;
|
370 |
}
|
371 |
|
372 |
-
|
|
|
|
|
|
|
373 |
|
374 |
return null;
|
375 |
}
|
@@ -417,8 +424,9 @@ ctSetCookie("%s", "%s");
|
|
417 |
';
|
418 |
$html = sprintf($html, $field_name, $ct_checkjs_key);
|
419 |
} else {
|
420 |
-
|
421 |
-
|
|
|
422 |
<input type="hidden" id="%s" name="%s" value="%s" />
|
423 |
<script type="text/javascript">
|
424 |
// <![CDATA[
|
@@ -435,6 +443,52 @@ document.getElementById("%s").value = document.getElementById("%s").value.replac
|
|
435 |
}
|
436 |
}
|
437 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
438 |
/**
|
439 |
* Is enable for user group
|
440 |
* @return boolean
|
@@ -493,7 +547,7 @@ function ct_frm_validate_entry ($errors, $values) {
|
|
493 |
return false;
|
494 |
}
|
495 |
|
496 |
-
$checkjs =
|
497 |
|
498 |
$post_info['comment_type'] = 'feedback';
|
499 |
$post_info = json_encode($post_info);
|
@@ -537,7 +591,7 @@ function ct_preprocess_comment($comment) {
|
|
537 |
// this action is called just when WP process POST request (adds new comment)
|
538 |
// this action is called by wp-comments-post.php
|
539 |
// after processing WP makes redirect to post page with comment's form by GET request (see above)
|
540 |
-
global $wpdb, $current_user, $comment_post_id, $ct_agent_version, $ct_comment_done, $ct_approved_request_id_label;
|
541 |
|
542 |
$options = ct_get_options();
|
543 |
if (ct_is_user_enable() === false || $options['comments_test'] == 0 || $ct_comment_done) {
|
@@ -576,8 +630,12 @@ function ct_preprocess_comment($comment) {
|
|
576 |
$comment_post_id = $comment['comment_post_ID'];
|
577 |
|
578 |
$post = get_post($comment_post_id);
|
|
|
|
|
|
|
|
|
579 |
|
580 |
-
$checkjs =
|
581 |
|
582 |
$example = null;
|
583 |
|
@@ -695,37 +753,15 @@ function ct_die_extended($comment_body) {
|
|
695 |
*
|
696 |
*
|
697 |
*/
|
698 |
-
function
|
699 |
$checkjs = null;
|
700 |
$js_field = null;
|
701 |
|
702 |
-
if (isset($
|
703 |
-
|
704 |
|
705 |
if ($js_field !== null) {
|
706 |
-
if($js_field == ct_get_checkjs_value()) {
|
707 |
-
$checkjs = 1;
|
708 |
-
} else {
|
709 |
-
$checkjs = 0;
|
710 |
-
}
|
711 |
-
}
|
712 |
-
|
713 |
-
return $checkjs;
|
714 |
-
}
|
715 |
-
|
716 |
-
/**
|
717 |
-
*
|
718 |
-
*
|
719 |
-
*/
|
720 |
-
function js_test_cookie($field_name = 'ct_checkjs') {
|
721 |
-
$checkjs = null;
|
722 |
-
$js_field = null;
|
723 |
-
|
724 |
-
if (isset($_COOKIE[$field_name]))
|
725 |
-
$js_field = $_COOKIE[$field_name];
|
726 |
-
|
727 |
-
if ($js_field !== null) {
|
728 |
-
if($js_field == ct_get_checkjs_value()) {
|
729 |
$checkjs = 1;
|
730 |
} else {
|
731 |
$checkjs = 0;
|
@@ -1005,14 +1041,15 @@ function ct_plugin_active($plugin_name){
|
|
1005 |
* Get ct_get_checkjs_value
|
1006 |
* @return string
|
1007 |
*/
|
1008 |
-
function ct_get_checkjs_value() {
|
1009 |
-
|
|
|
|
|
|
|
|
|
|
|
1010 |
|
1011 |
-
$
|
1012 |
-
if (isset($_SERVER['REMOTE_ADDR']))
|
1013 |
-
$remote_addr = $_SERVER['REMOTE_ADDR'];
|
1014 |
-
|
1015 |
-
return md5($options['apikey'] . '+' . $remote_addr);
|
1016 |
}
|
1017 |
|
1018 |
/**
|
@@ -1106,7 +1143,7 @@ function ct_registration_errors($errors, $sanitized_user_login = null, $user_ema
|
|
1106 |
return $errors;
|
1107 |
}
|
1108 |
|
1109 |
-
$checkjs =
|
1110 |
|
1111 |
require_once('cleantalk.class.php');
|
1112 |
|
@@ -1253,7 +1290,7 @@ function ct_contact_form_is_spam($form) {
|
|
1253 |
if (preg_match("/^.+$ct_checkjs_jpcf$/", $k))
|
1254 |
$js_field_name = $k;
|
1255 |
}
|
1256 |
-
$checkjs =
|
1257 |
|
1258 |
$sender_info = array(
|
1259 |
'sender_url' => @$form['comment_author_url']
|
@@ -1330,7 +1367,7 @@ function ct_wpcf7_spam($spam) {
|
|
1330 |
return $spam;
|
1331 |
}
|
1332 |
|
1333 |
-
$checkjs =
|
1334 |
|
1335 |
$post_info['comment_type'] = 'feedback';
|
1336 |
$post_info = json_encode($post_info);
|
@@ -1404,7 +1441,7 @@ function ct_si_contact_form_validate($form_errors = array(), $form_id_num = 0) {
|
|
1404 |
if ($options['contact_forms_test'] == 0)
|
1405 |
return $form_errors;
|
1406 |
|
1407 |
-
$checkjs =
|
1408 |
|
1409 |
$post_info['comment_type'] = 'feedback';
|
1410 |
$post_info = json_encode($post_info);
|
@@ -1752,9 +1789,9 @@ function ct_check_wplp(){
|
|
1752 |
if ($options['contact_forms_test'] == 0)
|
1753 |
return;
|
1754 |
|
1755 |
-
$checkjs =
|
1756 |
-
|
1757 |
-
|
1758 |
|
1759 |
$post_info['comment_type'] = 'feedback';
|
1760 |
$post_info = json_encode($post_info);
|
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.41
|
7 |
Author: СleanTalk <welcome@cleantalk.ru>
|
8 |
Author URI: http://cleantalk.org
|
9 |
*/
|
10 |
|
11 |
+
$ct_agent_version = 'wordpress-241';
|
12 |
$ct_checkjs_frm = 'ct_checkjs_frm';
|
13 |
$ct_checkjs_register_form = 'ct_checkjs_register_form';
|
14 |
$ct_session_request_id_label = 'request_id';
|
51 |
// COOKIE label for WP Landing Page proccessing result
|
52 |
$ct_wplp_result_label = 'ct_wplp_result';
|
53 |
|
54 |
+
// JetPack comment form loaded
|
55 |
+
$ct_jp_comments = false;
|
56 |
+
|
57 |
// Init action.
|
58 |
add_action('init', 'ct_init', 1);
|
59 |
|
123 |
(class_exists( 'Jetpack', false) && $jetpack_active_modules && in_array('comments', $jetpack_active_modules)) ||
|
124 |
(defined('LANDINGPAGES_CURRENT_VERSION'))
|
125 |
) {
|
126 |
+
add_action('wp_footer', 'ct_footer_add_cookie');
|
127 |
+
$ct_jp_comments = true;
|
128 |
}
|
129 |
|
130 |
//intercept WordPress Landing Pages POST
|
373 |
return false;
|
374 |
}
|
375 |
|
376 |
+
ct_add_hidden_fields2('ct_checkjs');
|
377 |
+
|
378 |
+
ct_init_session();
|
379 |
+
$_SESSION['formtime'] = time();
|
380 |
|
381 |
return null;
|
382 |
}
|
424 |
';
|
425 |
$html = sprintf($html, $field_name, $ct_checkjs_key);
|
426 |
} else {
|
427 |
+
|
428 |
+
$field_id = $field_name . '_' . md5(rand(0, 1000));
|
429 |
+
$html = '
|
430 |
<input type="hidden" id="%s" name="%s" value="%s" />
|
431 |
<script type="text/javascript">
|
432 |
// <![CDATA[
|
443 |
}
|
444 |
}
|
445 |
|
446 |
+
/**
|
447 |
+
* Adds hidden filed to define avaialbility of client's JavaScript
|
448 |
+
* @param int $post_id Post ID, not used
|
449 |
+
*/
|
450 |
+
function ct_add_hidden_fields2($field_name = 'ct_checkjs', $return_string = false) {
|
451 |
+
global $ct_checkjs_def;
|
452 |
+
|
453 |
+
$field_id = $field_name . '_' . md5(rand(0, 1000));
|
454 |
+
$field_id_div = 'div_' . $field_id;
|
455 |
+
$html = '
|
456 |
+
<div id="%s">
|
457 |
+
<span style="font-weight: bold;">Fill current <span style="color: red;">y_e_a_r</a>:</span>
|
458 |
+
<input type="text" id="%s" name="%s" value="%s" maxlength="4" size="4" style="width: 5em;" />
|
459 |
+
</div>
|
460 |
+
<script type="text/javascript">
|
461 |
+
// <![CDATA[
|
462 |
+
var date = new Date();
|
463 |
+
|
464 |
+
document.getElementById("%s").value = date.getFullYear();
|
465 |
+
if (document.getElementById("%s").value != %d) {
|
466 |
+
document.getElementById("%s").style.display = \'none\';
|
467 |
+
}
|
468 |
+
// ]]>
|
469 |
+
</script>
|
470 |
+
';
|
471 |
+
$html = sprintf(
|
472 |
+
$html,
|
473 |
+
$field_id_div,
|
474 |
+
$field_id,
|
475 |
+
$field_name,
|
476 |
+
$ct_checkjs_def,
|
477 |
+
$field_id,
|
478 |
+
$field_id,
|
479 |
+
$ct_checkjs_def,
|
480 |
+
$field_id_div
|
481 |
+
);
|
482 |
+
|
483 |
+
if ($return_string === true) {
|
484 |
+
return $html;
|
485 |
+
} else {
|
486 |
+
echo $html;
|
487 |
+
}
|
488 |
+
|
489 |
+
return null;
|
490 |
+
}
|
491 |
+
|
492 |
/**
|
493 |
* Is enable for user group
|
494 |
* @return boolean
|
547 |
return false;
|
548 |
}
|
549 |
|
550 |
+
$checkjs = js_test($ct_checkjs_frm);
|
551 |
|
552 |
$post_info['comment_type'] = 'feedback';
|
553 |
$post_info = json_encode($post_info);
|
591 |
// this action is called just when WP process POST request (adds new comment)
|
592 |
// this action is called by wp-comments-post.php
|
593 |
// after processing WP makes redirect to post page with comment's form by GET request (see above)
|
594 |
+
global $wpdb, $current_user, $comment_post_id, $ct_agent_version, $ct_comment_done, $ct_approved_request_id_label, $ct_jp_comments;
|
595 |
|
596 |
$options = ct_get_options();
|
597 |
if (ct_is_user_enable() === false || $options['comments_test'] == 0 || $ct_comment_done) {
|
630 |
$comment_post_id = $comment['comment_post_ID'];
|
631 |
|
632 |
$post = get_post($comment_post_id);
|
633 |
+
|
634 |
+
$simple_mode = true;
|
635 |
+
if ($ct_jp_comments)
|
636 |
+
$simple_mode = false;
|
637 |
|
638 |
+
$checkjs = js_test('ct_checkjs', $simple_mode);
|
639 |
|
640 |
$example = null;
|
641 |
|
753 |
*
|
754 |
*
|
755 |
*/
|
756 |
+
function js_test($field_name = 'ct_checkjs', $simple_mode = false) {
|
757 |
$checkjs = null;
|
758 |
$js_field = null;
|
759 |
|
760 |
+
if (isset($_REQUEST[$field_name]))
|
761 |
+
$js_field = $_REQUEST[$field_name];
|
762 |
|
763 |
if ($js_field !== null) {
|
764 |
+
if($js_field == ct_get_checkjs_value($simple_mode)) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
765 |
$checkjs = 1;
|
766 |
} else {
|
767 |
$checkjs = 0;
|
1041 |
* Get ct_get_checkjs_value
|
1042 |
* @return string
|
1043 |
*/
|
1044 |
+
function ct_get_checkjs_value($simple_mode = false) {
|
1045 |
+
if ($simple_mode) {
|
1046 |
+
$return = date("Y");
|
1047 |
+
} else {
|
1048 |
+
$options = ct_get_options();
|
1049 |
+
$return = md5($options['apikey'] . '+' . get_option('admin_email'));
|
1050 |
+
}
|
1051 |
|
1052 |
+
return $return;
|
|
|
|
|
|
|
|
|
1053 |
}
|
1054 |
|
1055 |
/**
|
1143 |
return $errors;
|
1144 |
}
|
1145 |
|
1146 |
+
$checkjs = js_test($ct_checkjs_register_form);
|
1147 |
|
1148 |
require_once('cleantalk.class.php');
|
1149 |
|
1290 |
if (preg_match("/^.+$ct_checkjs_jpcf$/", $k))
|
1291 |
$js_field_name = $k;
|
1292 |
}
|
1293 |
+
$checkjs = js_test($js_field_name);
|
1294 |
|
1295 |
$sender_info = array(
|
1296 |
'sender_url' => @$form['comment_author_url']
|
1367 |
return $spam;
|
1368 |
}
|
1369 |
|
1370 |
+
$checkjs = js_test($ct_checkjs_cf7);
|
1371 |
|
1372 |
$post_info['comment_type'] = 'feedback';
|
1373 |
$post_info = json_encode($post_info);
|
1441 |
if ($options['contact_forms_test'] == 0)
|
1442 |
return $form_errors;
|
1443 |
|
1444 |
+
$checkjs = js_test('ct_checkjs');
|
1445 |
|
1446 |
$post_info['comment_type'] = 'feedback';
|
1447 |
$post_info = json_encode($post_info);
|
1789 |
if ($options['contact_forms_test'] == 0)
|
1790 |
return;
|
1791 |
|
1792 |
+
$checkjs = js_test('ct_checkjs');
|
1793 |
+
if (null === $checkjs)
|
1794 |
+
$checkjs = 0;
|
1795 |
|
1796 |
$post_info['comment_type'] = 'feedback';
|
1797 |
$post_info = json_encode($post_info);
|