Version Description
Feb 17.02.2021 = * New: Integrations. WPDiscuz integration implemented. * New: Using custom modal message instead allert. * New: JS cleantalk-modal added. * New: Cleantalk\ApbctWP\RemoteCalls class. * New: Remote calls using Cleantalk\ApbctWP\RemoteCalls class. * New: Cleantalk\ApbctWP\Helper::http_requestrc_to_host(). Wrapper to using RC to the website itself. Makes testing RC before make main. * New: Cleantalk\ApbctWP\State::error_toggle(). * New: SFW update. Make test RC before main. * Udp: Integrations. Support several hooks for one integration. * Fix: Users. Feedback sending via deleting user fixed. * Fix: Users checker. Feedback sending via deleting user fixed. * Fix: IP detection. * Fix: Users scan. Confirmation message fixed. * Fix: SFW. The anti-flood option moved to the advanced settings. * Fix: SFW. Show the right url on block page for WPMS. * Fix: SFW. The anti-crawler option description fixed. * Fix: SFW. The anti-flood option description fixed. * Fix: SFW. AC checking on login page fixed. * Fix: CF7. Modified spam hook. * Fix: SFW. sendlogs returning error. * Fix: Cleantalk class fixed. * Fix: Clearing errors storage before sync. * Fix: Clearing SFW errors on updating to 5.151.6. * Fix: Updater. Support updating for versions without fix number implemented. * Fix: "Email Before Download" plugin request will be skipped. * Fix: SFW. Auto-updating option fixed for multisite activation. * Fix: Exception for Xoo login form. * Fix: Users deleting feedback fixed.
Release Info
Developer | glomberg |
Plugin | Spam protection, AntiSpam, FireWall by CleanTalk |
Version | 5.153 |
Comparing to | |
See all releases |
Code changes from version 5.152.5 to 5.153
- cleantalk.php +35 -145
- inc/cleantalk-admin.php +2 -0
- inc/cleantalk-ajax.php +3 -1
- inc/cleantalk-common.php +3 -3
- inc/cleantalk-pluggable.php +23 -0
- inc/cleantalk-public.php +26 -14
- inc/cleantalk-settings.php +14 -11
- inc/cleantalk-updater.php +13 -1
- js/apbct-public.min.js +2 -1
- js/apbct-public.min.js.map +1 -1
- js/cleantalk-modal.min.js +2 -0
- js/cleantalk-modal.min.js.map +1 -0
- lib/Cleantalk/Antispam/Cleantalk.php +545 -542
- lib/Cleantalk/Antispam/Integrations.php +102 -87
- lib/Cleantalk/Antispam/Integrations/Wpdiscuz.php +20 -0
- lib/Cleantalk/ApbctWP/FindSpam/ListTable/Users.php +13 -8
- lib/Cleantalk/ApbctWP/FindSpam/UsersChecker.php +2 -2
- lib/Cleantalk/ApbctWP/Firewall/AntiCrawler.php +2 -1
- lib/Cleantalk/ApbctWP/Firewall/AntiFlood.php +1 -1
- lib/Cleantalk/ApbctWP/Firewall/SFW.php +2 -2
- lib/Cleantalk/ApbctWP/Helper.php +43 -0
- lib/Cleantalk/ApbctWP/RemoteCalls.php +188 -0
- lib/Cleantalk/ApbctWP/State.php +39 -35
- lib/Cleantalk/Common/Helper.php +3 -2
- readme.txt +31 -1
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Anti-Spam by CleanTalk
|
4 |
Plugin URI: https://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: https://cleantalk.org
|
9 |
Text Domain: cleantalk-spam-protect
|
@@ -17,6 +17,7 @@ use Cleantalk\ApbctWP\Cron;
|
|
17 |
use Cleantalk\ApbctWP\DB;
|
18 |
use Cleantalk\ApbctWP\Firewall\SFW;
|
19 |
use Cleantalk\ApbctWP\Helper;
|
|
|
20 |
use Cleantalk\Common\Schema;
|
21 |
use Cleantalk\Variables\Get;
|
22 |
|
@@ -133,7 +134,7 @@ if( !defined( 'CLEANTALK_PLUGIN_DIR' ) ){
|
|
133 |
$tasks_to_run = Cron::checkTasks(); // Check for current tasks. Drop tasks inner counters.
|
134 |
if(
|
135 |
! empty( $tasks_to_run ) && // There is tasks to run
|
136 |
-
!
|
137 |
(
|
138 |
! defined( 'DOING_CRON' ) ||
|
139 |
( defined( 'DOING_CRON' ) && DOING_CRON !== true )
|
@@ -193,6 +194,7 @@ if( !defined( 'CLEANTALK_PLUGIN_DIR' ) ){
|
|
193 |
'LandingPageBuilder' => array( 'hook' => 'ulpb_formBuilderEmail_ajax', 'ajax' => true ),
|
194 |
'WpMembers' => array( 'hook' => 'wpmem_pre_register_data', 'ajax' => false ),
|
195 |
'Rafflepress' => array( 'hook' => 'rafflepress_lite_giveaway_api', 'ajax' => true ),
|
|
|
196 |
);
|
197 |
new \Cleantalk\Antispam\Integrations( $apbct_active_integrations );
|
198 |
|
@@ -248,9 +250,9 @@ if( !defined( 'CLEANTALK_PLUGIN_DIR' ) ){
|
|
248 |
add_action( 'wp_head', 'apbct_search_add_noindex', 1 );
|
249 |
|
250 |
// Remote calls
|
251 |
-
if(
|
252 |
-
|
253 |
-
|
254 |
// SpamFireWall check
|
255 |
if( $apbct->plugin_version == APBCT_VERSION && // Do not call with first start
|
256 |
$apbct->settings['spam_firewall'] == 1 &&
|
@@ -448,119 +450,6 @@ if( !defined( 'CLEANTALK_PLUGIN_DIR' ) ){
|
|
448 |
|
449 |
}
|
450 |
|
451 |
-
/**
|
452 |
-
* Checking if the current request is the Remote Call
|
453 |
-
*
|
454 |
-
* @return bool
|
455 |
-
*/
|
456 |
-
function apbct_is_remote_call() {
|
457 |
-
return isset($_GET['spbc_remote_call_token'], $_GET['spbc_remote_call_action'], $_GET['plugin_name']) &&
|
458 |
-
in_array($_GET['plugin_name'], array('antispam','anti-spam', 'apbct'));
|
459 |
-
}
|
460 |
-
|
461 |
-
/**
|
462 |
-
* Function preforms remote call
|
463 |
-
*/
|
464 |
-
function apbct_remote_call__perform()
|
465 |
-
{
|
466 |
-
global $apbct;
|
467 |
-
|
468 |
-
$remote_action = $_GET['spbc_remote_call_action'];
|
469 |
-
|
470 |
-
if( isset( $apbct->remote_calls[$remote_action] ) ){
|
471 |
-
if(time() - $apbct->remote_calls[$remote_action]['last_call'] > APBCT_REMOTE_CALL_SLEEP || ($remote_action == 'sfw_update' && isset($_GET['file_urls']))) {
|
472 |
-
|
473 |
-
$apbct->remote_calls[$remote_action]['last_call'] = time();
|
474 |
-
$apbct->save('remote_calls');
|
475 |
-
|
476 |
-
if(strtolower($_GET['spbc_remote_call_token']) == strtolower(md5($apbct->api_key))){
|
477 |
-
|
478 |
-
// Flag to let plugin know that Remote Call is running.
|
479 |
-
$apbct->rc_running = true;
|
480 |
-
|
481 |
-
switch ($remote_action) {
|
482 |
-
|
483 |
-
// Close renew banner
|
484 |
-
case 'close_renew_banner':
|
485 |
-
$apbct->data['notice_trial'] = 0;
|
486 |
-
$apbct->data['notice_renew'] = 0;
|
487 |
-
$apbct->saveData();
|
488 |
-
Cron::updateTask('check_account_status', 'ct_account_status_check', 86400);
|
489 |
-
die('OK');
|
490 |
-
break;
|
491 |
-
|
492 |
-
// SFW update
|
493 |
-
case 'sfw_update':
|
494 |
-
$result = ct_sfw_update( $apbct->api_key, true);
|
495 |
-
/**
|
496 |
-
* @todo CRUNCH
|
497 |
-
*/
|
498 |
-
if(is_string($result) && strpos($result, 'FAIL') !== false){
|
499 |
-
$result = json_decode(substr($result, 5), true);
|
500 |
-
}
|
501 |
-
die(empty($result['error']) ? 'OK' : 'FAIL '.json_encode(array('error' => $result['error'])));
|
502 |
-
break;
|
503 |
-
|
504 |
-
// SFW send logs
|
505 |
-
case 'sfw_send_logs':
|
506 |
-
$result = ct_sfw_send_logs();
|
507 |
-
die(empty($result['error']) ? 'OK' : 'FAIL '.json_encode(array('error' => $result['error'])));
|
508 |
-
break;
|
509 |
-
|
510 |
-
// Update plugin
|
511 |
-
case 'update_plugin':
|
512 |
-
add_action('wp', 'apbct_rc__update', 1);
|
513 |
-
break;
|
514 |
-
|
515 |
-
// Install plugin
|
516 |
-
case 'install_plugin':
|
517 |
-
add_action('wp', 'apbct_rc__install_plugin', 1);
|
518 |
-
break;
|
519 |
-
// Activate plugin
|
520 |
-
case 'activate_plugin':
|
521 |
-
$result = apbct_rc__activate_plugin($_GET['plugin']);
|
522 |
-
die(empty($result['error'])
|
523 |
-
? 'OK'
|
524 |
-
: 'FAIL '.json_encode(array('error' => $result['error'])));
|
525 |
-
break;
|
526 |
-
|
527 |
-
// Insert API key
|
528 |
-
case 'insert_auth_key':
|
529 |
-
$result = apbct_rc__insert_auth_key($_GET['auth_key'], $_GET['plugin']);
|
530 |
-
die(empty($result['error'])
|
531 |
-
? 'OK'
|
532 |
-
: 'FAIL '.json_encode(array('error' => $result['error'])));
|
533 |
-
break;
|
534 |
-
|
535 |
-
// Update settins
|
536 |
-
case 'update_settings':
|
537 |
-
$result = apbct_rc__update_settings($_GET);
|
538 |
-
die(empty($result['error'])
|
539 |
-
? 'OK'
|
540 |
-
: 'FAIL '.json_encode(array('error' => $result['error'])));
|
541 |
-
break;
|
542 |
-
// Deactivate plugin
|
543 |
-
case 'deactivate_plugin':
|
544 |
-
add_action('plugins_loaded', 'apbct_rc__deactivate_plugin', 1);
|
545 |
-
break;
|
546 |
-
|
547 |
-
// Uninstall plugin
|
548 |
-
case 'uninstall_plugin':
|
549 |
-
add_action('plugins_loaded', 'apbct_rc__uninstall_plugin', 1);
|
550 |
-
break;
|
551 |
-
// No action found
|
552 |
-
default:
|
553 |
-
die('FAIL '.json_encode(array('error' => 'UNKNOWN_ACTION_2')));
|
554 |
-
break;
|
555 |
-
}
|
556 |
-
|
557 |
-
}else
|
558 |
-
die('FAIL '.json_encode(array('error' => 'WRONG_TOKEN')));
|
559 |
-
}else
|
560 |
-
die('FAIL '.json_encode(array('error' => 'TOO_MANY_ATTEMPTS')));
|
561 |
-
}else
|
562 |
-
die('FAIL '.json_encode(array('error' => 'UNKNOWN_ACTION')));
|
563 |
-
}
|
564 |
|
565 |
/**
|
566 |
* Function for SpamFireWall check
|
@@ -663,6 +552,9 @@ function apbct_activation( $network = false ) {
|
|
663 |
Cron::addTask('get_brief_data', 'cleantalk_get_brief_data', 86400, time() + 3500); // Get data for dashboard widget
|
664 |
Cron::addTask('send_connection_report','ct_mail_send_connection_report', 86400, time() + 3500); // Send connection report to welcome@cleantalk.org
|
665 |
Cron::addTask('antiflood__clear_table', 'apbct_antiflood__clear_table', 86400, time() + 300); // Clear Anti-Flood table
|
|
|
|
|
|
|
666 |
}
|
667 |
switch_to_blog($initial_blog);
|
668 |
}else{
|
@@ -676,14 +568,17 @@ function apbct_activation( $network = false ) {
|
|
676 |
Cron::addTask('get_brief_data', 'cleantalk_get_brief_data', 86400, time() + 3500); // Get data for dashboard widget
|
677 |
Cron::addTask('send_connection_report','ct_mail_send_connection_report', 86400, time() + 3500); // Send connection report to welcome@cleantalk.org
|
678 |
Cron::addTask('antiflood__clear_table', 'apbct_antiflood__clear_table', 86400, time() + 300); // Clear Anti-Flood table
|
679 |
-
|
|
|
|
|
|
|
680 |
apbct_activation__create_tables($sqls);
|
681 |
ct_account_status_check(null, false);
|
682 |
}
|
683 |
|
684 |
// Additional options
|
685 |
add_option( 'ct_plugin_do_activation_redirect', true );
|
686 |
-
|
687 |
}
|
688 |
|
689 |
function apbct_activation__create_tables( $sqls, $db_prefix = '' ) {
|
@@ -821,6 +716,7 @@ function apbct_deactivation__delete_common_tables() {
|
|
821 |
global $wpdb;
|
822 |
$wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->base_prefix.'cleantalk_sfw`;'); // Deleting SFW data
|
823 |
$wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->base_prefix.'cleantalk_sfw_logs`;'); // Deleting SFW logs
|
|
|
824 |
$wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->base_prefix.'cleantalk_ac_log`;'); // Deleting SFW logs
|
825 |
$wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->base_prefix.'cleantalk_sessions`;'); // Deleting session table
|
826 |
$wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->base_prefix.'cleantalk_spamscan_logs`;'); // Deleting user/comments scan result table
|
@@ -832,6 +728,7 @@ function apbct_deactivation__delete_blog_tables() {
|
|
832 |
global $wpdb;
|
833 |
$wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->prefix.'cleantalk_sfw`;'); // Deleting SFW data
|
834 |
$wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->prefix.'cleantalk_sfw_logs`;'); // Deleting SFW logs
|
|
|
835 |
$wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->prefix.'cleantalk_ac_log`;'); // Deleting SFW logs
|
836 |
$wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->prefix.'cleantalk_sessions`;'); // Deleting session table
|
837 |
$wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->prefix.'cleantalk_spamscan_logs`;'); // Deleting user/comments scan result table
|
@@ -910,6 +807,12 @@ function ct_get_cookie()
|
|
910 |
// This action triggered by wp_schedule_single_event( time() + 900, 'ct_sfw_update' );
|
911 |
add_action( 'ct_sfw_update', 'ct_sfw_update' );
|
912 |
|
|
|
|
|
|
|
|
|
|
|
|
|
913 |
function ct_sfw_update( $api_key = '', $immediate = false ){
|
914 |
|
915 |
global $apbct, $wpdb;
|
@@ -950,7 +853,7 @@ function ct_sfw_update( $api_key = '', $immediate = false ){
|
|
950 |
$apbct->save( 'fw_stats' );
|
951 |
}
|
952 |
|
953 |
-
if(
|
954 |
// Remote call is in process, do updating
|
955 |
|
956 |
$file_urls = isset($_GET['file_urls']) ? urldecode( $_GET['file_urls'] ) : null;
|
@@ -992,7 +895,7 @@ function ct_sfw_update( $api_key = '', $immediate = false ){
|
|
992 |
$apbct->save('fw_stats');
|
993 |
|
994 |
if ( $url_count > $current_url ) {
|
995 |
-
return Helper::
|
996 |
get_option('siteurl'),
|
997 |
array(
|
998 |
'spbc_remote_call_token' => md5($api_key),
|
@@ -1027,10 +930,10 @@ function ct_sfw_update( $api_key = '', $immediate = false ){
|
|
1027 |
$apbct->stats['sfw']['last_update_time'] = time();
|
1028 |
$apbct->save('stats');
|
1029 |
|
1030 |
-
// Running sfw update once again in
|
1031 |
if( $is_first_updating !== false ) {
|
1032 |
if( $apbct->stats['sfw']['entries'] < 4000 ) {
|
1033 |
-
wp_schedule_single_event( time() +
|
1034 |
}
|
1035 |
delete_option( 'sfw_sync_first' );
|
1036 |
}
|
@@ -1048,7 +951,7 @@ function ct_sfw_update( $api_key = '', $immediate = false ){
|
|
1048 |
|
1049 |
} else {
|
1050 |
// Go to init remote call
|
1051 |
-
return Helper::
|
1052 |
get_option( 'siteurl' ),
|
1053 |
array(
|
1054 |
'spbc_remote_call_token' => md5( $api_key ),
|
@@ -1071,7 +974,11 @@ function ct_sfw_send_logs($api_key = '')
|
|
1071 |
|
1072 |
$api_key = !empty($apbct->api_key) ? $apbct->api_key : $api_key;
|
1073 |
|
1074 |
-
|
|
|
|
|
|
|
|
|
1075 |
|
1076 |
$result = SFW::send_log(
|
1077 |
DB::getInstance(),
|
@@ -1088,9 +995,8 @@ function ct_sfw_send_logs($api_key = '')
|
|
1088 |
|
1089 |
return $result;
|
1090 |
|
1091 |
-
}
|
1092 |
-
|
1093 |
-
return array('error' => 'SFW_DISABLED');
|
1094 |
}
|
1095 |
|
1096 |
function apbct_antiflood__clear_table(){
|
@@ -1833,22 +1739,6 @@ function apbct_cookies_test()
|
|
1833 |
}
|
1834 |
}
|
1835 |
|
1836 |
-
function apbct_cookies__delete($cookie){
|
1837 |
-
if(isset($_COOKIE[$cookie]))
|
1838 |
-
setcookie($cookie, '', time()-3600);
|
1839 |
-
}
|
1840 |
-
|
1841 |
-
function apbct_cookies__delete_all(){
|
1842 |
-
if(count($_COOKIE)){
|
1843 |
-
foreach($_COOKIE as $key => $val){
|
1844 |
-
if(preg_match("/apbct_|ct_/", $key)){
|
1845 |
-
setcookie($key, '', time()-3600);
|
1846 |
-
}
|
1847 |
-
} unset($key, $val);
|
1848 |
-
}
|
1849 |
-
return false;
|
1850 |
-
}
|
1851 |
-
|
1852 |
/**
|
1853 |
* Gets submit time
|
1854 |
* Uses Cookies with check via apbct_cookies_test()
|
3 |
Plugin Name: Anti-Spam by CleanTalk
|
4 |
Plugin URI: https://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.153
|
7 |
Author: СleanTalk <welcome@cleantalk.org>
|
8 |
Author URI: https://cleantalk.org
|
9 |
Text Domain: cleantalk-spam-protect
|
17 |
use Cleantalk\ApbctWP\DB;
|
18 |
use Cleantalk\ApbctWP\Firewall\SFW;
|
19 |
use Cleantalk\ApbctWP\Helper;
|
20 |
+
use Cleantalk\ApbctWP\RemoteCalls;
|
21 |
use Cleantalk\Common\Schema;
|
22 |
use Cleantalk\Variables\Get;
|
23 |
|
134 |
$tasks_to_run = Cron::checkTasks(); // Check for current tasks. Drop tasks inner counters.
|
135 |
if(
|
136 |
! empty( $tasks_to_run ) && // There is tasks to run
|
137 |
+
! RemoteCalls::check() && // Do not doing CRON in remote call action
|
138 |
(
|
139 |
! defined( 'DOING_CRON' ) ||
|
140 |
( defined( 'DOING_CRON' ) && DOING_CRON !== true )
|
194 |
'LandingPageBuilder' => array( 'hook' => 'ulpb_formBuilderEmail_ajax', 'ajax' => true ),
|
195 |
'WpMembers' => array( 'hook' => 'wpmem_pre_register_data', 'ajax' => false ),
|
196 |
'Rafflepress' => array( 'hook' => 'rafflepress_lite_giveaway_api', 'ajax' => true ),
|
197 |
+
'Wpdiscuz' => array( 'hook' => array( 'wpdAddComment', 'wpdAddInlineComment' ), 'ajax' => true ),
|
198 |
);
|
199 |
new \Cleantalk\Antispam\Integrations( $apbct_active_integrations );
|
200 |
|
250 |
add_action( 'wp_head', 'apbct_search_add_noindex', 1 );
|
251 |
|
252 |
// Remote calls
|
253 |
+
if( RemoteCalls::check() )
|
254 |
+
RemoteCalls::perform();
|
255 |
+
|
256 |
// SpamFireWall check
|
257 |
if( $apbct->plugin_version == APBCT_VERSION && // Do not call with first start
|
258 |
$apbct->settings['spam_firewall'] == 1 &&
|
450 |
|
451 |
}
|
452 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
453 |
|
454 |
/**
|
455 |
* Function for SpamFireWall check
|
552 |
Cron::addTask('get_brief_data', 'cleantalk_get_brief_data', 86400, time() + 3500); // Get data for dashboard widget
|
553 |
Cron::addTask('send_connection_report','ct_mail_send_connection_report', 86400, time() + 3500); // Send connection report to welcome@cleantalk.org
|
554 |
Cron::addTask('antiflood__clear_table', 'apbct_antiflood__clear_table', 86400, time() + 300); // Clear Anti-Flood table
|
555 |
+
|
556 |
+
// Flag for auto-updating once
|
557 |
+
add_option( 'sfw_update_first', true );
|
558 |
}
|
559 |
switch_to_blog($initial_blog);
|
560 |
}else{
|
568 |
Cron::addTask('get_brief_data', 'cleantalk_get_brief_data', 86400, time() + 3500); // Get data for dashboard widget
|
569 |
Cron::addTask('send_connection_report','ct_mail_send_connection_report', 86400, time() + 3500); // Send connection report to welcome@cleantalk.org
|
570 |
Cron::addTask('antiflood__clear_table', 'apbct_antiflood__clear_table', 86400, time() + 300); // Clear Anti-Flood table
|
571 |
+
|
572 |
+
// Flag for auto-updating once
|
573 |
+
add_option( 'sfw_update_first', true );
|
574 |
+
|
575 |
apbct_activation__create_tables($sqls);
|
576 |
ct_account_status_check(null, false);
|
577 |
}
|
578 |
|
579 |
// Additional options
|
580 |
add_option( 'ct_plugin_do_activation_redirect', true );
|
581 |
+
|
582 |
}
|
583 |
|
584 |
function apbct_activation__create_tables( $sqls, $db_prefix = '' ) {
|
716 |
global $wpdb;
|
717 |
$wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->base_prefix.'cleantalk_sfw`;'); // Deleting SFW data
|
718 |
$wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->base_prefix.'cleantalk_sfw_logs`;'); // Deleting SFW logs
|
719 |
+
$wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->base_prefix.'cleantalk_sfw__flood_logs`;'); // Deleting SFW logs
|
720 |
$wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->base_prefix.'cleantalk_ac_log`;'); // Deleting SFW logs
|
721 |
$wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->base_prefix.'cleantalk_sessions`;'); // Deleting session table
|
722 |
$wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->base_prefix.'cleantalk_spamscan_logs`;'); // Deleting user/comments scan result table
|
728 |
global $wpdb;
|
729 |
$wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->prefix.'cleantalk_sfw`;'); // Deleting SFW data
|
730 |
$wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->prefix.'cleantalk_sfw_logs`;'); // Deleting SFW logs
|
731 |
+
$wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->prefix.'cleantalk_sfw__flood_logs`;'); // Deleting SFW logs
|
732 |
$wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->prefix.'cleantalk_ac_log`;'); // Deleting SFW logs
|
733 |
$wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->prefix.'cleantalk_sessions`;'); // Deleting session table
|
734 |
$wpdb->query('DROP TABLE IF EXISTS `'. $wpdb->prefix.'cleantalk_spamscan_logs`;'); // Deleting user/comments scan result table
|
807 |
// This action triggered by wp_schedule_single_event( time() + 900, 'ct_sfw_update' );
|
808 |
add_action( 'ct_sfw_update', 'ct_sfw_update' );
|
809 |
|
810 |
+
/**
|
811 |
+
* @param string $api_key
|
812 |
+
* @param bool $immediate
|
813 |
+
*
|
814 |
+
* @return array|bool|int|string[]
|
815 |
+
*/
|
816 |
function ct_sfw_update( $api_key = '', $immediate = false ){
|
817 |
|
818 |
global $apbct, $wpdb;
|
853 |
$apbct->save( 'fw_stats' );
|
854 |
}
|
855 |
|
856 |
+
if( RemoteCalls::check() ) {
|
857 |
// Remote call is in process, do updating
|
858 |
|
859 |
$file_urls = isset($_GET['file_urls']) ? urldecode( $_GET['file_urls'] ) : null;
|
895 |
$apbct->save('fw_stats');
|
896 |
|
897 |
if ( $url_count > $current_url ) {
|
898 |
+
return Helper::http__request__rc_to_host(
|
899 |
get_option('siteurl'),
|
900 |
array(
|
901 |
'spbc_remote_call_token' => md5($api_key),
|
930 |
$apbct->stats['sfw']['last_update_time'] = time();
|
931 |
$apbct->save('stats');
|
932 |
|
933 |
+
// Running sfw update once again in 12 min if entries is < 4000
|
934 |
if( $is_first_updating !== false ) {
|
935 |
if( $apbct->stats['sfw']['entries'] < 4000 ) {
|
936 |
+
wp_schedule_single_event( time() + 720, 'ct_sfw_update' );
|
937 |
}
|
938 |
delete_option( 'sfw_sync_first' );
|
939 |
}
|
951 |
|
952 |
} else {
|
953 |
// Go to init remote call
|
954 |
+
return Helper::http__request__rc_to_host(
|
955 |
get_option( 'siteurl' ),
|
956 |
array(
|
957 |
'spbc_remote_call_token' => md5( $api_key ),
|
974 |
|
975 |
$api_key = !empty($apbct->api_key) ? $apbct->api_key : $api_key;
|
976 |
|
977 |
+
if( empty( $api_key ) && ! $apbct->data['moderate_ip'] ){
|
978 |
+
return true;
|
979 |
+
}
|
980 |
+
|
981 |
+
if( $apbct->settings['spam_firewall'] == 1 ) {
|
982 |
|
983 |
$result = SFW::send_log(
|
984 |
DB::getInstance(),
|
995 |
|
996 |
return $result;
|
997 |
|
998 |
+
} else
|
999 |
+
return array('error' => 'SFW_DISABLED');
|
|
|
1000 |
}
|
1001 |
|
1002 |
function apbct_antiflood__clear_table(){
|
1739 |
}
|
1740 |
}
|
1741 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1742 |
/**
|
1743 |
* Gets submit time
|
1744 |
* Uses Cookies with check via apbct_cookies_test()
|
@@ -314,6 +314,8 @@ function apbct_admin__enqueue_scripts($hook){
|
|
314 |
'ip_license' => $apbct->ip_license ? true : false,
|
315 |
'key_changed' => ! empty( $apbct->data['key_changed'] ) ? true : false,
|
316 |
));
|
|
|
|
|
317 |
}
|
318 |
|
319 |
// COMMENTS page JavaScript
|
314 |
'ip_license' => $apbct->ip_license ? true : false,
|
315 |
'key_changed' => ! empty( $apbct->data['key_changed'] ) ? true : false,
|
316 |
));
|
317 |
+
|
318 |
+
wp_enqueue_script('cleantalk-modal', plugins_url( '/cleantalk-spam-protect/js/cleantalk-modal.min.js' ), array(), APBCT_VERSION);
|
319 |
}
|
320 |
|
321 |
// COMMENTS page JavaScript
|
@@ -7,6 +7,8 @@ AJAX functions
|
|
7 |
|
8 |
//$cleantalk_ajax_actions_to_check - array for POST 'actions' we should check.
|
9 |
|
|
|
|
|
10 |
$cleantalk_ajax_actions_to_check[] = 'qcf_validate_form'; //Quick Contact Form
|
11 |
$cleantalk_ajax_actions_to_check[] = 'amoforms_submit'; //amoForms
|
12 |
|
@@ -356,7 +358,7 @@ function ct_ajax_hook($message_obj = false, $additional = false)
|
|
356 |
do_action( 'apbct_skipped_request', __FILE__ . ' -> ' . __FUNCTION__ . '():' . __LINE__ . '(' . apbct_is_skip_request() . ')', $_POST );
|
357 |
return false;
|
358 |
}
|
359 |
-
|
360 |
//General post_info for all ajax calls
|
361 |
$post_info = array(
|
362 |
'comment_type' => 'feedback_ajax',
|
7 |
|
8 |
//$cleantalk_ajax_actions_to_check - array for POST 'actions' we should check.
|
9 |
|
10 |
+
use Cleantalk\Variables\Post;
|
11 |
+
|
12 |
$cleantalk_ajax_actions_to_check[] = 'qcf_validate_form'; //Quick Contact Form
|
13 |
$cleantalk_ajax_actions_to_check[] = 'amoforms_submit'; //amoForms
|
14 |
|
358 |
do_action( 'apbct_skipped_request', __FILE__ . ' -> ' . __FUNCTION__ . '():' . __LINE__ . '(' . apbct_is_skip_request() . ')', $_POST );
|
359 |
return false;
|
360 |
}
|
361 |
+
|
362 |
//General post_info for all ajax calls
|
363 |
$post_info = array(
|
364 |
'comment_type' => 'feedback_ajax',
|
@@ -653,10 +653,10 @@ function ct_feedback($hash, $allow) {
|
|
653 |
global $apbct;
|
654 |
|
655 |
$ct_feedback = $hash . ':' . $allow . ';';
|
656 |
-
if($apbct->data['feedback_request'])
|
657 |
-
$apbct->data['feedback_request'] = $ct_feedback;
|
658 |
else
|
659 |
-
$apbct->data['feedback_request'] .= $ct_feedback;
|
660 |
|
661 |
$apbct->saveData();
|
662 |
}
|
653 |
global $apbct;
|
654 |
|
655 |
$ct_feedback = $hash . ':' . $allow . ';';
|
656 |
+
if( ! $apbct->data['feedback_request'] )
|
657 |
+
$apbct->data['feedback_request'] = $ct_feedback;
|
658 |
else
|
659 |
+
$apbct->data['feedback_request'] .= $ct_feedback;
|
660 |
|
661 |
$apbct->saveData();
|
662 |
}
|
@@ -1,5 +1,6 @@
|
|
1 |
<?php
|
2 |
|
|
|
3 |
use Cleantalk\Variables\Server;
|
4 |
|
5 |
/**
|
@@ -384,6 +385,28 @@ function apbct_is_skip_request( $ajax = false ) {
|
|
384 |
{
|
385 |
return 'divi_builder_save_epanel';
|
386 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
387 |
break;
|
388 |
|
389 |
case false :
|
1 |
<?php
|
2 |
|
3 |
+
use Cleantalk\Variables\Post;
|
4 |
use Cleantalk\Variables\Server;
|
5 |
|
6 |
/**
|
385 |
{
|
386 |
return 'divi_builder_save_epanel';
|
387 |
}
|
388 |
+
// Email Before Download plugin https://wordpress.org/plugins/email-before-download/ action skip
|
389 |
+
if ( apbct_is_plugin_active( 'email-before-download/email-before-download.php' ) &&
|
390 |
+
isset( $_POST['action'] ) &&
|
391 |
+
$_POST['action'] === 'ebd_inline_links' )
|
392 |
+
{
|
393 |
+
return 'ebd_inline_links';
|
394 |
+
}
|
395 |
+
// WP Discuz skip service requests. The plugin have the direct integration
|
396 |
+
if ( apbct_is_plugin_active( 'wpdiscuz/class.WpdiscuzCore.php' ) &&
|
397 |
+
isset( $_POST['action'] ) &&
|
398 |
+
strpos( $_POST['action'], 'wpd' ) !== false )
|
399 |
+
{
|
400 |
+
return 'ebd_inline_links';
|
401 |
+
}
|
402 |
+
// Exception for plugin https://ru.wordpress.org/plugins/easy-login-woocommerce/ login form
|
403 |
+
if(
|
404 |
+
apbct_is_plugin_active( 'easy-login-woocommerce\xoo-el-main.php' ) &&
|
405 |
+
Post::get( '_xoo_el_form' ) === 'login'
|
406 |
+
){
|
407 |
+
return 'xoo_login';
|
408 |
+
}
|
409 |
+
|
410 |
break;
|
411 |
|
412 |
case false :
|
@@ -181,7 +181,7 @@ function apbct_init() {
|
|
181 |
if(defined('WPCF7_VERSION')){
|
182 |
add_filter('wpcf7_form_elements', 'apbct_form__contactForm7__addField');
|
183 |
add_filter('wpcf7_validate', 'apbct_form__contactForm7__tesSpam__before_validate', 999, 2);
|
184 |
-
add_filter(WPCF7_VERSION >= '3.0.0' ? 'wpcf7_spam' : 'wpcf7_acceptance', 'apbct_form__contactForm7__testSpam');
|
185 |
}
|
186 |
|
187 |
// Formidable
|
@@ -1762,6 +1762,7 @@ function apbct_login__scripts(){
|
|
1762 |
|
1763 |
// Differnt JS params
|
1764 |
wp_enqueue_script( 'ct_public', APBCT_URL_PATH . '/js/apbct-public.min.js', array( 'jquery' ), APBCT_VERSION, false /*in header*/ );
|
|
|
1765 |
|
1766 |
wp_localize_script('ct_public', 'ctPublic', array(
|
1767 |
'_ajax_nonce' => wp_create_nonce('ct_secret_stuff'),
|
@@ -1922,7 +1923,7 @@ function ct_test_registration($nickname, $email, $ip){
|
|
1922 |
*/
|
1923 |
function ct_registration_errors($errors, $sanitized_user_login = null, $user_email = null) {
|
1924 |
|
1925 |
-
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;
|
1926 |
|
1927 |
// Go out if a registrered user action
|
1928 |
if (apbct_is_user_enable() === false) {
|
@@ -2048,6 +2049,7 @@ function ct_registration_errors($errors, $sanitized_user_login = null, $user_ema
|
|
2048 |
|
2049 |
} else {
|
2050 |
if ($ct_result->id !== null) {
|
|
|
2051 |
\Cleantalk\Common\Helper::apbct_cookie__set($apbct_cookie_register_ok_label, $ct_result->id, time()+10, '/');
|
2052 |
\Cleantalk\Common\Helper::apbct_cookie__set($apbct_cookie_request_id_label, $ct_result->id, time()+10, '/');
|
2053 |
}
|
@@ -2176,12 +2178,21 @@ function ct_check_registration_erros($errors, $sanitized_user_login = null, $use
|
|
2176 |
* @return null
|
2177 |
*/
|
2178 |
function apbct_user_register($user_id) {
|
2179 |
-
|
2180 |
-
|
2181 |
-
|
2182 |
-
|
2183 |
-
|
2184 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2185 |
}
|
2186 |
|
2187 |
|
@@ -2345,21 +2356,21 @@ function apbct_form__contactForm7__tesSpam__before_validate($result = null, $tag
|
|
2345 |
/**
|
2346 |
* Test CF7 message for spam
|
2347 |
*/
|
2348 |
-
function apbct_form__contactForm7__testSpam($
|
2349 |
|
2350 |
global $ct_checkjs_cf7, $apbct;
|
2351 |
|
2352 |
if(
|
2353 |
$apbct->settings['contact_forms_test'] == 0 ||
|
2354 |
-
$
|
2355 |
-
$
|
2356 |
$apbct->settings['protect_logged_in'] != 1 && is_user_logged_in() || // Skip processing for logged in users.
|
2357 |
apbct_exclusions_check__url() ||
|
2358 |
apbct_exclusions_check__ip() ||
|
2359 |
isset($apbct->cf7_checked)
|
2360 |
){
|
2361 |
do_action( 'apbct_skipped_request', __FILE__ . ' -> ' . __FUNCTION__ . '():' . __LINE__, $_POST );
|
2362 |
-
return $
|
2363 |
}
|
2364 |
|
2365 |
$checkjs = apbct_js_test($ct_checkjs_cf7, $_POST)
|
@@ -2413,13 +2424,13 @@ function apbct_form__contactForm7__testSpam($param) {
|
|
2413 |
|
2414 |
add_filter('wpcf7_display_message', 'apbct_form__contactForm7__showResponse', 10, 2);
|
2415 |
|
2416 |
-
$
|
2417 |
|
2418 |
}
|
2419 |
|
2420 |
$apbct->cf7_checked = true;
|
2421 |
|
2422 |
-
return $
|
2423 |
}
|
2424 |
|
2425 |
/**
|
@@ -3744,6 +3755,7 @@ function ct_enqueue_scripts_public($hook){
|
|
3744 |
|
3745 |
// Differnt JS params
|
3746 |
wp_enqueue_script( 'ct_public', APBCT_URL_PATH . '/js/apbct-public.min.js', array( 'jquery' ), APBCT_VERSION, false /*in header*/ );
|
|
|
3747 |
|
3748 |
wp_localize_script('ct_public', 'ctPublic', array(
|
3749 |
'_ajax_nonce' => wp_create_nonce('ct_secret_stuff'),
|
181 |
if(defined('WPCF7_VERSION')){
|
182 |
add_filter('wpcf7_form_elements', 'apbct_form__contactForm7__addField');
|
183 |
add_filter('wpcf7_validate', 'apbct_form__contactForm7__tesSpam__before_validate', 999, 2);
|
184 |
+
add_filter(WPCF7_VERSION >= '3.0.0' ? 'wpcf7_spam' : 'wpcf7_acceptance', 'apbct_form__contactForm7__testSpam', 9999, 2);
|
185 |
}
|
186 |
|
187 |
// Formidable
|
1762 |
|
1763 |
// Differnt JS params
|
1764 |
wp_enqueue_script( 'ct_public', APBCT_URL_PATH . '/js/apbct-public.min.js', array( 'jquery' ), APBCT_VERSION, false /*in header*/ );
|
1765 |
+
wp_enqueue_script('cleantalk-modal', plugins_url( '/cleantalk-spam-protect/js/cleantalk-modal.min.js' ), array(), APBCT_VERSION, false );
|
1766 |
|
1767 |
wp_localize_script('ct_public', 'ctPublic', array(
|
1768 |
'_ajax_nonce' => wp_create_nonce('ct_secret_stuff'),
|
1923 |
*/
|
1924 |
function ct_registration_errors($errors, $sanitized_user_login = null, $user_email = null) {
|
1925 |
|
1926 |
+
global $ct_checkjs_register_form, $apbct_cookie_request_id_label, $apbct_cookie_register_ok_label, $apbct_cookie_request_id, $bp, $ct_signup_done, $ct_negative_comment, $apbct, $ct_registration_error_comment, $cleantalk_executed;
|
1927 |
|
1928 |
// Go out if a registrered user action
|
1929 |
if (apbct_is_user_enable() === false) {
|
2049 |
|
2050 |
} else {
|
2051 |
if ($ct_result->id !== null) {
|
2052 |
+
$apbct_cookie_request_id = $ct_result->id;
|
2053 |
\Cleantalk\Common\Helper::apbct_cookie__set($apbct_cookie_register_ok_label, $ct_result->id, time()+10, '/');
|
2054 |
\Cleantalk\Common\Helper::apbct_cookie__set($apbct_cookie_request_id_label, $ct_result->id, time()+10, '/');
|
2055 |
}
|
2178 |
* @return null
|
2179 |
*/
|
2180 |
function apbct_user_register($user_id) {
|
2181 |
+
|
2182 |
+
global $apbct_cookie_request_id_label, $apbct_cookie_request_id;
|
2183 |
+
|
2184 |
+
if ( ! empty( $apbct_cookie_request_id ) ) {
|
2185 |
+
update_user_meta($user_id, 'ct_hash', $apbct_cookie_request_id);
|
2186 |
+
return;
|
2187 |
+
}
|
2188 |
+
|
2189 |
+
if ( isset($_COOKIE[$apbct_cookie_request_id_label]) ) {
|
2190 |
+
if(update_user_meta($user_id, 'ct_hash', $_COOKIE[$apbct_cookie_request_id_label])){
|
2191 |
+
\Cleantalk\Common\Helper::apbct_cookie__set($apbct_cookie_request_id_label, '0', 1, '/');
|
2192 |
+
}
|
2193 |
+
return;
|
2194 |
+
}
|
2195 |
+
|
2196 |
}
|
2197 |
|
2198 |
|
2356 |
/**
|
2357 |
* Test CF7 message for spam
|
2358 |
*/
|
2359 |
+
function apbct_form__contactForm7__testSpam($spam, $submission) {
|
2360 |
|
2361 |
global $ct_checkjs_cf7, $apbct;
|
2362 |
|
2363 |
if(
|
2364 |
$apbct->settings['contact_forms_test'] == 0 ||
|
2365 |
+
$spam == false && WPCF7_VERSION < '3.0.0' ||
|
2366 |
+
$spam === true && WPCF7_VERSION >= '3.0.0' ||
|
2367 |
$apbct->settings['protect_logged_in'] != 1 && is_user_logged_in() || // Skip processing for logged in users.
|
2368 |
apbct_exclusions_check__url() ||
|
2369 |
apbct_exclusions_check__ip() ||
|
2370 |
isset($apbct->cf7_checked)
|
2371 |
){
|
2372 |
do_action( 'apbct_skipped_request', __FILE__ . ' -> ' . __FUNCTION__ . '():' . __LINE__, $_POST );
|
2373 |
+
return $spam;
|
2374 |
}
|
2375 |
|
2376 |
$checkjs = apbct_js_test($ct_checkjs_cf7, $_POST)
|
2424 |
|
2425 |
add_filter('wpcf7_display_message', 'apbct_form__contactForm7__showResponse', 10, 2);
|
2426 |
|
2427 |
+
$spam = WPCF7_VERSION >= '3.0.0' ? true : false;
|
2428 |
|
2429 |
}
|
2430 |
|
2431 |
$apbct->cf7_checked = true;
|
2432 |
|
2433 |
+
return $spam;
|
2434 |
}
|
2435 |
|
2436 |
/**
|
3755 |
|
3756 |
// Differnt JS params
|
3757 |
wp_enqueue_script( 'ct_public', APBCT_URL_PATH . '/js/apbct-public.min.js', array( 'jquery' ), APBCT_VERSION, false /*in header*/ );
|
3758 |
+
wp_enqueue_script('cleantalk-modal', plugins_url( '/cleantalk-spam-protect/js/cleantalk-modal.min.js' ), array(), APBCT_VERSION, false );
|
3759 |
|
3760 |
wp_localize_script('ct_public', 'ctPublic', array(
|
3761 |
'_ajax_nonce' => wp_create_nonce('ct_secret_stuff'),
|
@@ -104,14 +104,6 @@ function apbct_settings__set_fileds( $fields ){
|
|
104 |
'description' => __("This option allows to filter spam bots before they access website. Also reduces CPU usage on hosting server and accelerates pages load time.", 'cleantalk-spam-protect'),
|
105 |
'childrens' => array('sfw__anti_flood', 'sfw__anti_crawler'),
|
106 |
),
|
107 |
-
'sfw__anti_flood' => array(
|
108 |
-
'type' => 'checkbox',
|
109 |
-
'title' => __('Anti-Flood', 'cleantalk-spam-protect'),
|
110 |
-
'class' => 'apbct_settings-field_wrapper--sub',
|
111 |
-
'parent' => 'spam_firewall',
|
112 |
-
'childrens' => array('sfw__anti_flood__view_limit',),
|
113 |
-
'description' => __('Shows SpamFireWall page for bot which are trying to scan your website. Look for the page limit setting below.', 'cleantalk-spam-protect'),
|
114 |
-
),
|
115 |
'sfw__anti_crawler' => array(
|
116 |
'type' => 'checkbox',
|
117 |
'title' => __('Anti-Crawler', 'cleantalk-spam-protect') . $additional_ac_title,
|
@@ -119,7 +111,7 @@ function apbct_settings__set_fileds( $fields ){
|
|
119 |
'parent' => 'spam_firewall',
|
120 |
'description' => __('Plugin shows SpamFireWall stop page for any bot, except allowed bots (Google, Yahoo and etc).', 'cleantalk-spam-protect')
|
121 |
. '<br>'
|
122 |
-
. __( 'Anti-Crawler includes blocking bots by the User-Agent.
|
123 |
),
|
124 |
),
|
125 |
),
|
@@ -443,10 +435,18 @@ function apbct_settings__set_fileds( $fields ){
|
|
443 |
'options_callback_params' => array(true),
|
444 |
'class' => 'apbct_settings-field_wrapper--sub',
|
445 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
446 |
'sfw__anti_flood__view_limit' => array(
|
447 |
'type' => 'text',
|
448 |
'title' => __('Anti-Flood Page Views Limit', 'cleantalk-spam-protect'),
|
449 |
-
'class' => 'apbct_settings-field_wrapper',
|
450 |
'parent' => 'sfw__anti_flood',
|
451 |
'description' => __('Count of page view per 1 minute before plugin shows SpamFireWall page. SpamFireWall page active for 30 second after that valid visitor (with JavaScript) passes the page to the demanded page of the site.', 'cleantalk-spam-protect'),
|
452 |
),
|
@@ -1554,7 +1554,10 @@ function apbct_settings__sync( $direct_call = false ){
|
|
1554 |
check_ajax_referer('ct_secret_nonce' );
|
1555 |
|
1556 |
global $apbct;
|
1557 |
-
|
|
|
|
|
|
|
1558 |
// Feedback with app_agent
|
1559 |
ct_send_feedback('0:' . APBCT_AGENT); // 0 - request_id, agent version.
|
1560 |
|
104 |
'description' => __("This option allows to filter spam bots before they access website. Also reduces CPU usage on hosting server and accelerates pages load time.", 'cleantalk-spam-protect'),
|
105 |
'childrens' => array('sfw__anti_flood', 'sfw__anti_crawler'),
|
106 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
'sfw__anti_crawler' => array(
|
108 |
'type' => 'checkbox',
|
109 |
'title' => __('Anti-Crawler', 'cleantalk-spam-protect') . $additional_ac_title,
|
111 |
'parent' => 'spam_firewall',
|
112 |
'description' => __('Plugin shows SpamFireWall stop page for any bot, except allowed bots (Google, Yahoo and etc).', 'cleantalk-spam-protect')
|
113 |
. '<br>'
|
114 |
+
. __( 'Anti-Crawler includes blocking bots by the User-Agent. Use Personal lists in the Dashboard to filter specific User-Agents.', 'cleantalk-spam-protect' ),
|
115 |
),
|
116 |
),
|
117 |
),
|
435 |
'options_callback_params' => array(true),
|
436 |
'class' => 'apbct_settings-field_wrapper--sub',
|
437 |
),
|
438 |
+
'sfw__anti_flood' => array(
|
439 |
+
'type' => 'checkbox',
|
440 |
+
'title' => __('Anti-Flood', 'cleantalk-spam-protect'),
|
441 |
+
'class' => 'apbct_settings-field_wrapper',
|
442 |
+
'parent' => 'spam_firewall',
|
443 |
+
'childrens' => array('sfw__anti_flood__view_limit',),
|
444 |
+
'description' => __('Shows the SpamFireWall page for bots trying to crawl your site. Look at the page limit setting below.', 'cleantalk-spam-protect'),
|
445 |
+
),
|
446 |
'sfw__anti_flood__view_limit' => array(
|
447 |
'type' => 'text',
|
448 |
'title' => __('Anti-Flood Page Views Limit', 'cleantalk-spam-protect'),
|
449 |
+
'class' => 'apbct_settings-field_wrapper--sub',
|
450 |
'parent' => 'sfw__anti_flood',
|
451 |
'description' => __('Count of page view per 1 minute before plugin shows SpamFireWall page. SpamFireWall page active for 30 second after that valid visitor (with JavaScript) passes the page to the demanded page of the site.', 'cleantalk-spam-protect'),
|
452 |
),
|
1554 |
check_ajax_referer('ct_secret_nonce' );
|
1555 |
|
1556 |
global $apbct;
|
1557 |
+
|
1558 |
+
//Clearing all errors
|
1559 |
+
$apbct->error_delete_all('and_save_data');
|
1560 |
+
|
1561 |
// Feedback with app_agent
|
1562 |
ct_send_feedback('0:' . APBCT_AGENT); // 0 - request_id, agent version.
|
1563 |
|
@@ -12,7 +12,7 @@ function apbct_run_update_actions($current_version, $new_version){
|
|
12 |
$new_version_str = implode('.', $new_version);
|
13 |
|
14 |
for($ver_major = $current_version[0]; $ver_major <= $new_version[0]; $ver_major++){
|
15 |
-
for($ver_minor = 0; $ver_minor <=
|
16 |
for($ver_fix = 0; $ver_fix <= 10; $ver_fix++){
|
17 |
|
18 |
if(version_compare("{$ver_major}.{$ver_minor}.{$ver_fix}", $current_version_str, '<='))
|
@@ -23,6 +23,12 @@ function apbct_run_update_actions($current_version, $new_version){
|
|
23 |
if(!empty($result['error']))
|
24 |
break;
|
25 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
if(version_compare("{$ver_major}.{$ver_minor}.{$ver_fix}", $new_version_str, '>='))
|
28 |
break(2);
|
@@ -728,3 +734,9 @@ function apbct_update_to_5_151_3 ()
|
|
728 |
$apbct->save('stats');
|
729 |
ct_sfw_update();
|
730 |
}
|
|
|
|
|
|
|
|
|
|
|
|
12 |
$new_version_str = implode('.', $new_version);
|
13 |
|
14 |
for($ver_major = $current_version[0]; $ver_major <= $new_version[0]; $ver_major++){
|
15 |
+
for($ver_minor = 0; $ver_minor <= 300; $ver_minor++){
|
16 |
for($ver_fix = 0; $ver_fix <= 10; $ver_fix++){
|
17 |
|
18 |
if(version_compare("{$ver_major}.{$ver_minor}.{$ver_fix}", $current_version_str, '<='))
|
23 |
if(!empty($result['error']))
|
24 |
break;
|
25 |
}
|
26 |
+
|
27 |
+
if( $ver_fix == 0 && function_exists("apbct_update_to_{$ver_major}_{$ver_minor}") ){
|
28 |
+
$result = call_user_func("apbct_update_to_{$ver_major}_{$ver_minor}");
|
29 |
+
if(!empty($result['error']))
|
30 |
+
break;
|
31 |
+
}
|
32 |
|
33 |
if(version_compare("{$ver_major}.{$ver_minor}.{$ver_fix}", $new_version_str, '>='))
|
34 |
break(2);
|
734 |
$apbct->save('stats');
|
735 |
ct_sfw_update();
|
736 |
}
|
737 |
+
|
738 |
+
function apbct_update_to_5_151_6 ()
|
739 |
+
{
|
740 |
+
global $apbct;
|
741 |
+
$apbct->error_delete( 'sfw_update', true );
|
742 |
+
}
|
@@ -1 +1,2 @@
|
|
1 |
-
function ctSetCookie(e,t){document.cookie=e+"="+encodeURIComponent(t)+"; path=/; samesite=lax"}function apbct_collect_visible_fields(e){var t=[],o="",n=0,i=[];for(var a in e.elements)isNaN(+a)||(t[a]=e.elements[a]);return(t=t.filter(function(e){return"none"!==getComputedStyle(e).display&&"hidden"!==getComputedStyle(e).visibility&&"0"!==getComputedStyle(e).opacity&&"hidden"!==e.getAttribute("type")&&"submit"!==e.getAttribute("type")&&null!==e.getAttribute("name")&&-1===i.indexOf(e.getAttribute("name"))&&(n++,-1===["radio","checkbox"].indexOf(e.getAttribute("type"))||(i.push(e.getAttribute("name")),!1))})).forEach(function(e,t,n){o+=" "+e.getAttribute("name")}),{visible_fields:o=o.trim(),visible_fields_count:n}}function apbct_visible_fields_set_cookie(e){var t="object"==typeof e&&null!==e?e:{};ctSetCookie("apbct_visible_fields",JSON.stringify(t))}function apbct_js_keys__set_input_value(e,t,n,o){
|
|
1 |
+
function ctSetCookie(e,t){document.cookie=e+"="+encodeURIComponent(t)+"; path=/; samesite=lax"}function apbct_collect_visible_fields(e){var t=[],o="",n=0,i=[];for(var a in e.elements)isNaN(+a)||(t[a]=e.elements[a]);return(t=t.filter(function(e){return"none"!==getComputedStyle(e).display&&"hidden"!==getComputedStyle(e).visibility&&"0"!==getComputedStyle(e).opacity&&"hidden"!==e.getAttribute("type")&&"submit"!==e.getAttribute("type")&&null!==e.getAttribute("name")&&-1===i.indexOf(e.getAttribute("name"))&&(n++,-1===["radio","checkbox"].indexOf(e.getAttribute("type"))||(i.push(e.getAttribute("name")),!1))})).forEach(function(e,t,n){o+=" "+e.getAttribute("name")}),{visible_fields:o=o.trim(),visible_fields_count:n}}function apbct_visible_fields_set_cookie(e){var t="object"==typeof e&&null!==e?e:{};ctSetCookie("apbct_visible_fields",JSON.stringify(t))}function apbct_js_keys__set_input_value(e,t,n,o){var i;null!==document.getElementById(n.input_name)&&(i=document.getElementById(n.input_name).value,document.getElementById(n.input_name).value=document.getElementById(n.input_name).value.replace(i,e.js_key))}function apbct_public_sendAJAX(t,n,o){var i=n.callback||null,a=n.callback_context||null,c=n.callback_params||null,e=n.async||!0,s=n.notJson||null,l=n.timeout||15e3,o=o||null,r=n.button||null,u=n.spinner||null,p=n.progressbar||null,d=n.silent||null,m=n.no_nonce||null;"string"==typeof t?(m||(t=t+"&_ajax_nonce="+ctPublic._ajax_nonce),t=t+"&no_cache="+Math.random()):(m||(t._ajax_nonce=ctPublic._ajax_nonce),t.no_cache=Math.random()),r&&(r.setAttribute("disabled","disabled"),r.style.cursor="not-allowed"),u&&jQuery(u).css("display","inline"),jQuery.ajax({type:"POST",url:ctPublic._ajax_url,data:t,async:e,success:function(e){r&&(r.removeAttribute("disabled"),r.style.cursor="pointer"),u&&jQuery(u).css("display","none"),s||(e=JSON.parse(e)),e.error?(setTimeout(function(){p&&p.fadeOut("slow")},1e3),alert("Error happens: "+(e.error||"Unkown"))):i&&(c?i.apply(a,c.concat(e,t,n,o)):i(e,t,n,o))},error:function(e,t,n){r&&(r.removeAttribute("disabled"),r.style.cursor="pointer"),u&&jQuery(u).css("display","none"),n&&!d&&(console.log("APBCT_AJAX_ERROR"),console.log(e),console.log(t),console.log("Anti-spam by Cleantalk plugin error: "+n+"Please, contact Cleantalk tech support https://wordpress.org/support/plugin/cleantalk-spam-protect/"),alert("Anti-spam by Cleantalk plugin error: "+n+"Please, contact Cleantalk tech support https://wordpress.org/support/plugin/cleantalk-spam-protect/"))},timeout:l})}!function(){var e=new Date,t=(new Date).getTime(),n=!0,o=[],i=0;function a(e,t,n){"function"==typeof window.addEventListener?e.addEventListener(t,n):e.attachEvent(t,n)}function c(e,t,n){"function"==typeof window.removeEventListener?e.removeEventListener(t,n):e.detachEvent(t,n)}ctSetCookie("ct_ps_timestamp",Math.floor((new Date).getTime()/1e3)),ctSetCookie("ct_fkp_timestamp","0"),ctSetCookie("ct_pointer_data","0"),ctSetCookie("ct_timezone","0"),setTimeout(function(){ctSetCookie("ct_timezone",e.getTimezoneOffset()/60*-1)},1e3);var s=function(){ctSetCookie("ct_fkp_timestamp",Math.floor((new Date).getTime()/1e3)),c(window,"mousedown",s),c(window,"keydown",s)},l=setInterval(function(){n=!0},150),r=setInterval(function(){ctSetCookie("ct_pointer_data",JSON.stringify(o))},1200),u=function(e){!0===n&&(o.push([Math.round(e.clientY),Math.round(e.clientX),Math.round((new Date).getTime()-t)]),n=!1,50<=++i&&(c(window,"mousemove",u),clearInterval(l),clearInterval(r)))};a(window,"mousemove",u),a(window,"mousedown",s),a(window,"keydown",s),a(window,"DOMContentLoaded",function(){ctSetCookie("apbct_visible_fields",0),setTimeout(function(){for(var e={},t=0;t<document.forms.length;t++){var n=document.forms[t];n.classList.contains("slp_search_form")||n.parentElement.classList.contains("mec-booking")||-1!==n.action.toString().indexOf("activehosted.com")||n.id&&"caspioform"==n.id||n.name.classList&&n.name.classList.contains("tinkoffPayRow")||(e[t]=apbct_collect_visible_fields(n),n.onsubmit_prev=n.onsubmit,n.onsubmit=function(e){var t={};t[0]=apbct_collect_visible_fields(this),apbct_visible_fields_set_cookie(t),e.target.onsubmit_prev instanceof Function&&setTimeout(function(){e.target.onsubmit_prev.call(e.target,e)},500)})}apbct_visible_fields_set_cookie(e)},1e3)})}(),"undefined"!=typeof jQuery&&jQuery(document).ajaxComplete(function(e,t,n){var o,i;!t.responseText||-1===t.responseText.indexOf('"apbct')||void 0!==(i=JSON.parse(t.responseText)).apbct&&(i=i.apbct).blocked&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:i.comment}})),(o=document.createElement("div")).setAttribute("id","apbct-result"),o.style.display="none",o.innerHTML=i.comment,document.body.append(o),cleantalkModal.open("apbct-result"),1==+i.stop_script&&window.stop())});
|
2 |
+
//# sourceMappingURL=apbct-public.min.js.map
|
@@ -1 +1 @@
|
|
1 |
-
{"version":3,"sources":["apbct-public.js"],"names":["ctSetCookie","c_name","value","document","cookie","encodeURIComponent","apbct_collect_visible_fields","form","inputs","inputs_visible","inputs_visible_count","inputs_with_duplicate_names","key","elements","isNaN","filter","elem","getComputedStyle","display","visibility","opacity","getAttribute","indexOf","push","forEach","i","visible_fields","trim","visible_fields_count","apbct_visible_fields_set_cookie","visible_fields_collection","collection","JSON","stringify","apbct_js_keys__set_input_value","result","data","params","obj","getElementById","input_name","ct_input_value","replace","js_key","apbct_public_sendAJAX","callback","callback_context","callback_params","async","notJson","timeout","button","spinner","progressbar","silent","no_nonce","ctPublic","_ajax_nonce","Math","random","no_cache","setAttribute","style","cursor","jQuery","css","ajax","type","url","_ajax_url","success","removeAttribute","parse","error","setTimeout","fadeOut","alert","apply","concat","jqXHR","textStatus","errorThrown","console","log","ct_date","Date","ctTimeMs","getTime","ctMouseEventTimerFlag","ctMouseData","ctMouseDataCounter","apbct_attach_event_handler","event","window","addEventListener","attachEvent","apbct_remove_event_handler","removeEventListener","detachEvent","floor","getTimezoneOffset","ctFunctionFirstKey","ctMouseReadInterval","setInterval","ctMouseWriteDataInterval","ctFunctionMouseMove","round","clientY","clientX","clearInterval","forms","length","classList","contains","parentElement","action","toString","id","name","onsubmit_prev","onsubmit","this","target","Function","call","ajaxComplete","xhr","settings","responseText","response","apbct","blocked","dispatchEvent","CustomEvent","bubbles","detail","message","comment","stop_script","stop"],"mappings":"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"}
|
1 |
+
{"version":3,"file":"apbct-public.min.js","sources":["apbct-public.js"],"sourcesContent":["(function() {\n\n\tvar ct_date = new Date(),\n\t\tctTimeMs = new Date().getTime(),\n\t\tctMouseEventTimerFlag = true, //Reading interval flag\n\t\tctMouseData = [],\n\t\tctMouseDataCounter = 0;\n\n\tfunction apbct_attach_event_handler(elem, event, callback){\n\t\tif(typeof window.addEventListener === \"function\") elem.addEventListener(event, callback);\n\t\telse elem.attachEvent(event, callback);\n\t}\n\n\tfunction apbct_remove_event_handler(elem, event, callback){\n\t\tif(typeof window.removeEventListener === \"function\") elem.removeEventListener(event, callback);\n\t\telse elem.detachEvent(event, callback);\n\t}\n\n\tctSetCookie(\"ct_ps_timestamp\", Math.floor(new Date().getTime()/1000));\n\tctSetCookie(\"ct_fkp_timestamp\", \"0\");\n\tctSetCookie(\"ct_pointer_data\", \"0\");\n\tctSetCookie(\"ct_timezone\", \"0\");\n\n\tsetTimeout(function(){\n\t\tctSetCookie(\"ct_timezone\", ct_date.getTimezoneOffset()/60*(-1));\n\t},1000);\n\n\t//Writing first key press timestamp\n\tvar ctFunctionFirstKey = function output(event){\n\t\tvar KeyTimestamp = Math.floor(new Date().getTime()/1000);\n\t\tctSetCookie(\"ct_fkp_timestamp\", KeyTimestamp);\n\t\tctKeyStopStopListening();\n\t};\n\n\t//Reading interval\n\tvar ctMouseReadInterval = setInterval(function(){\n\t\tctMouseEventTimerFlag = true;\n\t}, 150);\n\n\t//Writting interval\n\tvar ctMouseWriteDataInterval = setInterval(function(){\n\t\tctSetCookie(\"ct_pointer_data\", JSON.stringify(ctMouseData));\n\t}, 1200);\n\n\t//Logging mouse position each 150 ms\n\tvar ctFunctionMouseMove = function output(event){\n\t\tif(ctMouseEventTimerFlag === true){\n\n\t\t\tctMouseData.push([\n\t\t\t\tMath.round(event.clientY),\n\t\t\t\tMath.round(event.clientX),\n\t\t\t\tMath.round(new Date().getTime() - ctTimeMs)\n\t\t\t]);\n\n\t\t\tctMouseDataCounter++;\n\t\t\tctMouseEventTimerFlag = false;\n\t\t\tif(ctMouseDataCounter >= 50){\n\t\t\t\tctMouseStopData();\n\t\t\t}\n\t\t}\n\t};\n\n\t//Stop mouse observing function\n\tfunction ctMouseStopData(){\n\t\tapbct_remove_event_handler(window, \"mousemove\", ctFunctionMouseMove);\n\t\tclearInterval(ctMouseReadInterval);\n\t\tclearInterval(ctMouseWriteDataInterval);\n\t}\n\n\t//Stop key listening function\n\tfunction ctKeyStopStopListening(){\n\t\tapbct_remove_event_handler(window, \"mousedown\", ctFunctionFirstKey);\n\t\tapbct_remove_event_handler(window, \"keydown\", ctFunctionFirstKey);\n\t}\n\n\tapbct_attach_event_handler(window, \"mousemove\", ctFunctionMouseMove);\n\tapbct_attach_event_handler(window, \"mousedown\", ctFunctionFirstKey);\n\tapbct_attach_event_handler(window, \"keydown\", ctFunctionFirstKey);\n\n\t// Ready function\n\tfunction apbct_ready(){\n\n\t\tctSetCookie(\"apbct_visible_fields\", 0);\n\n\t\tsetTimeout(function(){\n\n\t\t\tvar visible_fields_collection = {};\n\n\t\t\tfor(var i = 0; i < document.forms.length; i++){\n\t\t\t\tvar form = document.forms[i];\n\n\t\t\t\t//Exclusion for forms\n\t\t\t\tif (\n\t\t\t\t\tform.classList.contains('slp_search_form') || //StoreLocatorPlus form\n\t\t\t\t\tform.parentElement.classList.contains('mec-booking') ||\n\t\t\t\t\tform.action.toString().indexOf('activehosted.com') !== -1 || // Active Campaign\n\t\t\t\t\t(form.id && form.id == 'caspioform') || //Caspio Form\n\t\t\t\t\tform.name.classList && form.name.classList.contains('tinkoffPayRow') //TinkoffPayForm\n\t\t\t\t)\n\t\t\t\t\tcontinue;\n\n\t\t\t\tvisible_fields_collection[i] = apbct_collect_visible_fields( form );\n\n\t\t\t\tform.onsubmit_prev = form.onsubmit;\n\t\t\t\tform.onsubmit = function (event) {\n\n\t\t\t\t\tvar visible_fields = {};\n\t\t\t\t\tvisible_fields[0] = apbct_collect_visible_fields(this);\n\t\t\t\t\tapbct_visible_fields_set_cookie( visible_fields );\n\n\t\t\t\t\t// Call previous submit action\n\t\t\t\t\tif (event.target.onsubmit_prev instanceof Function) {\n\t\t\t\t\t\tsetTimeout(function () {\n\t\t\t\t\t\t\tevent.target.onsubmit_prev.call(event.target, event);\n\t\t\t\t\t\t}, 500);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tapbct_visible_fields_set_cookie( visible_fields_collection );\n\n\t\t}, 1000);\n\t}\n\tapbct_attach_event_handler(window, \"DOMContentLoaded\", apbct_ready);\n\n}());\n\nfunction ctSetCookie(c_name, value) {\n\tdocument.cookie = c_name + \"=\" + encodeURIComponent(value) + \"; path=/; samesite=lax\";\n}\n\nfunction apbct_collect_visible_fields( form ) {\n\n\t// Get only fields\n\tvar inputs = [],\n\t\tinputs_visible = '',\n\t\tinputs_visible_count = 0,\n\t\tinputs_with_duplicate_names = [];\n\n\tfor(var key in form.elements){\n\t\tif(!isNaN(+key))\n\t\t\tinputs[key] = form.elements[key];\n\t}\n\n\t// Filter fields\n\tinputs = inputs.filter(function(elem){\n\n\t\t// Filter fields\n\t\tif( getComputedStyle(elem).display === \"none\" || // hidden\n\t\t\tgetComputedStyle(elem).visibility === \"hidden\" || // hidden\n\t\t\tgetComputedStyle(elem).opacity === \"0\" || // hidden\n\t\t\telem.getAttribute(\"type\") === \"hidden\" || // type == hidden\n\t\t\telem.getAttribute(\"type\") === \"submit\" || // type == submit\n\t\t\t//elem.value === \"\" || // empty value\n\t\t\telem.getAttribute('name') === null ||\n\t\t\tinputs_with_duplicate_names.indexOf( elem.getAttribute('name') ) !== -1 // name already added\n\t\t){\n\t\t\treturn false;\n\t\t}\n\n\t\t// Visible fields count\n\t\tinputs_visible_count++;\n\n\t\t// Filter inputs with same names for type == radio\n\t\tif( -1 !== ['radio', 'checkbox'].indexOf( elem.getAttribute(\"type\") )){\n\t\t\tinputs_with_duplicate_names.push( elem.getAttribute('name') );\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t});\n\n\t// Visible fields\n\tinputs.forEach(function(elem, i, elements){\n\t\tinputs_visible += \" \" + elem.getAttribute(\"name\");\n\t});\n\tinputs_visible = inputs_visible.trim();\n\n\treturn {\n\t\tvisible_fields : inputs_visible,\n\t\tvisible_fields_count : inputs_visible_count,\n\t}\n\n}\n\nfunction apbct_visible_fields_set_cookie( visible_fields_collection ) {\n\n\tvar collection = typeof visible_fields_collection === 'object' && visible_fields_collection !== null ? visible_fields_collection : {};\n\n\tctSetCookie(\"apbct_visible_fields\", JSON.stringify( collection ) );\n\n}\n\nfunction apbct_js_keys__set_input_value(result, data, params, obj){\n\tif (document.getElementById(params.input_name) !== null) {\n\t\tvar ct_input_value = document.getElementById(params.input_name).value;\n\t\tdocument.getElementById(params.input_name).value = document.getElementById(params.input_name).value.replace(ct_input_value, result.js_key);\n\t}\n}\nfunction apbct_public_sendAJAX(data, params, obj){\n\n\t// Default params\n\tvar callback = params.callback || null;\n\tvar callback_context = params.callback_context || null;\n\tvar callback_params = params.callback_params || null;\n\tvar async = params.async || true;\n\tvar notJson = params.notJson || null;\n\tvar timeout = params.timeout || 15000;\n\tvar obj = obj || null;\n\tvar button = params.button || null;\n\tvar spinner = params.spinner || null;\n\tvar progressbar = params.progressbar || null;\n\tvar silent = params.silent || null;\n\tvar no_nonce = params.no_nonce || null;\n\n\tif(typeof (data) === 'string') {\n\t\tif( ! no_nonce )\n\t\t\tdata = data + '&_ajax_nonce=' + ctPublic._ajax_nonce;\n\t\tdata = data + '&no_cache=' + Math.random()\n\t} else {\n\t\tif( ! no_nonce )\n\t\t\tdata._ajax_nonce = ctPublic._ajax_nonce;\n\t\tdata.no_cache = Math.random();\n\t}\n\t// Button and spinner\n\tif(button) {button.setAttribute('disabled', 'disabled'); button.style.cursor = 'not-allowed'; }\n\tif(spinner) jQuery(spinner).css('display', 'inline');\n\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\turl: ctPublic._ajax_url,\n\t\tdata: data,\n\t\tasync: async,\n\t\tsuccess: function(result){\n\t\t\tif(button){ button.removeAttribute('disabled'); button.style.cursor = 'pointer'; }\n\t\t\tif(spinner) jQuery(spinner).css('display', 'none');\n\t\t\tif(!notJson) result = JSON.parse(result);\n\t\t\tif(result.error){\n\t\t\t\tsetTimeout(function(){ if(progressbar) progressbar.fadeOut('slow'); }, 1000);\n\t\t\t\talert('Error happens: ' + (result.error || 'Unkown'));\n\t\t\t}else{\n\t\t\t\tif(callback) {\n\t\t\t\t\tif (callback_params)\n\t\t\t\t\t\tcallback.apply( callback_context, callback_params.concat( result, data, params, obj ) );\n\t\t\t\t\telse\n\t\t\t\t\t\tcallback(result, data, params, obj);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\terror: function(jqXHR, textStatus, errorThrown){\n\t\t\tif(button){ button.removeAttribute('disabled'); button.style.cursor = 'pointer'; }\n\t\t\tif(spinner) jQuery(spinner).css('display', 'none');\n\t\t\tif( errorThrown && ! silent ) {\n\t\t\t\tconsole.log('APBCT_AJAX_ERROR');\n\t\t\t\tconsole.log(jqXHR);\n\t\t\t\tconsole.log(textStatus);\n\t\t\t\tconsole.log('Anti-spam by Cleantalk plugin error: ' + errorThrown + 'Please, contact Cleantalk tech support https://wordpress.org/support/plugin/cleantalk-spam-protect/');\n\t\t\t\talert('Anti-spam by Cleantalk plugin error: ' + errorThrown + 'Please, contact Cleantalk tech support https://wordpress.org/support/plugin/cleantalk-spam-protect/');\n\t\t\t}\n\t\t},\n\t\ttimeout: timeout,\n\t});\n}\nif(typeof jQuery !== 'undefined') {\n\n\t// Capturing responses and output block message for unknown AJAX forms\n\tjQuery(document).ajaxComplete(function (event, xhr, settings) {\n\t\tif (xhr.responseText && xhr.responseText.indexOf('\"apbct') !== -1) {\n\t\t\tvar response = JSON.parse(xhr.responseText);\n\t\t\tif (typeof response.apbct !== 'undefined') {\n\t\t\t\tresponse = response.apbct;\n\t\t\t\tif (response.blocked) {\n\t\t\t\t\tdocument.dispatchEvent(\n\t\t\t\t\t\tnew CustomEvent( \"apbctAjaxBockAlert\", {\n\t\t\t\t\t\t\tbubbles: true,\n\t\t\t\t\t\t\tdetail: { message: response.comment }\n\t\t\t\t\t\t} )\n\t\t\t\t\t);\n\n\t\t\t\t\t// Create hidden element contains result.\n\t\t\t\t\tvar apbct_result = document.createElement( 'div' );\n\t\t\t\t\tapbct_result.setAttribute( 'id', 'apbct-result' );\n\t\t\t\t\tapbct_result.style.display = 'none';\n\t\t\t\t\tapbct_result.innerHTML = response.comment;\n\t\t\t\t\tdocument.body.append( apbct_result );\n\n\t\t\t\t\t// Show the element\n\t\t\t\t\tcleantalkModal.open('apbct-result');\n\n\t\t\t\t\tif(+response.stop_script == 1)\n\t\t\t\t\t\twindow.stop();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n}"],"names":["ctSetCookie","c_name","value","document","cookie","encodeURIComponent","apbct_collect_visible_fields","form","inputs","inputs_visible","inputs_visible_count","inputs_with_duplicate_names","key","elements","isNaN","filter","elem","getComputedStyle","display","visibility","opacity","getAttribute","indexOf","push","forEach","i","visible_fields","trim","visible_fields_count","apbct_visible_fields_set_cookie","visible_fields_collection","collection","JSON","stringify","apbct_js_keys__set_input_value","result","data","params","obj","ct_input_value","getElementById","input_name","replace","js_key","apbct_public_sendAJAX","callback","callback_context","callback_params","async","notJson","timeout","button","spinner","progressbar","silent","no_nonce","ctPublic","_ajax_nonce","Math","random","no_cache","setAttribute","style","cursor","jQuery","css","ajax","type","url","_ajax_url","success","removeAttribute","parse","error","setTimeout","fadeOut","alert","apply","concat","jqXHR","textStatus","errorThrown","console","log","ct_date","Date","ctTimeMs","getTime","ctMouseEventTimerFlag","ctMouseData","ctMouseDataCounter","apbct_attach_event_handler","event","window","addEventListener","attachEvent","apbct_remove_event_handler","removeEventListener","detachEvent","floor","getTimezoneOffset","ctFunctionFirstKey","ctMouseReadInterval","setInterval","ctMouseWriteDataInterval","ctFunctionMouseMove","round","clientY","clientX","clearInterval","forms","length","classList","contains","parentElement","action","toString","id","name","onsubmit_prev","onsubmit","this","target","Function","call","ajaxComplete","xhr","settings","apbct_result","response","responseText","apbct","blocked","dispatchEvent","CustomEvent","bubbles","detail","message","comment","createElement","innerHTML","body","append","cleantalkModal","open","stop_script","stop"],"mappings":"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"}
|
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
cleantalkModal={open:function(e){function t(){var e="";for(key in this.styles)e+=key+":"+this.styles[key]+";";return e}var o={styles:{"z-index":"9999",position:"fixed",top:"0",left:"0",width:"100%",height:"100%",background:"rgba(0,0,0,0.5)",display:"flex","justify-content":"center","align-items":"center"},toString:t},a={styles:{position:"relative",padding:"30px",background:"#FFF",border:"1px solid rgba(0,0,0,0.75)","border-radius":"4px","box-shadow":"7px 7px 5px 0px rgba(50,50,50,0.75)"},toString:t},l={styles:{position:"absolute",background:"#FFF",width:"20px",height:"20px",border:"2px solid rgba(0,0,0,0.75)","border-radius":"15px",cursor:"pointer",top:"-8px",right:"-8px"},toString:t},n={styles:{content:'""',display:"block",position:"absolute",background:"#000","border-radius":"1px",width:"2px",height:"16px",top:"2px",left:"9px",transform:"rotate(45deg)"},toString:t},d={styles:{content:'""',display:"block",position:"absolute",background:"#000","border-radius":"1px",width:"2px",height:"16px",top:"2px",left:"9px",transform:"rotate(-45deg)"},toString:t},r={styles:{overflow:"hidden"},toString:t},i=document.createElement("style");i.setAttribute("id","cleantalk-modal-styles"),i.innerHTML="body.cleantalk-modal-opened{"+r+"}",i.innerHTML+="#cleantalk-modal{"+o+"}",i.innerHTML+="#cleantalk-modal-close{"+l+"}",i.innerHTML+="#cleantalk-modal-close:before{"+n+"}",i.innerHTML+="#cleantalk-modal-close:after{"+d+"}",document.body.append(i);var s=document.createElement("div");s.setAttribute("id","cleantalk-modal"),document.body.append(s),document.body.classList.add("cleantalk-modal-opened");var c=document.getElementById(e).cloneNode(!0);c.removeAttribute("id"),c.removeAttribute("class"),c.removeAttribute("style"),c.setAttribute("style",a),s.append(c);var p=document.createElement("div");p.setAttribute("id","cleantalk-modal-close"),c.append(p)},close:function(){document.body.classList.remove("cleantalk-modal-opened"),document.getElementById("cleantalk-modal").remove(),document.getElementById("cleantalk-modal-styles").remove()}},document.addEventListener("click",function(e){(e.target&&"cleantalk-modal"===e.target.id||"cleantalk-modal-close"===e.target.id)&&cleantalkModal.close()});
|
2 |
+
//# sourceMappingURL=cleantalk-modal.min.js.map
|
@@ -0,0 +1 @@
|
|
|
1 |
+
{"version":3,"file":"cleantalk-modal.min.js","sources":["cleantalk-modal.js"],"sourcesContent":["/* Cleantalk Modal object */\ncleantalkModal = {\n\n open: function ( elementIdToShow ) {\n /* Cleantalk Modal CSS start */\n var renderCss = function () {\n var cssStr = '';\n for ( key in this.styles ) {\n cssStr += key + ':' + this.styles[key] + ';';\n }\n return cssStr;\n };\n var overlayCss = {\n styles: {\n \"z-index\": \"9999\",\n \"position\": \"fixed\",\n \"top\": \"0\",\n \"left\": \"0\",\n \"width\": \"100%\",\n \"height\": \"100%\",\n \"background\": \"rgba(0,0,0,0.5)\",\n \"display\": \"flex\",\n \"justify-content\" : \"center\",\n \"align-items\" : \"center\",\n },\n toString: renderCss\n };\n var innerCss = {\n styles: {\n \"position\" : \"relative\",\n \"padding\" : \"30px\",\n \"background\" : \"#FFF\",\n \"border\" : \"1px solid rgba(0,0,0,0.75)\",\n \"border-radius\" : \"4px\",\n \"box-shadow\" : \"7px 7px 5px 0px rgba(50,50,50,0.75)\",\n },\n toString: renderCss\n };\n var closeCss = {\n styles: {\n \"position\" : \"absolute\",\n \"background\" : \"#FFF\",\n \"width\" : \"20px\",\n \"height\" : \"20px\",\n \"border\" : \"2px solid rgba(0,0,0,0.75)\",\n \"border-radius\" : \"15px\",\n \"cursor\" : \"pointer\",\n \"top\" : \"-8px\",\n \"right\" : \"-8px\",\n },\n toString: renderCss\n };\n var closeCssBefore = {\n styles: {\n \"content\" : \"\\\"\\\"\",\n \"display\" : \"block\",\n \"position\" : \"absolute\",\n \"background\" : \"#000\",\n \"border-radius\" : \"1px\",\n \"width\" : \"2px\",\n \"height\" : \"16px\",\n \"top\" : \"2px\",\n \"left\" : \"9px\",\n \"transform\" : \"rotate(45deg)\",\n },\n toString: renderCss\n };\n var closeCssAfter = {\n styles: {\n \"content\" : \"\\\"\\\"\",\n \"display\" : \"block\",\n \"position\" : \"absolute\",\n \"background\" : \"#000\",\n \"border-radius\" : \"1px\",\n \"width\" : \"2px\",\n \"height\" : \"16px\",\n \"top\" : \"2px\",\n \"left\" : \"9px\",\n \"transform\" : \"rotate(-45deg)\",\n },\n toString: renderCss\n };\n var bodyCss = {\n styles: {\n \"overflow\" : \"hidden\",\n },\n toString: renderCss\n };\n var cleantalkModalStyle = document.createElement( 'style' );\n cleantalkModalStyle.setAttribute( 'id', 'cleantalk-modal-styles' );\n cleantalkModalStyle.innerHTML = 'body.cleantalk-modal-opened{' + bodyCss + '}';\n cleantalkModalStyle.innerHTML += '#cleantalk-modal{' + overlayCss + '}';\n cleantalkModalStyle.innerHTML += '#cleantalk-modal-close{' + closeCss + '}';\n cleantalkModalStyle.innerHTML += '#cleantalk-modal-close:before{' + closeCssBefore + '}';\n cleantalkModalStyle.innerHTML += '#cleantalk-modal-close:after{' + closeCssAfter + '}';\n document.body.append( cleantalkModalStyle );\n /* Cleantalk Modal CSS end */\n\n var overlay = document.createElement( 'div' );\n overlay.setAttribute( 'id', 'cleantalk-modal' );\n document.body.append( overlay );\n\n document.body.classList.add( 'cleantalk-modal-opened' );\n\n var inner = document.getElementById( elementIdToShow ).cloneNode( true );\n inner.removeAttribute( 'id' );\n inner.removeAttribute( 'class' );\n inner.removeAttribute( 'style' );\n inner.setAttribute( 'style', innerCss );\n overlay.append( inner );\n\n var close = document.createElement( 'div' );\n close.setAttribute( 'id', 'cleantalk-modal-close' );\n inner.append( close );\n },\n\n close: function () {\n document.body.classList.remove( 'cleantalk-modal-opened' );\n document.getElementById( 'cleantalk-modal' ).remove();\n document.getElementById( 'cleantalk-modal-styles' ).remove();\n }\n\n};\n\n/* Cleantalk Modal helpers */\ndocument.addEventListener('click',function( e ){\n if( e.target && e.target.id === 'cleantalk-modal' || e.target.id === 'cleantalk-modal-close' ){\n cleantalkModal.close();\n }\n});"],"names":["cleantalkModal","open","elementIdToShow","renderCss","cssStr","key","this","styles","overlayCss","z-index","position","top","left","width","height","background","display","justify-content","align-items","toString","innerCss","padding","border","border-radius","box-shadow","closeCss","cursor","right","closeCssBefore","content","transform","closeCssAfter","bodyCss","overflow","cleantalkModalStyle","document","createElement","setAttribute","innerHTML","body","append","overlay","classList","add","inner","getElementById","cloneNode","removeAttribute","close","remove","addEventListener","e","target","id"],"mappings":"AACAA,eAAiB,CAEbC,KAAM,SAAWC,GAEG,SAAZC,IACA,IAAIC,EAAS,GACb,IAAMC,OAAOC,KAAKC,OACdH,GAAUC,IAAM,IAAMC,KAAKC,OAAOF,KAAO,IAE7C,OAAOD,EALX,IAOII,EAAa,CACbD,OAAQ,CACJE,UAAW,OACXC,SAAY,QACZC,IAAO,IACPC,KAAQ,IACRC,MAAS,OACTC,OAAU,OACVC,WAAc,kBACdC,QAAW,OACXC,kBAAoB,SACpBC,cAAgB,UAEpBC,SAAUhB,GAEViB,EAAW,CACXb,OAAQ,CACJG,SAAa,WACbW,QAAY,OACZN,WAAe,OACfO,OAAW,6BACXC,gBAAkB,MAClBC,aAAe,uCAEnBL,SAAUhB,GAEVsB,EAAW,CACXlB,OAAQ,CACJG,SAAa,WACbK,WAAe,OACfF,MAAU,OACVC,OAAW,OACXQ,OAAW,6BACXC,gBAAkB,OAClBG,OAAW,UACXf,IAAQ,OACRgB,MAAU,QAEdR,SAAUhB,GAEVyB,EAAiB,CACjBrB,OAAQ,CACJsB,QAAY,KACZb,QAAY,QACZN,SAAa,WACbK,WAAe,OACfQ,gBAAkB,MAClBV,MAAU,MACVC,OAAW,OACXH,IAAQ,MACRC,KAAS,MACTkB,UAAc,iBAElBX,SAAUhB,GAEV4B,EAAgB,CAChBxB,OAAQ,CACJsB,QAAY,KACZb,QAAY,QACZN,SAAa,WACbK,WAAe,OACfQ,gBAAkB,MAClBV,MAAU,MACVC,OAAW,OACXH,IAAQ,MACRC,KAAS,MACTkB,UAAc,kBAElBX,SAAUhB,GAEV6B,EAAU,CACVzB,OAAQ,CACJ0B,SAAa,UAEjBd,SAAUhB,GAEV+B,EAAsBC,SAASC,cAAe,SAClDF,EAAoBG,aAAc,KAAM,0BACxCH,EAAoBI,UAAY,+BAAiCN,EAAU,IAC3EE,EAAoBI,WAAa,oBAAsB9B,EAAa,IACpE0B,EAAoBI,WAAa,0BAA4Bb,EAAW,IACxES,EAAoBI,WAAa,iCAAmCV,EAAiB,IACrFM,EAAoBI,WAAa,gCAAkCP,EAAgB,IACnFI,SAASI,KAAKC,OAAQN,GAGtB,IAAIO,EAAUN,SAASC,cAAe,OACtCK,EAAQJ,aAAc,KAAM,mBAC5BF,SAASI,KAAKC,OAAQC,GAEtBN,SAASI,KAAKG,UAAUC,IAAK,0BAE7B,IAAIC,EAAQT,SAASU,eAAgB3C,GAAkB4C,WAAW,GAClEF,EAAMG,gBAAiB,MACvBH,EAAMG,gBAAiB,SACvBH,EAAMG,gBAAiB,SACvBH,EAAMP,aAAc,QAASjB,GAC7BqB,EAAQD,OAAQI,GAEhB,IAAII,EAAQb,SAASC,cAAe,OACpCY,EAAMX,aAAc,KAAM,yBAC1BO,EAAMJ,OAAQQ,IAGlBA,MAAO,WACHb,SAASI,KAAKG,UAAUO,OAAQ,0BAChCd,SAASU,eAAgB,mBAAoBI,SAC7Cd,SAASU,eAAgB,0BAA2BI,WAM5Dd,SAASe,iBAAiB,QAAQ,SAAUC,IACpCA,EAAEC,QAA0B,oBAAhBD,EAAEC,OAAOC,IAA4C,0BAAhBF,EAAEC,OAAOC,KAC1DrD,eAAegD"}
|
@@ -1,542 +1,545 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Cleantalk\Antispam;
|
4 |
-
|
5 |
-
/**
|
6 |
-
* Cleantalk base class
|
7 |
-
*
|
8 |
-
* @version 2.2
|
9 |
-
* @package Cleantalk
|
10 |
-
* @subpackage Base
|
11 |
-
* @author Cleantalk team (welcome@cleantalk.org)
|
12 |
-
* @copyright (C) 2014 CleanTalk team (http://cleantalk.org)
|
13 |
-
* @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
|
14 |
-
* @see https://github.com/CleanTalk/php-antispam
|
15 |
-
*
|
16 |
-
*/
|
17 |
-
class Cleantalk {
|
18 |
-
|
19 |
-
/*
|
20 |
-
* Use Wordpress built-in API
|
21 |
-
*/
|
22 |
-
public $use_bultin_api = false;
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Maximum data size in bytes
|
26 |
-
* @var int
|
27 |
-
*/
|
28 |
-
private $dataMaxSise = 32768;
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Data compression rate
|
32 |
-
* @var int
|
33 |
-
*/
|
34 |
-
private $compressRate = 6;
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Server connection timeout in seconds
|
38 |
-
* @var int
|
39 |
-
*/
|
40 |
-
private $server_timeout = 15;
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Cleantalk server url
|
44 |
-
* @var string
|
45 |
-
*/
|
46 |
-
public $server_url = null;
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Last work url
|
50 |
-
* @var string
|
51 |
-
*/
|
52 |
-
public $work_url = null;
|
53 |
-
|
54 |
-
/**
|
55 |
-
* WOrk url ttl
|
56 |
-
* @var int
|
57 |
-
*/
|
58 |
-
public $server_ttl = null;
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Time wotk_url changer
|
62 |
-
* @var int
|
63 |
-
*/
|
64 |
-
public $server_changed = null;
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Flag is change server url
|
68 |
-
* @var bool
|
69 |
-
*/
|
70 |
-
public $server_change = false;
|
71 |
-
|
72 |
-
/**
|
73 |
-
* Codepage of the data
|
74 |
-
* @var bool
|
75 |
-
*/
|
76 |
-
public $data_codepage = null;
|
77 |
-
|
78 |
-
/**
|
79 |
-
* API version to use
|
80 |
-
* @var string
|
81 |
-
*/
|
82 |
-
public $api_version = '/api2.0';
|
83 |
-
|
84 |
-
/**
|
85 |
-
* Use https connection to servers
|
86 |
-
* @var bool
|
87 |
-
*/
|
88 |
-
public $ssl_on = false;
|
89 |
-
|
90 |
-
/**
|
91 |
-
* Path to SSL certificate
|
92 |
-
* @var string
|
93 |
-
*/
|
94 |
-
public $ssl_path = '';
|
95 |
-
|
96 |
-
/**
|
97 |
-
* Minimal server response in miliseconds to catch the server
|
98 |
-
*
|
99 |
-
*/
|
100 |
-
public $min_server_timeout = 50;
|
101 |
-
|
102 |
-
/**
|
103 |
-
* Maximal server response in miliseconds to catch the server
|
104 |
-
*
|
105 |
-
*/
|
106 |
-
public $max_server_timeout = 1500;
|
107 |
-
|
108 |
-
/**
|
109 |
-
* Function checks whether it is possible to publish the message
|
110 |
-
*
|
111 |
-
* @param CleantalkRequest $request
|
112 |
-
*
|
113 |
-
* @return bool|CleantalkResponse
|
114 |
-
*/
|
115 |
-
public function isAllowMessage(CleantalkRequest $request) {
|
116 |
-
$msg = $this->createMsg('check_message', $request);
|
117 |
-
return $this->httpRequest($msg);
|
118 |
-
}
|
119 |
-
|
120 |
-
/**
|
121 |
-
* Function checks whether it is possible to publish the message
|
122 |
-
*
|
123 |
-
* @param CleantalkRequest $request
|
124 |
-
*
|
125 |
-
* @return bool|CleantalkResponse
|
126 |
-
*/
|
127 |
-
public function isAllowUser(CleantalkRequest $request) {
|
128 |
-
$msg = $this->createMsg('check_newuser', $request);
|
129 |
-
return $this->httpRequest($msg);
|
130 |
-
}
|
131 |
-
|
132 |
-
/**
|
133 |
-
* Function sends the results of manual moderation
|
134 |
-
*
|
135 |
-
* @param CleantalkRequest $request
|
136 |
-
*
|
137 |
-
* @return bool|CleantalkResponse
|
138 |
-
*/
|
139 |
-
public function sendFeedback(CleantalkRequest $request) {
|
140 |
-
$msg = $this->createMsg('send_feedback', $request);
|
141 |
-
return $this->httpRequest($msg);
|
142 |
-
}
|
143 |
-
|
144 |
-
/**
|
145 |
-
* Create msg for cleantalk server
|
146 |
-
* @param string $method
|
147 |
-
* @param CleantalkRequest $request
|
148 |
-
* @return CleantalkRequest
|
149 |
-
*/
|
150 |
-
private function createMsg($method, CleantalkRequest $request) {
|
151 |
-
|
152 |
-
switch ($method) {
|
153 |
-
case 'check_message':
|
154 |
-
// Convert strings to UTF8
|
155 |
-
$request->message = \Cleantalk\ApbctWP\Helper::toUTF8($request->message, $this->data_codepage);
|
156 |
-
$request->example = \Cleantalk\ApbctWP\Helper::toUTF8($request->example, $this->data_codepage);
|
157 |
-
$request->sender_email = \Cleantalk\ApbctWP\Helper::toUTF8($request->sender_email, $this->data_codepage);
|
158 |
-
$request->sender_nickname = \Cleantalk\ApbctWP\Helper::toUTF8($request->sender_nickname, $this->data_codepage);
|
159 |
-
$request->message = $this->compressData($request->message);
|
160 |
-
$request->example = $this->compressData($request->example);
|
161 |
-
break;
|
162 |
-
|
163 |
-
case 'check_newuser':
|
164 |
-
// Convert strings to UTF8
|
165 |
-
$request->sender_email = \Cleantalk\ApbctWP\Helper::toUTF8($request->sender_email, $this->data_codepage);
|
166 |
-
$request->sender_nickname = \Cleantalk\ApbctWP\Helper::toUTF8($request->sender_nickname, $this->data_codepage);
|
167 |
-
break;
|
168 |
-
|
169 |
-
case 'send_feedback':
|
170 |
-
if (is_array($request->feedback)) {
|
171 |
-
$request->feedback = implode(';', $request->feedback);
|
172 |
-
}
|
173 |
-
break;
|
174 |
-
}
|
175 |
-
|
176 |
-
// Removing non UTF8 characters from request, because non UTF8 or malformed characters break json_encode().
|
177 |
-
foreach ($request as $param => $value) {
|
178 |
-
if(is_array($request->$param) || is_string($request->$param))
|
179 |
-
$request->$param = \Cleantalk\ApbctWP\Helper::removeNonUTF8($value);
|
180 |
-
}
|
181 |
-
|
182 |
-
$request->method_name = $method;
|
183 |
-
$request->message = is_array($request->message) ? json_encode($request->message) : $request->message;
|
184 |
-
|
185 |
-
// Wiping cleantalk's headers but, not for send_feedback
|
186 |
-
if($request->method_name != 'send_feedback'){
|
187 |
-
|
188 |
-
$ct_tmp = apache_request_headers();
|
189 |
-
|
190 |
-
if(isset($ct_tmp['Cookie']))
|
191 |
-
$cookie_name = 'Cookie';
|
192 |
-
elseif(isset($ct_tmp['cookie']))
|
193 |
-
$cookie_name = 'cookie';
|
194 |
-
else
|
195 |
-
$cookie_name = 'COOKIE';
|
196 |
-
|
197 |
-
$ct_tmp
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
$localData
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
$
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
$ping = $
|
359 |
-
}
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
$
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
$status =
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
$
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
curl_setopt($ch,
|
466 |
-
curl_setopt($ch,
|
467 |
-
curl_setopt($ch,
|
468 |
-
curl_setopt($ch,
|
469 |
-
|
470 |
-
curl_setopt($ch,
|
471 |
-
curl_setopt($ch,
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
'
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
$response['errstr'] = $
|
516 |
-
|
517 |
-
|
518 |
-
$response['errstr']
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
$
|
532 |
-
|
533 |
-
|
534 |
-
$response
|
535 |
-
|
536 |
-
$response =
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Cleantalk\Antispam;
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Cleantalk base class
|
7 |
+
*
|
8 |
+
* @version 2.2
|
9 |
+
* @package Cleantalk
|
10 |
+
* @subpackage Base
|
11 |
+
* @author Cleantalk team (welcome@cleantalk.org)
|
12 |
+
* @copyright (C) 2014 CleanTalk team (http://cleantalk.org)
|
13 |
+
* @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
|
14 |
+
* @see https://github.com/CleanTalk/php-antispam
|
15 |
+
*
|
16 |
+
*/
|
17 |
+
class Cleantalk {
|
18 |
+
|
19 |
+
/*
|
20 |
+
* Use Wordpress built-in API
|
21 |
+
*/
|
22 |
+
public $use_bultin_api = false;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Maximum data size in bytes
|
26 |
+
* @var int
|
27 |
+
*/
|
28 |
+
private $dataMaxSise = 32768;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Data compression rate
|
32 |
+
* @var int
|
33 |
+
*/
|
34 |
+
private $compressRate = 6;
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Server connection timeout in seconds
|
38 |
+
* @var int
|
39 |
+
*/
|
40 |
+
private $server_timeout = 15;
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Cleantalk server url
|
44 |
+
* @var string
|
45 |
+
*/
|
46 |
+
public $server_url = null;
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Last work url
|
50 |
+
* @var string
|
51 |
+
*/
|
52 |
+
public $work_url = null;
|
53 |
+
|
54 |
+
/**
|
55 |
+
* WOrk url ttl
|
56 |
+
* @var int
|
57 |
+
*/
|
58 |
+
public $server_ttl = null;
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Time wotk_url changer
|
62 |
+
* @var int
|
63 |
+
*/
|
64 |
+
public $server_changed = null;
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Flag is change server url
|
68 |
+
* @var bool
|
69 |
+
*/
|
70 |
+
public $server_change = false;
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Codepage of the data
|
74 |
+
* @var bool
|
75 |
+
*/
|
76 |
+
public $data_codepage = null;
|
77 |
+
|
78 |
+
/**
|
79 |
+
* API version to use
|
80 |
+
* @var string
|
81 |
+
*/
|
82 |
+
public $api_version = '/api2.0';
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Use https connection to servers
|
86 |
+
* @var bool
|
87 |
+
*/
|
88 |
+
public $ssl_on = false;
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Path to SSL certificate
|
92 |
+
* @var string
|
93 |
+
*/
|
94 |
+
public $ssl_path = '';
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Minimal server response in miliseconds to catch the server
|
98 |
+
*
|
99 |
+
*/
|
100 |
+
public $min_server_timeout = 50;
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Maximal server response in miliseconds to catch the server
|
104 |
+
*
|
105 |
+
*/
|
106 |
+
public $max_server_timeout = 1500;
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Function checks whether it is possible to publish the message
|
110 |
+
*
|
111 |
+
* @param CleantalkRequest $request
|
112 |
+
*
|
113 |
+
* @return bool|CleantalkResponse
|
114 |
+
*/
|
115 |
+
public function isAllowMessage(CleantalkRequest $request) {
|
116 |
+
$msg = $this->createMsg('check_message', $request);
|
117 |
+
return $this->httpRequest($msg);
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Function checks whether it is possible to publish the message
|
122 |
+
*
|
123 |
+
* @param CleantalkRequest $request
|
124 |
+
*
|
125 |
+
* @return bool|CleantalkResponse
|
126 |
+
*/
|
127 |
+
public function isAllowUser(CleantalkRequest $request) {
|
128 |
+
$msg = $this->createMsg('check_newuser', $request);
|
129 |
+
return $this->httpRequest($msg);
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Function sends the results of manual moderation
|
134 |
+
*
|
135 |
+
* @param CleantalkRequest $request
|
136 |
+
*
|
137 |
+
* @return bool|CleantalkResponse
|
138 |
+
*/
|
139 |
+
public function sendFeedback(CleantalkRequest $request) {
|
140 |
+
$msg = $this->createMsg('send_feedback', $request);
|
141 |
+
return $this->httpRequest($msg);
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Create msg for cleantalk server
|
146 |
+
* @param string $method
|
147 |
+
* @param CleantalkRequest $request
|
148 |
+
* @return CleantalkRequest
|
149 |
+
*/
|
150 |
+
private function createMsg($method, CleantalkRequest $request) {
|
151 |
+
|
152 |
+
switch ($method) {
|
153 |
+
case 'check_message':
|
154 |
+
// Convert strings to UTF8
|
155 |
+
$request->message = \Cleantalk\ApbctWP\Helper::toUTF8($request->message, $this->data_codepage);
|
156 |
+
$request->example = \Cleantalk\ApbctWP\Helper::toUTF8($request->example, $this->data_codepage);
|
157 |
+
$request->sender_email = \Cleantalk\ApbctWP\Helper::toUTF8($request->sender_email, $this->data_codepage);
|
158 |
+
$request->sender_nickname = \Cleantalk\ApbctWP\Helper::toUTF8($request->sender_nickname, $this->data_codepage);
|
159 |
+
$request->message = $this->compressData($request->message);
|
160 |
+
$request->example = $this->compressData($request->example);
|
161 |
+
break;
|
162 |
+
|
163 |
+
case 'check_newuser':
|
164 |
+
// Convert strings to UTF8
|
165 |
+
$request->sender_email = \Cleantalk\ApbctWP\Helper::toUTF8($request->sender_email, $this->data_codepage);
|
166 |
+
$request->sender_nickname = \Cleantalk\ApbctWP\Helper::toUTF8($request->sender_nickname, $this->data_codepage);
|
167 |
+
break;
|
168 |
+
|
169 |
+
case 'send_feedback':
|
170 |
+
if (is_array($request->feedback)) {
|
171 |
+
$request->feedback = implode(';', $request->feedback);
|
172 |
+
}
|
173 |
+
break;
|
174 |
+
}
|
175 |
+
|
176 |
+
// Removing non UTF8 characters from request, because non UTF8 or malformed characters break json_encode().
|
177 |
+
foreach ($request as $param => $value) {
|
178 |
+
if(is_array($request->$param) || is_string($request->$param))
|
179 |
+
$request->$param = \Cleantalk\ApbctWP\Helper::removeNonUTF8($value);
|
180 |
+
}
|
181 |
+
|
182 |
+
$request->method_name = $method;
|
183 |
+
$request->message = is_array($request->message) ? json_encode($request->message) : $request->message;
|
184 |
+
|
185 |
+
// Wiping cleantalk's headers but, not for send_feedback
|
186 |
+
if($request->method_name != 'send_feedback'){
|
187 |
+
|
188 |
+
$ct_tmp = apache_request_headers();
|
189 |
+
|
190 |
+
if(isset($ct_tmp['Cookie']))
|
191 |
+
$cookie_name = 'Cookie';
|
192 |
+
elseif(isset($ct_tmp['cookie']))
|
193 |
+
$cookie_name = 'cookie';
|
194 |
+
else
|
195 |
+
$cookie_name = 'COOKIE';
|
196 |
+
|
197 |
+
if( $ct_tmp ) {
|
198 |
+
$ct_tmp[$cookie_name] = preg_replace(array(
|
199 |
+
'/\s?ct_checkjs=[a-z0-9]*[^;]*;?/',
|
200 |
+
'/\s?ct_timezone=.{0,1}\d{1,2}[^;]*;?/',
|
201 |
+
'/\s?ct_pointer_data=.*5D[^;]*;?/',
|
202 |
+
'/\s?apbct_timestamp=\d*[^;]*;?/',
|
203 |
+
'/\s?apbct_site_landing_ts=\d*[^;]*;?/',
|
204 |
+
'/\s?apbct_cookies_test=%7B.*%7D[^;]*;?/',
|
205 |
+
'/\s?apbct_prev_referer=http.*?[^;]*;?/',
|
206 |
+
'/\s?ct_cookies_test=.*?[^;]*;?/',
|
207 |
+
'/\s?ct_ps_timestamp=.*?[^;]*;?/',
|
208 |
+
'/\s?ct_fkp_timestamp=\d*?[^;]*;?/',
|
209 |
+
'/\s?ct_sfw_pass_key=\d*?[^;]*;?/',
|
210 |
+
'/\s?apbct_page_hits=\d*?[^;]*;?/',
|
211 |
+
'/\s?apbct_visible_fields_count=\d*?[^;]*;?/',
|
212 |
+
'/\s?apbct_visible_fields=%7B.*%7D[^;]*;?/',
|
213 |
+
), '', $ct_tmp[$cookie_name]);
|
214 |
+
$request->all_headers = json_encode($ct_tmp);
|
215 |
+
}
|
216 |
+
|
217 |
+
}
|
218 |
+
|
219 |
+
return $request;
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* Compress data and encode to base64
|
224 |
+
* @param type string
|
225 |
+
* @return string
|
226 |
+
*/
|
227 |
+
private function compressData($data = null){
|
228 |
+
|
229 |
+
if (strlen($data) > $this->dataMaxSise && function_exists('\gzencode') && function_exists('base64_encode')){
|
230 |
+
|
231 |
+
$localData = \gzencode($data, $this->compressRate, FORCE_GZIP);
|
232 |
+
|
233 |
+
if ($localData === false)
|
234 |
+
return $data;
|
235 |
+
|
236 |
+
$localData = base64_encode($localData);
|
237 |
+
|
238 |
+
if ($localData === false)
|
239 |
+
return $data;
|
240 |
+
|
241 |
+
return $localData;
|
242 |
+
}
|
243 |
+
|
244 |
+
return $data;
|
245 |
+
}
|
246 |
+
|
247 |
+
/**
|
248 |
+
* httpRequest
|
249 |
+
* @param $msg
|
250 |
+
* @return boolean|\CleantalkResponse
|
251 |
+
*/
|
252 |
+
private function httpRequest($msg) {
|
253 |
+
|
254 |
+
// Using current server without changing it
|
255 |
+
$result = !empty($this->work_url) && ($this->server_changed + $this->server_ttl > time())
|
256 |
+
? $this->sendRequest($msg, $this->work_url, $this->server_timeout)
|
257 |
+
: false;
|
258 |
+
|
259 |
+
// Changing server
|
260 |
+
if ($result === false || (is_object($result) && $result->errno != 0)) {
|
261 |
+
|
262 |
+
// Split server url to parts
|
263 |
+
preg_match("/^(https?:\/\/)([^\/:]+)(.*)/i", $this->server_url, $matches);
|
264 |
+
|
265 |
+
$url_protocol = isset($matches[1]) ? $matches[1] : '';
|
266 |
+
$url_host = isset($matches[2]) ? $matches[2] : '';
|
267 |
+
$url_suffix = isset($matches[3]) ? $matches[3] : '';
|
268 |
+
|
269 |
+
$servers = $this->get_servers_ip($url_host);
|
270 |
+
|
271 |
+
// Loop until find work server
|
272 |
+
foreach ($servers as $server) {
|
273 |
+
|
274 |
+
$dns = \Cleantalk\ApbctWP\Helper::ip__resolve__cleantalks($server['ip']);
|
275 |
+
if(!$dns)
|
276 |
+
continue;
|
277 |
+
|
278 |
+
$this->work_url = $url_protocol.$dns.$url_suffix;
|
279 |
+
$this->server_ttl = $server['ttl'];
|
280 |
+
|
281 |
+
$result = $this->sendRequest($msg, $this->work_url, $this->server_timeout);
|
282 |
+
|
283 |
+
if ($result !== false && $result->errno === 0) {
|
284 |
+
$this->server_change = true;
|
285 |
+
break;
|
286 |
+
}
|
287 |
+
}
|
288 |
+
}
|
289 |
+
|
290 |
+
$response = new CleantalkResponse(null, $result);
|
291 |
+
|
292 |
+
if (!empty($this->data_codepage) && $this->data_codepage !== 'UTF-8') {
|
293 |
+
if (!empty($response->comment))
|
294 |
+
$response->comment = $this->stringFromUTF8($response->comment, $this->data_codepage);
|
295 |
+
if (!empty($response->errstr))
|
296 |
+
$response->errstr = $this->stringFromUTF8($response->errstr, $this->data_codepage);
|
297 |
+
if (!empty($response->sms_error_text))
|
298 |
+
$response->sms_error_text = $this->stringFromUTF8($response->sms_error_text, $this->data_codepage);
|
299 |
+
}
|
300 |
+
|
301 |
+
return $response;
|
302 |
+
}
|
303 |
+
|
304 |
+
/**
|
305 |
+
* Function DNS request
|
306 |
+
* @param $host
|
307 |
+
* @return array
|
308 |
+
*/
|
309 |
+
public function get_servers_ip($host)
|
310 |
+
{
|
311 |
+
if (!isset($host))
|
312 |
+
return null;
|
313 |
+
|
314 |
+
$servers = array();
|
315 |
+
|
316 |
+
// Get DNS records about URL
|
317 |
+
if (function_exists('dns_get_record')) {
|
318 |
+
$records = dns_get_record($host, DNS_A);
|
319 |
+
if ($records !== FALSE) {
|
320 |
+
foreach ($records as $server) {
|
321 |
+
$servers[] = $server;
|
322 |
+
}
|
323 |
+
}
|
324 |
+
}
|
325 |
+
|
326 |
+
// Another try if first failed
|
327 |
+
if (count($servers) == 0 && function_exists('gethostbynamel')) {
|
328 |
+
$records = gethostbynamel($host);
|
329 |
+
if ($records !== FALSE) {
|
330 |
+
foreach ($records as $server) {
|
331 |
+
$servers[] = array(
|
332 |
+
"ip" => $server,
|
333 |
+
"host" => $host,
|
334 |
+
"ttl" => $this->server_ttl
|
335 |
+
);
|
336 |
+
}
|
337 |
+
}
|
338 |
+
}
|
339 |
+
|
340 |
+
// If couldn't get records
|
341 |
+
if (count($servers) == 0){
|
342 |
+
|
343 |
+
$servers[] = array(
|
344 |
+
"ip" => null,
|
345 |
+
"host" => $host,
|
346 |
+
"ttl" => $this->server_ttl
|
347 |
+
);
|
348 |
+
|
349 |
+
// If records recieved
|
350 |
+
} else {
|
351 |
+
|
352 |
+
$tmp = null;
|
353 |
+
$fast_server_found = false;
|
354 |
+
|
355 |
+
foreach ($servers as $server) {
|
356 |
+
|
357 |
+
if ($fast_server_found) {
|
358 |
+
$ping = $this->max_server_timeout;
|
359 |
+
} else {
|
360 |
+
$ping = $this->httpPing($server['ip']);
|
361 |
+
$ping = $ping * 1000;
|
362 |
+
}
|
363 |
+
|
364 |
+
$tmp[$ping] = $server;
|
365 |
+
|
366 |
+
$fast_server_found = $ping < $this->min_server_timeout ? true : false;
|
367 |
+
|
368 |
+
}
|
369 |
+
|
370 |
+
if (count($tmp)){
|
371 |
+
ksort($tmp);
|
372 |
+
$response = $tmp;
|
373 |
+
}
|
374 |
+
|
375 |
+
}
|
376 |
+
|
377 |
+
return empty($response) ? null : $response;
|
378 |
+
}
|
379 |
+
|
380 |
+
/**
|
381 |
+
* Function to check response time
|
382 |
+
* param string
|
383 |
+
* @return int
|
384 |
+
*/
|
385 |
+
function httpPing($host){
|
386 |
+
|
387 |
+
// Skip localhost ping cause it raise error at fsockopen.
|
388 |
+
// And return minimun value
|
389 |
+
if ($host == 'localhost')
|
390 |
+
return 0.001;
|
391 |
+
|
392 |
+
$starttime = microtime(true);
|
393 |
+
$file = @fsockopen ($host, 80, $errno, $errstr, $this->max_server_timeout/1000);
|
394 |
+
$stoptime = microtime(true);
|
395 |
+
|
396 |
+
if (!$file) {
|
397 |
+
$status = $this->max_server_timeout/1000; // Site is down
|
398 |
+
} else {
|
399 |
+
fclose($file);
|
400 |
+
$status = ($stoptime - $starttime);
|
401 |
+
$status = round($status, 4);
|
402 |
+
}
|
403 |
+
|
404 |
+
return $status;
|
405 |
+
}
|
406 |
+
|
407 |
+
/**
|
408 |
+
* Send JSON request to servers
|
409 |
+
* @param $msg
|
410 |
+
* @return boolean|\CleantalkResponse
|
411 |
+
*/
|
412 |
+
private function sendRequest($data = null, $url, $server_timeout = 3)
|
413 |
+
{
|
414 |
+
$original_args = func_get_args();
|
415 |
+
// Convert to array
|
416 |
+
$data = (array)json_decode(json_encode($data), true);
|
417 |
+
|
418 |
+
//Cleaning from 'null' values
|
419 |
+
$tmp_data = array();
|
420 |
+
foreach($data as $key => $value){
|
421 |
+
if($value !== null)
|
422 |
+
$tmp_data[$key] = $value;
|
423 |
+
}
|
424 |
+
$data = $tmp_data;
|
425 |
+
unset($key, $value, $tmp_data);
|
426 |
+
|
427 |
+
// Convert to JSON
|
428 |
+
$data = json_encode($data);
|
429 |
+
|
430 |
+
if (isset($this->api_version)) {
|
431 |
+
$url = $url . $this->api_version;
|
432 |
+
}
|
433 |
+
|
434 |
+
$result = false;
|
435 |
+
$curl_error = null;
|
436 |
+
|
437 |
+
// Switching to secure connection
|
438 |
+
if ($this->ssl_on && !preg_match("/^https:/", $url)){
|
439 |
+
$url = preg_replace("/^(http)/i", "$1s", $url);
|
440 |
+
}
|
441 |
+
|
442 |
+
if($this->use_bultin_api){
|
443 |
+
|
444 |
+
$args = array(
|
445 |
+
'body' => $data,
|
446 |
+
'timeout' => $server_timeout,
|
447 |
+
'user-agent' => APBCT_AGENT.' '.get_bloginfo( 'url' ),
|
448 |
+
);
|
449 |
+
|
450 |
+
$result = wp_remote_post($url, $args);
|
451 |
+
|
452 |
+
if( is_wp_error( $result ) ) {
|
453 |
+
$errors = $result->get_error_message();
|
454 |
+
$result = false;
|
455 |
+
}else{
|
456 |
+
$result = wp_remote_retrieve_body($result);
|
457 |
+
}
|
458 |
+
|
459 |
+
}else{
|
460 |
+
|
461 |
+
if(function_exists('curl_init')) {
|
462 |
+
|
463 |
+
$ch = curl_init();
|
464 |
+
|
465 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
466 |
+
curl_setopt($ch, CURLOPT_TIMEOUT, $server_timeout);
|
467 |
+
curl_setopt($ch, CURLOPT_POST, 1);
|
468 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
469 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // receive server response ...
|
470 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); // resolve 'Expect: 100-continue' issue
|
471 |
+
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); // see http://stackoverflow.com/a/23322368
|
472 |
+
|
473 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Disabling CA cert verivication and
|
474 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); // Disabling common name verification
|
475 |
+
|
476 |
+
if ($this->ssl_on && $this->ssl_path != '') {
|
477 |
+
curl_setopt($ch, CURLOPT_CAINFO, $this->ssl_path);
|
478 |
+
}
|
479 |
+
|
480 |
+
$result = curl_exec($ch);
|
481 |
+
if (!$result) {
|
482 |
+
$curl_error = curl_error($ch);
|
483 |
+
// Use SSL next time, if error occurs.
|
484 |
+
if(!$this->ssl_on){
|
485 |
+
$this->ssl_on = true;
|
486 |
+
return $this->sendRequest($original_args[0], $original_args[1], $server_timeout);
|
487 |
+
}
|
488 |
+
}
|
489 |
+
|
490 |
+
curl_close($ch);
|
491 |
+
}
|
492 |
+
}
|
493 |
+
|
494 |
+
if (!$result) {
|
495 |
+
$allow_url_fopen = ini_get('allow_url_fopen');
|
496 |
+
if (function_exists('file_get_contents') && isset($allow_url_fopen) && $allow_url_fopen == '1') {
|
497 |
+
$opts = array('http' =>
|
498 |
+
array(
|
499 |
+
'method' => 'POST',
|
500 |
+
'header' => "Content-Type: text/html\r\n",
|
501 |
+
'content' => $data,
|
502 |
+
'timeout' => $server_timeout
|
503 |
+
)
|
504 |
+
);
|
505 |
+
|
506 |
+
$context = stream_context_create($opts);
|
507 |
+
$result = @file_get_contents($url, false, $context);
|
508 |
+
}
|
509 |
+
}
|
510 |
+
|
511 |
+
if (!$result) {
|
512 |
+
$response = null;
|
513 |
+
$response['errno'] = 2;
|
514 |
+
if (!\Cleantalk\ApbctWP\Helper::is_json($result)) {
|
515 |
+
$response['errstr'] = 'Wrong server response format: ' . substr( $result, 100 );
|
516 |
+
}
|
517 |
+
else {
|
518 |
+
$response['errstr'] = $curl_error
|
519 |
+
? sprintf( "CURL error: '%s'", $curl_error )
|
520 |
+
: 'No CURL support compiled in';
|
521 |
+
$response['errstr'] .= ' or disabled allow_url_fopen in php.ini.';
|
522 |
+
}
|
523 |
+
$response = json_decode( json_encode( $response ) );
|
524 |
+
|
525 |
+
return $response;
|
526 |
+
}
|
527 |
+
|
528 |
+
$errstr = null;
|
529 |
+
$response = json_decode($result);
|
530 |
+
if ($result !== false && is_object($response)) {
|
531 |
+
$response->errno = 0;
|
532 |
+
$response->errstr = $errstr;
|
533 |
+
} else {
|
534 |
+
$errstr = 'Unknown response from ' . $url . '.' . ' ' . $result;
|
535 |
+
|
536 |
+
$response = null;
|
537 |
+
$response['errno'] = 1;
|
538 |
+
$response['errstr'] = $errstr;
|
539 |
+
$response = json_decode(json_encode($response));
|
540 |
+
}
|
541 |
+
|
542 |
+
|
543 |
+
return $response;
|
544 |
+
}
|
545 |
+
}
|
@@ -1,88 +1,103 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
namespace Cleantalk\Antispam;
|
5 |
-
|
6 |
-
|
7 |
-
class Integrations
|
8 |
-
{
|
9 |
-
|
10 |
-
private $integrations = array();
|
11 |
-
|
12 |
-
private $integration;
|
13 |
-
|
14 |
-
public function __construct( $integrations )
|
15 |
-
{
|
16 |
-
$this->integrations = $integrations;
|
17 |
-
|
18 |
-
foreach( $this->integrations as $integration_name => $integration_info ) {
|
19 |
-
if( $integration_info['ajax'] ) {
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
$
|
46 |
-
if( !
|
47 |
-
//
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
namespace Cleantalk\Antispam;
|
5 |
+
|
6 |
+
|
7 |
+
class Integrations
|
8 |
+
{
|
9 |
+
|
10 |
+
private $integrations = array();
|
11 |
+
|
12 |
+
private $integration;
|
13 |
+
|
14 |
+
public function __construct( $integrations )
|
15 |
+
{
|
16 |
+
$this->integrations = $integrations;
|
17 |
+
|
18 |
+
foreach( $this->integrations as $integration_name => $integration_info ) {
|
19 |
+
if( $integration_info['ajax'] ) {
|
20 |
+
if( is_array( $integration_info['hook'] ) ) {
|
21 |
+
foreach( $integration_info['hook'] as $hook ) {
|
22 |
+
add_action( 'wp_ajax_' . $hook, array( $this, 'checkSpam' ), 1 );
|
23 |
+
add_action( 'wp_ajax_nopriv_' . $hook, array( $this, 'checkSpam' ), 1 );
|
24 |
+
}
|
25 |
+
} else {
|
26 |
+
add_action( 'wp_ajax_' . $integration_info['hook'], array( $this, 'checkSpam' ), 1 );
|
27 |
+
add_action( 'wp_ajax_nopriv_' . $integration_info['hook'], array( $this, 'checkSpam' ), 1 );
|
28 |
+
}
|
29 |
+
} else {
|
30 |
+
add_action( $integration_info['hook'], array( $this, 'checkSpam' ) );
|
31 |
+
}
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
public function checkSpam( $argument )
|
36 |
+
{
|
37 |
+
global $cleantalk_executed;
|
38 |
+
|
39 |
+
// Getting current integration name
|
40 |
+
$current_integration = $this->get_current_integration_triggered( current_filter() );
|
41 |
+
if( $current_integration ) {
|
42 |
+
// Instantiate the integration object
|
43 |
+
$class = '\\Cleantalk\\Antispam\\Integrations\\' . $current_integration;
|
44 |
+
if( class_exists( $class )) {
|
45 |
+
$this->integration = new $class();
|
46 |
+
if( ! ( $this->integration instanceof \Cleantalk\Antispam\Integrations\IntegrationBase ) ) {
|
47 |
+
// @ToDo have to handle an error
|
48 |
+
do_action( 'apbct_skipped_request', __FILE__ . ' -> ' . __FUNCTION__ . '():' . __LINE__, array('Integration is not instanse of IntegrationBase class.') );
|
49 |
+
return;
|
50 |
+
}
|
51 |
+
// Run data collecting for spam checking
|
52 |
+
$data = $this->integration->getDataForChecking( $argument );
|
53 |
+
if( ! is_null( $data ) ) {
|
54 |
+
// Go spam checking
|
55 |
+
$base_call_result = apbct_base_call(
|
56 |
+
array(
|
57 |
+
'message' => !empty( $data['message'] ) ? json_encode( $data['message'] ) : '',
|
58 |
+
'sender_email' => !empty( $data['email'] ) ? $data['email'] : '',
|
59 |
+
'sender_nickname' => !empty( $data['nickname'] ) ? $data['nickname'] : '',
|
60 |
+
'post_info' => array(
|
61 |
+
'comment_type' => 'contact_form_wordpress_' . strtolower($current_integration),
|
62 |
+
'post_url' => apbct_get_server_variable( 'HTTP_REFERER' ), // Page URL must be an previous page
|
63 |
+
),
|
64 |
+
),
|
65 |
+
isset( $data['register'] ) ? true : false
|
66 |
+
);
|
67 |
+
|
68 |
+
$ct_result = $base_call_result['ct_result'];
|
69 |
+
|
70 |
+
$cleantalk_executed = true;
|
71 |
+
|
72 |
+
if ($ct_result->allow == 0) {
|
73 |
+
// Do blocking if it is a spam
|
74 |
+
$this->integration->doBlock( $ct_result->comment );
|
75 |
+
}
|
76 |
+
} else {
|
77 |
+
// @ToDo have to handle an error
|
78 |
+
return;
|
79 |
+
}
|
80 |
+
}
|
81 |
+
}
|
82 |
+
}
|
83 |
+
|
84 |
+
private function get_current_integration_triggered( $hook )
|
85 |
+
{
|
86 |
+
if( $hook !== false ) {
|
87 |
+
foreach( $this->integrations as $integration_name => $integration_info ) {
|
88 |
+
if( is_array( $integration_info['hook'] ) ) {
|
89 |
+
foreach( $integration_info['hook'] as $integration_hook ) {
|
90 |
+
if( strpos( $hook, $integration_hook ) !== false ) {
|
91 |
+
return $integration_name;
|
92 |
+
}
|
93 |
+
}
|
94 |
+
} else {
|
95 |
+
if( strpos( $hook, $integration_info['hook'] ) !== false ) {
|
96 |
+
return $integration_name;
|
97 |
+
}
|
98 |
+
}
|
99 |
+
}
|
100 |
+
}
|
101 |
+
return false;
|
102 |
+
}
|
103 |
}
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
namespace Cleantalk\Antispam\Integrations;
|
5 |
+
|
6 |
+
|
7 |
+
class Wpdiscuz extends IntegrationBase {
|
8 |
+
|
9 |
+
function getDataForChecking( $argument ) {
|
10 |
+
|
11 |
+
return ct_get_fields_any( $_POST );
|
12 |
+
|
13 |
+
}
|
14 |
+
|
15 |
+
function doBlock( $message ) {
|
16 |
+
|
17 |
+
wp_send_json_error( 'wc_error_email_text' );
|
18 |
+
|
19 |
+
}
|
20 |
+
}
|
@@ -152,15 +152,20 @@ class Users extends \Cleantalk\ApbctWP\CleantalkListTable
|
|
152 |
|
153 |
function removeSpam( $ids ) {
|
154 |
|
155 |
-
$
|
156 |
-
foreach($ids as $id) {
|
157 |
-
$sanitized_ids[] = sanitize_key( $id );
|
158 |
-
}
|
159 |
-
$ids_string = implode( ', ', $sanitized_ids );
|
160 |
-
global $wpdb;
|
161 |
|
162 |
-
|
163 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
|
165 |
}
|
166 |
|
152 |
|
153 |
function removeSpam( $ids ) {
|
154 |
|
155 |
+
foreach( $ids as $id ) {
|
|
|
|
|
|
|
|
|
|
|
156 |
|
157 |
+
$user_id = sanitize_key( $id ) ;
|
158 |
+
|
159 |
+
//Send feedback
|
160 |
+
$hash = get_user_meta($user_id, 'ct_hash', true);
|
161 |
+
if( $hash ) {
|
162 |
+
ct_feedback( $hash, 0 );
|
163 |
+
}
|
164 |
+
|
165 |
+
//Delete user and posts
|
166 |
+
wp_delete_user( $user_id );
|
167 |
+
|
168 |
+
}
|
169 |
|
170 |
}
|
171 |
|
@@ -26,7 +26,7 @@ class UsersChecker extends Checker
|
|
26 |
'ct_prev_till' => !empty($prev_check['till']) ? $prev_check['till'] : false,
|
27 |
'ct_timeout' => __('Failed from timeout. Going to check users again.', 'cleantalk-spam-protect'),
|
28 |
'ct_timeout_delete' => __('Failed from timeout. Going to run a new attempt to delete spam users.', 'cleantalk-spam-protect'),
|
29 |
-
'ct_confirm_deletion_all' => __('
|
30 |
'ct_iusers' => __('users.', 'cleantalk-spam-protect'),
|
31 |
'ct_csv_filename' => "user_check_by_".$current_user->user_login,
|
32 |
'ct_status_string' => __("Checked %s, found %s spam users and %s bad users (without IP or email)", 'cleantalk-spam-protect'),
|
@@ -209,7 +209,7 @@ class UsersChecker extends Checker
|
|
209 |
$curr_ip = preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $curr_ip) === 1 ? $curr_ip : null;
|
210 |
$curr_email = preg_match('/^\S+@\S+\.\S+$/', $curr_email) === 1 ? $curr_email : null;
|
211 |
|
212 |
-
if( empty( $curr_ip )
|
213 |
$check_result['bad']++;
|
214 |
update_user_meta( $u[$i]->ID,'ct_bad','1',true );
|
215 |
update_user_meta( $u[$i]->ID, 'ct_checked', date("Y-m-d H:m:s"), true) ;
|
26 |
'ct_prev_till' => !empty($prev_check['till']) ? $prev_check['till'] : false,
|
27 |
'ct_timeout' => __('Failed from timeout. Going to check users again.', 'cleantalk-spam-protect'),
|
28 |
'ct_timeout_delete' => __('Failed from timeout. Going to run a new attempt to delete spam users.', 'cleantalk-spam-protect'),
|
29 |
+
'ct_confirm_deletion_all' => __('Do you confirm deletion selected accounts and all content owned by the accounts? Please do backup of the site before deletion!', 'cleantalk-spam-protect'),
|
30 |
'ct_iusers' => __('users.', 'cleantalk-spam-protect'),
|
31 |
'ct_csv_filename' => "user_check_by_".$current_user->user_login,
|
32 |
'ct_status_string' => __("Checked %s, found %s spam users and %s bad users (without IP or email)", 'cleantalk-spam-protect'),
|
209 |
$curr_ip = preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $curr_ip) === 1 ? $curr_ip : null;
|
210 |
$curr_email = preg_match('/^\S+@\S+\.\S+$/', $curr_email) === 1 ? $curr_email : null;
|
211 |
|
212 |
+
if( empty( $curr_ip ) || empty( $curr_email ) ){
|
213 |
$check_result['bad']++;
|
214 |
update_user_meta( $u[$i]->ID,'ct_bad','1',true );
|
215 |
update_user_meta( $u[$i]->ID, 'ct_checked', date("Y-m-d H:m:s"), true) ;
|
@@ -245,6 +245,7 @@ class AntiCrawler extends \Cleantalk\Common\Firewall\FirewallModule{
|
|
245 |
}
|
246 |
|
247 |
add_action( 'wp_head', array( '\Cleantalk\ApbctWP\Firewall\AntiCrawler', 'set_cookie' ) );
|
|
|
248 |
|
249 |
}
|
250 |
|
@@ -342,7 +343,7 @@ class AntiCrawler extends \Cleantalk\Common\Firewall\FirewallModule{
|
|
342 |
'{CLEANTALK_TITLE}' => __( 'Antispam by CleanTalk', 'cleantalk-spam-protect' ),
|
343 |
'{REMOTE_ADDRESS}' => $result['ip'],
|
344 |
'{SERVICE_ID}' => $this->apbct->data['service_id'] . ', ' . $net_count,
|
345 |
-
'{HOST}' =>
|
346 |
'{COOKIE_ANTICRAWLER}' => hash( 'sha256', $apbct->api_key . $apbct->data['salt'] ),
|
347 |
'{COOKIE_ANTICRAWLER_PASSED}' => '1',
|
348 |
'{GENERATED}' => '<p>The page was generated at ' . date( 'D, d M Y H:i:s' ) . "</p>",
|
245 |
}
|
246 |
|
247 |
add_action( 'wp_head', array( '\Cleantalk\ApbctWP\Firewall\AntiCrawler', 'set_cookie' ) );
|
248 |
+
add_action( 'login_head', array( '\Cleantalk\ApbctWP\Firewall\AntiCrawler', 'set_cookie' ) );
|
249 |
|
250 |
}
|
251 |
|
343 |
'{CLEANTALK_TITLE}' => __( 'Antispam by CleanTalk', 'cleantalk-spam-protect' ),
|
344 |
'{REMOTE_ADDRESS}' => $result['ip'],
|
345 |
'{SERVICE_ID}' => $this->apbct->data['service_id'] . ', ' . $net_count,
|
346 |
+
'{HOST}' => get_home_url() . ', ' . APBCT_VERSION,
|
347 |
'{COOKIE_ANTICRAWLER}' => hash( 'sha256', $apbct->api_key . $apbct->data['salt'] ),
|
348 |
'{COOKIE_ANTICRAWLER_PASSED}' => '1',
|
349 |
'{GENERATED}' => '<p>The page was generated at ' . date( 'D, d M Y H:i:s' ) . "</p>",
|
@@ -186,7 +186,7 @@ class AntiFlood extends \Cleantalk\Common\Firewall\FirewallModule{
|
|
186 |
'{REMOTE_ADDRESS}' => $result['ip'],
|
187 |
'{REQUEST_URI}' => Server::get( 'REQUEST_URI' ),
|
188 |
'{SERVICE_ID}' => $this->apbct->data['service_id'] . ', ' . $net_count,
|
189 |
-
'{HOST}' =>
|
190 |
'{GENERATED}' => '<p>The page was generated at ' . date( 'D, d M Y H:i:s' ) . "</p>",
|
191 |
'{COOKIE_ANTIFLOOD_PASSED}' => md5( $this->api_key . $result['ip'] ),
|
192 |
);
|
186 |
'{REMOTE_ADDRESS}' => $result['ip'],
|
187 |
'{REQUEST_URI}' => Server::get( 'REQUEST_URI' ),
|
188 |
'{SERVICE_ID}' => $this->apbct->data['service_id'] . ', ' . $net_count,
|
189 |
+
'{HOST}' => get_home_url() . ', ' . APBCT_VERSION,
|
190 |
'{GENERATED}' => '<p>The page was generated at ' . date( 'D, d M Y H:i:s' ) . "</p>",
|
191 |
'{COOKIE_ANTIFLOOD_PASSED}' => md5( $this->api_key . $result['ip'] ),
|
192 |
);
|
@@ -243,7 +243,7 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule {
|
|
243 |
'{CLEANTALK_TITLE}' => ($this->test ? __('This is the testing page for SpamFireWall', 'cleantalk-spam-protect') : ''),
|
244 |
'{REMOTE_ADDRESS}' => $result['ip'],
|
245 |
'{SERVICE_ID}' => $this->apbct->data['service_id'] . ', ' . $net_count,
|
246 |
-
'{HOST}' =>
|
247 |
'{GENERATED}' => '<p>The page was generated at ' . date( 'D, d M Y H:i:s' ) . "</p>",
|
248 |
'{REQUEST_URI}' => Server::get( 'REQUEST_URI' ),
|
249 |
|
@@ -428,7 +428,7 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule {
|
|
428 |
$patterns[] = 'async';
|
429 |
}
|
430 |
|
431 |
-
return Helper::
|
432 |
get_option( 'siteurl' ),
|
433 |
array(
|
434 |
'spbc_remote_call_token' => md5( $ct_key ),
|
243 |
'{CLEANTALK_TITLE}' => ($this->test ? __('This is the testing page for SpamFireWall', 'cleantalk-spam-protect') : ''),
|
244 |
'{REMOTE_ADDRESS}' => $result['ip'],
|
245 |
'{SERVICE_ID}' => $this->apbct->data['service_id'] . ', ' . $net_count,
|
246 |
+
'{HOST}' => get_home_url() . ', ' . APBCT_VERSION,
|
247 |
'{GENERATED}' => '<p>The page was generated at ' . date( 'D, d M Y H:i:s' ) . "</p>",
|
248 |
'{REQUEST_URI}' => Server::get( 'REQUEST_URI' ),
|
249 |
|
428 |
$patterns[] = 'async';
|
429 |
}
|
430 |
|
431 |
+
return Helper::http__request__rc_to_host(
|
432 |
get_option( 'siteurl' ),
|
433 |
array(
|
434 |
'spbc_remote_call_token' => md5( $ct_key ),
|
@@ -71,4 +71,47 @@ class Helper extends \Cleantalk\Common\Helper
|
|
71 |
static public function http__request__get_content( $url ){
|
72 |
return static::http__request( $url, array(), 'get dont_split_to_array');
|
73 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
}
|
71 |
static public function http__request__get_content( $url ){
|
72 |
return static::http__request( $url, array(), 'get dont_split_to_array');
|
73 |
}
|
74 |
+
|
75 |
+
static public function http__request__rc_to_host( $rc_action, $request_params, $patterns = array() ){
|
76 |
+
|
77 |
+
global $apbct;
|
78 |
+
|
79 |
+
$request_params__default = array(
|
80 |
+
'spbc_remote_call_token' => md5( $apbct->api_key ),
|
81 |
+
'spbc_remote_call_action' => $rc_action,
|
82 |
+
'plugin_name' => 'apbct',
|
83 |
+
);
|
84 |
+
|
85 |
+
$result__rc_check_website = static::http__request(
|
86 |
+
get_option( 'siteurl' ),
|
87 |
+
array_merge( $request_params__default, $request_params, array( 'test' => 'test' ) ),
|
88 |
+
array( 'get', )
|
89 |
+
);
|
90 |
+
|
91 |
+
if( empty( $result__rc_check_website['error'] ) ){
|
92 |
+
|
93 |
+
if( preg_match( '@^.*?OK$@', $result__rc_check_website) ){
|
94 |
+
|
95 |
+
static::http__request(
|
96 |
+
get_option( 'siteurl' ),
|
97 |
+
array_merge( $request_params__default, $request_params ),
|
98 |
+
array_merge( array( 'get', ), $patterns )
|
99 |
+
);
|
100 |
+
|
101 |
+
}else
|
102 |
+
return array(
|
103 |
+
'error' => 'WRONG_SITE_RESPONSE ACTION: ' . $rc_action . ' RESPONSE: ' . htmlspecialchars( substr(
|
104 |
+
! is_string( $result__rc_check_website )
|
105 |
+
? print_r( $result__rc_check_website, true )
|
106 |
+
: $result__rc_check_website,
|
107 |
+
0,
|
108 |
+
400
|
109 |
+
) )
|
110 |
+
);
|
111 |
+
}else
|
112 |
+
return array( 'error' => 'WRONG_SITE_RESPONSE TEST ACTION: ' . $rc_action . ' ERROR: ' . $result__rc_check_website['error'] );
|
113 |
+
|
114 |
+
return true;
|
115 |
+
}
|
116 |
+
|
117 |
}
|
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
namespace Cleantalk\ApbctWP;
|
5 |
+
|
6 |
+
use Cleantalk\Variables\Get;
|
7 |
+
use Cleantalk\ApbctWP\Cron;
|
8 |
+
|
9 |
+
class RemoteCalls
|
10 |
+
{
|
11 |
+
|
12 |
+
const COOLDOWN = 10;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Checking if the current request is the Remote Call
|
16 |
+
*
|
17 |
+
* @return bool
|
18 |
+
*/
|
19 |
+
public static function check() {
|
20 |
+
|
21 |
+
return
|
22 |
+
Get::get('spbc_remote_call_token') &&
|
23 |
+
Get::get('spbc_remote_call_action') &&
|
24 |
+
Get::get('plugin_name') &&
|
25 |
+
in_array(Get::get('plugin_name'), array('antispam','anti-spam', 'apbct') );
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Execute corresponding method of RemoteCalls if exists
|
30 |
+
*
|
31 |
+
* @return void|string
|
32 |
+
*/
|
33 |
+
public static function perform(){
|
34 |
+
|
35 |
+
global $apbct;
|
36 |
+
|
37 |
+
$action = strtolower( Get::get( 'spbc_remote_call_action' ) );
|
38 |
+
$token = strtolower( Get::get( 'spbc_remote_call_token' ) );
|
39 |
+
|
40 |
+
if(isset($apbct->remote_calls[$action])){
|
41 |
+
|
42 |
+
$cooldown = isset($apbct->remote_calls[$action]['cooldown']) ? $apbct->remote_calls[$action]['cooldown'] : self::COOLDOWN;
|
43 |
+
|
44 |
+
// Return OK for test remote calls
|
45 |
+
if ( Get::get( 'test' ) )
|
46 |
+
die('OK');
|
47 |
+
|
48 |
+
if( time() - $apbct->remote_calls[ $action ]['last_call'] >= $cooldown ){
|
49 |
+
|
50 |
+
$apbct->remote_calls[$action]['last_call'] = time();
|
51 |
+
$apbct->save('remote_calls');
|
52 |
+
|
53 |
+
// Check API key
|
54 |
+
if($token == strtolower(md5($apbct->api_key)) ){
|
55 |
+
|
56 |
+
// Flag to let plugin know that Remote Call is running.
|
57 |
+
$apbct->rc_running = true;
|
58 |
+
|
59 |
+
$action = 'action__'.$action;
|
60 |
+
|
61 |
+
if(method_exists('Cleantalk\ApbctWP\RemoteCalls', $action)){
|
62 |
+
|
63 |
+
if(get_option('spbc_deactivation_in_process') === false){ // Continue if plugin is active
|
64 |
+
|
65 |
+
// Delay before perform action;
|
66 |
+
if ( Get::get( 'delay' ) )
|
67 |
+
sleep( Get::get( 'delay' ) );
|
68 |
+
|
69 |
+
$action_result = RemoteCalls::$action();
|
70 |
+
$response = empty( $action_result['error'] )
|
71 |
+
? 'OK'
|
72 |
+
: 'FAIL ' . json_encode( array( 'error' => $action_result['error'] ) );
|
73 |
+
|
74 |
+
if( ! Get::get( 'continue_execution' ) ){
|
75 |
+
die( $response );
|
76 |
+
}
|
77 |
+
|
78 |
+
return $response;
|
79 |
+
|
80 |
+
// Stop execution if plugin is deactivated
|
81 |
+
}else{
|
82 |
+
delete_option('cleantalk_deactivation_in_process');
|
83 |
+
$out = 'FAIL '.json_encode(array('error' => 'PLUGIN_DEACTIVATION_IN_PROCESS'));
|
84 |
+
}
|
85 |
+
}else
|
86 |
+
$out = 'FAIL '.json_encode(array('error' => 'UNKNOWN_ACTION_METHOD'));
|
87 |
+
}else
|
88 |
+
$out = 'FAIL '.json_encode(array('error' => 'WRONG_TOKEN'));
|
89 |
+
}else
|
90 |
+
$out = 'FAIL '.json_encode(array('error' => 'TOO_MANY_ATTEMPTS'));
|
91 |
+
}else
|
92 |
+
$out = 'FAIL '.json_encode(array('error' => 'UNKNOWN_ACTION'));
|
93 |
+
|
94 |
+
die($out);
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Close renew banner
|
99 |
+
*
|
100 |
+
* @return string
|
101 |
+
*/
|
102 |
+
public static function action__close_renew_banner(){
|
103 |
+
|
104 |
+
global $apbct;
|
105 |
+
|
106 |
+
$apbct->data['notice_trial'] = 0;
|
107 |
+
$apbct->data['notice_renew'] = 0;
|
108 |
+
$apbct->saveData();
|
109 |
+
Cron::updateTask( 'check_account_status', 'ct_account_status_check', 86400 );
|
110 |
+
|
111 |
+
return 'OK';
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* SFW update
|
116 |
+
*
|
117 |
+
* @return string
|
118 |
+
*/
|
119 |
+
public static function action__sfw_update(){
|
120 |
+
|
121 |
+
global $apbct;
|
122 |
+
|
123 |
+
$result = ct_sfw_update( $apbct->api_key, true );
|
124 |
+
$apbct->error_toggle( ! empty( $result['error'] ), 'sfw_update', $result);
|
125 |
+
|
126 |
+
return $result;
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* SFW send logs
|
131 |
+
*
|
132 |
+
* @return string
|
133 |
+
*/
|
134 |
+
public static function action__sfw_send_logs(){
|
135 |
+
|
136 |
+
return ct_sfw_send_logs();
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Update plugin
|
141 |
+
*/
|
142 |
+
public static function action__update_plugin(){
|
143 |
+
add_action( 'wp', 'apbct_rc__update', 1 );
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Install plugin
|
148 |
+
*/
|
149 |
+
public static function action__install_plugin(){
|
150 |
+
add_action( 'wp', 'apbct_rc__install_plugin', 1 );
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Activate plugin
|
155 |
+
*/
|
156 |
+
public static function action__activate_plugin(){
|
157 |
+
return apbct_rc__activate_plugin( $_GET['plugin'] );
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
* Insert API key
|
162 |
+
*/
|
163 |
+
public static function action__insert_auth_key(){
|
164 |
+
return apbct_rc__insert_auth_key( $_GET['auth_key'], $_GET['plugin'] );
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Update settins
|
169 |
+
*/
|
170 |
+
public static function action__update_settings(){
|
171 |
+
return apbct_rc__update_settings( $_GET );
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Deactivate plugin
|
176 |
+
*/
|
177 |
+
public static function action__deactivate_plugin(){
|
178 |
+
add_action( 'plugins_loaded', 'apbct_rc__deactivate_plugin', 1 );
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Uninstall plugin
|
183 |
+
*/
|
184 |
+
public static function action__uninstall_plugin(){
|
185 |
+
add_action( 'plugins_loaded', 'apbct_rc__uninstall_plugin', 1 );
|
186 |
+
}
|
187 |
+
|
188 |
+
}
|
@@ -228,39 +228,26 @@ class State
|
|
228 |
'service_id' => 0,
|
229 |
'auto_update' => 0,
|
230 |
);
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
'insert_auth_key' => array(
|
252 |
-
'last_call' => 0,
|
253 |
-
),
|
254 |
-
'deactivate_plugin' => array(
|
255 |
-
'last_call' => 0,
|
256 |
-
),
|
257 |
-
'uninstall_plugin' => array(
|
258 |
-
'last_call' => 0,
|
259 |
-
),
|
260 |
-
'update_settings' => array(
|
261 |
-
'last_call' => 0,
|
262 |
-
),
|
263 |
-
);
|
264 |
|
265 |
public $def_stats = array(
|
266 |
'sfw' => array(
|
@@ -517,8 +504,25 @@ class State
|
|
517 |
if($save_flag)
|
518 |
$this->saveErrors();
|
519 |
}
|
520 |
-
|
521 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
522 |
* Magic.
|
523 |
* Add new variables to storage[NEW_VARIABLE]
|
524 |
* And duplicates it in storage['data'][NEW_VARIABLE]
|
228 |
'service_id' => 0,
|
229 |
'auto_update' => 0,
|
230 |
);
|
231 |
+
|
232 |
+
public $def_remote_calls = array(
|
233 |
+
|
234 |
+
//Common
|
235 |
+
'close_renew_banner' => array( 'last_call' => 0, 'cooldown' => 0 ),
|
236 |
+
'check_website' => array( 'last_call' => 0, 'cooldown' => 0 ),
|
237 |
+
'update_settings' => array( 'last_call' => 0, 'cooldown' => 0 ),
|
238 |
+
|
239 |
+
// Firewall
|
240 |
+
'sfw_update' => array( 'last_call' => 0, 'cooldown' => 0 ),
|
241 |
+
'sfw_send_logs' => array( 'last_call' => 0, 'cooldown' => 0 ),
|
242 |
+
|
243 |
+
// Installation
|
244 |
+
'update_plugin' => array( 'last_call' => 0, 'cooldown' => 0 ),
|
245 |
+
'install_plugin' => array( 'last_call' => 0, 'cooldown' => 0 ),
|
246 |
+
'activate_plugin' => array( 'last_call' => 0, 'cooldown' => 0 ),
|
247 |
+
'insert_auth_key' => array( 'last_call' => 0, 'cooldown' => 0 ),
|
248 |
+
'deactivate_plugin' => array( 'last_call' => 0, 'cooldown' => 0 ),
|
249 |
+
'uninstall_plugin' => array( 'last_call' => 0, 'cooldown' => 0 ),
|
250 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
|
252 |
public $def_stats = array(
|
253 |
'sfw' => array(
|
504 |
if($save_flag)
|
505 |
$this->saveErrors();
|
506 |
}
|
507 |
+
|
508 |
+
/**
|
509 |
+
* Set or deletes an error depends of the first bool parameter
|
510 |
+
*
|
511 |
+
* @param $add_error
|
512 |
+
* @param $error
|
513 |
+
* @param $type
|
514 |
+
* @param null $major_type
|
515 |
+
* @param bool $set_time
|
516 |
+
* @param bool $save_flag
|
517 |
+
*/
|
518 |
+
public function error_toggle($add_error, $type, $error, $major_type = null, $set_time = true, $save_flag = true ){
|
519 |
+
if( $add_error )
|
520 |
+
$this->error_add( $type, $error, $major_type, $set_time );
|
521 |
+
else
|
522 |
+
$this->error_delete( $type, $save_flag, $major_type );
|
523 |
+
}
|
524 |
+
|
525 |
+
/**
|
526 |
* Magic.
|
527 |
* Add new variables to storage[NEW_VARIABLE]
|
528 |
* And duplicates it in storage['data'][NEW_VARIABLE]
|
@@ -232,7 +232,8 @@ class Helper
|
|
232 |
|
233 |
// Is private network
|
234 |
if(
|
235 |
-
$out
|
|
|
236 |
(
|
237 |
self::ip__is_private_network( $out, $ip_version ) ||
|
238 |
self::ip__mask_match(
|
@@ -240,7 +241,7 @@ class Helper
|
|
240 |
Server::get( 'SERVER_ADDR' ) . '/24',
|
241 |
$ip_version
|
242 |
)
|
243 |
-
)
|
244 |
){
|
245 |
//@todo Remove local IP from x-forwarded-for and x-real-ip
|
246 |
$out = $out ?: self::ip__get( 'x_forwarded_for', $v4_only, $headers );
|
232 |
|
233 |
// Is private network
|
234 |
if(
|
235 |
+
! $out ||
|
236 |
+
($out &&
|
237 |
(
|
238 |
self::ip__is_private_network( $out, $ip_version ) ||
|
239 |
self::ip__mask_match(
|
241 |
Server::get( 'SERVER_ADDR' ) . '/24',
|
242 |
$ip_version
|
243 |
)
|
244 |
+
))
|
245 |
){
|
246 |
//@todo Remove local IP from x-forwarded-for and x-real-ip
|
247 |
$out = $out ?: self::ip__get( 'x_forwarded_for', $v4_only, $headers );
|
@@ -4,7 +4,7 @@ Tags: spam, antispam, anti-spam, comments, firewall
|
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 5.6
|
6 |
Requires PHP: 5.4
|
7 |
-
Stable tag: 5.
|
8 |
License: GPLv2
|
9 |
|
10 |
Spam protection, anti-spam, firewall, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
|
@@ -580,6 +580,36 @@ If your website has forms that send data to external sources, you can enable opt
|
|
580 |
|
581 |
== Changelog ==
|
582 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
583 |
= 5.152.5 Feb 04 2020 =
|
584 |
* Fix: SFW. Auto-updating interval decreased to 5 mins.
|
585 |
* Fix: Divi. Skip saving epanel.
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 5.6
|
6 |
Requires PHP: 5.4
|
7 |
+
Stable tag: 5.153
|
8 |
License: GPLv2
|
9 |
|
10 |
Spam protection, anti-spam, firewall, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
|
580 |
|
581 |
== Changelog ==
|
582 |
|
583 |
+
= 5.153 Feb 17.02.2021 =
|
584 |
+
* New: Integrations. WPDiscuz integration implemented.
|
585 |
+
* New: Using custom modal message instead allert.
|
586 |
+
* New: JS cleantalk-modal added.
|
587 |
+
* New: Cleantalk\ApbctWP\RemoteCalls class.
|
588 |
+
* New: Remote calls using Cleantalk\ApbctWP\RemoteCalls class.
|
589 |
+
* New: Cleantalk\ApbctWP\Helper::http__request__rc_to_host(). Wrapper to using RC to the website itself. Makes testing RC before make main.
|
590 |
+
* New: Cleantalk\ApbctWP\State::error_toggle().
|
591 |
+
* New: SFW update. Make test RC before main.
|
592 |
+
* Udp: Integrations. Support several hooks for one integration.
|
593 |
+
* Fix: Users. Feedback sending via deleting user fixed.
|
594 |
+
* Fix: Users checker. Feedback sending via deleting user fixed.
|
595 |
+
* Fix: IP detection.
|
596 |
+
* Fix: Users scan. Confirmation message fixed.
|
597 |
+
* Fix: SFW. The anti-flood option moved to the advanced settings.
|
598 |
+
* Fix: SFW. Show the right url on block page for WPMS.
|
599 |
+
* Fix: SFW. The anti-crawler option description fixed.
|
600 |
+
* Fix: SFW. The anti-flood option description fixed.
|
601 |
+
* Fix: SFW. AC checking on login page fixed.
|
602 |
+
* Fix: CF7. Modified spam hook.
|
603 |
+
* Fix: SFW. send_logs returning error.
|
604 |
+
* Fix: Cleantalk class fixed.
|
605 |
+
* Fix: Clearing errors storage before sync.
|
606 |
+
* Fix: Clearing SFW errors on updating to 5.151.6.
|
607 |
+
* Fix: Updater. Support updating for versions without fix number implemented.
|
608 |
+
* Fix: "Email Before Download" plugin request will be skipped.
|
609 |
+
* Fix: SFW. Auto-updating option fixed for multisite activation.
|
610 |
+
* Fix: Exception for Xoo login form.
|
611 |
+
* Fix: Users deleting feedback fixed.
|
612 |
+
|
613 |
= 5.152.5 Feb 04 2020 =
|
614 |
* Fix: SFW. Auto-updating interval decreased to 5 mins.
|
615 |
* Fix: Divi. Skip saving epanel.
|