Version Description
July 25 2019 = * Fix: Plenty of minor fixes. * Fix: wpDiscuz integration. * Fix: Integration with bbPress. * Fix: New comment email notification. * New: Follow-Up Emails integration. * Fix: Woocommerce integration. * Fix: Spelling.
Download this release
Release Info
Developer | Safronik |
Plugin | Spam protection, AntiSpam, FireWall by CleanTalk |
Version | 5.123 |
Comparing to | |
See all releases |
Code changes from version 5.122 to 5.123
- cleantalk.php +38 -204
- inc/cleantalk-ajax.php +12 -6
- inc/cleantalk-pluggable.php +229 -0
- inc/cleantalk-public.php +47 -56
- inc/cleantalk-settings.php +2 -2
- lib/CleantalkAPI_base.php +30 -25
- inc/cleantalk-integrations.php → lib/CleantalkIntegration.php +0 -0
- lib/CleantalkState.php +2 -1
- readme.txt +19 -1
cleantalk.php
CHANGED
@@ -3,12 +3,12 @@
|
|
3 |
Plugin Name: Anti-Spam by CleanTalk
|
4 |
Plugin URI: http://cleantalk.org
|
5 |
Description: Max power, all-in-one, no Captcha, premium anti-spam plugin. No comment spam, no registration spam, no contact spam, protects any WordPress forms.
|
6 |
-
Version: 5.
|
7 |
Author: СleanTalk <welcome@cleantalk.org>
|
8 |
Author URI: http://cleantalk.org
|
9 |
Text Domain: cleantalk
|
10 |
Domain Path: /i18n
|
11 |
-
|
12 |
|
13 |
$cleantalk_executed = false;
|
14 |
|
@@ -49,16 +49,18 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
|
|
49 |
|
50 |
require_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkDB_Wordpress.php'); // Database class
|
51 |
|
52 |
-
require_once( CLEANTALK_PLUGIN_DIR . 'lib/cleantalk-php-patch.php');
|
53 |
-
require_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkHelper.php');
|
54 |
-
require_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkAPI_base.php');
|
55 |
-
require_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkAPI.php');
|
56 |
-
require_once( CLEANTALK_PLUGIN_DIR . 'lib/Cleantalk.php');
|
57 |
-
require_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkRequest.php');
|
58 |
-
require_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkResponse.php');
|
59 |
-
require_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkCron.php');
|
60 |
-
require_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkState.php');
|
61 |
-
require_once( CLEANTALK_PLUGIN_DIR . '
|
|
|
|
|
62 |
|
63 |
// Global ArrayObject with settings and other global varables
|
64 |
global $apbct;
|
@@ -150,7 +152,7 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
|
|
150 |
&& !empty($_POST['FB_userdata'])
|
151 |
){
|
152 |
require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-public.php');
|
153 |
-
if (
|
154 |
$ct_check_post_result=false;
|
155 |
ct_registration_errors(null);
|
156 |
}
|
@@ -1403,194 +1405,49 @@ function apbct_sfw__delete_tables( $blog_id, $drop ) {
|
|
1403 |
}
|
1404 |
|
1405 |
/**
|
1406 |
-
*
|
|
|
|
|
1407 |
*
|
1408 |
-
* @return
|
1409 |
*/
|
1410 |
-
function
|
1411 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1412 |
}
|
1413 |
|
1414 |
/**
|
1415 |
* Checks if the current user has role
|
1416 |
*
|
1417 |
-
* @param array $roles
|
1418 |
-
* @param int $user User ID to check
|
|
|
1419 |
* @return boolean Does the user has this role|roles
|
1420 |
*/
|
1421 |
function apbct_is_user_role_in( $roles, $user = false ){
|
1422 |
|
1423 |
-
if( is_numeric($user) )
|
1424 |
-
if(
|
1425 |
-
|
|
|
|
|
1426 |
if( empty($user->ID) )
|
1427 |
return false;
|
1428 |
-
|
1429 |
foreach( (array) $roles as $role ){
|
1430 |
-
if( isset($user->caps[ $role ]) || in_array($role, $user->roles) )
|
1431 |
return true;
|
1432 |
}
|
1433 |
|
1434 |
return false;
|
1435 |
}
|
1436 |
|
1437 |
-
function apbct_wp_get_current_user(){
|
1438 |
-
|
1439 |
-
global $current_user;
|
1440 |
-
|
1441 |
-
if(!(defined('XMLRPC_REQUEST') && XMLRPC_REQUEST)){
|
1442 |
-
|
1443 |
-
if(!empty($current_user)){
|
1444 |
-
$user_id = is_object($current_user) && isset($current_user->ID) && !($current_user instanceof WP_User)
|
1445 |
-
? $current_user->ID
|
1446 |
-
: null;
|
1447 |
-
}else{
|
1448 |
-
$user_id = empty($user_id) && !empty($_COOKIE[LOGGED_IN_COOKIE])
|
1449 |
-
? apbct_wp_validate_auth_cookie($_COOKIE[LOGGED_IN_COOKIE], 'logged_in')
|
1450 |
-
: null;
|
1451 |
-
}
|
1452 |
-
|
1453 |
-
if($user_id){
|
1454 |
-
$current_user = new WP_User($user_id);
|
1455 |
-
}
|
1456 |
-
|
1457 |
-
}
|
1458 |
-
|
1459 |
-
return $current_user;
|
1460 |
-
}
|
1461 |
-
|
1462 |
-
function apbct_wp_set_current_user($user = null){
|
1463 |
-
global $current_user;
|
1464 |
-
if($user instanceof WP_User)
|
1465 |
-
$current_user = $user;
|
1466 |
-
else
|
1467 |
-
return false;
|
1468 |
-
return true;
|
1469 |
-
}
|
1470 |
-
|
1471 |
-
/**
|
1472 |
-
* Validates authentication cookie.
|
1473 |
-
*
|
1474 |
-
* The checks include making sure that the authentication cookie is set and
|
1475 |
-
* pulling in the contents (if $cookie is not used).
|
1476 |
-
*
|
1477 |
-
* Makes sure the cookie is not expired. Verifies the hash in cookie is what is
|
1478 |
-
* should be and compares the two.
|
1479 |
-
*
|
1480 |
-
* @param string $cookie Optional. If used, will validate contents instead of cookie's
|
1481 |
-
* @param string $scheme Optional. The cookie scheme to use: auth, secure_auth, or logged_in
|
1482 |
-
*
|
1483 |
-
* @return false|int False if invalid cookie, User ID if valid.
|
1484 |
-
* @global int $login_grace_period
|
1485 |
-
*
|
1486 |
-
*/
|
1487 |
-
function apbct_wp_validate_auth_cookie( $cookie = '', $scheme = '' ) {
|
1488 |
-
|
1489 |
-
$cookie_elements = apbct_wp_parse_auth_cookie($cookie, $scheme);
|
1490 |
-
|
1491 |
-
$scheme = $cookie_elements['scheme'];
|
1492 |
-
$username = $cookie_elements['username'];
|
1493 |
-
$hmac = $cookie_elements['hmac'];
|
1494 |
-
$token = $cookie_elements['token'];
|
1495 |
-
$expiration = $cookie_elements['expiration'];
|
1496 |
-
|
1497 |
-
// Allow a grace period for POST and Ajax requests
|
1498 |
-
$expired = apbct_is_ajax() || 'POST' == $_SERVER['REQUEST_METHOD']
|
1499 |
-
? $expiration + HOUR_IN_SECONDS
|
1500 |
-
: $cookie_elements['expiration'];
|
1501 |
-
|
1502 |
-
// Quick check to see if an honest cookie has expired
|
1503 |
-
if($expired >= time()){
|
1504 |
-
$user = apbct_wp_get_user_by('login', $username);
|
1505 |
-
if($user){
|
1506 |
-
$pass_frag = substr($user->user_pass, 8, 4);
|
1507 |
-
$key = apbct_wp_hash($username . '|' . $pass_frag . '|' . $expiration . '|' . $token, $scheme);
|
1508 |
-
// If ext/hash is not present, compat.php's hash_hmac() does not support sha256.
|
1509 |
-
$algo = function_exists('hash') ? 'sha256' : 'sha1';
|
1510 |
-
$hash = hash_hmac($algo, $username . '|' . $expiration . '|' . $token, $key);
|
1511 |
-
if(hash_equals($hash, $hmac)){
|
1512 |
-
$sessions = get_user_meta($user->ID, 'session_tokens', true);
|
1513 |
-
$sessions = current($sessions);
|
1514 |
-
if(is_array($sessions)){
|
1515 |
-
if(is_int($sessions['expiration']) && $sessions['expiration'] > time()){
|
1516 |
-
return $user->ID;
|
1517 |
-
}else
|
1518 |
-
return false;
|
1519 |
-
}else
|
1520 |
-
return false;
|
1521 |
-
}else
|
1522 |
-
return false;
|
1523 |
-
}else
|
1524 |
-
return false;
|
1525 |
-
}else
|
1526 |
-
return false;
|
1527 |
-
}
|
1528 |
-
|
1529 |
-
function apbct_wp_get_user_by($field, $value){
|
1530 |
-
|
1531 |
-
$userdata = WP_User::get_data_by($field, $value);
|
1532 |
-
|
1533 |
-
if(!$userdata)
|
1534 |
-
return false;
|
1535 |
-
|
1536 |
-
$user = new WP_User;
|
1537 |
-
$user->init($userdata);
|
1538 |
-
|
1539 |
-
return $user;
|
1540 |
-
}
|
1541 |
-
|
1542 |
-
/**
|
1543 |
-
* Get hash of given string.
|
1544 |
-
*
|
1545 |
-
* @param string $data Plain text to hash
|
1546 |
-
* @param string $scheme Authentication scheme (auth, secure_auth, logged_in, nonce)
|
1547 |
-
* @return string Hash of $data
|
1548 |
-
*/
|
1549 |
-
function apbct_wp_hash( $data, $scheme = 'auth' ) {
|
1550 |
-
|
1551 |
-
$values = array(
|
1552 |
-
'key' => '',
|
1553 |
-
'salt' => '',
|
1554 |
-
);
|
1555 |
-
|
1556 |
-
foreach(array('key', 'salt') as $type){
|
1557 |
-
$const = strtoupper( "{$scheme}_{$type}");
|
1558 |
-
if ( defined($const) && constant($const)){
|
1559 |
-
$values[$type] = constant($const);
|
1560 |
-
}elseif(!$values[$type]){
|
1561 |
-
$values[$type] = get_site_option( "{$scheme}_{$type}");
|
1562 |
-
if (!$values[$type]){
|
1563 |
-
$values[$type] = '';
|
1564 |
-
}
|
1565 |
-
}
|
1566 |
-
}
|
1567 |
-
|
1568 |
-
$salt = $values['key'] . $values['salt'];
|
1569 |
-
|
1570 |
-
return hash_hmac('md5', $data, $salt);
|
1571 |
-
}
|
1572 |
-
|
1573 |
-
/**
|
1574 |
-
* Parse a cookie into its components
|
1575 |
-
*
|
1576 |
-
* @param string $cookie
|
1577 |
-
* @param string $scheme Optional. The cookie scheme to use: auth, secure_auth, or logged_in
|
1578 |
-
*
|
1579 |
-
* @return array|false Authentication cookie components
|
1580 |
-
*
|
1581 |
-
*/
|
1582 |
-
function apbct_wp_parse_auth_cookie($cookie = '', $scheme = '')
|
1583 |
-
{
|
1584 |
-
$cookie_elements = explode('|', $cookie);
|
1585 |
-
if(count($cookie_elements) !== 4){
|
1586 |
-
return false;
|
1587 |
-
}
|
1588 |
-
|
1589 |
-
list($username, $expiration, $token, $hmac) = $cookie_elements;
|
1590 |
-
|
1591 |
-
return compact('username', 'expiration', 'token', 'hmac', 'scheme');
|
1592 |
-
}
|
1593 |
-
|
1594 |
/**
|
1595 |
* Update and rotate statistics with requests exection time
|
1596 |
*
|
@@ -1616,29 +1473,6 @@ function apbct_statistics__rotate($exec_time){
|
|
1616 |
$apbct->save('stats');
|
1617 |
}
|
1618 |
|
1619 |
-
/**
|
1620 |
-
* Checks if the request is AJAX
|
1621 |
-
*
|
1622 |
-
* @return boolean
|
1623 |
-
*/
|
1624 |
-
function apbct_is_ajax() {
|
1625 |
-
|
1626 |
-
return
|
1627 |
-
(defined( 'DOING_AJAX' ) && DOING_AJAX) || // by standart WP functions
|
1628 |
-
(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') || // by Request type
|
1629 |
-
!empty($_POST['quform_ajax']); // special. QForms
|
1630 |
-
|
1631 |
-
}
|
1632 |
-
|
1633 |
-
function apbct_is_plugin_active_for_network( $plugin ){
|
1634 |
-
if ( ! APBCT_WPMS )
|
1635 |
-
return false;
|
1636 |
-
$plugins = get_site_option( 'active_sitewide_plugins' );
|
1637 |
-
return isset( $plugins[ $plugin ] )
|
1638 |
-
? true
|
1639 |
-
: false;
|
1640 |
-
}
|
1641 |
-
|
1642 |
/**
|
1643 |
* Runs update actions for new version.
|
1644 |
*
|
3 |
Plugin Name: Anti-Spam by CleanTalk
|
4 |
Plugin URI: http://cleantalk.org
|
5 |
Description: Max power, all-in-one, no Captcha, premium anti-spam plugin. No comment spam, no registration spam, no contact spam, protects any WordPress forms.
|
6 |
+
Version: 5.123
|
7 |
Author: СleanTalk <welcome@cleantalk.org>
|
8 |
Author URI: http://cleantalk.org
|
9 |
Text Domain: cleantalk
|
10 |
Domain Path: /i18n
|
11 |
+
*/+
|
12 |
|
13 |
$cleantalk_executed = false;
|
14 |
|
49 |
|
50 |
require_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkDB_Wordpress.php'); // Database class
|
51 |
|
52 |
+
require_once( CLEANTALK_PLUGIN_DIR . 'lib/cleantalk-php-patch.php'); // Pathces fpr different functions which not exists
|
53 |
+
require_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkHelper.php'); // Helper class. Different useful functions
|
54 |
+
require_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkAPI_base.php'); // API.
|
55 |
+
require_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkAPI.php'); // API extension for Wordpress
|
56 |
+
require_once( CLEANTALK_PLUGIN_DIR . 'lib/Cleantalk.php'); // Main class for request
|
57 |
+
require_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkRequest.php'); // Holds request data
|
58 |
+
require_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkResponse.php'); // Holds response data
|
59 |
+
require_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkCron.php'); // Cron handling
|
60 |
+
require_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkState.php'); // State class
|
61 |
+
// require_once( CLEANTALK_PLUGIN_DIR . 'lib/CleantalkIntegration.php'); // Integrations
|
62 |
+
require_once( CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-pluggable.php'); // Pluggable functions
|
63 |
+
require_once( CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-common.php');
|
64 |
|
65 |
// Global ArrayObject with settings and other global varables
|
66 |
global $apbct;
|
152 |
&& !empty($_POST['FB_userdata'])
|
153 |
){
|
154 |
require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-public.php');
|
155 |
+
if (apbct_is_user_enable()){
|
156 |
$ct_check_post_result=false;
|
157 |
ct_registration_errors(null);
|
158 |
}
|
1405 |
}
|
1406 |
|
1407 |
/**
|
1408 |
+
* Is enable for user group
|
1409 |
+
*
|
1410 |
+
* @param WP_User $user
|
1411 |
*
|
1412 |
+
* @return boolean
|
1413 |
*/
|
1414 |
+
function apbct_is_user_enable($user = null) {
|
1415 |
+
|
1416 |
+
global $current_user;
|
1417 |
+
|
1418 |
+
$user = !empty($user) ? $user : $current_user;
|
1419 |
+
|
1420 |
+
return apbct_is_user_role_in(array('administrator', 'editor', 'author'), $user)
|
1421 |
+
? false
|
1422 |
+
: true;
|
1423 |
}
|
1424 |
|
1425 |
/**
|
1426 |
* Checks if the current user has role
|
1427 |
*
|
1428 |
+
* @param array $roles array of strings
|
1429 |
+
* @param int|string|WP_User|mixed $user User ID to check|user_login|WP_User
|
1430 |
+
*
|
1431 |
* @return boolean Does the user has this role|roles
|
1432 |
*/
|
1433 |
function apbct_is_user_role_in( $roles, $user = false ){
|
1434 |
|
1435 |
+
if( is_numeric($user) && function_exists('get_userdata')) $user = get_userdata( $user );
|
1436 |
+
if( is_string($user) && function_exists('get_user_by')) $user = get_user_by('login', $user );
|
1437 |
+
if( ! $user && function_exists('wp_get_current_user')) $user = wp_get_current_user();
|
1438 |
+
if( ! $user ) $user = apbct_wp_get_current_user();
|
1439 |
+
|
1440 |
if( empty($user->ID) )
|
1441 |
return false;
|
1442 |
+
|
1443 |
foreach( (array) $roles as $role ){
|
1444 |
+
if( isset($user->caps[ strtolower($role) ]) || in_array(strtolower($role), $user->roles) )
|
1445 |
return true;
|
1446 |
}
|
1447 |
|
1448 |
return false;
|
1449 |
}
|
1450 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1451 |
/**
|
1452 |
* Update and rotate statistics with requests exection time
|
1453 |
*
|
1473 |
$apbct->save('stats');
|
1474 |
}
|
1475 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1476 |
/**
|
1477 |
* Runs update actions for new version.
|
1478 |
*
|
inc/cleantalk-ajax.php
CHANGED
@@ -136,6 +136,12 @@ $cleantalk_hooked_actions[]='ninja_forms_ajax_submit';
|
|
136 |
$cleantalk_hooked_actions[]='nf_ajax_submit';
|
137 |
$cleantalk_hooked_actions[]='ninja_forms_process'; // Depricated ?
|
138 |
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
function ct_validate_email_ajaxlogin($email=null, $is_ajax=true){
|
140 |
|
141 |
require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-public.php');
|
@@ -252,9 +258,7 @@ function ct_ajax_hook($message_obj = false, $additional = false)
|
|
252 |
$message_obj = (array)$message_obj;
|
253 |
|
254 |
// Get current_user and set it globaly
|
255 |
-
|
256 |
-
apbct_wp_set_current_user(apbct_wp_get_current_user());
|
257 |
-
}
|
258 |
|
259 |
// Go out because of not spam data
|
260 |
$skip_post = array(
|
@@ -279,13 +283,15 @@ function ct_ajax_hook($message_obj = false, $additional = false)
|
|
279 |
'validate_register_email', // Service id #313320
|
280 |
'elementor_pro_forms_send_form', //Elementor Pro
|
281 |
'phone-orders-for-woocommerce', //Phone orders for woocommerce backend
|
|
|
|
|
282 |
);
|
283 |
|
284 |
// Skip test if
|
285 |
if( !$apbct->settings['general_contact_forms_test'] || // Test disabled
|
286 |
-
!
|
287 |
-
(function_exists('get_current_user_id') && get_current_user_id() != 0) || // Check with default wp_* function if it's admin
|
288 |
-
($apbct->settings['protect_logged_in'] && (
|
289 |
check_url_exclusions() || // url exclusions
|
290 |
(isset($_POST['action']) && in_array($_POST['action'], $skip_post)) || // Special params
|
291 |
(isset($_GET['action']) && in_array($_GET['action'], $skip_post)) || // Special params
|
136 |
$cleantalk_hooked_actions[]='nf_ajax_submit';
|
137 |
$cleantalk_hooked_actions[]='ninja_forms_process'; // Depricated ?
|
138 |
|
139 |
+
/* Follow-Up Emails */
|
140 |
+
$cleantalk_hooked_actions[] = 'fue_wc_set_cart_email'; // Don't check email via this plugin
|
141 |
+
|
142 |
+
/* Follow-Up Emails */
|
143 |
+
$cleantalk_hooked_actions[] = 'fue_wc_set_cart_email'; // Don't check email via this plugin
|
144 |
+
|
145 |
function ct_validate_email_ajaxlogin($email=null, $is_ajax=true){
|
146 |
|
147 |
require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-public.php');
|
258 |
$message_obj = (array)$message_obj;
|
259 |
|
260 |
// Get current_user and set it globaly
|
261 |
+
apbct_wp_set_current_user($current_user instanceof WP_User ? $current_user : apbct_wp_get_current_user() );
|
|
|
|
|
262 |
|
263 |
// Go out because of not spam data
|
264 |
$skip_post = array(
|
283 |
'validate_register_email', // Service id #313320
|
284 |
'elementor_pro_forms_send_form', //Elementor Pro
|
285 |
'phone-orders-for-woocommerce', //Phone orders for woocommerce backend
|
286 |
+
'ihc_check_reg_field_ajax', //Ajax check required fields
|
287 |
+
'OSTC_lostPassword', //Lost password ajax form
|
288 |
);
|
289 |
|
290 |
// Skip test if
|
291 |
if( !$apbct->settings['general_contact_forms_test'] || // Test disabled
|
292 |
+
!apbct_is_user_enable($apbct->user) || // User is admin, editor, author
|
293 |
+
// (function_exists('get_current_user_id') && get_current_user_id() != 0) || // Check with default wp_* function if it's admin
|
294 |
+
($apbct->settings['protect_logged_in'] && ($apbct->user instanceof WP_User) && $apbct->user->ID !== 0 ) || // Logged in user
|
295 |
check_url_exclusions() || // url exclusions
|
296 |
(isset($_POST['action']) && in_array($_POST['action'], $skip_post)) || // Special params
|
297 |
(isset($_GET['action']) && in_array($_GET['action'], $skip_post)) || // Special params
|
inc/cleantalk-pluggable.php
ADDED
@@ -0,0 +1,229 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Getting current user by cookie
|
5 |
+
*
|
6 |
+
* @return WP_User|null
|
7 |
+
*/
|
8 |
+
function apbct_wp_get_current_user(){
|
9 |
+
|
10 |
+
global $apbct, $current_user;
|
11 |
+
|
12 |
+
$user = null;
|
13 |
+
|
14 |
+
if(!(defined('XMLRPC_REQUEST') && XMLRPC_REQUEST)){
|
15 |
+
|
16 |
+
if(!empty($apbct->user)){
|
17 |
+
$user_id = is_object($current_user) && isset($current_user->ID) && !($current_user instanceof WP_User)
|
18 |
+
? $current_user->ID
|
19 |
+
: null;
|
20 |
+
}else{
|
21 |
+
$user_id = empty($user_id) && !empty($_COOKIE[LOGGED_IN_COOKIE])
|
22 |
+
? apbct_wp_validate_auth_cookie($_COOKIE[LOGGED_IN_COOKIE], 'logged_in')
|
23 |
+
: null;
|
24 |
+
}
|
25 |
+
|
26 |
+
if($user_id){
|
27 |
+
$user = new WP_User($user_id);
|
28 |
+
}
|
29 |
+
|
30 |
+
}
|
31 |
+
|
32 |
+
return $user ? $user : $current_user;
|
33 |
+
}
|
34 |
+
|
35 |
+
function apbct_wp_set_current_user($user = null){
|
36 |
+
|
37 |
+
global $apbct;
|
38 |
+
|
39 |
+
if( $user instanceof WP_User ){
|
40 |
+
$apbct->user = $user;
|
41 |
+
return true;
|
42 |
+
}
|
43 |
+
|
44 |
+
return false;
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Validates authentication cookie.
|
49 |
+
*
|
50 |
+
* The checks include making sure that the authentication cookie is set and
|
51 |
+
* pulling in the contents (if $cookie is not used).
|
52 |
+
*
|
53 |
+
* Makes sure the cookie is not expired. Verifies the hash in cookie is what is
|
54 |
+
* should be and compares the two.
|
55 |
+
*
|
56 |
+
* @param string $cookie Optional. If used, will validate contents instead of cookie's
|
57 |
+
* @param string $scheme Optional. The cookie scheme to use: auth, secure_auth, or logged_in
|
58 |
+
*
|
59 |
+
* @return false|int False if invalid cookie, User ID if valid.
|
60 |
+
* @global int $login_grace_period
|
61 |
+
*
|
62 |
+
*/
|
63 |
+
function apbct_wp_validate_auth_cookie( $cookie = '', $scheme = '' ) {
|
64 |
+
|
65 |
+
$cookie_elements = apbct_wp_parse_auth_cookie($cookie, $scheme);
|
66 |
+
|
67 |
+
$scheme = $cookie_elements['scheme'];
|
68 |
+
$username = $cookie_elements['username'];
|
69 |
+
$hmac = $cookie_elements['hmac'];
|
70 |
+
$token = $cookie_elements['token'];
|
71 |
+
$expiration = $cookie_elements['expiration'];
|
72 |
+
|
73 |
+
// Allow a grace period for POST and Ajax requests
|
74 |
+
$expired = apbct_is_ajax() || 'POST' == $_SERVER['REQUEST_METHOD']
|
75 |
+
? $expiration + HOUR_IN_SECONDS
|
76 |
+
: $cookie_elements['expiration'];
|
77 |
+
|
78 |
+
// Quick check to see if an honest cookie has expired
|
79 |
+
if($expired >= time()){
|
80 |
+
$user = apbct_wp_get_user_by('login', $username);
|
81 |
+
if($user){
|
82 |
+
$pass_frag = substr($user->user_pass, 8, 4);
|
83 |
+
$key = apbct_wp_hash($username . '|' . $pass_frag . '|' . $expiration . '|' . $token, $scheme);
|
84 |
+
// If ext/hash is not present, compat.php's hash_hmac() does not support sha256.
|
85 |
+
$algo = function_exists('hash') ? 'sha256' : 'sha1';
|
86 |
+
$hash = hash_hmac($algo, $username . '|' . $expiration . '|' . $token, $key);
|
87 |
+
if(hash_equals($hash, $hmac)){
|
88 |
+
$sessions = get_user_meta($user->ID, 'session_tokens', true);
|
89 |
+
$sessions = current($sessions);
|
90 |
+
if(is_array($sessions)){
|
91 |
+
if(is_int($sessions['expiration']) && $sessions['expiration'] > time()){
|
92 |
+
return $user->ID;
|
93 |
+
}else
|
94 |
+
return false;
|
95 |
+
}else
|
96 |
+
return false;
|
97 |
+
}else
|
98 |
+
return false;
|
99 |
+
}else
|
100 |
+
return false;
|
101 |
+
}else
|
102 |
+
return false;
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Gets user by filed
|
107 |
+
*
|
108 |
+
* @param $field
|
109 |
+
* @param $value
|
110 |
+
*
|
111 |
+
* @return bool|WP_User
|
112 |
+
*/
|
113 |
+
function apbct_wp_get_user_by($field, $value){
|
114 |
+
|
115 |
+
$userdata = WP_User::get_data_by($field, $value);
|
116 |
+
|
117 |
+
if(!$userdata)
|
118 |
+
return false;
|
119 |
+
|
120 |
+
$user = new WP_User;
|
121 |
+
$user->init($userdata);
|
122 |
+
|
123 |
+
return $user;
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Get hash of given string.
|
128 |
+
*
|
129 |
+
* @param string $data Plain text to hash
|
130 |
+
* @param string $scheme Authentication scheme (auth, secure_auth, logged_in, nonce)
|
131 |
+
* @return string Hash of $data
|
132 |
+
*/
|
133 |
+
function apbct_wp_hash( $data, $scheme = 'auth' ) {
|
134 |
+
|
135 |
+
$values = array(
|
136 |
+
'key' => '',
|
137 |
+
'salt' => '',
|
138 |
+
);
|
139 |
+
|
140 |
+
foreach(array('key', 'salt') as $type){
|
141 |
+
$const = strtoupper( "{$scheme}_{$type}");
|
142 |
+
if ( defined($const) && constant($const)){
|
143 |
+
$values[$type] = constant($const);
|
144 |
+
}elseif(!$values[$type]){
|
145 |
+
$values[$type] = get_site_option( "{$scheme}_{$type}");
|
146 |
+
if (!$values[$type]){
|
147 |
+
$values[$type] = '';
|
148 |
+
}
|
149 |
+
}
|
150 |
+
}
|
151 |
+
|
152 |
+
$salt = $values['key'] . $values['salt'];
|
153 |
+
|
154 |
+
return hash_hmac('md5', $data, $salt);
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Parse a cookie into its components
|
159 |
+
*
|
160 |
+
* @param string $cookie
|
161 |
+
* @param string $scheme Optional. The cookie scheme to use: auth, secure_auth, or logged_in
|
162 |
+
*
|
163 |
+
* @return array|false Authentication cookie components
|
164 |
+
*
|
165 |
+
*/
|
166 |
+
function apbct_wp_parse_auth_cookie($cookie = '', $scheme = '')
|
167 |
+
{
|
168 |
+
$cookie_elements = explode('|', $cookie);
|
169 |
+
if(count($cookie_elements) !== 4){
|
170 |
+
return false;
|
171 |
+
}
|
172 |
+
|
173 |
+
list($username, $expiration, $token, $hmac) = $cookie_elements;
|
174 |
+
|
175 |
+
return compact('username', 'expiration', 'token', 'hmac', 'scheme');
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Checks if the plugin is active
|
180 |
+
*
|
181 |
+
* @param string $plugin relative path from plugin folder like cleantalk-spam-protect/cleantalk.php
|
182 |
+
*
|
183 |
+
* @return bool
|
184 |
+
*/
|
185 |
+
function apbct_is_plugin_active( $plugin ) {
|
186 |
+
return in_array( $plugin, (array) get_option( 'active_plugins', array() ) ) || apbct_is_plugin_active_for_network( $plugin );
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Checks if the plugin is active for network
|
191 |
+
*
|
192 |
+
* @param string $plugin relative path from plugin folder like cleantalk-spam-protect/cleantalk.php
|
193 |
+
*
|
194 |
+
* @return bool
|
195 |
+
*/
|
196 |
+
function apbct_is_plugin_active_for_network( $plugin ){
|
197 |
+
|
198 |
+
if ( ! APBCT_WPMS )
|
199 |
+
return false;
|
200 |
+
|
201 |
+
$plugins = get_site_option( 'active_sitewide_plugins' );
|
202 |
+
|
203 |
+
return isset( $plugins[ $plugin ] )
|
204 |
+
? true
|
205 |
+
: false;
|
206 |
+
}
|
207 |
+
|
208 |
+
/**
|
209 |
+
* Checks if the request is AJAX
|
210 |
+
*
|
211 |
+
* @return boolean
|
212 |
+
*/
|
213 |
+
function apbct_is_ajax() {
|
214 |
+
|
215 |
+
return
|
216 |
+
(defined( 'DOING_AJAX' ) && DOING_AJAX) || // by standart WP functions
|
217 |
+
(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') || // by Request type
|
218 |
+
!empty($_POST['quform_ajax']); // special. QForms
|
219 |
+
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* Checks if the user is logged in
|
224 |
+
*
|
225 |
+
* @return bool
|
226 |
+
*/
|
227 |
+
function apbct_is_user_logged_in(){
|
228 |
+
return count($_COOKIE) && defined('LOGGED_IN_COOKIE') && isset($_COOKIE[LOGGED_IN_COOKIE]);
|
229 |
+
}
|
inc/cleantalk-public.php
CHANGED
@@ -1,8 +1,5 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
// File with integrations
|
4 |
-
//require_once('cleantalk-integrations.php');
|
5 |
-
|
6 |
/**
|
7 |
* Init functions
|
8 |
* @return mixed[] Array of options
|
@@ -150,11 +147,8 @@ function apbct_init() {
|
|
150 |
}
|
151 |
|
152 |
// Formidable
|
153 |
-
if(class_exists('FrmSettings')){
|
154 |
-
//add_action('frm_validate_entry', 'ct_frm_validate_entry', 1, 2);
|
155 |
add_filter( 'frm_entries_before_create', 'ct_frm_validate_entry', 10, 2 );
|
156 |
-
add_action('frm_entries_footer_scripts', 'ct_frm_entries_footer_scripts', 20, 2);
|
157 |
-
}
|
158 |
|
159 |
// BuddyPress
|
160 |
if(class_exists('BuddyPress')){
|
@@ -213,7 +207,7 @@ function apbct_init() {
|
|
213 |
}
|
214 |
|
215 |
// Wilcity theme registration validation fix
|
216 |
-
add_filter( 'wilcity/filter/wiloke-listing-tools/validate-before-insert-account', '
|
217 |
|
218 |
|
219 |
// Gravity forms
|
@@ -250,11 +244,11 @@ function apbct_init() {
|
|
250 |
ct_contact_form_validate();
|
251 |
}
|
252 |
|
253 |
-
if (
|
254 |
|
255 |
if ($apbct->settings['general_contact_forms_test'] == 1 && !isset($_POST['comment_post_ID']) && !isset($_GET['for'])){
|
256 |
$ct_check_post_result=false;
|
257 |
-
ct_contact_form_validate
|
258 |
}
|
259 |
if(isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST' &&
|
260 |
$apbct->settings['general_postdata_test'] == 1 &&
|
@@ -660,7 +654,7 @@ function ct_comment_form($post_id){
|
|
660 |
|
661 |
global $apbct;
|
662 |
|
663 |
-
if (
|
664 |
return false;
|
665 |
}
|
666 |
|
@@ -763,27 +757,6 @@ function ct_add_hidden_fields($field_name = 'ct_checkjs', $return_string = false
|
|
763 |
}
|
764 |
}
|
765 |
|
766 |
-
/**
|
767 |
-
* Is enable for user group
|
768 |
-
* @return boolean
|
769 |
-
*/
|
770 |
-
function ct_is_user_enable() {
|
771 |
-
global $current_user;
|
772 |
-
|
773 |
-
if (!isset($current_user->roles)) {
|
774 |
-
return true;
|
775 |
-
}
|
776 |
-
|
777 |
-
$disable_roles = array('administrator', 'editor', 'author');
|
778 |
-
foreach ($current_user->roles as $k => $v) {
|
779 |
-
if (in_array($v, $disable_roles))
|
780 |
-
return false;
|
781 |
-
}
|
782 |
-
|
783 |
-
return true;
|
784 |
-
//return !current_user_can('publish_posts');
|
785 |
-
}
|
786 |
-
|
787 |
/**
|
788 |
* Public function - Insert JS code for spam tests
|
789 |
* return null;
|
@@ -894,8 +867,8 @@ function ct_bbp_get_topic($topic){
|
|
894 |
*/
|
895 |
function ct_bbp_new_pre_content ($comment) {
|
896 |
|
897 |
-
global $apbct, $current_user
|
898 |
-
|
899 |
if ( !$apbct->settings['comments_test']) {
|
900 |
return $comment;
|
901 |
}
|
@@ -910,18 +883,21 @@ function ct_bbp_new_pre_content ($comment) {
|
|
910 |
: apbct_js_test('ct_checkjs', $_POST);
|
911 |
|
912 |
$post_info['comment_type'] = 'bbpress_comment';
|
913 |
-
$post_info['post_url'] = bbp_get_topic_permalink();
|
914 |
-
|
915 |
-
if(
|
916 |
-
$
|
917 |
-
|
918 |
-
|
919 |
-
|
|
|
|
|
|
|
920 |
$base_call_result = apbct_base_call(
|
921 |
array(
|
922 |
'message' => $comment,
|
923 |
-
'sender_email' =>
|
924 |
-
'sender_nickname' =>
|
925 |
'post_info' => $post_info,
|
926 |
'js_on' => $checkjs,
|
927 |
'sender_info' => array('sender_url' => isset($_POST['bbp_anonymous_website']) ? $_POST['bbp_anonymous_website'] : null),
|
@@ -1043,7 +1019,7 @@ function ct_preprocess_comment($comment) {
|
|
1043 |
if (
|
1044 |
($comment['comment_type']!='trackback') &&
|
1045 |
(
|
1046 |
-
|
1047 |
$apbct->settings['comments_test'] == 0 ||
|
1048 |
$ct_comment_done ||
|
1049 |
(isset($_SERVER['HTTP_REFERER']) && stripos($_SERVER['HTTP_REFERER'],'page=wysija_campaigns&action=editTemplate')!==false) ||
|
@@ -1192,9 +1168,7 @@ function ct_preprocess_comment($comment) {
|
|
1192 |
}
|
1193 |
|
1194 |
// Change mail notification if license is out of date
|
1195 |
-
if($apbct->data['moderate'] == 0
|
1196 |
-
($ct_result->fast_submit == 1 || $ct_result->blacklisted == 1 || $ct_result->js_disabled == 1)
|
1197 |
-
){
|
1198 |
$apbct->sender_email = $comment['comment_author_email'];
|
1199 |
$apbct->sender_ip = CleantalkHelper::ip__get(array('real'));
|
1200 |
add_filter('comment_moderation_text', 'apbct_comment__Wordpress__changeMailNotification', 100, 2); // Comment sent to moderation
|
@@ -1256,10 +1230,10 @@ function apbct_comment__Wordpress__changeMailNotification($notify_message, $comm
|
|
1256 |
|
1257 |
$notify_message =
|
1258 |
PHP_EOL
|
1259 |
-
.__('CleanTalk AntiSpam: This message is spam.', 'cleantalk')
|
1260 |
."\n".__('You could check it in CleanTalk\'s anti-spam database:', 'cleantalk')
|
1261 |
-
."\n".'IP: https://cleantalk.org/blacklists/' . $apbct->sender_ip
|
1262 |
-
."\n".'Email: https://cleantalk.org/blacklists/' . $apbct->sender_email
|
1263 |
."\n".PHP_EOL . sprintf(
|
1264 |
__('Activate protection in your Anti-Spam Dashboard: %s.', 'clentalk'),
|
1265 |
'https://cleantalk.org/my/?cp_mode=antispam&utm_source=newsletter&utm_medium=email&utm_campaign=wp_spam_comment_passed'
|
@@ -1628,7 +1602,7 @@ function ct_registration_errors($errors, $sanitized_user_login = null, $user_ema
|
|
1628 |
global $ct_checkjs_register_form, $apbct_cookie_request_id_label, $apbct_cookie_register_ok_label, $bp, $ct_signup_done, $ct_negative_comment, $apbct, $ct_registration_error_comment, $cleantalk_executed;
|
1629 |
|
1630 |
// Go out if a registrered user action
|
1631 |
-
if (
|
1632 |
return $errors;
|
1633 |
}
|
1634 |
|
@@ -2641,7 +2615,8 @@ function ct_contact_form_validate() {
|
|
2641 |
strpos($_SERVER['REQUEST_URI'],'?provider=facebook&')!==false ||
|
2642 |
(isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'],'/wp-admin/') !== false) ||
|
2643 |
strpos($_SERVER['REQUEST_URI'],'/login/')!==false ||
|
2644 |
-
strpos($_SERVER['REQUEST_URI'], '/my-account/edit-account/')!==false ||
|
|
|
2645 |
strpos($_SERVER['REQUEST_URI'], '/peepsoajax/profilefieldsajax.validate_register')!== false ||
|
2646 |
isset($_GET['ptype']) && $_GET['ptype']=='login' ||
|
2647 |
check_url_exclusions() ||
|
@@ -2660,7 +2635,7 @@ function ct_contact_form_validate() {
|
|
2660 |
isset($_GET['for']) ||
|
2661 |
(isset($_POST['log'], $_POST['pwd'])) || //WooCommerce Sensei login form fix
|
2662 |
(isset($_POST['wc_reset_password'], $_POST['_wpnonce'], $_POST['_wp_http_referer'])) || // WooCommerce recovery password form
|
2663 |
-
(isset($_POST['woocommerce-login-nonce']
|
2664 |
(isset($_POST['wc-api']) && strtolower($_POST['wc-api']) == 'wc_gateway_systempay') || // Woo Systempay payment plugin
|
2665 |
(isset($_POST['_wpcf7'], $_POST['_wpcf7_version'], $_POST['_wpcf7_locale'])) || //CF7 fix)
|
2666 |
(isset($_POST['hash'], $_POST['device_unique_id'], $_POST['device_name'])) ||//Mobile Assistant Connector fix
|
@@ -2705,7 +2680,7 @@ function ct_contact_form_validate() {
|
|
2705 |
){
|
2706 |
$post_info['comment_type'] = 'order';
|
2707 |
if($apbct->settings['wc_checkout_test'] == 0){
|
2708 |
-
if ( $apbct->settings['wc_register_from_order'] == 1 ) {
|
2709 |
$post_info['comment_type'] = 'wc_register_from_order';
|
2710 |
} else {
|
2711 |
remove_filter('woocommerce_register_post', 'ct_register_post', 1 );
|
@@ -2859,6 +2834,21 @@ function ct_contact_form_validate_postdata() {
|
|
2859 |
(isset($pagenow) && $pagenow == 'wp-login.php') || // WordPress log in form
|
2860 |
(isset($pagenow) && $pagenow == 'wp-login.php' && isset($_GET['action']) && $_GET['action']=='lostpassword') ||
|
2861 |
strpos($_SERVER['REQUEST_URI'],'/checkout/')!==false ||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2862 |
strpos($_SERVER['REQUEST_URI'],'/wp-admin/')!==false ||
|
2863 |
strpos($_SERVER['REQUEST_URI'],'wp-login.php')!==false||
|
2864 |
strpos($_SERVER['REQUEST_URI'],'wp-comments-post.php')!==false ||
|
@@ -2882,7 +2872,8 @@ function ct_contact_form_validate_postdata() {
|
|
2882 |
(isset($_POST['provider'], $_POST['authcode']) && $_POST['provider'] == 'Two_Factor_Totp') || //TwoFactor authorization
|
2883 |
(isset($_GET['wc-ajax']) && $_GET['wc-ajax'] == 'sa_wc_buy_now_get_ajax_buy_now_button') || //BuyNow add to cart
|
2884 |
strpos($_SERVER['REQUEST_URI'],'/wp-json/wpstatistics/v1/hit')!==false || //WPStatistics
|
2885 |
-
(isset($_POST['ihcaction']) && $_POST['ihcaction'] == 'login') //Skip login form
|
|
|
2886 |
) {
|
2887 |
return null;
|
2888 |
}
|
@@ -3189,7 +3180,7 @@ function apbct_shrotcode_handler__GDPR_public_notice__form( $attrs ){
|
|
3189 |
* @param $data array ['username'] ['password'] ['email']
|
3190 |
* @return array array( 'status' => 'error' ) or array( 'status' => 'success' ) by default
|
3191 |
*/
|
3192 |
-
function
|
3193 |
$check = ct_test_registration( $data['username'], $data['email'], '' );
|
3194 |
if( $check['allow'] == 0 ) {
|
3195 |
return array( 'status' => 'error' );
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
3 |
/**
|
4 |
* Init functions
|
5 |
* @return mixed[] Array of options
|
147 |
}
|
148 |
|
149 |
// Formidable
|
|
|
|
|
150 |
add_filter( 'frm_entries_before_create', 'ct_frm_validate_entry', 10, 2 );
|
151 |
+
add_action( 'frm_entries_footer_scripts', 'ct_frm_entries_footer_scripts', 20, 2 );
|
|
|
152 |
|
153 |
// BuddyPress
|
154 |
if(class_exists('BuddyPress')){
|
207 |
}
|
208 |
|
209 |
// Wilcity theme registration validation fix
|
210 |
+
add_filter( 'wilcity/filter/wiloke-listing-tools/validate-before-insert-account', 'apbct_wilcity_reg_validation', 10, 2 );
|
211 |
|
212 |
|
213 |
// Gravity forms
|
244 |
ct_contact_form_validate();
|
245 |
}
|
246 |
|
247 |
+
if (apbct_is_user_enable()) {
|
248 |
|
249 |
if ($apbct->settings['general_contact_forms_test'] == 1 && !isset($_POST['comment_post_ID']) && !isset($_GET['for'])){
|
250 |
$ct_check_post_result=false;
|
251 |
+
add_action( 'wp', 'ct_contact_form_validate', 999 );
|
252 |
}
|
253 |
if(isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST' &&
|
254 |
$apbct->settings['general_postdata_test'] == 1 &&
|
654 |
|
655 |
global $apbct;
|
656 |
|
657 |
+
if (apbct_is_user_enable() === false) {
|
658 |
return false;
|
659 |
}
|
660 |
|
757 |
}
|
758 |
}
|
759 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
760 |
/**
|
761 |
* Public function - Insert JS code for spam tests
|
762 |
* return null;
|
867 |
*/
|
868 |
function ct_bbp_new_pre_content ($comment) {
|
869 |
|
870 |
+
global $apbct, $current_user;
|
871 |
+
|
872 |
if ( !$apbct->settings['comments_test']) {
|
873 |
return $comment;
|
874 |
}
|
883 |
: apbct_js_test('ct_checkjs', $_POST);
|
884 |
|
885 |
$post_info['comment_type'] = 'bbpress_comment';
|
886 |
+
$post_info['post_url'] = bbp_get_topic_permalink();
|
887 |
+
|
888 |
+
if( is_user_logged_in() ) {
|
889 |
+
$sender_email = $current_user->user_email;
|
890 |
+
$sender_nickname = $current_user->display_name;
|
891 |
+
} else {
|
892 |
+
$sender_email = isset($_POST['bbp_anonymous_email']) ? $_POST['bbp_anonymous_email'] : null;
|
893 |
+
$sender_nickname = isset($_POST['bbp_anonymous_name']) ? $_POST['bbp_anonymous_name'] : null;
|
894 |
+
}
|
895 |
+
|
896 |
$base_call_result = apbct_base_call(
|
897 |
array(
|
898 |
'message' => $comment,
|
899 |
+
'sender_email' => $sender_email,
|
900 |
+
'sender_nickname' => $sender_nickname,
|
901 |
'post_info' => $post_info,
|
902 |
'js_on' => $checkjs,
|
903 |
'sender_info' => array('sender_url' => isset($_POST['bbp_anonymous_website']) ? $_POST['bbp_anonymous_website'] : null),
|
1019 |
if (
|
1020 |
($comment['comment_type']!='trackback') &&
|
1021 |
(
|
1022 |
+
apbct_is_user_enable() === false ||
|
1023 |
$apbct->settings['comments_test'] == 0 ||
|
1024 |
$ct_comment_done ||
|
1025 |
(isset($_SERVER['HTTP_REFERER']) && stripos($_SERVER['HTTP_REFERER'],'page=wysija_campaigns&action=editTemplate')!==false) ||
|
1168 |
}
|
1169 |
|
1170 |
// Change mail notification if license is out of date
|
1171 |
+
if($apbct->data['moderate'] == 0){
|
|
|
|
|
1172 |
$apbct->sender_email = $comment['comment_author_email'];
|
1173 |
$apbct->sender_ip = CleantalkHelper::ip__get(array('real'));
|
1174 |
add_filter('comment_moderation_text', 'apbct_comment__Wordpress__changeMailNotification', 100, 2); // Comment sent to moderation
|
1230 |
|
1231 |
$notify_message =
|
1232 |
PHP_EOL
|
1233 |
+
.__('CleanTalk AntiSpam: This message is possible spam.', 'cleantalk')
|
1234 |
."\n".__('You could check it in CleanTalk\'s anti-spam database:', 'cleantalk')
|
1235 |
+
."\n".'IP: https://cleantalk.org/blacklists/' . $apbct->sender_ip
|
1236 |
+
."\n".'Email: https://cleantalk.org/blacklists/' . $apbct->sender_email
|
1237 |
."\n".PHP_EOL . sprintf(
|
1238 |
__('Activate protection in your Anti-Spam Dashboard: %s.', 'clentalk'),
|
1239 |
'https://cleantalk.org/my/?cp_mode=antispam&utm_source=newsletter&utm_medium=email&utm_campaign=wp_spam_comment_passed'
|
1602 |
global $ct_checkjs_register_form, $apbct_cookie_request_id_label, $apbct_cookie_register_ok_label, $bp, $ct_signup_done, $ct_negative_comment, $apbct, $ct_registration_error_comment, $cleantalk_executed;
|
1603 |
|
1604 |
// Go out if a registrered user action
|
1605 |
+
if (apbct_is_user_enable() === false) {
|
1606 |
return $errors;
|
1607 |
}
|
1608 |
|
2615 |
strpos($_SERVER['REQUEST_URI'],'?provider=facebook&')!==false ||
|
2616 |
(isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'],'/wp-admin/') !== false) ||
|
2617 |
strpos($_SERVER['REQUEST_URI'],'/login/')!==false ||
|
2618 |
+
strpos($_SERVER['REQUEST_URI'], '/my-account/edit-account/')!==false || //WooCommerce edit account page
|
2619 |
+
(isset($_POST['action']) && $_POST['action'] == 'save_account_details') || //WooCommerce edit account action
|
2620 |
strpos($_SERVER['REQUEST_URI'], '/peepsoajax/profilefieldsajax.validate_register')!== false ||
|
2621 |
isset($_GET['ptype']) && $_GET['ptype']=='login' ||
|
2622 |
check_url_exclusions() ||
|
2635 |
isset($_GET['for']) ||
|
2636 |
(isset($_POST['log'], $_POST['pwd'])) || //WooCommerce Sensei login form fix
|
2637 |
(isset($_POST['wc_reset_password'], $_POST['_wpnonce'], $_POST['_wp_http_referer'])) || // WooCommerce recovery password form
|
2638 |
+
((isset($_POST['woocommerce-login-nonce']) || isset($_POST['_wpnonce'])) && isset($_POST['login'], $_POST['password'], $_POST['_wp_http_referer'])) || // WooCommerce login form
|
2639 |
(isset($_POST['wc-api']) && strtolower($_POST['wc-api']) == 'wc_gateway_systempay') || // Woo Systempay payment plugin
|
2640 |
(isset($_POST['_wpcf7'], $_POST['_wpcf7_version'], $_POST['_wpcf7_locale'])) || //CF7 fix)
|
2641 |
(isset($_POST['hash'], $_POST['device_unique_id'], $_POST['device_name'])) ||//Mobile Assistant Connector fix
|
2680 |
){
|
2681 |
$post_info['comment_type'] = 'order';
|
2682 |
if($apbct->settings['wc_checkout_test'] == 0){
|
2683 |
+
if ( $apbct->settings['wc_register_from_order'] == 1 && ! is_user_logged_in() ) {
|
2684 |
$post_info['comment_type'] = 'wc_register_from_order';
|
2685 |
} else {
|
2686 |
remove_filter('woocommerce_register_post', 'ct_register_post', 1 );
|
2834 |
(isset($pagenow) && $pagenow == 'wp-login.php') || // WordPress log in form
|
2835 |
(isset($pagenow) && $pagenow == 'wp-login.php' && isset($_GET['action']) && $_GET['action']=='lostpassword') ||
|
2836 |
strpos($_SERVER['REQUEST_URI'],'/checkout/')!==false ||
|
2837 |
+
/* WooCommerce Service Requests - skip them */
|
2838 |
+
isset($_GET['wc-ajax']) && (
|
2839 |
+
$_GET['wc-ajax']=='checkout' ||
|
2840 |
+
$_GET['wc-ajax']=='get_refreshed_fragments' ||
|
2841 |
+
$_GET['wc-ajax']=='apply_coupon' ||
|
2842 |
+
$_GET['wc-ajax']=='remove_coupon' ||
|
2843 |
+
$_GET['wc-ajax']=='update_shipping_method' ||
|
2844 |
+
$_GET['wc-ajax']=='get_cart_totals' ||
|
2845 |
+
$_GET['wc-ajax']=='update_order_review' ||
|
2846 |
+
$_GET['wc-ajax']=='add_to_cart' ||
|
2847 |
+
$_GET['wc-ajax']=='remove_from_cart' ||
|
2848 |
+
$_GET['wc-ajax']=='get_variation' ||
|
2849 |
+
$_GET['wc-ajax']=='get_customer_location'
|
2850 |
+
) ||
|
2851 |
+
/* END: WooCommerce Service Requests */
|
2852 |
strpos($_SERVER['REQUEST_URI'],'/wp-admin/')!==false ||
|
2853 |
strpos($_SERVER['REQUEST_URI'],'wp-login.php')!==false||
|
2854 |
strpos($_SERVER['REQUEST_URI'],'wp-comments-post.php')!==false ||
|
2872 |
(isset($_POST['provider'], $_POST['authcode']) && $_POST['provider'] == 'Two_Factor_Totp') || //TwoFactor authorization
|
2873 |
(isset($_GET['wc-ajax']) && $_GET['wc-ajax'] == 'sa_wc_buy_now_get_ajax_buy_now_button') || //BuyNow add to cart
|
2874 |
strpos($_SERVER['REQUEST_URI'],'/wp-json/wpstatistics/v1/hit')!==false || //WPStatistics
|
2875 |
+
(isset($_POST['ihcaction']) && $_POST['ihcaction'] == 'login') || //Skip login form
|
2876 |
+
(isset($_POST['action']) && $_POST['action'] == 'infinite_scroll') //Scroll
|
2877 |
) {
|
2878 |
return null;
|
2879 |
}
|
3180 |
* @param $data array ['username'] ['password'] ['email']
|
3181 |
* @return array array( 'status' => 'error' ) or array( 'status' => 'success' ) by default
|
3182 |
*/
|
3183 |
+
function apbct_wilcity_reg_validation( $success, $data ) {
|
3184 |
$check = ct_test_registration( $data['username'], $data['email'], '' );
|
3185 |
if( $check['allow'] == 0 ) {
|
3186 |
return array( 'status' => 'error' );
|
inc/cleantalk-settings.php
CHANGED
@@ -234,7 +234,7 @@ function apbct_settings__add_page() {
|
|
234 |
'childrens' => array('set_cookies__sessions'),
|
235 |
),
|
236 |
'set_cookies__sessions' => array(
|
237 |
-
'title' => __('Use alternative mechanism for cookies
|
238 |
'description' => __('Doesn\'t use cookie or PHP sessions. Collect data for all types of bots.', 'cleantalk'),
|
239 |
'parent' => 'set_cookies',
|
240 |
'class' => 'apbct_settings-field_wrapper--sub',
|
@@ -728,7 +728,7 @@ function apbct_settings__field__api_key(){
|
|
728 |
echo '<input checked type="checkbox" id="license_agreed" onclick="apbctSettingsDependencies(\'get_key_auto\');"/>';
|
729 |
echo '<label for="spbc_license_agreed">';
|
730 |
printf(
|
731 |
-
__('I
|
732 |
'<a href="https://cleantalk.org/publicoffer" target="_blank" style="color:#66b;">', '</a>'
|
733 |
);
|
734 |
echo "</label>";
|
234 |
'childrens' => array('set_cookies__sessions'),
|
235 |
),
|
236 |
'set_cookies__sessions' => array(
|
237 |
+
'title' => __('Use alternative mechanism for cookies', 'cleantalk'),
|
238 |
'description' => __('Doesn\'t use cookie or PHP sessions. Collect data for all types of bots.', 'cleantalk'),
|
239 |
'parent' => 'set_cookies',
|
240 |
'class' => 'apbct_settings-field_wrapper--sub',
|
728 |
echo '<input checked type="checkbox" id="license_agreed" onclick="apbctSettingsDependencies(\'get_key_auto\');"/>';
|
729 |
echo '<label for="spbc_license_agreed">';
|
730 |
printf(
|
731 |
+
__('I accept %sLicense Agreement%s.', 'security-malware-firewall'),
|
732 |
'<a href="https://cleantalk.org/publicoffer" target="_blank" style="color:#66b;">', '</a>'
|
733 |
);
|
734 |
echo "</label>";
|
lib/CleantalkAPI_base.php
CHANGED
@@ -105,6 +105,7 @@ class CleantalkAPI_base
|
|
105 |
*
|
106 |
* @param string api_key API key
|
107 |
* @param string $path_to_cms Path to website
|
|
|
108 |
* @return type
|
109 |
*/
|
110 |
static public function method__notice_paid_till($api_key, $path_to_cms, $do_check = true)
|
@@ -336,9 +337,12 @@ class CleantalkAPI_base
|
|
336 |
/**
|
337 |
* Function gets spam domains report
|
338 |
*
|
339 |
-
* @param string
|
340 |
-
* @param
|
341 |
-
* @
|
|
|
|
|
|
|
342 |
*/
|
343 |
static public function method__backlinks_check_cms($api_key, $data, $date = null, $do_check = true)
|
344 |
{
|
@@ -362,7 +366,7 @@ class CleantalkAPI_base
|
|
362 |
* @param string api_key
|
363 |
* @param array logs
|
364 |
* @param bool do_check
|
365 |
-
* @return
|
366 |
*/
|
367 |
static public function method__security_backend_logs($api_key, $logs, $do_check = true)
|
368 |
{
|
@@ -381,15 +385,16 @@ class CleantalkAPI_base
|
|
381 |
|
382 |
/**
|
383 |
* Sends data about auto repairs
|
384 |
-
*
|
385 |
-
* @param
|
386 |
-
* @param
|
387 |
-
* @param
|
388 |
-
* @param
|
389 |
-
* @param
|
390 |
-
* @param
|
391 |
-
* @param
|
392 |
-
*
|
|
|
393 |
*/
|
394 |
static public function method__security_mscan_repairs($api_key, $repair_result, $repair_comment, $repaired_processed_files, $repaired_total_files_proccessed, $backup_id, $do_check = true)
|
395 |
{
|
@@ -412,10 +417,11 @@ class CleantalkAPI_base
|
|
412 |
/**
|
413 |
* Force server to update checksums for specific plugin\theme
|
414 |
*
|
415 |
-
* @param
|
416 |
-
* @param
|
417 |
-
* @param
|
418 |
-
*
|
|
|
419 |
*/
|
420 |
static public function method__request_checksums($api_key, $plugins_and_themes_to_refresh, $do_check = true)
|
421 |
{
|
@@ -434,11 +440,11 @@ class CleantalkAPI_base
|
|
434 |
/**
|
435 |
* Function sends raw request to API server
|
436 |
*
|
437 |
-
* @param
|
438 |
-
* @param
|
439 |
-
* @param
|
440 |
-
* @param
|
441 |
-
* @return
|
442 |
*/
|
443 |
static public function send_request($data, $url = self::URL, $timeout = 5, $ssl = false)
|
444 |
{
|
@@ -524,8 +530,8 @@ class CleantalkAPI_base
|
|
524 |
/**
|
525 |
* Function checks server response
|
526 |
*
|
527 |
-
* @param string result
|
528 |
-
* @param string
|
529 |
* @return mixed (array || array('error' => true))
|
530 |
*/
|
531 |
static public function check_response($result, $method_name = null)
|
@@ -558,7 +564,6 @@ class CleantalkAPI_base
|
|
558 |
);
|
559 |
}
|
560 |
|
561 |
-
$out = array();
|
562 |
// Pathces for different methods
|
563 |
switch ($method_name) {
|
564 |
|
105 |
*
|
106 |
* @param string api_key API key
|
107 |
* @param string $path_to_cms Path to website
|
108 |
+
*
|
109 |
* @return type
|
110 |
*/
|
111 |
static public function method__notice_paid_till($api_key, $path_to_cms, $do_check = true)
|
337 |
/**
|
338 |
* Function gets spam domains report
|
339 |
*
|
340 |
+
* @param string $api_key
|
341 |
+
* @param array|string|mixed $data
|
342 |
+
* @param string $date
|
343 |
+
* @param bool do_check
|
344 |
+
*
|
345 |
+
* @return array|bool|mixed
|
346 |
*/
|
347 |
static public function method__backlinks_check_cms($api_key, $data, $date = null, $do_check = true)
|
348 |
{
|
366 |
* @param string api_key
|
367 |
* @param array logs
|
368 |
* @param bool do_check
|
369 |
+
* @return array|bool|mixed
|
370 |
*/
|
371 |
static public function method__security_backend_logs($api_key, $logs, $do_check = true)
|
372 |
{
|
385 |
|
386 |
/**
|
387 |
* Sends data about auto repairs
|
388 |
+
*
|
389 |
+
* @param string $api_key
|
390 |
+
* @param $repair_result
|
391 |
+
* @param $repair_comment
|
392 |
+
* @param $repaired_processed_files
|
393 |
+
* @param $repaired_total_files_proccessed
|
394 |
+
* @param $backup_id
|
395 |
+
* @param bool $do_check
|
396 |
+
*
|
397 |
+
* @return array|bool|mixed
|
398 |
*/
|
399 |
static public function method__security_mscan_repairs($api_key, $repair_result, $repair_comment, $repaired_processed_files, $repaired_total_files_proccessed, $backup_id, $do_check = true)
|
400 |
{
|
417 |
/**
|
418 |
* Force server to update checksums for specific plugin\theme
|
419 |
*
|
420 |
+
* @param string $api_key
|
421 |
+
* @param string $plugins_and_themes_to_refresh
|
422 |
+
* @param bool $do_check
|
423 |
+
*
|
424 |
+
* @return array|bool|mixed
|
425 |
*/
|
426 |
static public function method__request_checksums($api_key, $plugins_and_themes_to_refresh, $do_check = true)
|
427 |
{
|
440 |
/**
|
441 |
* Function sends raw request to API server
|
442 |
*
|
443 |
+
* @param array $data to send
|
444 |
+
* @param string $url of API server
|
445 |
+
* @param integer $timeout timeout in seconds
|
446 |
+
* @param boolean $ssl use ssl on not
|
447 |
+
* @return array|bool
|
448 |
*/
|
449 |
static public function send_request($data, $url = self::URL, $timeout = 5, $ssl = false)
|
450 |
{
|
530 |
/**
|
531 |
* Function checks server response
|
532 |
*
|
533 |
+
* @param string $result
|
534 |
+
* @param string $method_name
|
535 |
* @return mixed (array || array('error' => true))
|
536 |
*/
|
537 |
static public function check_response($result, $method_name = null)
|
564 |
);
|
565 |
}
|
566 |
|
|
|
567 |
// Pathces for different methods
|
568 |
switch ($method_name) {
|
569 |
|
inc/cleantalk-integrations.php → lib/CleantalkIntegration.php
RENAMED
File without changes
|
lib/CleantalkState.php
CHANGED
@@ -14,7 +14,8 @@
|
|
14 |
*/
|
15 |
|
16 |
class CleantalkState
|
17 |
-
{
|
|
|
18 |
public $option_prefix = 'cleantalk';
|
19 |
public $storage = array();
|
20 |
public $integrations = array();
|
14 |
*/
|
15 |
|
16 |
class CleantalkState
|
17 |
+
{
|
18 |
+
public $user = null;
|
19 |
public $option_prefix = 'cleantalk';
|
20 |
public $storage = array();
|
21 |
public $integrations = array();
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: safronik
|
|
3 |
Tags: spam, antispam, protection, comments, firewall
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 5.3
|
6 |
-
Stable tag: 5.
|
7 |
License: GPLv2
|
8 |
|
9 |
Spam protection, antispam, all-in-one, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
|
@@ -575,6 +575,15 @@ If your website has forms that send data to external sources, you can enable opt
|
|
575 |
10. Website's options.
|
576 |
|
577 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
578 |
= 5.122 July 10 2019 =
|
579 |
* Spam Protection improved.
|
580 |
* Fix: Error while checking account status.
|
@@ -1947,6 +1956,15 @@ If your website has forms that send data to external sources, you can enable opt
|
|
1947 |
* First version
|
1948 |
|
1949 |
== Upgrade Notice ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1950 |
= 5.122 July 10 2019 =
|
1951 |
* Spam Protection improved.
|
1952 |
* Fix: Error while checking account status.
|
3 |
Tags: spam, antispam, protection, comments, firewall
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 5.3
|
6 |
+
Stable tag: 5.123
|
7 |
License: GPLv2
|
8 |
|
9 |
Spam protection, antispam, all-in-one, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
|
575 |
10. Website's options.
|
576 |
|
577 |
== Changelog ==
|
578 |
+
= 5.123 July 25 2019 =
|
579 |
+
* Fix: Plenty of minor fixes.
|
580 |
+
* Fix: wpDiscuz integration.
|
581 |
+
* Fix: Integration with bbPress.
|
582 |
+
* Fix: New comment email notification.
|
583 |
+
* New: Follow-Up Emails integration.
|
584 |
+
* Fix: Woocommerce integration.
|
585 |
+
* Fix: Spelling.
|
586 |
+
|
587 |
= 5.122 July 10 2019 =
|
588 |
* Spam Protection improved.
|
589 |
* Fix: Error while checking account status.
|
1956 |
* First version
|
1957 |
|
1958 |
== Upgrade Notice ==
|
1959 |
+
= 5.123 July 25 2019 =
|
1960 |
+
* Fix: Plenty of minor fixes.
|
1961 |
+
* Fix: wpDiscuz integration.
|
1962 |
+
* Fix: Integration with bbPress.
|
1963 |
+
* Fix: New comment email notification.
|
1964 |
+
* New: Follow-Up Emails integration.
|
1965 |
+
* Fix: Woocommerce integration.
|
1966 |
+
* Fix: Spelling.
|
1967 |
+
|
1968 |
= 5.122 July 10 2019 =
|
1969 |
* Spam Protection improved.
|
1970 |
* Fix: Error while checking account status.
|