Version Description
Jun 02 2020 = * Fix: Profile link fixed. * Fix: WPMS plugin name fixed. * Fix: WPMS plugin settings link fixed. * Fix: Integration with Easy Forms for Mailchimp. * Fix: JS check on the registration form. * Fix: Double JS attaching on the login page. * Fix: Clear SpamFireWall table. Throw error if failed. * Upd: Cookies attr "samesite" added. * New: Users checking result icons added. * Upd: Whitelists support added for SFW. * Fix: Clear users meta everywhere by complete deactivation. * New: Comment notification updated - blacklist links added. * Fix: PHP Warning in cleantalk-pluggable.php. * Fix: White Label mode is not accessible if CLEANTALK_ACCESS_KEY is defined. * Fix: Deprecated condition. * Fix: Setting layout for the right to left direction languages.
Release Info
Developer | glomberg |
Plugin | Spam protection, AntiSpam, FireWall by CleanTalk |
Version | 5.139 |
Comparing to | |
See all releases |
Code changes from version 5.138.1 to 5.139
- cleantalk.php +62 -59
- inc/cleantalk-admin.php +10 -2
- inc/cleantalk-ajax.php +8 -6
- inc/cleantalk-find-spam.php +4 -0
- inc/cleantalk-pluggable.php +287 -287
- inc/cleantalk-public.php +48 -14
- inc/cleantalk-settings.php +25 -20
- inc/find-spam/ClassCleantalkFindSpamUsersChecker.php +65 -36
- inc/sfw_die_page.html +5 -5
- js/apbct-public--alt.min.js +2 -2
- js/apbct-public--alt.min.js.map +1 -1
- js/apbct-public.min.js +1 -1
- js/apbct-public.min.js.map +1 -1
- js/cleantalk-admin-settings-page.min.js +2 -1
- js/cleantalk-admin-settings-page.min.js.map +1 -1
- js/cleantalk-admin.min.js +2 -2
- js/cleantalk-admin.min.js.map +1 -1
- js/cleantalk-comments-checkspam.min.js +2 -1
- js/cleantalk-comments-checkspam.min.js.map +1 -1
- js/cleantalk-users-checkspam.min.js +2 -2
- js/cleantalk-users-checkspam.min.js.map +1 -1
- js/cleantalk-users-editscreen.min.js +2 -2
- js/cleantalk-users-editscreen.min.js.map +1 -1
- js/cleantalk_nocache.min.js +2 -2
- js/cleantalk_nocache.min.js.map +1 -1
- lib/Cleantalk/Antispam/API.php +4 -2
- lib/Cleantalk/Antispam/Helper.php +744 -703
- lib/Cleantalk/Antispam/SFW.php +25 -28
- lib/CleantalkState.php +565 -562
- readme.txt +19 -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
|
@@ -96,13 +96,7 @@ if( !defined( 'CLEANTALK_PLUGIN_DIR' ) ){
|
|
96 |
$apbct->data['user_counter']['since'] = isset($apbct->data['user_counter']['since']) ? $apbct->data['user_counter']['since'] : date('d M');
|
97 |
$apbct->data['connection_reports']['since'] = isset($apbct->data['connection_reports']['since']) ? $apbct->data['user_counter']['since'] : date('d M');
|
98 |
|
99 |
-
$apbct->settings_link = is_network_admin() ? 'settings.php?page=cleantalk' : 'options-general.php?page=cleantalk';
|
100 |
-
|
101 |
-
$apbct->cookie_domain = isset( $_SERVER['HTTP_HOST'] )
|
102 |
-
? '.' . $_SERVER['HTTP_HOST']
|
103 |
-
: isset( $_SERVER['SERVER_NAME'] )
|
104 |
-
? '.' . $_SERVER['SERVER_NAME']
|
105 |
-
: null;
|
106 |
|
107 |
if(!$apbct->white_label){
|
108 |
require_once( CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-widget.php');
|
@@ -583,7 +577,7 @@ function apbct_sfw__check()
|
|
583 |
$apbct->data['sfw_counter']['all']++;
|
584 |
$apbct->saveData();
|
585 |
if(!headers_sent())
|
586 |
-
|
587 |
}
|
588 |
break;
|
589 |
}else{
|
@@ -597,8 +591,8 @@ function apbct_sfw__check()
|
|
597 |
$spbc_key = !empty($spbc_settings['spbc_key']) ? $spbc_settings['spbc_key'] : false;
|
598 |
if($_GET['access'] === $apbct->api_key || ($spbc_key !== false && $_GET['access'] === $spbc_key)){
|
599 |
$is_sfw_check = false;
|
600 |
-
|
601 |
-
|
602 |
}
|
603 |
unset($spbc_settings, $spbc_key);
|
604 |
}
|
@@ -633,7 +627,7 @@ function apbct_sfw__check()
|
|
633 |
}else{
|
634 |
reset($sfw->passed_ips);
|
635 |
if(!empty($apbct->settings['set_cookies']) && !headers_sent() && key($sfw->passed_ips))
|
636 |
-
|
637 |
}
|
638 |
}
|
639 |
unset($is_sfw_check, $sfw, $sfw_ip, $ct_cur_ip);
|
@@ -806,6 +800,7 @@ function apbct_deactivation( $network ) {
|
|
806 |
|
807 |
if($apbct->settings['complete_deactivation']){
|
808 |
apbct_deactivation__delete_all_options();
|
|
|
809 |
apbct_deactivation__delete_all_options__in_network();
|
810 |
}
|
811 |
|
@@ -818,8 +813,10 @@ function apbct_deactivation( $network ) {
|
|
818 |
apbct_deactivation__delete_common_tables();
|
819 |
delete_option('cleantalk_cron'); // Deleting cron entries
|
820 |
|
821 |
-
if($apbct->settings['complete_deactivation'])
|
822 |
-
|
|
|
|
|
823 |
|
824 |
// Deactivation on standalone blog
|
825 |
}elseif(!is_multisite()){
|
@@ -951,49 +948,46 @@ function ct_sfw_update($immediate = false){
|
|
951 |
$file_urls = isset($_GET['file_urls']) ? urldecode( $_GET['file_urls'] ) : null;
|
952 |
$file_urls = isset($file_urls) ? explode(',', $file_urls) : null;
|
953 |
|
954 |
-
if
|
955 |
|
956 |
//Reset previous entries count
|
957 |
$apbct->stats['sfw']['entries'] = 0;
|
958 |
$apbct->save('stats');
|
959 |
|
960 |
-
$
|
961 |
|
962 |
-
}
|
963 |
-
if (is_array($file_urls) && count($file_urls)) {
|
964 |
-
|
965 |
-
$result = $sfw->sfw_update($apbct->api_key, $file_urls[0], $immediate);
|
966 |
-
|
967 |
-
if(empty($result['error'])){
|
968 |
-
|
969 |
-
array_shift($file_urls);
|
970 |
|
971 |
-
|
972 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
973 |
$apbct->save('stats');
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
'spbc_remote_call_token' => md5($apbct->api_key),
|
980 |
-
'spbc_remote_call_action' => 'sfw_update',
|
981 |
-
'plugin_name' => 'apbct',
|
982 |
-
'file_urls' => implode(',', $file_urls),
|
983 |
-
),
|
984 |
-
array('get', 'async')
|
985 |
-
);
|
986 |
-
} else {
|
987 |
-
//Files array is empty update sfw time
|
988 |
-
$apbct->stats['sfw']['last_update_time'] = time();
|
989 |
-
$apbct->save('stats');
|
990 |
-
}
|
991 |
-
} else
|
992 |
-
return $result;
|
993 |
-
}
|
994 |
-
}
|
995 |
-
|
996 |
-
return $result;
|
997 |
}
|
998 |
|
999 |
return array('error' => 'SFW_DISABLED');
|
@@ -1544,7 +1538,7 @@ function apbct_store__urls(){
|
|
1544 |
// Saving
|
1545 |
$apbct->settings['store_urls__sessions']
|
1546 |
? apbct_alt_session__save('apbct_urls', json_encode($urls))
|
1547 |
-
: apbct_cookie__set('apbct_urls', json_encode($urls), time()+86400*3, '/', parse_url(get_option('siteurl'),PHP_URL_HOST), false, true, 'Lax');
|
1548 |
|
1549 |
// REFERER
|
1550 |
// Get current fererer
|
@@ -1561,7 +1555,7 @@ function apbct_store__urls(){
|
|
1561 |
|
1562 |
$apbct->settings['store_urls__sessions']
|
1563 |
? apbct_alt_session__save('apbct_site_referer', $new_site_referer)
|
1564 |
-
: apbct_cookie__set('apbct_site_referer', $new_site_referer, time()+86400*3, '/', parse_url(get_option('siteurl'),PHP_URL_HOST), false, true, 'Lax');
|
1565 |
}
|
1566 |
|
1567 |
$apbct->flags__url_stored = true;
|
@@ -1569,7 +1563,12 @@ function apbct_store__urls(){
|
|
1569 |
}
|
1570 |
}
|
1571 |
|
1572 |
-
|
|
|
|
|
|
|
|
|
|
|
1573 |
|
1574 |
// For PHP 7.3+ and above
|
1575 |
if( version_compare( phpversion(), '7.3.0', '>=' ) ){
|
@@ -1588,8 +1587,12 @@ function apbct_cookie__set($name, $value = '', $expires = 0, $path = '', $domain
|
|
1588 |
setcookie( $name, $value, $params );
|
1589 |
|
1590 |
// For PHP 5.6 - 7.2
|
1591 |
-
}else
|
1592 |
-
|
|
|
|
|
|
|
|
|
1593 |
}
|
1594 |
|
1595 |
/*
|
@@ -1634,7 +1637,7 @@ function apbct_cookie(){
|
|
1634 |
$apbct_timestamp = time();
|
1635 |
$apbct->settings['set_cookies__sessions']
|
1636 |
? apbct_alt_session__save('apbct_timestamp', $apbct_timestamp)
|
1637 |
-
: apbct_cookie__set('apbct_timestamp', $apbct_timestamp, 0, '/', $domain, false, true, 'Lax' );
|
1638 |
$cookie_test_value['cookies_names'][] = 'apbct_timestamp';
|
1639 |
$cookie_test_value['check_value'] .= $apbct_timestamp;
|
1640 |
}
|
@@ -1643,7 +1646,7 @@ function apbct_cookie(){
|
|
1643 |
if(apbct_get_server_variable( 'HTTP_REFERER' )){
|
1644 |
$apbct->settings['set_cookies__sessions']
|
1645 |
? apbct_alt_session__save('apbct_prev_referer', apbct_get_server_variable( 'HTTP_REFERER' ))
|
1646 |
-
: apbct_cookie__set('apbct_prev_referer', apbct_get_server_variable( 'HTTP_REFERER' ), 0, '/', $domain, false, true, 'Lax' );
|
1647 |
$cookie_test_value['cookies_names'][] = 'apbct_prev_referer';
|
1648 |
$cookie_test_value['check_value'] .= apbct_get_server_variable( 'HTTP_REFERER' );
|
1649 |
}
|
@@ -1656,7 +1659,7 @@ function apbct_cookie(){
|
|
1656 |
$site_landing_timestamp = time();
|
1657 |
$apbct->settings['set_cookies__sessions']
|
1658 |
? apbct_alt_session__save('apbct_site_landing_ts', $site_landing_timestamp)
|
1659 |
-
: apbct_cookie__set('apbct_site_landing_ts', $site_landing_timestamp, 0, '/', $domain, false, true, 'Lax' );
|
1660 |
}
|
1661 |
$cookie_test_value['cookies_names'][] = 'apbct_site_landing_ts';
|
1662 |
$cookie_test_value['check_value'] .= $site_landing_timestamp;
|
@@ -1671,7 +1674,7 @@ function apbct_cookie(){
|
|
1671 |
|
1672 |
$apbct->settings['set_cookies__sessions']
|
1673 |
? apbct_alt_session__save('apbct_page_hits', $page_hits)
|
1674 |
-
: apbct_cookie__set('apbct_page_hits', $page_hits, 0, '/', $domain, false, true, 'Lax' );
|
1675 |
|
1676 |
$cookie_test_value['cookies_names'][] = 'apbct_page_hits';
|
1677 |
$cookie_test_value['check_value'] .= $page_hits;
|
@@ -1679,7 +1682,7 @@ function apbct_cookie(){
|
|
1679 |
// Cookies test
|
1680 |
$cookie_test_value['check_value'] = md5($cookie_test_value['check_value']);
|
1681 |
if(!$apbct->settings['set_cookies__sessions'])
|
1682 |
-
|
1683 |
|
1684 |
$apbct->flags__cookies_setuped = true;
|
1685 |
|
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.139
|
7 |
Author: СleanTalk <welcome@cleantalk.org>
|
8 |
Author URI: https://cleantalk.org
|
9 |
Text Domain: cleantalk
|
96 |
$apbct->data['user_counter']['since'] = isset($apbct->data['user_counter']['since']) ? $apbct->data['user_counter']['since'] : date('d M');
|
97 |
$apbct->data['connection_reports']['since'] = isset($apbct->data['connection_reports']['since']) ? $apbct->data['user_counter']['since'] : date('d M');
|
98 |
|
99 |
+
$apbct->settings_link = is_network_admin() ? 'settings.php?page=cleantalk' : 'options-general.php?page=cleantalk';
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
|
101 |
if(!$apbct->white_label){
|
102 |
require_once( CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-widget.php');
|
577 |
$apbct->data['sfw_counter']['all']++;
|
578 |
$apbct->saveData();
|
579 |
if(!headers_sent())
|
580 |
+
\Cleantalk\Antispam\Helper::apbct_cookie__set ('ct_sfw_passed', '0', time()+86400*3, '/', '', false, true, 'Lax' );
|
581 |
}
|
582 |
break;
|
583 |
}else{
|
591 |
$spbc_key = !empty($spbc_settings['spbc_key']) ? $spbc_settings['spbc_key'] : false;
|
592 |
if($_GET['access'] === $apbct->api_key || ($spbc_key !== false && $_GET['access'] === $spbc_key)){
|
593 |
$is_sfw_check = false;
|
594 |
+
\Cleantalk\Antispam\Helper::apbct_cookie__set('spbc_firewall_pass_key', md5(apbct_get_server_variable( 'REMOTE_ADDR' ) . $spbc_key), time()+1200, '/', '');
|
595 |
+
\Cleantalk\Antispam\Helper::apbct_cookie__set('ct_sfw_pass_key', md5(apbct_get_server_variable( 'REMOTE_ADDR' ) . $apbct->api_key), time()+1200, '/', '');
|
596 |
}
|
597 |
unset($spbc_settings, $spbc_key);
|
598 |
}
|
627 |
}else{
|
628 |
reset($sfw->passed_ips);
|
629 |
if(!empty($apbct->settings['set_cookies']) && !headers_sent() && key($sfw->passed_ips))
|
630 |
+
\Cleantalk\Antispam\Helper::apbct_cookie__set( 'ct_sfw_pass_key', md5( $sfw->passed_ips[ key( $sfw->passed_ips ) ]['ip'] . $apbct->api_key ), time() + 86400 * 30, '/', '', false );
|
631 |
}
|
632 |
}
|
633 |
unset($is_sfw_check, $sfw, $sfw_ip, $ct_cur_ip);
|
800 |
|
801 |
if($apbct->settings['complete_deactivation']){
|
802 |
apbct_deactivation__delete_all_options();
|
803 |
+
apbct_deactivation__delete_meta();
|
804 |
apbct_deactivation__delete_all_options__in_network();
|
805 |
}
|
806 |
|
813 |
apbct_deactivation__delete_common_tables();
|
814 |
delete_option('cleantalk_cron'); // Deleting cron entries
|
815 |
|
816 |
+
if($apbct->settings['complete_deactivation']) {
|
817 |
+
apbct_deactivation__delete_all_options();
|
818 |
+
apbct_deactivation__delete_meta();
|
819 |
+
}
|
820 |
|
821 |
// Deactivation on standalone blog
|
822 |
}elseif(!is_multisite()){
|
948 |
$file_urls = isset($_GET['file_urls']) ? urldecode( $_GET['file_urls'] ) : null;
|
949 |
$file_urls = isset($file_urls) ? explode(',', $file_urls) : null;
|
950 |
|
951 |
+
if( ! $file_urls ){
|
952 |
|
953 |
//Reset previous entries count
|
954 |
$apbct->stats['sfw']['entries'] = 0;
|
955 |
$apbct->save('stats');
|
956 |
|
957 |
+
$sfw->sfw_update($apbct->api_key, null, $immediate);
|
958 |
|
959 |
+
}elseif( is_array( $file_urls ) && count( $file_urls ) ){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
960 |
|
961 |
+
$result = $sfw->sfw_update($apbct->api_key, $file_urls[0], $immediate);
|
962 |
+
|
963 |
+
if( empty( $result['error'] ) ){
|
964 |
+
|
965 |
+
array_shift($file_urls);
|
966 |
+
|
967 |
+
//Increment sfw entries
|
968 |
+
$apbct->stats['sfw']['entries'] += $result;
|
969 |
+
$apbct->save('stats');
|
970 |
+
|
971 |
+
if (count($file_urls)) {
|
972 |
+
CleantalkHelper::http__request(
|
973 |
+
get_option('siteurl'),
|
974 |
+
array(
|
975 |
+
'spbc_remote_call_token' => md5($apbct->api_key),
|
976 |
+
'spbc_remote_call_action' => 'sfw_update',
|
977 |
+
'plugin_name' => 'apbct',
|
978 |
+
'file_urls' => implode(',', $file_urls),
|
979 |
+
),
|
980 |
+
array('get', 'async')
|
981 |
+
);
|
982 |
+
} else {
|
983 |
+
//Files array is empty update sfw time
|
984 |
+
$apbct->stats['sfw']['last_update_time'] = time();
|
985 |
$apbct->save('stats');
|
986 |
+
}
|
987 |
+
}else
|
988 |
+
return $result;
|
989 |
+
}else
|
990 |
+
return array('error' => 'SFW_UPDATE WRONG_FILE_URLS');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
991 |
}
|
992 |
|
993 |
return array('error' => 'SFW_DISABLED');
|
1538 |
// Saving
|
1539 |
$apbct->settings['store_urls__sessions']
|
1540 |
? apbct_alt_session__save('apbct_urls', json_encode($urls))
|
1541 |
+
: \Cleantalk\Antispam\Helper::apbct_cookie__set('apbct_urls', json_encode($urls), time()+86400*3, '/', parse_url(get_option('siteurl'),PHP_URL_HOST), false, true, 'Lax');
|
1542 |
|
1543 |
// REFERER
|
1544 |
// Get current fererer
|
1555 |
|
1556 |
$apbct->settings['store_urls__sessions']
|
1557 |
? apbct_alt_session__save('apbct_site_referer', $new_site_referer)
|
1558 |
+
: \Cleantalk\Antispam\Helper::apbct_cookie__set('apbct_site_referer', $new_site_referer, time()+86400*3, '/', parse_url(get_option('siteurl'),PHP_URL_HOST), false, true, 'Lax');
|
1559 |
}
|
1560 |
|
1561 |
$apbct->flags__url_stored = true;
|
1563 |
}
|
1564 |
}
|
1565 |
|
1566 |
+
/**
|
1567 |
+
* Universal method to adding cookies.
|
1568 |
+
* Use \Cleantalk\Antispam\Helper::apbct_cookie__set() instead.
|
1569 |
+
* @deprecated
|
1570 |
+
*/
|
1571 |
+
function apbct_cookie__set($name, $value = '', $expires = 0, $path = '', $domain = null, $secure = false, $httponly = false, $samesite = 'Lax' ){
|
1572 |
|
1573 |
// For PHP 7.3+ and above
|
1574 |
if( version_compare( phpversion(), '7.3.0', '>=' ) ){
|
1587 |
setcookie( $name, $value, $params );
|
1588 |
|
1589 |
// For PHP 5.6 - 7.2
|
1590 |
+
}else {
|
1591 |
+
if($samesite)
|
1592 |
+
$path = $path . '; samesite=' . $samesite;
|
1593 |
+
setcookie( $name, $value, $expires, $path, $domain, $secure, $httponly );
|
1594 |
+
}
|
1595 |
+
|
1596 |
}
|
1597 |
|
1598 |
/*
|
1637 |
$apbct_timestamp = time();
|
1638 |
$apbct->settings['set_cookies__sessions']
|
1639 |
? apbct_alt_session__save('apbct_timestamp', $apbct_timestamp)
|
1640 |
+
: \Cleantalk\Antispam\Helper::apbct_cookie__set('apbct_timestamp', $apbct_timestamp, 0, '/', $domain, false, true, 'Lax' );
|
1641 |
$cookie_test_value['cookies_names'][] = 'apbct_timestamp';
|
1642 |
$cookie_test_value['check_value'] .= $apbct_timestamp;
|
1643 |
}
|
1646 |
if(apbct_get_server_variable( 'HTTP_REFERER' )){
|
1647 |
$apbct->settings['set_cookies__sessions']
|
1648 |
? apbct_alt_session__save('apbct_prev_referer', apbct_get_server_variable( 'HTTP_REFERER' ))
|
1649 |
+
: \Cleantalk\Antispam\Helper::apbct_cookie__set('apbct_prev_referer', apbct_get_server_variable( 'HTTP_REFERER' ), 0, '/', $domain, false, true, 'Lax' );
|
1650 |
$cookie_test_value['cookies_names'][] = 'apbct_prev_referer';
|
1651 |
$cookie_test_value['check_value'] .= apbct_get_server_variable( 'HTTP_REFERER' );
|
1652 |
}
|
1659 |
$site_landing_timestamp = time();
|
1660 |
$apbct->settings['set_cookies__sessions']
|
1661 |
? apbct_alt_session__save('apbct_site_landing_ts', $site_landing_timestamp)
|
1662 |
+
: \Cleantalk\Antispam\Helper::apbct_cookie__set('apbct_site_landing_ts', $site_landing_timestamp, 0, '/', $domain, false, true, 'Lax' );
|
1663 |
}
|
1664 |
$cookie_test_value['cookies_names'][] = 'apbct_site_landing_ts';
|
1665 |
$cookie_test_value['check_value'] .= $site_landing_timestamp;
|
1674 |
|
1675 |
$apbct->settings['set_cookies__sessions']
|
1676 |
? apbct_alt_session__save('apbct_page_hits', $page_hits)
|
1677 |
+
: \Cleantalk\Antispam\Helper::apbct_cookie__set('apbct_page_hits', $page_hits, 0, '/', $domain, false, true, 'Lax' );
|
1678 |
|
1679 |
$cookie_test_value['cookies_names'][] = 'apbct_page_hits';
|
1680 |
$cookie_test_value['check_value'] .= $page_hits;
|
1682 |
// Cookies test
|
1683 |
$cookie_test_value['check_value'] = md5($cookie_test_value['check_value']);
|
1684 |
if(!$apbct->settings['set_cookies__sessions'])
|
1685 |
+
\Cleantalk\Antispam\Helper::apbct_cookie__set('apbct_cookies_test', urlencode(json_encode($cookie_test_value)), 0, '/', $domain, false, true, 'Lax' );
|
1686 |
|
1687 |
$apbct->flags__cookies_setuped = true;
|
1688 |
|
@@ -329,6 +329,7 @@ function apbct_admin__enqueue_scripts($hook){
|
|
329 |
|
330 |
// USERS page JavaScript
|
331 |
if($hook == 'users.php'){
|
|
|
332 |
wp_enqueue_script('ct_users_editscreen', plugins_url('/cleantalk-spam-protect/js/cleantalk-users-editscreen.min.js'), array(), APBCT_VERSION);
|
333 |
wp_localize_script( 'jquery', 'ctUsersScreen', array(
|
334 |
'spambutton_text' => __("Find spam-users", 'cleantalk'),
|
@@ -358,7 +359,14 @@ function apbct_admin__notice_message(){
|
|
358 |
|
359 |
//Misc
|
360 |
$user_token = ($apbct->user_token ? '&user_token='.$apbct->user_token : '');
|
361 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
362 |
|
363 |
if($self_owned_key && $is_dashboard && $is_admin){
|
364 |
// Auto update notice
|
@@ -388,7 +396,7 @@ function apbct_admin__notice_message(){
|
|
388 |
if (!apbct_api_key__is_correct() && $apbct->moderate_ip == 0){
|
389 |
echo "<div class='error'>"
|
390 |
."<h3>"
|
391 |
-
.sprintf(__("Please enter Access Key in %s settings to enable anti spam protection!", 'cleantalk'), "<a href='{$settings_link}'
|
392 |
."</h3>"
|
393 |
."</div>";
|
394 |
$apbct->notice_show = false;
|
329 |
|
330 |
// USERS page JavaScript
|
331 |
if($hook == 'users.php'){
|
332 |
+
wp_enqueue_style ('ct_icons', plugins_url('/cleantalk-spam-protect/css/cleantalk-icons.min.css'), array(), APBCT_VERSION, 'all');
|
333 |
wp_enqueue_script('ct_users_editscreen', plugins_url('/cleantalk-spam-protect/js/cleantalk-users-editscreen.min.js'), array(), APBCT_VERSION);
|
334 |
wp_localize_script( 'jquery', 'ctUsersScreen', array(
|
335 |
'spambutton_text' => __("Find spam-users", 'cleantalk'),
|
359 |
|
360 |
//Misc
|
361 |
$user_token = ($apbct->user_token ? '&user_token='.$apbct->user_token : '');
|
362 |
+
|
363 |
+
if( is_network_admin() ) {
|
364 |
+
$site_url = get_site_option('siteurl');
|
365 |
+
$site_url = preg_match( '/\/$/', $site_url ) ? $site_url : $site_url . '/';
|
366 |
+
$settings_link = $site_url . 'wp-admin/options-general.php?page=cleantalk';
|
367 |
+
} else {
|
368 |
+
$settings_link = 'options-general.php?page=cleantalk';
|
369 |
+
}
|
370 |
|
371 |
if($self_owned_key && $is_dashboard && $is_admin){
|
372 |
// Auto update notice
|
396 |
if (!apbct_api_key__is_correct() && $apbct->moderate_ip == 0){
|
397 |
echo "<div class='error'>"
|
398 |
."<h3>"
|
399 |
+
.sprintf(__("Please enter Access Key in %s settings to enable anti spam protection!", 'cleantalk'), "<a href='{$settings_link}'>$apbct->plugin_name</a>")
|
400 |
."</h3>"
|
401 |
."</div>";
|
402 |
$apbct->notice_show = false;
|
@@ -300,7 +300,8 @@ function ct_ajax_hook($message_obj = false, $additional = false)
|
|
300 |
'dflg_do_sign_in_user', // Unknown plugin
|
301 |
'cartflows_save_cart_abandonment_data', // WooCommerce cartflow
|
302 |
'rcp_process_register_form', // WordPress Membership Plugin – Restrict Content
|
303 |
-
'give_process_donation' // GiveWP
|
|
|
304 |
);
|
305 |
|
306 |
// Skip test if
|
@@ -379,18 +380,19 @@ function ct_ajax_hook($message_obj = false, $additional = false)
|
|
379 |
$post_info['comment_type'] = 'order';
|
380 |
}
|
381 |
//Easy Forms for Mailchimp
|
382 |
-
if(
|
383 |
$post_info['comment_type'] = 'contact_enquire_wordpress_easy_forms_for_mailchimp';
|
384 |
-
if(
|
385 |
-
$form_data = explode( '&',
|
386 |
$form_data_arr = array();
|
387 |
foreach ( $form_data as $val ) {
|
388 |
$form_data_element = explode( '=', $val );
|
389 |
$form_data_arr[$form_data_element[0]] = @$form_data_element[1];
|
390 |
}
|
391 |
-
if( isset( $form_data_arr['EMAIL'] ) )
|
392 |
$ct_post_temp['email'] = $form_data_arr['EMAIL'];
|
393 |
-
|
|
|
394 |
}
|
395 |
}
|
396 |
|
300 |
'dflg_do_sign_in_user', // Unknown plugin
|
301 |
'cartflows_save_cart_abandonment_data', // WooCommerce cartflow
|
302 |
'rcp_process_register_form', // WordPress Membership Plugin – Restrict Content
|
303 |
+
'give_process_donation', // GiveWP
|
304 |
+
'apus_ajax_login', // ???? plugin authorization
|
305 |
);
|
306 |
|
307 |
// Skip test if
|
380 |
$post_info['comment_type'] = 'order';
|
381 |
}
|
382 |
//Easy Forms for Mailchimp
|
383 |
+
if( \Cleantalk\Common\Post::get('action') == 'process_form_submission' ){
|
384 |
$post_info['comment_type'] = 'contact_enquire_wordpress_easy_forms_for_mailchimp';
|
385 |
+
if( \Cleantalk\Common\Post::get('form_data') ) {
|
386 |
+
$form_data = explode( '&', urldecode( \Cleantalk\Common\Post::get('form_data') ) );
|
387 |
$form_data_arr = array();
|
388 |
foreach ( $form_data as $val ) {
|
389 |
$form_data_element = explode( '=', $val );
|
390 |
$form_data_arr[$form_data_element[0]] = @$form_data_element[1];
|
391 |
}
|
392 |
+
if( isset( $form_data_arr['EMAIL'] ) )
|
393 |
$ct_post_temp['email'] = $form_data_arr['EMAIL'];
|
394 |
+
if( isset( $form_data_arr['FNAME'] ) )
|
395 |
+
$ct_post_temp['nickname'] = $form_data_arr['FNAME'];
|
396 |
}
|
397 |
}
|
398 |
|
@@ -60,3 +60,7 @@ function ct_save_screen_option() {
|
|
60 |
}, 10, 3 );
|
61 |
|
62 |
}
|
|
|
|
|
|
|
|
60 |
}, 10, 3 );
|
61 |
|
62 |
}
|
63 |
+
|
64 |
+
// Add checked icons into users table
|
65 |
+
add_filter( 'manage_users_columns', array( 'ClassCleantalkFindSpamUsersChecker', 'ct_manage_users_columns' ), 10, 1 );
|
66 |
+
add_filter( 'manage_users_custom_column', array( 'ClassCleantalkFindSpamUsersChecker', 'ct_manage_users_custom_column' ), 10, 3 );
|
@@ -1,288 +1,288 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Getting current user by cookie
|
5 |
-
*
|
6 |
-
* @return WP_User|null
|
7 |
-
*/
|
8 |
-
function apbct_wp_get_current_user(){
|
9 |
-
|
10 |
-
global $apbct, $current_user;
|
11 |
-
|
12 |
-
$user = null;
|
13 |
-
|
14 |
-
if(!(defined('XMLRPC_REQUEST') && XMLRPC_REQUEST)){
|
15 |
-
|
16 |
-
if(!empty($apbct->user)){
|
17 |
-
$user_id = is_object($current_user) && isset($current_user->ID) && !($current_user instanceof WP_User)
|
18 |
-
? $current_user->ID
|
19 |
-
: null;
|
20 |
-
}else{
|
21 |
-
$user_id = empty($user_id) && defined('LOGGED_IN_COOKIE') && !empty($_COOKIE[LOGGED_IN_COOKIE])
|
22 |
-
? apbct_wp_validate_auth_cookie($_COOKIE[LOGGED_IN_COOKIE], 'logged_in')
|
23 |
-
: null;
|
24 |
-
}
|
25 |
-
|
26 |
-
if($user_id){
|
27 |
-
$user = new WP_User($user_id);
|
28 |
-
}
|
29 |
-
|
30 |
-
}
|
31 |
-
|
32 |
-
return $user ? $user : $current_user;
|
33 |
-
}
|
34 |
-
|
35 |
-
function apbct_wp_set_current_user($user = null){
|
36 |
-
|
37 |
-
global $apbct;
|
38 |
-
|
39 |
-
if( $user instanceof WP_User ){
|
40 |
-
$apbct->user = $user;
|
41 |
-
return true;
|
42 |
-
}
|
43 |
-
|
44 |
-
return false;
|
45 |
-
}
|
46 |
-
|
47 |
-
/**
|
48 |
-
* Validates authentication cookie.
|
49 |
-
*
|
50 |
-
* The checks include making sure that the authentication cookie is set and
|
51 |
-
* pulling in the contents (if $cookie is not used).
|
52 |
-
*
|
53 |
-
* Makes sure the cookie is not expired. Verifies the hash in cookie is what is
|
54 |
-
* should be and compares the two.
|
55 |
-
*
|
56 |
-
* @param string $cookie Optional. If used, will validate contents instead of cookie's
|
57 |
-
* @param string $scheme Optional. The cookie scheme to use: auth, secure_auth, or logged_in
|
58 |
-
*
|
59 |
-
* @return false|int False if invalid cookie, User ID if valid.
|
60 |
-
* @global int $login_grace_period
|
61 |
-
*
|
62 |
-
*/
|
63 |
-
function apbct_wp_validate_auth_cookie( $cookie = '', $scheme = '' ) {
|
64 |
-
|
65 |
-
$cookie_elements = apbct_wp_parse_auth_cookie($cookie, $scheme);
|
66 |
-
|
67 |
-
$scheme = $cookie_elements['scheme'];
|
68 |
-
$username = $cookie_elements['username'];
|
69 |
-
$hmac = $cookie_elements['hmac'];
|
70 |
-
$token = $cookie_elements['token'];
|
71 |
-
$expiration = $cookie_elements['expiration'];
|
72 |
-
|
73 |
-
// Allow a grace period for POST and Ajax requests
|
74 |
-
$expired = apbct_is_ajax() || apbct_is_post()
|
75 |
-
? $expiration + HOUR_IN_SECONDS
|
76 |
-
: $cookie_elements['expiration'];
|
77 |
-
|
78 |
-
// Quick check to see if an honest cookie has expired
|
79 |
-
if($expired >= time()){
|
80 |
-
$user = apbct_wp_get_user_by('login', $username);
|
81 |
-
if($user){
|
82 |
-
$pass_frag = substr($user->user_pass, 8, 4);
|
83 |
-
$key = apbct_wp_hash($username . '|' . $pass_frag . '|' . $expiration . '|' . $token, $scheme);
|
84 |
-
// If ext/hash is not present, compat.php's hash_hmac() does not support sha256.
|
85 |
-
$algo = function_exists('hash') ? 'sha256' : 'sha1';
|
86 |
-
$hash = hash_hmac($algo, $username . '|' . $expiration . '|' . $token, $key);
|
87 |
-
if(hash_equals($hash, $hmac)){
|
88 |
-
$sessions = get_user_meta($user->ID, 'session_tokens', true);
|
89 |
-
$sessions = current($sessions);
|
90 |
-
if(is_array($sessions)){
|
91 |
-
if(is_int($sessions['expiration']) && $sessions['expiration'] > time()){
|
92 |
-
return $user->ID;
|
93 |
-
}else
|
94 |
-
return false;
|
95 |
-
}else
|
96 |
-
return false;
|
97 |
-
}else
|
98 |
-
return false;
|
99 |
-
}else
|
100 |
-
return false;
|
101 |
-
}else
|
102 |
-
return false;
|
103 |
-
}
|
104 |
-
|
105 |
-
/**
|
106 |
-
* Gets user by filed
|
107 |
-
*
|
108 |
-
* @param $field
|
109 |
-
* @param $value
|
110 |
-
*
|
111 |
-
* @return bool|WP_User
|
112 |
-
*/
|
113 |
-
function apbct_wp_get_user_by($field, $value){
|
114 |
-
|
115 |
-
$userdata = WP_User::get_data_by($field, $value);
|
116 |
-
|
117 |
-
if(!$userdata)
|
118 |
-
return false;
|
119 |
-
|
120 |
-
$user = new WP_User;
|
121 |
-
$user->init($userdata);
|
122 |
-
|
123 |
-
return $user;
|
124 |
-
}
|
125 |
-
|
126 |
-
/**
|
127 |
-
* Get hash of given string.
|
128 |
-
*
|
129 |
-
* @param string $data Plain text to hash
|
130 |
-
* @param string $scheme Authentication scheme (auth, secure_auth, logged_in, nonce)
|
131 |
-
* @return string Hash of $data
|
132 |
-
*/
|
133 |
-
function apbct_wp_hash( $data, $scheme = 'auth' ) {
|
134 |
-
|
135 |
-
$values = array(
|
136 |
-
'key' => '',
|
137 |
-
'salt' => '',
|
138 |
-
);
|
139 |
-
|
140 |
-
foreach(array('key', 'salt') as $type){
|
141 |
-
$const = strtoupper( "{$scheme}_{$type}");
|
142 |
-
if ( defined($const) && constant($const)){
|
143 |
-
$values[$type] = constant($const);
|
144 |
-
}elseif(!$values[$type]){
|
145 |
-
$values[$type] = get_site_option( "{$scheme}_{$type}");
|
146 |
-
if (!$values[$type]){
|
147 |
-
$values[$type] = '';
|
148 |
-
}
|
149 |
-
}
|
150 |
-
}
|
151 |
-
|
152 |
-
$salt = $values['key'] . $values['salt'];
|
153 |
-
|
154 |
-
return hash_hmac('md5', $data, $salt);
|
155 |
-
}
|
156 |
-
|
157 |
-
/**
|
158 |
-
* Parse a cookie into its components
|
159 |
-
*
|
160 |
-
* @param string $cookie
|
161 |
-
* @param string $scheme Optional. The cookie scheme to use: auth, secure_auth, or logged_in
|
162 |
-
*
|
163 |
-
* @return array|false Authentication cookie components
|
164 |
-
*
|
165 |
-
*/
|
166 |
-
function apbct_wp_parse_auth_cookie($cookie = '', $scheme = '')
|
167 |
-
{
|
168 |
-
$cookie_elements = explode('|', $cookie);
|
169 |
-
if(count($cookie_elements) !== 4){
|
170 |
-
return false;
|
171 |
-
}
|
172 |
-
|
173 |
-
list($username, $expiration, $token, $hmac) = $cookie_elements;
|
174 |
-
|
175 |
-
return compact('username', 'expiration', 'token', 'hmac', 'scheme');
|
176 |
-
}
|
177 |
-
|
178 |
-
/**
|
179 |
-
* Checks if the plugin is active
|
180 |
-
*
|
181 |
-
* @param string $plugin relative path from plugin folder like cleantalk-spam-protect/cleantalk.php
|
182 |
-
*
|
183 |
-
* @return bool
|
184 |
-
*/
|
185 |
-
function apbct_is_plugin_active( $plugin ) {
|
186 |
-
return in_array( $plugin, (array) get_option( 'active_plugins', array() ) ) || apbct_is_plugin_active_for_network( $plugin );
|
187 |
-
}
|
188 |
-
|
189 |
-
/**
|
190 |
-
* Checks if the plugin is active for network
|
191 |
-
*
|
192 |
-
* @param string $plugin relative path from plugin folder like cleantalk-spam-protect/cleantalk.php
|
193 |
-
*
|
194 |
-
* @return bool
|
195 |
-
*/
|
196 |
-
function apbct_is_plugin_active_for_network( $plugin ){
|
197 |
-
|
198 |
-
if ( ! APBCT_WPMS )
|
199 |
-
return false;
|
200 |
-
|
201 |
-
$plugins = get_site_option( 'active_sitewide_plugins' );
|
202 |
-
|
203 |
-
return isset( $plugins[ $plugin ] )
|
204 |
-
? true
|
205 |
-
: false;
|
206 |
-
}
|
207 |
-
|
208 |
-
/**
|
209 |
-
* Checks if the request is AJAX
|
210 |
-
*
|
211 |
-
* @return boolean
|
212 |
-
*/
|
213 |
-
function apbct_is_ajax() {
|
214 |
-
|
215 |
-
return
|
216 |
-
(defined( 'DOING_AJAX' ) && DOING_AJAX) || // by standart WP functions
|
217 |
-
(apbct_get_server_variable( 'HTTP_X_REQUESTED_WITH' ) && strtolower(apbct_get_server_variable( 'HTTP_X_REQUESTED_WITH' )) == 'xmlhttprequest') || // by Request type
|
218 |
-
!empty($_POST['quform_ajax']) || // special. QForms
|
219 |
-
!empty($_POST['iphorm_ajax']); // special. IPHorm
|
220 |
-
|
221 |
-
}
|
222 |
-
|
223 |
-
/**
|
224 |
-
* Checks if the user is logged in
|
225 |
-
*
|
226 |
-
* @return bool
|
227 |
-
*/
|
228 |
-
function apbct_is_user_logged_in(){
|
229 |
-
$siteurl = get_site_option( 'siteurl' );
|
230 |
-
$cookiehash = $siteurl ? md5( $siteurl ) : '';
|
231 |
-
return count($_COOKIE) && isset($_COOKIE['wordpress_logged_in_'.$cookiehash]);
|
232 |
-
}
|
233 |
-
|
234 |
-
/*
|
235 |
-
* GETTING SERVER VARIABLES BY VARIOUS WAYS
|
236 |
-
*/
|
237 |
-
function apbct_get_server_variable( $server_variable_name ){
|
238 |
-
|
239 |
-
$var_name = strtoupper( $server_variable_name );
|
240 |
-
|
241 |
-
if( function_exists( 'filter_input' ) )
|
242 |
-
$value = filter_input( INPUT_SERVER, $var_name );
|
243 |
-
|
244 |
-
if( empty( $value ) )
|
245 |
-
$value = isset( $_SERVER[ $var_name ] ) ? $_SERVER[ $var_name ] : '';
|
246 |
-
|
247 |
-
// Convert to upper case for REQUEST_METHOD
|
248 |
-
if( in_array( $server_variable_name, array( 'REQUEST_METHOD' ) ) )
|
249 |
-
$value = strtoupper( $value );
|
250 |
-
|
251 |
-
// Convert HTML chars for HTTP_USER_AGENT, HTTP_USER_AGENT, SERVER_NAME
|
252 |
-
if( in_array( $server_variable_name, array( 'HTTP_USER_AGENT', 'HTTP_USER_AGENT', 'SERVER_NAME' ) ) )
|
253 |
-
$value = htmlspecialchars( $value );
|
254 |
-
|
255 |
-
return $value;
|
256 |
-
}
|
257 |
-
|
258 |
-
function apbct_is_post(){
|
259 |
-
return apbct_get_server_variable('REQUEST_METHOD') === 'POST';
|
260 |
-
}
|
261 |
-
|
262 |
-
function apbct_is_get(){
|
263 |
-
return apbct_get_server_variable('REQUEST_METHOD') === 'GET';
|
264 |
-
}
|
265 |
-
|
266 |
-
function apbct_is_in_referer( $str ){
|
267 |
-
return stripos( apbct_get_server_variable('HTTP_REFERER'), $str ) !== false;
|
268 |
-
}
|
269 |
-
|
270 |
-
function apbct_is_in_uri( $str ){
|
271 |
-
return stripos( apbct_get_server_variable('REQUEST_URI'), $str ) !== false;
|
272 |
-
}
|
273 |
-
|
274 |
-
/*
|
275 |
-
* Checking if current request is a cron job
|
276 |
-
* Support for wordpress < 4.8.0
|
277 |
-
*
|
278 |
-
* @return bool
|
279 |
-
*/
|
280 |
-
function apbct_wp_doing_cron() {
|
281 |
-
|
282 |
-
if( function_exists( 'wp_doing_cron' ) ) {
|
283 |
-
return wp_doing_cron();
|
284 |
-
} else {
|
285 |
-
return ( defined( 'DOING_CRON' ) && DOING_CRON );
|
286 |
-
}
|
287 |
-
|
288 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Getting current user by cookie
|
5 |
+
*
|
6 |
+
* @return WP_User|null
|
7 |
+
*/
|
8 |
+
function apbct_wp_get_current_user(){
|
9 |
+
|
10 |
+
global $apbct, $current_user;
|
11 |
+
|
12 |
+
$user = null;
|
13 |
+
|
14 |
+
if(!(defined('XMLRPC_REQUEST') && XMLRPC_REQUEST)){
|
15 |
+
|
16 |
+
if(!empty($apbct->user)){
|
17 |
+
$user_id = is_object($current_user) && isset($current_user->ID) && !($current_user instanceof WP_User)
|
18 |
+
? $current_user->ID
|
19 |
+
: null;
|
20 |
+
}else{
|
21 |
+
$user_id = empty($user_id) && defined('LOGGED_IN_COOKIE') && !empty($_COOKIE[LOGGED_IN_COOKIE])
|
22 |
+
? apbct_wp_validate_auth_cookie($_COOKIE[LOGGED_IN_COOKIE], 'logged_in')
|
23 |
+
: null;
|
24 |
+
}
|
25 |
+
|
26 |
+
if($user_id){
|
27 |
+
$user = new WP_User($user_id);
|
28 |
+
}
|
29 |
+
|
30 |
+
}
|
31 |
+
|
32 |
+
return $user ? $user : $current_user;
|
33 |
+
}
|
34 |
+
|
35 |
+
function apbct_wp_set_current_user($user = null){
|
36 |
+
|
37 |
+
global $apbct;
|
38 |
+
|
39 |
+
if( $user instanceof WP_User ){
|
40 |
+
$apbct->user = $user;
|
41 |
+
return true;
|
42 |
+
}
|
43 |
+
|
44 |
+
return false;
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Validates authentication cookie.
|
49 |
+
*
|
50 |
+
* The checks include making sure that the authentication cookie is set and
|
51 |
+
* pulling in the contents (if $cookie is not used).
|
52 |
+
*
|
53 |
+
* Makes sure the cookie is not expired. Verifies the hash in cookie is what is
|
54 |
+
* should be and compares the two.
|
55 |
+
*
|
56 |
+
* @param string $cookie Optional. If used, will validate contents instead of cookie's
|
57 |
+
* @param string $scheme Optional. The cookie scheme to use: auth, secure_auth, or logged_in
|
58 |
+
*
|
59 |
+
* @return false|int False if invalid cookie, User ID if valid.
|
60 |
+
* @global int $login_grace_period
|
61 |
+
*
|
62 |
+
*/
|
63 |
+
function apbct_wp_validate_auth_cookie( $cookie = '', $scheme = '' ) {
|
64 |
+
|
65 |
+
$cookie_elements = apbct_wp_parse_auth_cookie($cookie, $scheme);
|
66 |
+
|
67 |
+
$scheme = $cookie_elements['scheme'];
|
68 |
+
$username = $cookie_elements['username'];
|
69 |
+
$hmac = $cookie_elements['hmac'];
|
70 |
+
$token = $cookie_elements['token'];
|
71 |
+
$expiration = $cookie_elements['expiration'];
|
72 |
+
|
73 |
+
// Allow a grace period for POST and Ajax requests
|
74 |
+
$expired = apbct_is_ajax() || apbct_is_post()
|
75 |
+
? $expiration + HOUR_IN_SECONDS
|
76 |
+
: $cookie_elements['expiration'];
|
77 |
+
|
78 |
+
// Quick check to see if an honest cookie has expired
|
79 |
+
if($expired >= time()){
|
80 |
+
$user = apbct_wp_get_user_by('login', $username);
|
81 |
+
if($user){
|
82 |
+
$pass_frag = substr($user->user_pass, 8, 4);
|
83 |
+
$key = apbct_wp_hash($username . '|' . $pass_frag . '|' . $expiration . '|' . $token, $scheme);
|
84 |
+
// If ext/hash is not present, compat.php's hash_hmac() does not support sha256.
|
85 |
+
$algo = function_exists('hash') ? 'sha256' : 'sha1';
|
86 |
+
$hash = hash_hmac($algo, $username . '|' . $expiration . '|' . $token, $key);
|
87 |
+
if(hash_equals($hash, $hmac)){
|
88 |
+
$sessions = get_user_meta($user->ID, 'session_tokens', true);
|
89 |
+
$sessions = is_array($sessions) ? current($sessions) : $sessions;
|
90 |
+
if(is_array($sessions)){
|
91 |
+
if(is_int($sessions['expiration']) && $sessions['expiration'] > time()){
|
92 |
+
return $user->ID;
|
93 |
+
}else
|
94 |
+
return false;
|
95 |
+
}else
|
96 |
+
return false;
|
97 |
+
}else
|
98 |
+
return false;
|
99 |
+
}else
|
100 |
+
return false;
|
101 |
+
}else
|
102 |
+
return false;
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Gets user by filed
|
107 |
+
*
|
108 |
+
* @param $field
|
109 |
+
* @param $value
|
110 |
+
*
|
111 |
+
* @return bool|WP_User
|
112 |
+
*/
|
113 |
+
function apbct_wp_get_user_by($field, $value){
|
114 |
+
|
115 |
+
$userdata = WP_User::get_data_by($field, $value);
|
116 |
+
|
117 |
+
if(!$userdata)
|
118 |
+
return false;
|
119 |
+
|
120 |
+
$user = new WP_User;
|
121 |
+
$user->init($userdata);
|
122 |
+
|
123 |
+
return $user;
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Get hash of given string.
|
128 |
+
*
|
129 |
+
* @param string $data Plain text to hash
|
130 |
+
* @param string $scheme Authentication scheme (auth, secure_auth, logged_in, nonce)
|
131 |
+
* @return string Hash of $data
|
132 |
+
*/
|
133 |
+
function apbct_wp_hash( $data, $scheme = 'auth' ) {
|
134 |
+
|
135 |
+
$values = array(
|
136 |
+
'key' => '',
|
137 |
+
'salt' => '',
|
138 |
+
);
|
139 |
+
|
140 |
+
foreach(array('key', 'salt') as $type){
|
141 |
+
$const = strtoupper( "{$scheme}_{$type}");
|
142 |
+
if ( defined($const) && constant($const)){
|
143 |
+
$values[$type] = constant($const);
|
144 |
+
}elseif(!$values[$type]){
|
145 |
+
$values[$type] = get_site_option( "{$scheme}_{$type}");
|
146 |
+
if (!$values[$type]){
|
147 |
+
$values[$type] = '';
|
148 |
+
}
|
149 |
+
}
|
150 |
+
}
|
151 |
+
|
152 |
+
$salt = $values['key'] . $values['salt'];
|
153 |
+
|
154 |
+
return hash_hmac('md5', $data, $salt);
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Parse a cookie into its components
|
159 |
+
*
|
160 |
+
* @param string $cookie
|
161 |
+
* @param string $scheme Optional. The cookie scheme to use: auth, secure_auth, or logged_in
|
162 |
+
*
|
163 |
+
* @return array|false Authentication cookie components
|
164 |
+
*
|
165 |
+
*/
|
166 |
+
function apbct_wp_parse_auth_cookie($cookie = '', $scheme = '')
|
167 |
+
{
|
168 |
+
$cookie_elements = explode('|', $cookie);
|
169 |
+
if(count($cookie_elements) !== 4){
|
170 |
+
return false;
|
171 |
+
}
|
172 |
+
|
173 |
+
list($username, $expiration, $token, $hmac) = $cookie_elements;
|
174 |
+
|
175 |
+
return compact('username', 'expiration', 'token', 'hmac', 'scheme');
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Checks if the plugin is active
|
180 |
+
*
|
181 |
+
* @param string $plugin relative path from plugin folder like cleantalk-spam-protect/cleantalk.php
|
182 |
+
*
|
183 |
+
* @return bool
|
184 |
+
*/
|
185 |
+
function apbct_is_plugin_active( $plugin ) {
|
186 |
+
return in_array( $plugin, (array) get_option( 'active_plugins', array() ) ) || apbct_is_plugin_active_for_network( $plugin );
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Checks if the plugin is active for network
|
191 |
+
*
|
192 |
+
* @param string $plugin relative path from plugin folder like cleantalk-spam-protect/cleantalk.php
|
193 |
+
*
|
194 |
+
* @return bool
|
195 |
+
*/
|
196 |
+
function apbct_is_plugin_active_for_network( $plugin ){
|
197 |
+
|
198 |
+
if ( ! APBCT_WPMS )
|
199 |
+
return false;
|
200 |
+
|
201 |
+
$plugins = get_site_option( 'active_sitewide_plugins' );
|
202 |
+
|
203 |
+
return isset( $plugins[ $plugin ] )
|
204 |
+
? true
|
205 |
+
: false;
|
206 |
+
}
|
207 |
+
|
208 |
+
/**
|
209 |
+
* Checks if the request is AJAX
|
210 |
+
*
|
211 |
+
* @return boolean
|
212 |
+
*/
|
213 |
+
function apbct_is_ajax() {
|
214 |
+
|
215 |
+
return
|
216 |
+
(defined( 'DOING_AJAX' ) && DOING_AJAX) || // by standart WP functions
|
217 |
+
(apbct_get_server_variable( 'HTTP_X_REQUESTED_WITH' ) && strtolower(apbct_get_server_variable( 'HTTP_X_REQUESTED_WITH' )) == 'xmlhttprequest') || // by Request type
|
218 |
+
!empty($_POST['quform_ajax']) || // special. QForms
|
219 |
+
!empty($_POST['iphorm_ajax']); // special. IPHorm
|
220 |
+
|
221 |
+
}
|
222 |
+
|
223 |
+
/**
|
224 |
+
* Checks if the user is logged in
|
225 |
+
*
|
226 |
+
* @return bool
|
227 |
+
*/
|
228 |
+
function apbct_is_user_logged_in(){
|
229 |
+
$siteurl = get_site_option( 'siteurl' );
|
230 |
+
$cookiehash = $siteurl ? md5( $siteurl ) : '';
|
231 |
+
return count($_COOKIE) && isset($_COOKIE['wordpress_logged_in_'.$cookiehash]);
|
232 |
+
}
|
233 |
+
|
234 |
+
/*
|
235 |
+
* GETTING SERVER VARIABLES BY VARIOUS WAYS
|
236 |
+
*/
|
237 |
+
function apbct_get_server_variable( $server_variable_name ){
|
238 |
+
|
239 |
+
$var_name = strtoupper( $server_variable_name );
|
240 |
+
|
241 |
+
if( function_exists( 'filter_input' ) )
|
242 |
+
$value = filter_input( INPUT_SERVER, $var_name );
|
243 |
+
|
244 |
+
if( empty( $value ) )
|
245 |
+
$value = isset( $_SERVER[ $var_name ] ) ? $_SERVER[ $var_name ] : '';
|
246 |
+
|
247 |
+
// Convert to upper case for REQUEST_METHOD
|
248 |
+
if( in_array( $server_variable_name, array( 'REQUEST_METHOD' ) ) )
|
249 |
+
$value = strtoupper( $value );
|
250 |
+
|
251 |
+
// Convert HTML chars for HTTP_USER_AGENT, HTTP_USER_AGENT, SERVER_NAME
|
252 |
+
if( in_array( $server_variable_name, array( 'HTTP_USER_AGENT', 'HTTP_USER_AGENT', 'SERVER_NAME' ) ) )
|
253 |
+
$value = htmlspecialchars( $value );
|
254 |
+
|
255 |
+
return $value;
|
256 |
+
}
|
257 |
+
|
258 |
+
function apbct_is_post(){
|
259 |
+
return apbct_get_server_variable('REQUEST_METHOD') === 'POST';
|
260 |
+
}
|
261 |
+
|
262 |
+
function apbct_is_get(){
|
263 |
+
return apbct_get_server_variable('REQUEST_METHOD') === 'GET';
|
264 |
+
}
|
265 |
+
|
266 |
+
function apbct_is_in_referer( $str ){
|
267 |
+
return stripos( apbct_get_server_variable('HTTP_REFERER'), $str ) !== false;
|
268 |
+
}
|
269 |
+
|
270 |
+
function apbct_is_in_uri( $str ){
|
271 |
+
return stripos( apbct_get_server_variable('REQUEST_URI'), $str ) !== false;
|
272 |
+
}
|
273 |
+
|
274 |
+
/*
|
275 |
+
* Checking if current request is a cron job
|
276 |
+
* Support for wordpress < 4.8.0
|
277 |
+
*
|
278 |
+
* @return bool
|
279 |
+
*/
|
280 |
+
function apbct_wp_doing_cron() {
|
281 |
+
|
282 |
+
if( function_exists( 'wp_doing_cron' ) ) {
|
283 |
+
return wp_doing_cron();
|
284 |
+
} else {
|
285 |
+
return ( defined( 'DOING_CRON' ) && DOING_CRON );
|
286 |
+
}
|
287 |
+
|
288 |
}
|
@@ -935,7 +935,7 @@ function ct_add_hidden_fields($field_name = 'ct_checkjs', $return_string = false
|
|
935 |
|
936 |
$html = "<script type='text/javascript'>
|
937 |
function ctSetCookie(c_name, value, def_value){
|
938 |
-
document.cookie = c_name + '=' + escape(value) + '; path
|
939 |
}
|
940 |
ctSetCookie('{$field_name}', '{$ct_checkjs_key}', '{$ct_checkjs_def}');
|
941 |
</script>";
|
@@ -1374,6 +1374,8 @@ function ct_preprocess_comment($comment) {
|
|
1374 |
add_filter('pre_comment_approved', 'ct_set_not_approved', 999, 2);
|
1375 |
else
|
1376 |
add_filter('pre_comment_approved', 'ct_set_approved', 999, 2);
|
|
|
|
|
1377 |
}else{
|
1378 |
|
1379 |
global $ct_comment, $ct_stop_words;
|
@@ -1500,6 +1502,33 @@ function apbct_comment__Wordpress__changeMailNotification($notify_message, $comm
|
|
1500 |
|
1501 |
}
|
1502 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1503 |
/**
|
1504 |
* Set die page with Cleantalk comment.
|
1505 |
* @global array $ct_comment
|
@@ -1706,7 +1735,9 @@ function ct_register_form() {
|
|
1706 |
}
|
1707 |
|
1708 |
function apbct_login__scripts(){
|
|
|
1709 |
echo '<script src="'.APBCT_URL_PATH.'/js/apbct-public.min.js"></script>';
|
|
|
1710 |
}
|
1711 |
|
1712 |
/**
|
@@ -1922,7 +1953,7 @@ function ct_registration_errors($errors, $sanitized_user_login = null, $user_ema
|
|
1922 |
}else{
|
1923 |
// This hack can be helpfull when plugin uses with untested themes&signups plugins.
|
1924 |
$checkjs_post = apbct_js_test($ct_checkjs_register_form, $_POST);
|
1925 |
-
$checkjs_cookie = apbct_js_test(
|
1926 |
$checkjs = $checkjs_cookie ? $checkjs_cookie : $checkjs_post;
|
1927 |
}
|
1928 |
|
@@ -1986,8 +2017,8 @@ function ct_registration_errors($errors, $sanitized_user_login = null, $user_ema
|
|
1986 |
|
1987 |
} else {
|
1988 |
if ($ct_result->id !== null) {
|
1989 |
-
|
1990 |
-
|
1991 |
}
|
1992 |
}
|
1993 |
|
@@ -2117,7 +2148,7 @@ function apbct_user_register($user_id) {
|
|
2117 |
global $apbct_cookie_request_id_label;
|
2118 |
if (isset($_COOKIE[$apbct_cookie_request_id_label])) {
|
2119 |
if(update_user_meta($user_id, 'ct_hash', $_COOKIE[$apbct_cookie_request_id_label])){
|
2120 |
-
|
2121 |
}
|
2122 |
}
|
2123 |
}
|
@@ -2913,7 +2944,7 @@ function ct_check_wplp(){
|
|
2913 |
$cleantalk_comment = 'OK';
|
2914 |
}
|
2915 |
|
2916 |
-
|
2917 |
} else {
|
2918 |
// Next POST/AJAX submit(s) of same WPLP form
|
2919 |
$cleantalk_comment = $_COOKIE[$ct_wplp_result_label];
|
@@ -3614,14 +3645,17 @@ function ct_enqueue_scripts_public($hook){
|
|
3614 |
|
3615 |
if($apbct->settings['registrations_test'] || $apbct->settings['comments_test'] || $apbct->settings['contact_forms_test'] || $apbct->settings['general_contact_forms_test'] || $apbct->settings['wc_checkout_test'] || $apbct->settings['check_external'] || $apbct->settings['check_internal'] || $apbct->settings['bp_private_messages'] || $apbct->settings['general_postdata_test']){
|
3616 |
|
3617 |
-
|
3618 |
-
|
3619 |
-
|
3620 |
-
|
3621 |
-
|
3622 |
-
'
|
3623 |
-
|
3624 |
-
|
|
|
|
|
|
|
3625 |
// GDPR script
|
3626 |
if($apbct->settings['gdpr_enabled']){
|
3627 |
|
935 |
|
936 |
$html = "<script type='text/javascript'>
|
937 |
function ctSetCookie(c_name, value, def_value){
|
938 |
+
document.cookie = c_name + '=' + escape(value) + '; path=/; samesite=lax';
|
939 |
}
|
940 |
ctSetCookie('{$field_name}', '{$ct_checkjs_key}', '{$ct_checkjs_def}');
|
941 |
</script>";
|
1374 |
add_filter('pre_comment_approved', 'ct_set_not_approved', 999, 2);
|
1375 |
else
|
1376 |
add_filter('pre_comment_approved', 'ct_set_approved', 999, 2);
|
1377 |
+
// Modify the email notification
|
1378 |
+
add_filter('comment_notification_text', 'apbct_comment__wordpress__show_blacklists', 100, 2); // Add two blacklist links: by email and IP
|
1379 |
}else{
|
1380 |
|
1381 |
global $ct_comment, $ct_stop_words;
|
1502 |
|
1503 |
}
|
1504 |
|
1505 |
+
function apbct_comment__wordpress__show_blacklists( $notify_message, $comment_id ) {
|
1506 |
+
|
1507 |
+
$comment_details = get_comments( array( 'comment__in' => $comment_id ) );
|
1508 |
+
$comment_details = $comment_details[0];
|
1509 |
+
|
1510 |
+
if( isset( $comment_details->comment_author_email ) ) {
|
1511 |
+
|
1512 |
+
$black_list_link = 'https://cleantalk.org/blacklists/';
|
1513 |
+
|
1514 |
+
$links = PHP_EOL;
|
1515 |
+
$links .= esc_html__( 'Check for spam:', 'cleantalk' );
|
1516 |
+
$links .= PHP_EOL;
|
1517 |
+
$links .= $black_list_link . $comment_details->comment_author_email;
|
1518 |
+
$links .= PHP_EOL;
|
1519 |
+
if( ! empty( $comment_details->comment_author_IP ) ) {
|
1520 |
+
$links .= $black_list_link . $comment_details->comment_author_IP;
|
1521 |
+
$links .= PHP_EOL;
|
1522 |
+
}
|
1523 |
+
|
1524 |
+
return $notify_message . $links;
|
1525 |
+
|
1526 |
+
}
|
1527 |
+
|
1528 |
+
return $notify_message;
|
1529 |
+
|
1530 |
+
}
|
1531 |
+
|
1532 |
/**
|
1533 |
* Set die page with Cleantalk comment.
|
1534 |
* @global array $ct_comment
|
1735 |
}
|
1736 |
|
1737 |
function apbct_login__scripts(){
|
1738 |
+
global $apbct;
|
1739 |
echo '<script src="'.APBCT_URL_PATH.'/js/apbct-public.min.js"></script>';
|
1740 |
+
$apbct->public_script_loaded = true;
|
1741 |
}
|
1742 |
|
1743 |
/**
|
1953 |
}else{
|
1954 |
// This hack can be helpfull when plugin uses with untested themes&signups plugins.
|
1955 |
$checkjs_post = apbct_js_test($ct_checkjs_register_form, $_POST);
|
1956 |
+
$checkjs_cookie = apbct_js_test('ct_checkjs', $_COOKIE);
|
1957 |
$checkjs = $checkjs_cookie ? $checkjs_cookie : $checkjs_post;
|
1958 |
}
|
1959 |
|
2017 |
|
2018 |
} else {
|
2019 |
if ($ct_result->id !== null) {
|
2020 |
+
\Cleantalk\Antispam\Helper::apbct_cookie__set($apbct_cookie_register_ok_label, $ct_result->id, time()+10, '/');
|
2021 |
+
\Cleantalk\Antispam\Helper::apbct_cookie__set($apbct_cookie_request_id_label, $ct_result->id, time()+10, '/');
|
2022 |
}
|
2023 |
}
|
2024 |
|
2148 |
global $apbct_cookie_request_id_label;
|
2149 |
if (isset($_COOKIE[$apbct_cookie_request_id_label])) {
|
2150 |
if(update_user_meta($user_id, 'ct_hash', $_COOKIE[$apbct_cookie_request_id_label])){
|
2151 |
+
\Cleantalk\Antispam\Helper::apbct_cookie__set($apbct_cookie_request_id_label, '0', 1, '/');
|
2152 |
}
|
2153 |
}
|
2154 |
}
|
2944 |
$cleantalk_comment = 'OK';
|
2945 |
}
|
2946 |
|
2947 |
+
\Cleantalk\Antispam\Helper::apbct_cookie__set($ct_wplp_result_label, $cleantalk_comment, strtotime("+5 seconds"), '/');
|
2948 |
} else {
|
2949 |
// Next POST/AJAX submit(s) of same WPLP form
|
2950 |
$cleantalk_comment = $_COOKIE[$ct_wplp_result_label];
|
3645 |
|
3646 |
if($apbct->settings['registrations_test'] || $apbct->settings['comments_test'] || $apbct->settings['contact_forms_test'] || $apbct->settings['general_contact_forms_test'] || $apbct->settings['wc_checkout_test'] || $apbct->settings['check_external'] || $apbct->settings['check_internal'] || $apbct->settings['bp_private_messages'] || $apbct->settings['general_postdata_test']){
|
3647 |
|
3648 |
+
if( ! $apbct->public_script_loaded ) {
|
3649 |
+
|
3650 |
+
// Differnt JS params
|
3651 |
+
wp_enqueue_script( 'ct_public', APBCT_URL_PATH . '/js/apbct-public.min.js', array( 'jquery' ), APBCT_VERSION, false /*in header*/ );
|
3652 |
+
|
3653 |
+
wp_localize_script( 'ct_public', 'ctPublic', array(
|
3654 |
+
'_ajax_nonce' => wp_create_nonce( 'ct_secret_stuff' ),
|
3655 |
+
'_ajax_url' => admin_url( 'admin-ajax.php' ),
|
3656 |
+
) );
|
3657 |
+
}
|
3658 |
+
|
3659 |
// GDPR script
|
3660 |
if($apbct->settings['gdpr_enabled']){
|
3661 |
|
@@ -441,11 +441,12 @@ function apbct_settings__set_fileds__network( $fields ){
|
|
441 |
'title' => __('Enable White Label Mode', 'cleantalk'),
|
442 |
'description' => sprintf(__("Learn more information %shere%s.", 'cleantalk'), '<a target="_blank" href="https://cleantalk.org/ru/help/hosting-white-label">', '</a>'),
|
443 |
'childrens' => array( 'white_label__hoster_key', 'white_label__plugin_name', 'allow_custom_key', ),
|
|
|
444 |
'network' => true,
|
445 |
),
|
446 |
'white_label__hoster_key' => array(
|
447 |
'title' => __('Hoster API Key', 'cleantalk'),
|
448 |
-
'description' => sprintf(__("You can get it in %sCleantalk's Control Panel%s", 'cleantalk'), '<a target="_blank" href="https://cleantalk.org/my
|
449 |
'type' => 'text',
|
450 |
'parent' => 'white_label',
|
451 |
'class' => 'apbct_settings-field_wrapper--sub',
|
@@ -468,6 +469,8 @@ function apbct_settings__set_fileds__network( $fields ){
|
|
468 |
. (defined('CLEANTALK_ACCESS_KEY')
|
469 |
? ' <span style="color: red">'
|
470 |
. __('Constant <b>CLEANTALK_ACCESS_KEY</b> is set. All websites will use API key from this constant. Look into wp-config.php', 'cleantalk')
|
|
|
|
|
471 |
. '</span>'
|
472 |
: ''
|
473 |
),
|
@@ -1128,26 +1131,28 @@ function apbct_settings__field__draw($params = array()){
|
|
1128 |
: '';
|
1129 |
|
1130 |
echo '<div class="apbct_settings-field_content apbct_settings-field_content--'.$params['type'].'">';
|
1131 |
-
|
1132 |
-
foreach($params['options'] as $option){
|
1133 |
-
echo '<input'
|
1134 |
-
.' type="radio"'
|
1135 |
-
." class='apbct_setting_{$params['type']} apbct_setting---{$params['name']}'"
|
1136 |
-
." id='apbct_setting_{$params['name']}__{$option['label']}'"
|
1137 |
-
.' name="cleantalk_settings['.$params['name'].']"'
|
1138 |
-
.' value="'.$option['val'].'"'
|
1139 |
-
. $disabled
|
1140 |
-
.($params['childrens']
|
1141 |
-
? ' onchange="apbctSettingsDependencies(\'' . $childrens . '\', ' . $option['childrens_enable'] . ')"'
|
1142 |
-
: ''
|
1143 |
-
)
|
1144 |
-
.($value == $option['val'] ? ' checked' : '')
|
1145 |
-
.($params['required'] ? ' required="required"' : '')
|
1146 |
-
.' />';
|
1147 |
-
echo '<label for="apbct_setting_'.$params['name'].'__'.$option['label'].'"> ' . $option['label'] . '</label>';
|
1148 |
-
echo ' ';
|
1149 |
-
}
|
1150 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1151 |
echo isset($params['description'])
|
1152 |
? '<div class="apbct_settings-field_description">'.$params['description'].'</div>'
|
1153 |
: '';
|
441 |
'title' => __('Enable White Label Mode', 'cleantalk'),
|
442 |
'description' => sprintf(__("Learn more information %shere%s.", 'cleantalk'), '<a target="_blank" href="https://cleantalk.org/ru/help/hosting-white-label">', '</a>'),
|
443 |
'childrens' => array( 'white_label__hoster_key', 'white_label__plugin_name', 'allow_custom_key', ),
|
444 |
+
'disabled' => defined('CLEANTALK_ACCESS_KEY'),
|
445 |
'network' => true,
|
446 |
),
|
447 |
'white_label__hoster_key' => array(
|
448 |
'title' => __('Hoster API Key', 'cleantalk'),
|
449 |
+
'description' => sprintf(__("You can get it in %sCleantalk's Control Panel%s", 'cleantalk'), '<a target="_blank" href="https://cleantalk.org/my/profile">', '</a>'),
|
450 |
'type' => 'text',
|
451 |
'parent' => 'white_label',
|
452 |
'class' => 'apbct_settings-field_wrapper--sub',
|
469 |
. (defined('CLEANTALK_ACCESS_KEY')
|
470 |
? ' <span style="color: red">'
|
471 |
. __('Constant <b>CLEANTALK_ACCESS_KEY</b> is set. All websites will use API key from this constant. Look into wp-config.php', 'cleantalk')
|
472 |
+
. '<br>'
|
473 |
+
. __('You are not able to use white label mode while <b>CLEANTALK_ACCESS_KEY</b> is defined.', 'cleantalk')
|
474 |
. '</span>'
|
475 |
: ''
|
476 |
),
|
1131 |
: '';
|
1132 |
|
1133 |
echo '<div class="apbct_settings-field_content apbct_settings-field_content--'.$params['type'].'">';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1134 |
|
1135 |
+
echo '<div class="apbct_switchers" style="direction: ltr">';
|
1136 |
+
foreach($params['options'] as $option){
|
1137 |
+
echo '<input'
|
1138 |
+
.' type="radio"'
|
1139 |
+
." class='apbct_setting_{$params['type']} apbct_setting---{$params['name']}'"
|
1140 |
+
." id='apbct_setting_{$params['name']}__{$option['label']}'"
|
1141 |
+
.' name="cleantalk_settings['.$params['name'].']"'
|
1142 |
+
.' value="'.$option['val'].'"'
|
1143 |
+
. $disabled
|
1144 |
+
.($params['childrens']
|
1145 |
+
? ' onchange="apbctSettingsDependencies(\'' . $childrens . '\', ' . $option['childrens_enable'] . ')"'
|
1146 |
+
: ''
|
1147 |
+
)
|
1148 |
+
.($value == $option['val'] ? ' checked' : '')
|
1149 |
+
.($params['required'] ? ' required="required"' : '')
|
1150 |
+
.' />';
|
1151 |
+
echo '<label for="apbct_setting_'.$params['name'].'__'.$option['label'].'"> ' . $option['label'] . '</label>';
|
1152 |
+
echo ' ';
|
1153 |
+
}
|
1154 |
+
echo '</div>';
|
1155 |
+
|
1156 |
echo isset($params['description'])
|
1157 |
? '<div class="apbct_settings-field_description">'.$params['description'].'</div>'
|
1158 |
: '';
|
@@ -130,7 +130,7 @@ class ClassCleantalkFindSpamUsersChecker extends ClassCleantalkFindSpamChecker
|
|
130 |
|
131 |
check_ajax_referer('ct_secret_nonce', 'security');
|
132 |
|
133 |
-
global $apbct;
|
134 |
|
135 |
$amount = !empty($_POST['amount']) && intval($_POST['amount'])
|
136 |
? intval($_POST['amount'])
|
@@ -140,32 +140,6 @@ class ClassCleantalkFindSpamUsersChecker extends ClassCleantalkFindSpamChecker
|
|
140 |
'administrator'
|
141 |
);
|
142 |
|
143 |
-
$params = array(
|
144 |
-
'fields' => array(
|
145 |
-
'ID',
|
146 |
-
'user_email',
|
147 |
-
'user_registered',
|
148 |
-
),
|
149 |
-
'meta_query' => array(
|
150 |
-
'relation' => 'AND',
|
151 |
-
array(
|
152 |
-
'key' => 'ct_checked_now',
|
153 |
-
'compare' => 'NOT EXISTS'
|
154 |
-
),
|
155 |
-
array(
|
156 |
-
'key' => 'ct_checked',
|
157 |
-
'compare' => 'NOT EXISTS'
|
158 |
-
),
|
159 |
-
array(
|
160 |
-
'key' => 'ct_bad',
|
161 |
-
'compare' => 'NOT EXISTS'
|
162 |
-
)
|
163 |
-
),
|
164 |
-
'orderby' => 'registered',
|
165 |
-
'order' => 'ASC',
|
166 |
-
'number' => $amount,
|
167 |
-
);
|
168 |
-
|
169 |
if(isset($_POST['from'], $_POST['till'])){
|
170 |
|
171 |
$from_date = date('Y-m-d', intval(strtotime($_POST['from'])));
|
@@ -178,9 +152,18 @@ class ClassCleantalkFindSpamUsersChecker extends ClassCleantalkFindSpamChecker
|
|
178 |
'inclusive' => true,
|
179 |
);
|
180 |
}
|
181 |
-
|
182 |
-
|
183 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
$check_result = array(
|
185 |
'end' => 0,
|
186 |
'checked' => 0,
|
@@ -196,9 +179,9 @@ class ClassCleantalkFindSpamUsersChecker extends ClassCleantalkFindSpamChecker
|
|
196 |
foreach( $u as $user_index => $user ){
|
197 |
|
198 |
if( ! isset( $curr_date ) )
|
199 |
-
$curr_date = ( substr( $user->
|
200 |
|
201 |
-
if( substr( $user->
|
202 |
unset( $u[$user_index] );
|
203 |
|
204 |
}
|
@@ -233,8 +216,8 @@ class ClassCleantalkFindSpamUsersChecker extends ClassCleantalkFindSpamChecker
|
|
233 |
$data[] = $curr_email;
|
234 |
// Patch for empty IP/Email
|
235 |
$u[$i]->data = new \stdClass();
|
236 |
-
$u[$i]->
|
237 |
-
$u[$i]->
|
238 |
}
|
239 |
}
|
240 |
|
@@ -272,8 +255,8 @@ class ClassCleantalkFindSpamUsersChecker extends ClassCleantalkFindSpamChecker
|
|
272 |
$mark_spam_ip = false;
|
273 |
$mark_spam_email = false;
|
274 |
|
275 |
-
$uip = $u[$i]->
|
276 |
-
$uim = $u[$i]->
|
277 |
|
278 |
if( isset( $result[$uip] ) && $result[$uip]['appears'] == 1 )
|
279 |
$mark_spam_ip = true;
|
@@ -601,4 +584,50 @@ class ClassCleantalkFindSpamUsersChecker extends ClassCleantalkFindSpamChecker
|
|
601 |
die($count_all);
|
602 |
}
|
603 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
604 |
}
|
130 |
|
131 |
check_ajax_referer('ct_secret_nonce', 'security');
|
132 |
|
133 |
+
global $apbct, $wpdb;
|
134 |
|
135 |
$amount = !empty($_POST['amount']) && intval($_POST['amount'])
|
136 |
? intval($_POST['amount'])
|
140 |
'administrator'
|
141 |
);
|
142 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
if(isset($_POST['from'], $_POST['till'])){
|
144 |
|
145 |
$from_date = date('Y-m-d', intval(strtotime($_POST['from'])));
|
152 |
'inclusive' => true,
|
153 |
);
|
154 |
}
|
155 |
+
|
156 |
+
$u = $wpdb->get_results("
|
157 |
+
SELECT {$wpdb->users}.ID, {$wpdb->users}.user_email, {$wpdb->users}.user_registered
|
158 |
+
FROM {$wpdb->users}
|
159 |
+
WHERE
|
160 |
+
NOT EXISTS(SELECT * FROM {$wpdb->usermeta} as meta WHERE {$wpdb->users}.ID = meta.user_id AND meta.meta_key = 'ct_bad') AND
|
161 |
+
NOT EXISTS(SELECT * FROM {$wpdb->usermeta} as meta WHERE {$wpdb->users}.ID = meta.user_id AND meta.meta_key = 'ct_checked') AND
|
162 |
+
NOT EXISTS(SELECT * FROM {$wpdb->usermeta} as meta WHERE {$wpdb->users}.ID = meta.user_id AND meta.meta_key = 'ct_checked_now')
|
163 |
+
ORDER BY {$wpdb->users}.user_registered ASC
|
164 |
+
LIMIT $amount;"
|
165 |
+
);
|
166 |
+
|
167 |
$check_result = array(
|
168 |
'end' => 0,
|
169 |
'checked' => 0,
|
179 |
foreach( $u as $user_index => $user ){
|
180 |
|
181 |
if( ! isset( $curr_date ) )
|
182 |
+
$curr_date = ( substr( $user->user_registered, 0, 10 ) ? substr( $user->user_registered, 0, 10 ) : '' );
|
183 |
|
184 |
+
if( substr( $user->user_registered, 0, 10 ) != $curr_date )
|
185 |
unset( $u[$user_index] );
|
186 |
|
187 |
}
|
216 |
$data[] = $curr_email;
|
217 |
// Patch for empty IP/Email
|
218 |
$u[$i]->data = new \stdClass();
|
219 |
+
$u[$i]->user_ip = empty($curr_ip) ? 'none' : $curr_ip;
|
220 |
+
$u[$i]->user_email = empty($curr_email) ? 'none' : $curr_email;
|
221 |
}
|
222 |
}
|
223 |
|
255 |
$mark_spam_ip = false;
|
256 |
$mark_spam_email = false;
|
257 |
|
258 |
+
$uip = $u[$i]->user_ip;
|
259 |
+
$uim = $u[$i]->user_email;
|
260 |
|
261 |
if( isset( $result[$uip] ) && $result[$uip]['appears'] == 1 )
|
262 |
$mark_spam_ip = true;
|
584 |
die($count_all);
|
585 |
}
|
586 |
|
587 |
+
/**
|
588 |
+
* Add hidden column into the users table
|
589 |
+
*
|
590 |
+
* @param $columns
|
591 |
+
* @return mixed
|
592 |
+
*/
|
593 |
+
public static function ct_manage_users_columns( $columns ) {
|
594 |
+
|
595 |
+
$columns['apbct_status hidden'] = '';
|
596 |
+
return $columns;
|
597 |
+
|
598 |
+
}
|
599 |
+
|
600 |
+
/**
|
601 |
+
* Generates <span> with information about user scan using user's meta.
|
602 |
+
*
|
603 |
+
* @param $value
|
604 |
+
* @param $column_name
|
605 |
+
* @param $user_id
|
606 |
+
* @return string
|
607 |
+
*/
|
608 |
+
public static function ct_manage_users_custom_column( $value, $column_name, $user_id ) {
|
609 |
+
|
610 |
+
if( 'apbct_status hidden' == $column_name ) {
|
611 |
+
|
612 |
+
$is_checked = get_user_meta( $user_id, 'ct_checked', true);
|
613 |
+
if( ! empty( $is_checked ) ) {
|
614 |
+
$is_checked = date( 'M d Y', strtotime( $is_checked ) );
|
615 |
+
$is_spam = get_user_meta( $user_id, 'ct_marked_as_spam', true );
|
616 |
+
if( ! empty( $is_spam ) ) {
|
617 |
+
$text = sprintf( esc_html__( 'SPAM. Checked %s.', 'cleantalk' ), $is_checked );
|
618 |
+
$value = '<span id="apbct_checked_spam">' . $text . '</span>';
|
619 |
+
} else {
|
620 |
+
$text = sprintf( esc_html__( 'Not spam. Checked %s.', 'cleantalk' ), $is_checked );
|
621 |
+
$value = '<span id="apbct_checked_not_spam">' . $text . '</span>';
|
622 |
+
}
|
623 |
+
} else {
|
624 |
+
$value = '<span id="apbct_not_checked">' . esc_html__( 'Not checked yet. Anti-Spam by CleanTalk.', 'cleantalk' ) . '</span>';
|
625 |
+
}
|
626 |
+
|
627 |
+
}
|
628 |
+
|
629 |
+
return $value;
|
630 |
+
|
631 |
+
}
|
632 |
+
|
633 |
}
|
@@ -1,5 +1,4 @@
|
|
1 |
-
<!
|
2 |
-
|
3 |
<html lang='en'>
|
4 |
<head>
|
5 |
<meta charset='utf-8' />
|
@@ -67,9 +66,10 @@
|
|
67 |
var ct_date = new Date;
|
68 |
|
69 |
function set_spamFireWallCookie(cookie_name, cookie_value) {
|
70 |
-
var date = new Date
|
|
|
71 |
date.setDate(date.getDate() + 30);
|
72 |
-
document.cookie = cookie_name + '=' + escape(cookie_value) + '; path=/; expires=' + date.toUTCString();
|
73 |
return null;
|
74 |
}
|
75 |
|
@@ -130,4 +130,4 @@
|
|
130 |
</script>
|
131 |
{DEBUG}
|
132 |
</body>
|
133 |
-
</html>
|
1 |
+
<!DOCTYPE html>
|
|
|
2 |
<html lang='en'>
|
3 |
<head>
|
4 |
<meta charset='utf-8' />
|
66 |
var ct_date = new Date;
|
67 |
|
68 |
function set_spamFireWallCookie(cookie_name, cookie_value) {
|
69 |
+
var date = new Date,
|
70 |
+
domain = document.location.host;
|
71 |
date.setDate(date.getDate() + 30);
|
72 |
+
document.cookie = cookie_name + '=' + escape(cookie_value) + '; path=/; domain=' + domain + '; expires=' + date.toUTCString() + '; samesite=lax';
|
73 |
return null;
|
74 |
}
|
75 |
|
130 |
</script>
|
131 |
{DEBUG}
|
132 |
</body>
|
133 |
+
</html>
|
@@ -1,2 +1,2 @@
|
|
1 |
-
var apbct_fingerprint=new Fingerprint({canvas:!0,ie_activex:!0,hasher:apbct_md5}).get();function apbct_cookie__get(n,i){var s={};return"string"==typeof(n=n||null)&&(n=n.split()),"none"==(i=i||["apbct_","ct_"])&&(i=null),"string"==typeof i&&(i=i.split()),document.cookie.split(";").forEach(function(o,e,c){var t=o.trim().split("=");n&&n.forEach(function(o,e,c){t[0]===o&&(s[t[0]]=t[1])}),i&&i.forEach(function(o,e,c){0===t[0].indexOf(o)&&(s[t[0]]=t[1])})}),s}function apbct_cookie__delete(n,i){var s=new Date(0);"string"==typeof(n=n||null)&&(n=n.split()),"none"==(i=i||["apbct_","ct_"])&&(i=null),"string"==typeof i&&(i=i.split()),document.cookie.split(";").forEach(function(o,e,c){var t=o.trim().split("=");n&&n.forEach(function(o,e,c){t[0]===o&&(document.cookie=t[0]+"=; path=/; expires="+s.toUTCString())}),i&&i.forEach(function(o,e,c){0===t[0].indexOf(o)&&(document.cookie=t[0]+"=; path=/; expires="+s.toUTCString())})})}jQuery(document).ready(function(){jQuery.ajax({type:"POST",url:apbctPublicAlt.ajax_url,data:{apbct_action:"get_sessions",apbct_secret:apbctPublicAlt.nonce,session_id:apbct_fingerprint},async:!0,success:function(o){if(console.log("success"),(o=JSON.parse(o)).result)for(cookie in console.log(o),o.cookies)console.log(cookie),document.cookie=cookie+"="+o.cookies[cookie]+"; path=/;";else console.log(o),console.log("APBCT SESSIONS GET ERROR")},error:function(o){console.log("err"),console.log(o)}}),window.onunload=function(){cookies=apbct_cookie__get(),console.log("leave"),jQuery.ajax({type:"POST",url:apbctPublicAlt.ajax_url,data:{apbct_action:"set_sessions",apbct_secret:apbctPublicAlt.nonce,session_id:apbct_fingerprint,data:cookies},async:!1,success:function(o){(o=JSON.parse(o)).result?(console.log("success"),console.log(o),apbct_cookie__delete(),console.log("cookie DELETED")):(console.log("APBCT SESSIONS GET ERROR"),console.log(o))},error:function(o){console.log("err"),console.log(o)}})}});
|
2 |
-
//# sourceMappingURL=apbct-public--alt.min.js.map
|
1 |
+
var apbct_fingerprint=new Fingerprint({canvas:!0,ie_activex:!0,hasher:apbct_md5}).get();function apbct_cookie__get(n,i){var s={};return"string"==typeof(n=n||null)&&(n=n.split()),"none"==(i=i||["apbct_","ct_"])&&(i=null),"string"==typeof i&&(i=i.split()),document.cookie.split(";").forEach(function(o,e,c){var t=o.trim().split("=");n&&n.forEach(function(o,e,c){t[0]===o&&(s[t[0]]=t[1])}),i&&i.forEach(function(o,e,c){0===t[0].indexOf(o)&&(s[t[0]]=t[1])})}),s}function apbct_cookie__delete(n,i){var s=new Date(0);"string"==typeof(n=n||null)&&(n=n.split()),"none"==(i=i||["apbct_","ct_"])&&(i=null),"string"==typeof i&&(i=i.split()),document.cookie.split(";").forEach(function(o,e,c){var t=o.trim().split("=");n&&n.forEach(function(o,e,c){t[0]===o&&(document.cookie=t[0]+"=; path=/; expires="+s.toUTCString()+"; samesite=lax")}),i&&i.forEach(function(o,e,c){0===t[0].indexOf(o)&&(document.cookie=t[0]+"=; path=/; expires="+s.toUTCString()+"; samesite=lax")})})}jQuery(document).ready(function(){jQuery.ajax({type:"POST",url:apbctPublicAlt.ajax_url,data:{apbct_action:"get_sessions",apbct_secret:apbctPublicAlt.nonce,session_id:apbct_fingerprint},async:!0,success:function(o){if(console.log("success"),(o=JSON.parse(o)).result)for(cookie in console.log(o),o.cookies)console.log(cookie),document.cookie=cookie+"="+o.cookies[cookie]+"; path=/; samesite=lax";else console.log(o),console.log("APBCT SESSIONS GET ERROR")},error:function(o){console.log("err"),console.log(o)}}),window.onunload=function(){cookies=apbct_cookie__get(),console.log("leave"),jQuery.ajax({type:"POST",url:apbctPublicAlt.ajax_url,data:{apbct_action:"set_sessions",apbct_secret:apbctPublicAlt.nonce,session_id:apbct_fingerprint,data:cookies},async:!1,success:function(o){(o=JSON.parse(o)).result?(console.log("success"),console.log(o),apbct_cookie__delete(),console.log("cookie DELETED")):(console.log("APBCT SESSIONS GET ERROR"),console.log(o))},error:function(o){console.log("err"),console.log(o)}})}});
|
2 |
+
//# sourceMappingURL=apbct-public--alt.min.js.map
|
@@ -1 +1 @@
|
|
1 |
-
{"version":3,"
|
1 |
+
{"version":3,"file":"apbct-public--alt.min.js","sources":["apbct-public--alt.js"],"sourcesContent":["// Fingerprint\r\nvar apbct_fingerprint = new Fingerprint({canvas: true, ie_activex: true, hasher: apbct_md5}).get();\r\n\r\n/* Function: Reuturns cookie with prefix */\r\nfunction apbct_cookie__get(names, prefixes){\r\n\tvar cookie = {};\r\n\tnames = names || null;\r\n\tif(typeof names == 'string') names = names.split();\r\n\tprefixes = prefixes || ['apbct_', 'ct_'];\r\n\tif(prefixes == 'none') prefixes = null;\r\n\tif(typeof prefixes == 'string') prefixes = prefixes.split();\r\n\tdocument.cookie.split(';').forEach(function(item, i, arr){\r\n\t\tvar curr = item.trim().split('=');\r\n\t\t// Detect by full cookie name\r\n\t\tif(names){\r\n\t\t\tnames.forEach(function(name, i, all){\r\n\t\t\t\tif(curr[0] === name)\r\n\t\t\t\t\tcookie[curr[0]] = (curr[1]);\r\n\t\t\t});\r\n\t\t}\r\n\t\t// Detect by name prefix\r\n\t\tif(prefixes){\r\n\t\t\tprefixes.forEach(function(prefix, i, all){\r\n\t\t\t\tif(curr[0].indexOf(prefix) === 0)\r\n\t\t\t\t\tcookie[curr[0]] = (curr[1]);\r\n\t\t\t});\r\n\t\t}\r\n\t});\r\n\treturn cookie;\r\n}\r\n\r\n/* Function: Deletes cookie with prefix */\r\nfunction apbct_cookie__delete(names, prefixes){\r\n\tvar date = new Date(0);\r\n\tnames = names || null;\r\n\tif(typeof names == 'string') names = names.split();\r\n\tprefixes = prefixes || ['apbct_', 'ct_'];\r\n\tif(prefixes == 'none') prefixes = null;\r\n\tif(typeof prefixes == 'string') prefixes = prefixes.split();\t\r\n\tdocument.cookie.split(';').forEach(function(item, i, arr){\r\n\t\tvar curr = item.trim().split('=');\r\n\t\t// Detect by full cookie name\r\n\t\tif(names){\r\n\t\t\tnames.forEach(function(name, i, all){\r\n\t\t\t\tif(curr[0] === name)\r\n\t\t\t\t\tdocument.cookie = curr[0] + \"=; path=/; expires=\" + date.toUTCString() + '; samesite=lax';\r\n\t\t\t});\r\n\t\t}\r\n\t\t// Detect by name prefix\r\n\t\tif(prefixes){\r\n\t\t\tprefixes.forEach(function(prefix, i, all){\r\n\t\t\t\tif(curr[0].indexOf(prefix) === 0)\r\n\t\t\t\t\tdocument.cookie = curr[0] + \"=; path=/; expires=\" + date.toUTCString() + '; samesite=lax';\r\n\t\t\t});\r\n\t\t}\r\n\t});\r\n}\r\n\r\njQuery(document).ready(function(){\r\n\t\r\n\t jQuery.ajax({\r\n\t\t type: \"POST\",\r\n\t\t url: apbctPublicAlt.ajax_url,\r\n\t\t data: {\r\n\t\t\t apbct_action: 'get_sessions',\r\n\t\t\t apbct_secret: apbctPublicAlt.nonce,\r\n\t\t\t session_id: apbct_fingerprint,\r\n\t\t },\r\n\t\t async: true,\r\n\t\t success: function(msg){\r\n\t\t\t console.log('success');\r\n\t\t\t msg = JSON.parse(msg);\r\n\t\t\t\r\n\t\t\t if(msg.result){\r\n\t\t\t\t console.log(msg);\r\n\t\t\t\t for(cookie in msg.cookies){\r\n\t\t\t\t\t console.log(cookie);\r\n//\t\t\t\t\t console.log(msg.cookies[cookie]);\r\n\t\t\t\t\t document.cookie = cookie + \"=\" + msg.cookies[cookie] + \"; path=/; samesite=lax\";\r\n\t\t\t\t };\r\n\t\t\t }else{\r\n\t\t\t\t console.log(msg);\r\n\t\t\t\t console.log('APBCT SESSIONS GET ERROR');\r\n\t\t\t }\r\n\t\t },\r\n\t\t error: function(err){\r\n\t\t\t console.log('err');\r\n\t\t\t console.log(err);\r\n\t\t }\r\n\t });\r\n\t\r\n\twindow.onunload = function(){\r\n\t\t\r\n\t\t// Getting ct_ and apbct_ cookies\r\n\t\t cookies = apbct_cookie__get();\r\n\t\t\r\n\t\tconsole.log('leave');\r\n\t\t\r\n\t\t jQuery.ajax({\r\n\t\t\ttype: \"POST\",\r\n\t\t\turl: apbctPublicAlt.ajax_url,\r\n\t\t\tdata: {\r\n\t\t\t\tapbct_action: 'set_sessions',\r\n\t\t\t\tapbct_secret: apbctPublicAlt.nonce,\r\n\t\t\t\tsession_id: apbct_fingerprint,\r\n\t\t\t\tdata: cookies,\r\n\t\t\t},\r\n\t\t\tasync: false,\r\n\t\t\tsuccess: function(msg){\r\n\t\t\t\tmsg = JSON.parse(msg);\r\n\t\t\t\tif(msg.result){\r\n\t\t\t\t\tconsole.log('success');\r\n\t\t\t\t\tconsole.log(msg);\r\n\t\t\t\t\t// Deleting ct_ and apbct_ cookies on success\r\n\t\t\t\t\tapbct_cookie__delete();\r\n\t\t\t\t\tconsole.log('cookie DELETED');\r\n\t\t\t\t}else{\r\n\t\t\t\t\tconsole.log('APBCT SESSIONS GET ERROR');\r\n\t\t\t\t\tconsole.log(msg);\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\terror: function(err){\r\n\t\t\t\tconsole.log('err');\r\n\t\t\t\tconsole.log(err);\r\n\t\t\t}\r\n\t\t}); \r\n\t}\r\n});"],"names":["apbct_fingerprint","Fingerprint","canvas","ie_activex","hasher","apbct_md5","get","apbct_cookie__get","names","prefixes","cookie","split","document","forEach","item","i","arr","curr","trim","name","all","prefix","indexOf","apbct_cookie__delete","date","Date","toUTCString","jQuery","ready","ajax","type","url","apbctPublicAlt","ajax_url","data","apbct_action","apbct_secret","nonce","session_id","async","success","msg","console","log","JSON","parse","result","cookies","error","err","window","onunload"],"mappings":"AACA,IAAIA,kBAAoB,IAAIC,YAAY,CAACC,QAAQ,EAAMC,YAAY,EAAMC,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eK,MAC7BC,WAAYtC,mBAEbuC,OAAO,EACPC,QAAS,SAASC,GAIjB,GAHAC,QAAQC,IAAI,YACZF,EAAMG,KAAKC,MAAMJ,IAEVK,OAEN,IAAIpC,UADJgC,QAAQC,IAAIF,GACEA,EAAIM,QACjBL,QAAQC,IAAIjC,QAEZE,SAASF,OAASA,OAAS,IAAM+B,EAAIM,QAAQrC,QAAU,8BAGxDgC,QAAQC,IAAIF,GACZC,QAAQC,IAAI,6BAGdK,MAAO,SAASC,GACfP,QAAQC,IAAI,OACZD,QAAQC,IAAIM,MAIfC,OAAOC,SAAW,WAGhBJ,QAAUxC,oBAEXmC,QAAQC,IAAI,SAEXhB,OAAOE,KAAK,CACZC,KAAM,OACNC,IAAKC,eAAeC,SACpBC,KAAM,CACLC,aAAc,eACdC,aAAcJ,eAAeK,MAC7BC,WAAYtC,kBACZkC,KAAMa,SAEPR,OAAO,EACPC,QAAS,SAASC,IACjBA,EAAMG,KAAKC,MAAMJ,IACVK,QACNJ,QAAQC,IAAI,WACZD,QAAQC,IAAIF,GAEZlB,uBACAmB,QAAQC,IAAI,oBAEZD,QAAQC,IAAI,4BACZD,QAAQC,IAAIF,KAGdO,MAAO,SAASC,GACfP,QAAQC,IAAI,OACZD,QAAQC,IAAIM"}
|
@@ -1,2 +1,2 @@
|
|
1 |
-
function apbct_js_keys__set_input_value(e,t,n,o){
|
2 |
//# sourceMappingURL=apbct-public.min.js.map
|
1 |
+
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_sendAJAXRequest(o,t,n){var i=t.callback||null,a=t.notJson||null,e=t.timeout||15e3,c=t.async||!0,n=n||null;"string"==typeof o?o=o+"&_ajax_nonce="+ctPublic._ajax_nonce+"&no_cache="+Math.random():(o._ajax_nonce=ctPublic._ajax_nonce,o.no_cache=Math.random()),jQuery.ajax({type:"POST",url:ctPublic._ajax_url,data:o,async:c,success:function(e){a||(e=JSON.parse(e)),e.error||i&&i(e,o,t,n)},error:function(e,t,n){console.log("APBCT_AJAX_ERROR"),console.log(o),console.log(e),console.log(t),console.log(n)},timeout:e})}!function(){var e=new Date,t=(new Date).getTime(),n=!0,o=[],i=0;function c(e,t){document.cookie=e+"="+encodeURIComponent(t)+"; path=/; samesite=lax"}function a(e,t,n){"function"==typeof window.addEventListener?e.addEventListener(t,n):e.attachEvent(t,n)}function u(e,t,n){"function"==typeof window.removeEventListener?e.removeEventListener(t,n):e.detachEvent(t,n)}c("ct_ps_timestamp",Math.floor((new Date).getTime()/1e3)),c("ct_fkp_timestamp","0"),c("ct_pointer_data","0"),c("ct_timezone","0"),setTimeout(function(){c("ct_timezone",e.getTimezoneOffset()/60*-1)},1e3);var s=function(){c("ct_fkp_timestamp",Math.floor((new Date).getTime()/1e3)),u(window,"mousedown",s),u(window,"keydown",s)},r=setInterval(function(){n=!0},150),l=setInterval(function(){c("ct_pointer_data",JSON.stringify(o))},1200),m=function(e){!0===n&&(o.push([Math.round(e.clientY),Math.round(e.clientX),Math.round((new Date).getTime()-t)]),n=!1,50<=++i&&(u(window,"mousemove",m),clearInterval(r),clearInterval(l)))};a(window,"mousemove",m),a(window,"mousedown",s),a(window,"keydown",s),a(window,"DOMContentLoaded",function(){c("apbct_visible_fields",0),c("apbct_visible_fields_count",0),setTimeout(function(){for(var e=0;e<document.forms.length;e++){var t=document.forms[e];t.classList.contains("slp_search_form")||(t.onsubmit_prev=t.onsubmit,t.onsubmit=function(e){var t=[],o="",n=0,i=[];for(var a in this.elements)isNaN(+a)||(t[a]=this.elements[a]);(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")&&""!==e.value&&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")}),c("apbct_visible_fields",o=o.trim()),c("apbct_visible_fields_count",n),e.target.onsubmit_prev instanceof Function&&setTimeout(function(){e.target.onsubmit_prev.call(e.target,e)},500)})}},1e3)})}(),"undefined"!=typeof jQuery&&jQuery(document).ajaxComplete(function(e,t,n){var o;!t.responseText||-1===t.responseText.indexOf('"apbct')||void 0!==(o=JSON.parse(t.responseText)).apbct&&(o=o.apbct).blocked&&(alert(o.comment),1==+o.stop_script&&window.stop())});
|
2 |
//# sourceMappingURL=apbct-public.min.js.map
|
@@ -1 +1 @@
|
|
1 |
-
{"version":3,"sources":["apbct-public.js"],"names":["apbct_js_keys__set_input_value","result","data","params","obj","document","getElementById","input_name","ct_input_value","value","replace","js_key","ct_date","Date","ctTimeMs","getTime","ctMouseEventTimerFlag","ctMouseData","ctMouseDataCounter","ctSetCookieSec","c_name","cookie","encodeURIComponent","apbct_attach_event_handler","elem","event","callback","window","addEventListener","attachEvent","apbct_remove_event_handler","removeEventListener","detachEvent","Math","floor","setTimeout","getTimezoneOffset","ctFunctionFirstKey","ctMouseReadInterval","setInterval","ctMouseWriteDataInterval","JSON","stringify","ctFunctionMouseMove","push","round","clientY","clientX","clearInterval","i","forms","length","form","classList","contains","onsubmit_prev","onsubmit","elements","key","this","isNaN","visible_fields_count","filter","getComputedStyle","display","visibility","opacity","getAttribute","forEach","el","j","els","visible_fields","trim","target","Function","call","jQuery","apbct_sendAJAXRequest","notJson","timeout","_ajax_nonce","ctPublic","ajax","type","url","_ajax_url","success","parse","error","jqXHR","textStatus","errorThrown","console","log","ajaxComplete","xhr","settings","responseText","indexOf","response","apbct","blocked","alert","comment","stop_script","stop"],"mappings":"AAkKA,SAASA,+BAA+BC,EAAQC,EAAMC,EAAQC,GAC7D,GAAmD,OAA/CC,SAASC,eAAeH,EAAOI,YAAsB,CACxD,IAAIC,EAAiBH,SAASC,eAAe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AAwB,CAiBjC,SAASC,sBAAsB5E,EAAMC,EAAQC,GAG5C,IAAIsB,EAAWvB,EAAOuB,UAAY,KAC9BqD,EAAU5E,EAAO4E,SAAW,KAC5BC,EAAU7E,EAAO6E,SAAW,KAC5B5E,EAAMA,GAAO,KAEjBF,EAAK+E,YAAcC,SAASD,YAE5BJ,OAAOM,KAAK,CACXC,KAAM,OACNC,IAAKH,SAASI,UACdpF,KAAMA,EACNqF,QAAS,SAAUtF,GACb8E,IAAS9E,EAASwC,KAAK+C,MAAMvF,IAC9BA,EAAOwF,OAGN/D,GACHA,EAASzB,EAAQC,EAAMC,EAAQC,IAGlCqF,MAAO,SAAUC,EAAOC,EAAYC,GACnCC,QAAQC,IAAI,oBACZD,QAAQC,IAAI5F,GACZ2F,QAAQC,IAAIJ,GACZG,QAAQC,IAAIH,GACZE,QAAQC,IAAIF,IAEbZ,QAASA,IA5CXH,OAAOxE,UAAU0F,aAAa,SAAUtE,EAAOuE,EAAKC,GACnD,GAAID,EAAIE,eAAwD,IAAxCF,EAAIE,aAAaC,QAAQ,UAAkB,CAClE,IAAIC,EAAW3D,KAAK+C,MAAMQ,EAAIE,mBACA,IAAnBE,EAASC,QACnBD,EAAWA,EAASC,OACPC,UACZC,MAAMH,EAASI,SACa,IAAxBJ,EAASK,aACZ9E,OAAO+E","file":"apbct-public.min.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 ctSetCookieSec(c_name, value) {\n\t\tdocument.cookie = c_name + \"=\" + encodeURIComponent(value) + \"; path=/\";\n\t}\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\tctSetCookieSec(\"ct_ps_timestamp\", Math.floor(new Date().getTime()/1000));\n\tctSetCookieSec(\"ct_fkp_timestamp\", \"0\");\n\tctSetCookieSec(\"ct_pointer_data\", \"0\");\n\tctSetCookieSec(\"ct_timezone\", \"0\");\n\n\tsetTimeout(function(){\n\t\tctSetCookieSec(\"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\tctSetCookieSec(\"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\tctSetCookieSec(\"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\t\tctSetCookieSec(\"apbct_visible_fields\", 0);\n\t\tctSetCookieSec(\"apbct_visible_fields_count\", 0);\n\t\tsetTimeout(function(){\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 StoreLocatorPlus form\n\t\t\t\tif (form.classList.contains('slp_search_form'))\n\t\t\t\t\tcontinue;\n\t\t\t\t\n\t\t\t\tform.onsubmit_prev = form.onsubmit;\n\t\t\t\tform.onsubmit = function(event){\n\n\t\t\t\t\t// Get only fields\n\t\t\t\t\tvar elements = [];\n\t\t\t\t\tfor(var key in this.elements){\n\t\t\t\t\t\tif(!isNaN(+key))\n\t\t\t\t\t\t\telements[key] = this.elements[key];\n\t\t\t\t\t}\n\n\t\t\t\t\t// Filter fields\n\t\t\t\t\telements = elements.filter(function(elem){\n\n\t\t\t\t\t\tvar pass = true;\n\n\t\t\t\t\t\t// Filter fields\n\t\t\t\t\t\tif( getComputedStyle(elem).display === \"none\" || // hidden\n\t\t\t\t\t\t\tgetComputedStyle(elem).visibility === \"hidden\" || // hidden\n\t\t\t\t\t\t\tgetComputedStyle(elem).opacity === \"0\" || // hidden\n\t\t\t\t\t\t\telem.getAttribute(\"type\") === \"hidden\" || // type == hidden\n\t\t\t\t\t\t\telem.getAttribute(\"type\") === \"submit\" || // type == submit\n\t\t\t\t\t\t\telem.value === \"\" || // empty value\n\t\t\t\t\t\t\telem.getAttribute('name') === null\n\t\t\t\t\t\t){\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Filter elements with same names for type == radio\n\t\t\t\t\t\tif(elem.getAttribute(\"type\") === \"radio\"){\n\t\t\t\t\t\t\telements.forEach(function(el, j, els){\n\t\t\t\t\t\t\t\tif(elem.getAttribute('name') === el.getAttribute('name')){\n\t\t\t\t\t\t\t\t\tpass = false;\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t});\n\n\t\t\t\t\t// Visible fields count\n\t\t\t\t\tvar visible_fields_count = elements.length;\n\n\t\t\t\t\t// Visible fields\n\t\t\t\t\tvar visible_fields = '';\n\t\t\t\t\telements.forEach(function(elem, i, elements){\n\t\t\t\t\t\tvisible_fields += \" \" + elem.getAttribute(\"name\");\n\t\t\t\t\t});\n\t\t\t\t\tvisible_fields = visible_fields.trim();\n\n\t\t\t\t\tctSetCookieSec(\"apbct_visible_fields\", visible_fields);\n\t\t\t\t\tctSetCookieSec(\"apbct_visible_fields_count\", visible_fields_count);\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\t\t}, 1000);\n\t}\n\tapbct_attach_event_handler(window, \"DOMContentLoaded\", apbct_ready);\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}\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\talert(response.comment);\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\n\tfunction apbct_sendAJAXRequest(data, params, obj) {\n\n\t\t// Default params\n\t\tvar callback = params.callback || null;\n\t\tvar notJson = params.notJson || null;\n\t\tvar timeout = params.timeout || 15000;\n\t\tvar obj = obj || null;\n\n\t\tdata._ajax_nonce = ctPublic._ajax_nonce;\n\n\t\tjQuery.ajax({\n\t\t\ttype: \"POST\",\n\t\t\turl: ctPublic._ajax_url,\n\t\t\tdata: data,\n\t\t\tsuccess: function (result) {\n\t\t\t\tif (!notJson) result = JSON.parse(result);\n\t\t\t\tif (result.error) {\n\n\t\t\t\t} else {\n\t\t\t\t\tif (callback)\n\t\t\t\t\t\tcallback(result, data, params, obj);\n\t\t\t\t}\n\t\t\t},\n\t\t\terror: function (jqXHR, textStatus, errorThrown) {\n\t\t\t\tconsole.log('APBCT_AJAX_ERROR');\n\t\t\t\tconsole.log(data);\n\t\t\t\tconsole.log(jqXHR);\n\t\t\t\tconsole.log(textStatus);\n\t\t\t\tconsole.log(errorThrown);\n\t\t\t},\n\t\t\ttimeout: timeout\n\t\t});\n\t}\n}"]}
|
1 |
+
{"version":3,"file":"apbct-public.min.js","sources":["apbct-public.js"],"sourcesContent":["(function() {\r\n\r\n\tvar ct_date = new Date(),\r\n\t\tctTimeMs = new Date().getTime(),\r\n\t\tctMouseEventTimerFlag = true, //Reading interval flag\r\n\t\tctMouseData = [],\r\n\t\tctMouseDataCounter = 0;\r\n\r\n\tfunction ctSetCookieSec(c_name, value) {\r\n\t\tdocument.cookie = c_name + \"=\" + encodeURIComponent(value) + \"; path=/; samesite=lax\";\r\n\t}\r\n\r\n\tfunction apbct_attach_event_handler(elem, event, callback){\r\n\t\tif(typeof window.addEventListener === \"function\") elem.addEventListener(event, callback);\r\n\t\telse elem.attachEvent(event, callback);\r\n\t}\r\n\r\n\tfunction apbct_remove_event_handler(elem, event, callback){\r\n\t\tif(typeof window.removeEventListener === \"function\") elem.removeEventListener(event, callback);\r\n\t\telse elem.detachEvent(event, callback);\r\n\t}\r\n\r\n\tctSetCookieSec(\"ct_ps_timestamp\", Math.floor(new Date().getTime()/1000));\r\n\tctSetCookieSec(\"ct_fkp_timestamp\", \"0\");\r\n\tctSetCookieSec(\"ct_pointer_data\", \"0\");\r\n\tctSetCookieSec(\"ct_timezone\", \"0\");\r\n\r\n\tsetTimeout(function(){\r\n\t\tctSetCookieSec(\"ct_timezone\", ct_date.getTimezoneOffset()/60*(-1));\r\n\t},1000);\r\n\r\n\t//Writing first key press timestamp\r\n\tvar ctFunctionFirstKey = function output(event){\r\n\t\tvar KeyTimestamp = Math.floor(new Date().getTime()/1000);\r\n\t\tctSetCookieSec(\"ct_fkp_timestamp\", KeyTimestamp);\r\n\t\tctKeyStopStopListening();\r\n\t};\r\n\r\n\t//Reading interval\r\n\tvar ctMouseReadInterval = setInterval(function(){\r\n\t\tctMouseEventTimerFlag = true;\r\n\t}, 150);\r\n\r\n\t//Writting interval\r\n\tvar ctMouseWriteDataInterval = setInterval(function(){\r\n\t\tctSetCookieSec(\"ct_pointer_data\", JSON.stringify(ctMouseData));\r\n\t}, 1200);\r\n\r\n\t//Logging mouse position each 150 ms\r\n\tvar ctFunctionMouseMove = function output(event){\r\n\t\tif(ctMouseEventTimerFlag === true){\r\n\r\n\t\t\tctMouseData.push([\r\n\t\t\t\tMath.round(event.clientY),\r\n\t\t\t\tMath.round(event.clientX),\r\n\t\t\t\tMath.round(new Date().getTime() - ctTimeMs)\r\n\t\t\t]);\r\n\r\n\t\t\tctMouseDataCounter++;\r\n\t\t\tctMouseEventTimerFlag = false;\r\n\t\t\tif(ctMouseDataCounter >= 50){\r\n\t\t\t\tctMouseStopData();\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\r\n\t//Stop mouse observing function\r\n\tfunction ctMouseStopData(){\r\n\t\tapbct_remove_event_handler(window, \"mousemove\", ctFunctionMouseMove);\r\n\t\tclearInterval(ctMouseReadInterval);\r\n\t\tclearInterval(ctMouseWriteDataInterval);\r\n\t}\r\n\r\n\t//Stop key listening function\r\n\tfunction ctKeyStopStopListening(){\r\n\t\tapbct_remove_event_handler(window, \"mousedown\", ctFunctionFirstKey);\r\n\t\tapbct_remove_event_handler(window, \"keydown\", ctFunctionFirstKey);\r\n\t}\r\n\r\n\tapbct_attach_event_handler(window, \"mousemove\", ctFunctionMouseMove);\r\n\tapbct_attach_event_handler(window, \"mousedown\", ctFunctionFirstKey);\r\n\tapbct_attach_event_handler(window, \"keydown\", ctFunctionFirstKey);\r\n\r\n\t// Ready function\r\n\tfunction apbct_ready(){\r\n\r\n\t\tctSetCookieSec(\"apbct_visible_fields\", 0);\r\n\t\tctSetCookieSec(\"apbct_visible_fields_count\", 0);\r\n\r\n\t\tsetTimeout(function(){\r\n\r\n\t\t\tfor(var i = 0; i < document.forms.length; i++){\r\n\t\t\t\tvar form = document.forms[i];\r\n\r\n\t\t\t\t//Exclusion for StoreLocatorPlus form\r\n\t\t\t\tif (form.classList.contains('slp_search_form'))\r\n\t\t\t\t\tcontinue;\r\n\r\n\t\t\t\tform.onsubmit_prev = form.onsubmit;\r\n\t\t\t\tform.onsubmit = function(event){\r\n\r\n\t\t\t\t\t// Get only fields\r\n\t\t\t\t\tvar inputs = [],\r\n\t\t\t\t\t\tinputs_visible = '',\r\n\t\t\t\t\t\tinputs_visible_count = 0,\r\n\t\t\t\t\t\tinputs_with_duplicate_names = [];\r\n\r\n\t\t\t\t\tfor(var key in this.elements){\r\n\t\t\t\t\t\tif(!isNaN(+key))\r\n\t\t\t\t\t\t\tinputs[key] = this.elements[key];\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t// Filter fields\r\n\t\t\t\t\tinputs = inputs.filter(function(elem){\r\n\r\n\t\t\t\t\t\t// Filter fields\r\n\t\t\t\t\t\tif( getComputedStyle(elem).display === \"none\" || // hidden\r\n\t\t\t\t\t\t\tgetComputedStyle(elem).visibility === \"hidden\" || // hidden\r\n\t\t\t\t\t\t\tgetComputedStyle(elem).opacity === \"0\" || // hidden\r\n\t\t\t\t\t\t\telem.getAttribute(\"type\") === \"hidden\" || // type == hidden\r\n\t\t\t\t\t\t\telem.getAttribute(\"type\") === \"submit\" || // type == submit\r\n\t\t\t\t\t\t\telem.value === \"\" || // empty value\r\n\t\t\t\t\t\t\telem.getAttribute('name') === null ||\r\n\t\t\t\t\t\t\tinputs_with_duplicate_names.indexOf( elem.getAttribute('name') ) !== -1 // name already added\r\n\t\t\t\t\t\t){\r\n\t\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t// Visible fields count\r\n\t\t\t\t\t\tinputs_visible_count++;\r\n\r\n\t\t\t\t\t\t// Filter inputs with same names for type == radio\r\n\t\t\t\t\t\tif( -1 !== ['radio', 'checkbox'].indexOf( elem.getAttribute(\"type\") )){\r\n\t\t\t\t\t\t\tinputs_with_duplicate_names.push( elem.getAttribute('name') );\r\n\t\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t});\r\n\r\n\t\t\t\t\t// Visible fields\r\n\t\t\t\t\tinputs.forEach(function(elem, i, elements){\r\n\t\t\t\t\t\tinputs_visible += \" \" + elem.getAttribute(\"name\");\r\n\t\t\t\t\t});\r\n\t\t\t\t\tinputs_visible = inputs_visible.trim();\r\n\r\n\t\t\t\t\tctSetCookieSec(\"apbct_visible_fields\", inputs_visible);\r\n\t\t\t\t\tctSetCookieSec(\"apbct_visible_fields_count\", inputs_visible_count);\r\n\r\n\t\t\t\t\t// Call previous submit action\r\n\t\t\t\t\tif(event.target.onsubmit_prev instanceof Function){\r\n\t\t\t\t\t\tsetTimeout(function(){\r\n\t\t\t\t\t\t\tevent.target.onsubmit_prev.call(event.target, event);\r\n\t\t\t\t\t\t}, 500);\r\n\t\t\t\t\t}\r\n\t\t\t\t};\r\n\t\t\t}\r\n\t\t}, 1000);\r\n\t}\r\n\tapbct_attach_event_handler(window, \"DOMContentLoaded\", apbct_ready);\r\n\r\n}());\r\n\r\nfunction apbct_js_keys__set_input_value(result, data, params, obj){\r\n\tif (document.getElementById(params.input_name) !== null) {\r\n\t\tvar ct_input_value = document.getElementById(params.input_name).value;\r\n\t\tdocument.getElementById(params.input_name).value = document.getElementById(params.input_name).value.replace(ct_input_value, result.js_key);\r\n\t}\r\n}\r\n\r\nif(typeof jQuery !== 'undefined') {\r\n\r\n\t// Capturing responses and output block message for unknown AJAX forms\r\n\tjQuery(document).ajaxComplete(function (event, xhr, settings) {\r\n\t\tif (xhr.responseText && xhr.responseText.indexOf('\"apbct') !== -1) {\r\n\t\t\tvar response = JSON.parse(xhr.responseText);\r\n\t\t\tif (typeof response.apbct !== 'undefined') {\r\n\t\t\t\tresponse = response.apbct;\r\n\t\t\t\tif (response.blocked) {\r\n\t\t\t\t\talert(response.comment);\r\n\t\t\t\t\tif(+response.stop_script == 1)\r\n\t\t\t\t\t\twindow.stop();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t});\r\n\r\n\tfunction apbct_sendAJAXRequest(data, params, obj) {\r\n\r\n\t\t// Default params\r\n\t\tvar callback = params.callback || null;\r\n\t\tvar notJson = params.notJson || null;\r\n\t\tvar timeout = params.timeout || 15000;\r\n\t\tvar async = params.async || true;\r\n\t\tvar obj = obj || null;\r\n\r\n\t\tif(typeof (data) === 'string') {\r\n\t\t\tdata = data + '&_ajax_nonce=' + ctPublic._ajax_nonce + '&no_cache=' + Math.random();\r\n\t\t}else{\r\n\t\t\tdata._ajax_nonce = ctPublic._ajax_nonce;\r\n\t\t\tdata.no_cache = Math.random();\r\n\t\t}\r\n\r\n\t\tjQuery.ajax({\r\n\t\t\ttype: \"POST\",\r\n\t\t\turl: ctPublic._ajax_url,\r\n\t\t\tdata: data,\r\n\t\t\tasync: async,\r\n\t\t\tsuccess: function (result) {\r\n\t\t\t\tif (!notJson) result = JSON.parse(result);\r\n\t\t\t\tif (result.error) {\r\n\r\n\t\t\t\t} else {\r\n\t\t\t\t\tif (callback)\r\n\t\t\t\t\t\tcallback(result, data, params, obj);\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\terror: function (jqXHR, textStatus, errorThrown) {\r\n\t\t\t\tconsole.log('APBCT_AJAX_ERROR');\r\n\t\t\t\tconsole.log(data);\r\n\t\t\t\tconsole.log(jqXHR);\r\n\t\t\t\tconsole.log(textStatus);\r\n\t\t\t\tconsole.log(errorThrown);\r\n\t\t\t},\r\n\t\t\ttimeout: timeout\r\n\t\t});\r\n\t}\r\n}"],"names":["apbct_js_keys__set_input_value","result","data","params","obj","ct_input_value","document","getElementById","input_name","value","replace","js_key","apbct_sendAJAXRequest","callback","notJson","timeout","async","ctPublic","_ajax_nonce","Math","random","no_cache","jQuery","ajax","type","url","_ajax_url","success","JSON","parse","error","jqXHR","textStatus","errorThrown","console","log","ct_date","Date","ctTimeMs","getTime","ctMouseEventTimerFlag","ctMouseData","ctMouseDataCounter","ctSetCookieSec","c_name","cookie","encodeURIComponent","apbct_attach_event_handler","elem","event","window","addEventListener","attachEvent","apbct_remove_event_handler","removeEventListener","detachEvent","floor","setTimeout","getTimezoneOffset","ctFunctionFirstKey","ctMouseReadInterval","setInterval","ctMouseWriteDataInterval","stringify","ctFunctionMouseMove","push","round","clientY","clientX","clearInterval","i","forms","length","form","classList","contains","onsubmit_prev","onsubmit","inputs","inputs_visible","inputs_visible_count","inputs_with_duplicate_names","key","this","elements","isNaN","filter","getComputedStyle","display","visibility","opacity","getAttribute","indexOf","forEach","trim","target","Function","call","ajaxComplete","xhr","settings","response","responseText","apbct","blocked","alert","comment","stop_script","stop"],"mappings":"AAmKA,SAASA,+BAA+BC,EAAQC,EAAMC,EAA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/B,IAAI,IAAIC,KAAOC,KAAKC,SACfC,OAAOH,KACVJ,EAAOI,GAAOC,KAAKC,SAASF,KAI9BJ,EAASA,EAAOQ,OAAO,SAAStC,GAG/B,MAA0C,SAAtCuC,iBAAiBvC,GAAMwC,SACY,WAAtCD,iBAAiBvC,GAAMyC,YACe,MAAtCF,iBAAiBvC,GAAM0C,SACe,WAAtC1C,EAAK2C,aAAa,SACoB,WAAtC3C,EAAK2C,aAAa,SACoB,KAAtC3C,EAAKvC,OACiC,OAAtCuC,EAAK2C,aAAa,UACoD,IAAtEV,EAA4BW,QAAS5C,EAAK2C,aAAa,WAMxDX,KAGK,IAAM,CAAC,QAAS,YAAYY,QAAS5C,EAAK2C,aAAa,WAC3DV,EAA4BhB,KAAMjB,EAAK2C,aAAa,UAC7C,OAOFE,QAAQ,SAAS7C,EAAMsB,EAAGc,GAChCL,GAAkB,IAAM/B,EAAK2C,aAAa,UAI3ChD,EAAe,uBAFfoC,EAAiBA,EAAee,QAGhCnD,EAAe,6BAA8BqC,GAG1C/B,EAAM8C,OAAOnB,yBAAyBoB,UACxCvC,WAAW,WACVR,EAAM8C,OAAOnB,cAAcqB,KAAKhD,EAAM8C,OAAQ9C,IAC5C,SAIJ,OA7JL,GA0KqB,oBAAX3B,QAGTA,OAAOhB,UAAU4F,aAAa,SAAUjD,EAAOkD,EAAKC,GACnD,IACKC,GADDF,EAAIG,eAAwD,IAAxCH,EAAIG,aAAaV,QAAQ,gBAElB,KAD1BS,EAAWzE,KAAKC,MAAMsE,EAAIG,eACVC,QACnBF,EAAWA,EAASE,OACPC,UACZC,MAAMJ,EAASK,SACa,IAAxBL,EAASM,aACZzD,OAAO0D"}
|
@@ -1 +1,2 @@
|
|
1 |
-
function apbct_banner_check(){var i=setInterval(function(){apbct_sendAJAX({action:"apbct_settings__check_renew_banner"},{callback:function(e,t,n,c){e.close_renew_banner&&(jQuery("#apbct_renew_notice").length&&jQuery("#apbct_renew_notice").hide("slow"),jQuery("#apbct_trial_notice").length&&jQuery("#apbct_trial_notice").hide("slow"),clearInterval(i))}})},6e4)}function apbct_get_elems(e){for(var t,n=0,c=(e=e.split(",")).length;n<c;n++)t=jQuery("#"+e[n]),e[n]=0===t.length?jQuery("."+e[n]):t;return e}function apbct_get_elems__native(e){"string"==typeof e&&(e=e.split(","));var i=[];return e.forEach(function(e,t,n){var c=document.getElementById(e);if(null===c){if(null!==(c=document.getElementsByClassName(e))&&0!==c.length)for(key in c)0<=+key&&i.push(c[key])}else i.push(c[key])}),i}function apbct_show_hide_elem(e){for(var t=0,n=(e=apbct_get_elems(e)).length;t<n;t++)e[t].each(function(e,t){var n=(t=jQuery(t)).next("label")||t.prev("label")||null;t.is(":visible")?(t.hide(),n&&n.hide()):(t.show(),n&&n.show())})}function apbctSettingsDependencies(e,a){a=+a||null,apbct_get_elems__native(e).forEach(function(e,t,n){function c(){console.log(e),e.setAttribute("disabled","disabled")}function i(){e.removeAttribute("disabled")}
|
|
1 |
+
function apbct_banner_check(){var i=setInterval(function(){apbct_sendAJAX({action:"apbct_settings__check_renew_banner"},{callback:function(e,t,n,c){e.close_renew_banner&&(jQuery("#apbct_renew_notice").length&&jQuery("#apbct_renew_notice").hide("slow"),jQuery("#apbct_trial_notice").length&&jQuery("#apbct_trial_notice").hide("slow"),clearInterval(i))}})},6e4)}function apbct_get_elems(e){for(var t,n=0,c=(e=e.split(",")).length;n<c;n++)t=jQuery("#"+e[n]),e[n]=0===t.length?jQuery("."+e[n]):t;return e}function apbct_get_elems__native(e){"string"==typeof e&&(e=e.split(","));var i=[];return e.forEach(function(e,t,n){var c=document.getElementById(e);if(null===c){if(null!==(c=document.getElementsByClassName(e))&&0!==c.length)for(key in c)0<=+key&&i.push(c[key])}else i.push(c[key])}),i}function apbct_show_hide_elem(e){for(var t=0,n=(e=apbct_get_elems(e)).length;t<n;t++)e[t].each(function(e,t){var n=(t=jQuery(t)).next("label")||t.prev("label")||null;t.is(":visible")?(t.hide(),n&&n.hide()):(t.show(),n&&n.show())})}function apbctSettingsDependencies(e,a){a=+a||null,apbct_get_elems__native(e).forEach(function(e,t,n){function c(){console.log(e),e.setAttribute("disabled","disabled")}function i(){e.removeAttribute("disabled")}null!==a?1===a?i():c():null===e.getAttribute("disabled")?c():i()})}function apbct_settings__showDescription(e,t){var i=function(e){void 0!==e&&(0!=jQuery(e.target).parent(".apbct_long_desc").length&&!jQuery(e.target).hasClass("apbct_long_desc__cancel")||jQuery(e.target).hasClass("apbct_long_description__show"))||(jQuery(".apbct_long_desc").remove(),jQuery(document).off("click",i))};i(),e.after("<div id='apbct_long_desc__"+t+"' class='apbct_long_desc'></div>");var n=jQuery("#apbct_long_desc__"+t);n.append("<i class='icon-spin1 animate-spin'></i>").append("<div class='apbct_long_desc__angle'></div>").css({top:e.position().top-5,left:e.position().left+25}),apbct_sendAJAX({action:"apbct_settings__get_description",setting_id:t},{spinner:n.children("img"),callback:function(e,t,n,c){c.empty().append("<div class='apbct_long_desc__angle'></div>").append("<i class='apbct_long_desc__cancel icon-cancel'></i>").append("<h3 class='apbct_long_desc__title'>"+e.title+"</h3>").append("<p>"+e.desc+"</p>"),jQuery(document).on("click",i)}},n)}jQuery(document).ready(function(){"rtl"===getComputedStyle(document.getElementsByClassName("apbct_settings-title")[0]).direction&&jQuery(".apbct_switchers").css("text-align","right"),jQuery("#apbct_showApiKey").on("click",function(){jQuery(".apbct_setting---apikey").val(jQuery(".apbct_setting---apikey").attr("key")),jQuery(".apbct_setting---apikey+div").show(),jQuery(this).fadeOut(300)});var e=new Date;jQuery("#ct_admin_timezone").val(e.getTimezoneOffset()/60*-1),jQuery("#apbct_gdpr_open_modal").on("click",function(){jQuery("#gdpr_dialog").dialog({modal:!0,show:!0,position:{my:"center",at:"center",of:window},width:+jQuery("#wpbody").width()/100*70,height:"auto",title:"GDPR compliance",draggable:!1,resizable:!1,closeText:"Close"})}),jQuery(document).on("click",".apbct_settings-long_description---show",function(){self=jQuery(this),apbct_settings__showDescription(self,self.attr("setting"))}),(jQuery("#apbct_renew_notice").length||jQuery("#apbct_trial_notice").length)&&apbct_banner_check()});
|
2 |
+
//# sourceMappingURL=cleantalk-admin-settings-page.min.js.map
|
@@ -1 +1 @@
|
|
1 |
-
{"version":3,"sources":["cleantalk-admin-settings-page.js"],"names":["apbct_banner_check","bannerChecker","setInterval","apbct_sendAJAX","action","callback","result","data","params","obj","close_renew_banner","jQuery","length","hide","clearInterval","apbct_get_elems","elems","tmp","i","len","split","apbct_get_elems__native","out","forEach","elem","arr","document","getElementById","getElementsByClassName","key","push","apbct_show_hide_elem","each","label","next","prev","is","show","apbctSettingsDependencies","ids","enable","do_disable","console","log","setAttribute","do_enable","removeAttribute","getAttribute","apbct_settings__showDescription","setting_id","remove_desc_func","e","target","parent","hasClass","remove","off","after","append","css","top","position","left","spinner","children","empty","title","desc","on","ready","val","attr","this","fadeOut","d","Date","getTimezoneOffset","dialog","modal","my","at","of","window","width","height","draggable","resizable","closeText","self"],"mappings":"
|
1 |
+
{"version":3,"sources":["cleantalk-admin-settings-page.js"],"names":["apbct_banner_check","bannerChecker","setInterval","apbct_sendAJAX","action","callback","result","data","params","obj","close_renew_banner","jQuery","length","hide","clearInterval","apbct_get_elems","elems","tmp","i","len","split","apbct_get_elems__native","out","forEach","elem","arr","document","getElementById","getElementsByClassName","key","push","apbct_show_hide_elem","each","label","next","prev","is","show","apbctSettingsDependencies","ids","enable","do_disable","console","log","setAttribute","do_enable","removeAttribute","getAttribute","apbct_settings__showDescription","setting_id","remove_desc_func","e","target","parent","hasClass","remove","off","after","append","css","top","position","left","spinner","children","empty","title","desc","on","ready","getComputedStyle","direction","val","attr","this","fadeOut","d","Date","getTimezoneOffset","dialog","modal","my","at","of","window","width","height","draggable","resizable","closeText","self"],"mappings":"AA6CA,SAASA,qBACR,IAAIC,EAAgBC,YAAa,WAChCC,eACC,CAACC,OAAQ,sCACT,CACCC,SAAU,SAASC,EAAQC,EAAMC,EAAQC,GACpCH,EAAOI,qBACNC,OAAO,uBAAuBC,QACjCD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AC5CzD,OAAO,gBAAgBoE,OAAO,CAC7BC,OAAM,EACN3C,MAAM,EACNwB,SAAU,CAAEoB,GAAI,SAAUC,GAAI,SAAUC,GAAIC,QAC5CC,OAAS1E,OAAO,WAAW0E,QAAU,IAAM,GAC3CC,OAAQ,OACRpB,MAAO,kBACPqB,WAAW,EACXC,WAAW,EACXC,UAAW,YAIb9E,OAAOe,UAAU0C,GAAG,QAAS,0CAA2C,WACvEsB,KAAO/E,OAAO+D,MACd1B,gCAAgC0C,KAAMA,KAAKjB,KAAK,eAG7C9D,OAAO,uBAAuBC,QAAUD,OAAO,uBAAuBC,SACzEZ","file":"cleantalk-admin-settings-page.min.js","sourcesContent":["jQuery(document).ready(function(){\n\n\t// Crunch for Right to Left direction languages\n\tif(getComputedStyle(document.getElementsByClassName('apbct_settings-title')[0]).direction === 'rtl'){\n\t\tjQuery('.apbct_switchers').css('text-align', 'right');\n\t}\n\n\t// Show/Hide access key\n jQuery('#apbct_showApiKey').on('click', function(){\n jQuery('.apbct_setting---apikey').val(jQuery('.apbct_setting---apikey').attr('key'));\n jQuery('.apbct_setting---apikey+div').show();\n jQuery(this).fadeOut(300);\n });\n\n\tvar d = new Date();\n\tjQuery('#ct_admin_timezone').val(d.getTimezoneOffset()/60*(-1));\n\t\n\t// GDPR modal window\n\tjQuery('#apbct_gdpr_open_modal').on('click', function(){\n\t\tjQuery('#gdpr_dialog').dialog({\n\t\t\tmodal:true, \n\t\t\tshow: true,\n\t\t\tposition: { my: \"center\", at: \"center\", of: window },\n\t\t\twidth: +(jQuery('#wpbody').width() / 100 * 70), // 70% of #wpbody\n\t\t\theight: 'auto',\n\t\t\ttitle: 'GDPR compliance',\n\t\t\tdraggable: false,\n\t\t\tresizable: false,\n\t\t\tcloseText: \"Close\",\n\t\t});\n\t});\n\n\tjQuery(document).on('click', '.apbct_settings-long_description---show', function(){\n\t\tself = jQuery(this);\n\t\tapbct_settings__showDescription(self, self.attr('setting'));\n\t});\n\n\tif (jQuery('#apbct_renew_notice').length || jQuery('#apbct_trial_notice').length) \n\t\tapbct_banner_check();\n\t\n});\n\n/**\n * Checking current account status for renew notice\n */\nfunction apbct_banner_check() {\n\tvar bannerChecker = setInterval( function() {\n\t\tapbct_sendAJAX(\n\t\t\t{action: 'apbct_settings__check_renew_banner'},\n\t\t\t{\n\t\t\t\tcallback: function(result, data, params, obj){\n\t\t\t\t\tif (result.close_renew_banner) {\n\t\t\t\t\t\tif (jQuery('#apbct_renew_notice').length)\n\t\t\t\t\t\t\tjQuery('#apbct_renew_notice').hide('slow');\n\t\t\t\t\t\tif (jQuery('#apbct_trial_notice').length)\n\t\t\t\t\t\t\tjQuery('#apbct_trial_notice').hide('slow');\n\t\t\t\t\t\tclearInterval(bannerChecker);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}, 60000);\n}\n\n/**\n * Select elems like #{selector} or .{selector}\n * Selector passed in string separated by ,\n *\n * @param elems\n * @returns {*}\n */\nfunction apbct_get_elems(elems){\n elems = elems.split(',');\n for( var i=0, len = elems.length, tmp; i < len; i++){\n tmp = jQuery('#'+elems[i]);\n elems[i] = tmp.length === 0 ? jQuery('.'+elems[i]) : tmp;\n }\n return elems;\n}\n\n/**\n * Select elems like #{selector} or .{selector}\n * Selector could be passed in a string ( separated by comma ) or in array ( [ elem1, elem2, ... ] )\n *\n * @param elems string|array\n * @returns array\n */\nfunction apbct_get_elems__native(elems){\n\n\t// Make array from a string\n\tif(typeof elems === 'string')\n\t\telems = elems.split(',');\n\n\tvar out = [];\n\n\telems.forEach(function(elem, i, arr) {\n\n\t\t// try to get elements with such IDs\n\t\tvar tmp = document.getElementById(elem);\n\t\tif (tmp !== null){\n\t\t\tout.push( tmp[key] );\n\t\t\treturn;\n\t\t}\n\n\t\t// try to get elements with such class name\n\t\t// write each elem from collection to new element of outpur array\n\t\ttmp = document.getElementsByClassName(elem);\n\t\tif (tmp !== null && tmp.length !==0 ){\n\t\t\tfor(key in tmp){\n\t\t\t\tif( +key >= 0 ){\n\t\t\t\t\tout.push( tmp[key] );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n\n\treturn out;\n}\n\nfunction apbct_show_hide_elem(elems){\n\telems = apbct_get_elems(elems);\n for( var i=0, len = elems.length; i < len; i++){\n elems[i].each(function (i, elem) {\n elem = jQuery(elem);\n var label = elem.next('label') || elem.prev('label') || null;\n if (elem.is(\":visible\")) {\n elem.hide();\n if (label) label.hide();\n } else {\n elem.show();\n if (label) label.show();\n }\n });\n }\n}\n\n/**\n * Settings dependences. Switch|toggle depended elements state (disabled|enabled)\n * Recieve list of selectors ( without class mark (.) or id mark (#) )\n *\n * @param ids string|array Selectors\n * @param enable\n */\nfunction apbctSettingsDependencies(ids, enable){\n\n\tenable = +enable || null;\n\n\t// Get elements\n\tvar elems = apbct_get_elems__native( ids );\n\n\telems.forEach(function(elem, i, arr){\n\n\t\tvar do_disable = function(){console.log( elem ); elem.setAttribute('disabled', 'disabled');},\n\t\t\tdo_enable = function(){elem.removeAttribute('disabled');};\n\n\t\t// Set defined state\n\t\tif(enable !== null) // Set\n\t\t\tenable === 1 ? do_enable() : do_disable();\n\n\t\t// Toggle\n\t\telse{\n\t\t\telem.getAttribute('disabled') === null ? do_disable() : do_enable();\n\t\t}\n\n\t});\n}\n\nfunction apbct_settings__showDescription(label, setting_id){\n\n\tvar remove_desc_func = function(e){\n\t\tif(typeof e === 'undefined' || ((jQuery(e.target).parent('.apbct_long_desc').length == 0 || jQuery(e.target).hasClass('apbct_long_desc__cancel')) && !jQuery(e.target).hasClass('apbct_long_description__show'))){\n\t\t\tjQuery('.apbct_long_desc').remove();\n\t\t\tjQuery(document).off('click', remove_desc_func);\n\t\t}\n\t};\n\n\tremove_desc_func();\n\n\tlabel.after(\"<div id='apbct_long_desc__\"+setting_id+\"' class='apbct_long_desc'></div>\");\n\tvar obj = jQuery('#apbct_long_desc__'+setting_id);\n\tobj.append(\"<i class='icon-spin1 animate-spin'></i>\")\n\t\t.append(\"<div class='apbct_long_desc__angle'></div>\")\n\t\t.css({\n\t\t\ttop: label.position().top - 5,\n\t\t\tleft: label.position().left + 25\n\t\t});\n\n\n\tapbct_sendAJAX(\n\t\t{action: 'apbct_settings__get_description', setting_id: setting_id},\n\t\t{\n\t\t\tspinner: obj.children('img'),\n\t\t\tcallback: function(result, data, params, obj){\n\n\t\t\t\tobj.empty()\n\t\t\t\t\t.append(\"<div class='apbct_long_desc__angle'></div>\")\n\t\t\t\t\t.append(\"<i class='apbct_long_desc__cancel icon-cancel'></i>\")\n\t\t\t\t\t.append(\"<h3 class='apbct_long_desc__title'>\"+result.title+\"</h3>\")\n\t\t\t\t\t.append(\"<p>\"+result.desc+\"</p>\");\n\n\t\t\t\tjQuery(document).on('click', remove_desc_func);\n\t\t\t}\n\t\t},\n\t\tobj\n\t);\n}"]}
|
@@ -1,2 +1,2 @@
|
|
1 |
-
function apbct_sendAJAX(n,o,t){var r=o.callback||null,
|
2 |
-
//# sourceMappingURL=cleantalk-admin.min.js.map
|
1 |
+
function apbct_sendAJAX(n,o,t){var r=o.callback||null,a=o.notJson||null,e=o.timeout||15e3,t=t||null,l=o.button||null,s=o.spinner||null,u=o.progressbar||null;l&&(l.setAttribute("disabled","disabled"),l.style.cursor="not-allowed"),s&&jQuery(s).css("display","inline"),n._ajax_nonce=ctAdminCommon._ajax_nonce,jQuery.ajax({type:"POST",url:ctAdminCommon._ajax_url,data:n,success:function(e){l&&(l.removeAttribute("disabled"),l.style.cursor="pointer"),s&&jQuery(s).css("display","none"),a||(e=JSON.parse(e)),e.error?(setTimeout(function(){u&&u.fadeOut("slow")},1e3),alert("Error happens: "+(e.error||"Unkown"))):r&&r(e,n,o,t)},error:function(e,n,o){l&&(l.removeAttribute("disabled"),l.style.cursor="pointer"),s&&jQuery(s).css("display","none"),console.log("APBCT_AJAX_ERROR"),console.log(e),console.log(n),console.log(o),o&&alert(o)},timeout:e})}jQuery(document).ready(function(){jQuery(".apbct_update_notice").on("click","button",function(){var e=new Date((new Date).getTime()+2592e6);document.cookie="apbct_update_banner_closed=1; path=/; expires="+e.toUTCString()+"; samesite=lax"}),jQuery('li a[href="options-general.php?page=cleantalk"]').css("white-space","nowrap")});
|
2 |
+
//# sourceMappingURL=cleantalk-admin.min.js.map
|
@@ -1 +1 @@
|
|
1 |
-
{"version":3,"
|
1 |
+
{"version":3,"file":"cleantalk-admin.min.js","sources":["cleantalk-admin.js"],"sourcesContent":["jQuery(document).ready(function(){\r\n\t\r\n\t// Auto update banner close handler\r\n\tjQuery('.apbct_update_notice').on('click', 'button', function(){\r\n\t\tvar ct_date = new Date(new Date().getTime() + 1000 * 86400 * 30 );\r\n\t\tdocument.cookie = \"apbct_update_banner_closed=1; path=/; expires=\" + ct_date.toUTCString() + \"; samesite=lax\";\r\n\t});\r\n\t\r\n\tjQuery('li a[href=\"options-general.php?page=cleantalk\"]').css('white-space','nowrap');\r\n\t\r\n});\r\n\r\nfunction apbct_sendAJAX(data, params, obj){\r\n\r\n\t// Default params\r\n\tvar callback = params.callback || null;\r\n\tvar notJson = params.notJson || null;\r\n\tvar timeout = params.timeout || 15000;\r\n\tvar obj = obj || null;\r\n\tvar button = params.button || null;\r\n\tvar spinner = params.spinner || null;\r\n\tvar progressbar = params.progressbar || null;\r\n\r\n\t// Button and spinner\r\n\tif(button) {button.setAttribute('disabled', 'disabled'); button.style.cursor = 'not-allowed'; }\r\n\tif(spinner) jQuery(spinner).css('display', 'inline');\r\n\r\n\t// Adding security code\r\n\tdata._ajax_nonce = ctAdminCommon._ajax_nonce;\r\n\r\n\tjQuery.ajax({\r\n\t\ttype: \"POST\",\r\n\t\turl: ctAdminCommon._ajax_url,\r\n\t\tdata: data,\r\n\t\tsuccess: function(result){\r\n\t\t\tif(button){ button.removeAttribute('disabled'); button.style.cursor = 'pointer'; }\r\n\t\t\tif(spinner) jQuery(spinner).css('display', 'none');\r\n\t\t\tif(!notJson) result = JSON.parse(result);\r\n\t\t\tif(result.error){\r\n\t\t\t\tsetTimeout(function(){ if(progressbar) progressbar.fadeOut('slow'); }, 1000);\r\n\t\t\t\talert('Error happens: ' + (result.error || 'Unkown'));\r\n\t\t\t}else{\r\n\t\t\t\tif(callback)\r\n\t\t\t\t\tcallback(result, data, params, obj);\r\n\t\t\t}\r\n\t\t},\r\n\t\terror: function(jqXHR, textStatus, errorThrown){\r\n\t\t\tif(button){ button.removeAttribute('disabled'); button.style.cursor = 'pointer'; }\r\n\t\t\tif(spinner) jQuery(spinner).css('display', 'none');\r\n\t\t\tconsole.log('APBCT_AJAX_ERROR');\r\n\t\t\tconsole.log(jqXHR);\r\n\t\t\tconsole.log(textStatus);\r\n\t\t\tconsole.log(errorThrown);\r\n\t\t\tif(errorThrown)\r\n\t\t\t\talert(errorThrown);\r\n\t\t},\r\n\t\ttimeout: timeout,\r\n\t});\r\n}"],"names":["apbct_sendAJAX","data","params","obj","callback","notJson","timeout","button","spinner","progressbar","setAttribute","style","cursor","jQuery","css","_ajax_nonce","ctAdminCommon","ajax","type","url","_ajax_url","success","result","removeAttribute","JSON","parse","error","setTimeout","fadeOut","alert","jqXHR","textStatus","errorThrown","console","log","document","ready","on","ct_date","Date","getTime","cookie","toUTCString"],"mappings":"AAYA,SAASA,eAAeC,EAAMC,EAAQC,GAGrC,IAAIC,EAAcF,EAAOE,UAAe,KACpCC,EAAcH,EAAOG,SAAe,KACpCC,EAAcJ,EAAOI,SAAe,KACpCH,EAAcA,GAAsB,KACpCI,EAAcL,EAAOK,QAAe,KACpCC,EAAcN,EAAOM,SAAe,KACpCC,EAAcP,EAAOO,aAAe,KAGrCF,IAAUA,EAAOG,aAAa,WAAY,YAAaH,EAAOI,MAAMC,OAAS,eAC7EJ,GAASK,OAAOL,GAASM,IAAI,UAAW,UAG3Cb,EAAKc,YAAcC,cAAcD,YAEjCF,OAAOI,KAAK,CACXC,KAAM,OACNC,IAAKH,cAAcI,UACnBnB,KAAMA,EACNoB,QAAS,SAASC,GACdf,IAAUA,EAAOgB,gBAAgB,YAAahB,EAAOI,MAAMC,OAAS,WACpEJ,GAAUK,OAAOL,GAASM,IAAI,UAAW,QACxCT,IAASiB,EAASE,KAAKC,MAAMH,IAC9BA,EAAOI,OACTC,WAAW,WAAelB,GAAaA,EAAYmB,QAAQ,SAAY,KACvEC,MAAM,mBAAqBP,EAAOI,OAAS,YAExCtB,GACFA,EAASkB,EAAQrB,EAAMC,EAAQC,IAGlCuB,MAAO,SAASI,EAAOC,EAAYC,GAC/BzB,IAAUA,EAAOgB,gBAAgB,YAAahB,EAAOI,MAAMC,OAAS,WACpEJ,GAASK,OAAOL,GAASM,IAAI,UAAW,QAC3CmB,QAAQC,IAAI,oBACZD,QAAQC,IAAIJ,GACZG,QAAQC,IAAIH,GACZE,QAAQC,IAAIF,GACTA,GACFH,MAAMG,IAER1B,QAASA,IAxDXO,OAAOsB,UAAUC,MAAM,WAGtBvB,OAAO,wBAAwBwB,GAAG,QAAS,SAAU,WACpD,IAAIC,EAAU,IAAIC,MAAK,IAAIA,MAAOC,UAAY,QAC9CL,SAASM,OAAS,iDAAmDH,EAAQI,cAAgB,mBAG9F7B,OAAO,mDAAmDC,IAAI,cAAc"}
|
@@ -1 +1,2 @@
|
|
1 |
-
var ct_working=!(String.prototype.printf=function(){var e=this;for(var t in arguments)
|
|
1 |
+
var ct_working=!(String.prototype.printf=function(){var e=this;for(var t in arguments)var c=e.substring(0,e.indexOf("%s",0)),_=e.substring(e.indexOf("%s",0)+2,e.length),e=c+arguments[t]+_;return e}),ct_new_check=!0,ct_cooling_down_flag=!1,ct_close_animate=!0,ct_accurate_check=!1,ct_pause=!1,ct_prev_accurate=ctCommentsCheck.ct_prev_accurate,ct_prev_from=ctCommentsCheck.ct_prev_from,ct_prev_till=ctCommentsCheck.ct_prev_till,ct_cool_down_time=9e4,ct_requests_counter=0,ct_max_requests=60,ct_ajax_nonce=ctCommentsCheck.ct_ajax_nonce,ct_comments_total=0,ct_comments_checked=0,ct_comments_spam=0,ct_comments_bad=0,ct_unchecked="unset",ct_date_from=0,ct_date_till=0;function animate_comment(e,t){ct_close_animate?.3==e?jQuery("#comment-"+t).fadeTo(200,e,function(){animate_comment(1,t)}):jQuery("#comment-"+t).fadeTo(200,e,function(){animate_comment(.3,t)}):ct_close_animate=!0}function ct_clear_comments(){var e=0,t=0;jQuery("#ct_allow_date_range").is(":checked")&&(e=jQuery("#ct_date_range_from").val(),t=jQuery("#ct_date_range_till").val());var c={action:"ajax_clear_comments",security:ct_ajax_nonce,from:e,till:t};jQuery.ajax({type:"POST",url:ajaxurl,data:c,success:function(e){ct_show_info(),ct_send_comments()}})}function ct_cooling_down_toggle(){ct_cooling_down_flag=!1,ct_send_comments(),ct_show_info()}function ct_send_comments(){if(!0!==ct_cooling_down_flag){if(ct_max_requests<=ct_requests_counter)return setTimeout(ct_cooling_down_toggle,ct_cool_down_time),void(ct_cooling_down_flag=!(ct_requests_counter=0));ct_requests_counter++;var e={action:"ajax_check_comments",security:ct_ajax_nonce,new_check:ct_new_check,unchecked:ct_unchecked};ct_accurate_check&&(e.accurate_check=!0),ct_date_from&&ct_date_till&&(e.from=ct_date_from,e.till=ct_date_till),jQuery.ajax({type:"POST",url:ajaxurl,data:e,success:function(e){var t,c;e=jQuery.parseJSON(e),parseInt(e.error)?(ct_working=!1,confirm(e.error_message+". Do you want to proceed?")?ct_send_comments():(t="edit-comments.php?page=ct_check_spam",0!=ct_date_from&&0!=ct_date_till&&(t+="&from="+ct_date_from+"&till="+ct_date_till),location.href=t)):(ct_new_check=!1,1==parseInt(e.end)||!0===ct_pause?(1==parseInt(e.end)&&(document.cookie="ct_paused_comments_check=0; path=/; samesite=lax"),ct_working=!1,jQuery("#ct_working_message").hide(),t="edit-comments.php?page=ct_check_spam",0!=ct_date_from&&0!=ct_date_till&&(t+="&from="+ct_date_from+"&till="+ct_date_till),location.href=t):0==parseInt(e.end)&&(ct_comments_checked+=e.checked,ct_comments_spam+=e.spam,ct_comments_bad+=e.bad,ct_unchecked=ct_comments_total-ct_comments_checked-ct_comments_bad,c=(c=String(ctCommentsCheck.ct_status_string)).printf(ct_comments_checked,ct_comments_spam,ct_comments_bad),0<parseInt(ct_comments_spam)&&(c+=ctCommentsCheck.ct_status_string_warning),jQuery("#ct_checking_status").html(c),jQuery("#ct_error_message").hide(),+ct_comments_total<ct_comments_checked+ct_comments_bad&&(document.cookie="ct_comments_start_check=1; path=/; samesite=lax",document.cookie="ct_comments_safe_check=1; path=/; samesite=lax",location.href="edit-comments.php?page=ct_check_spam"),ct_send_comments()))},error:function(e,t,c){jQuery("#ct_error_message").show(),jQuery("#cleantalk_ajax_error").html(t),jQuery("#cleantalk_js_func").html("Check comments"),setTimeout(ct_send_comments(),3e3)},timeout:25e3})}}function ct_show_info(){if(ct_working){if(1==ct_cooling_down_flag)return jQuery("#ct_cooling_notice").html("Waiting for API to cool down. (About a minute)"),void jQuery("#ct_cooling_notice").show();var e;jQuery("#ct_cooling_notice").hide(),ct_comments_total||(e={action:"ajax_info_comments",security:ct_ajax_nonce},ct_date_from&&ct_date_till&&(e.from=ct_date_from,e.till=ct_date_till),jQuery.ajax({type:"POST",url:ajaxurl,data:e,success:function(e){e=jQuery.parseJSON(e),jQuery("#ct_checking_status").html(e.message),ct_comments_total=e.total,ct_comments_spam=e.spam,ct_comments_checked=e.checked,ct_comments_bad=e.bad},error:function(e,t,c){jQuery("#ct_error_message").show(),jQuery("#cleantalk_ajax_error").html(t),jQuery("#cleantalk_js_func").html("Check comments"),setTimeout(ct_show_info(),3e3)},timeout:15e3}))}}function ct_toggle_depended(e,t){t=t||null;var c=jQuery(e.data("depended"));e.data("state")||t?(e.data("state",!1),c.prop("disabled",!0),c.removeProp("checked"),c.data("depended")&&ct_toggle_depended(c,!0)):(e.data("state",!0),c.removeProp("disabled"))}function ct_delete_all(_){var e={action:"ajax_delete_all",security:ct_ajax_nonce};jQuery("."+_.target.id).addClass("disabled"),jQuery(".spinner").css("visibility","visible"),jQuery.ajax({type:"POST",url:ajaxurl,data:e,success:function(e){0<e?(jQuery("#cleantalk_comments_left").html(e),ct_delete_all(_)):(jQuery("."+_.target.id).removeClass("disabled"),jQuery(".spinner").css("visibility","hidden"),location.href="edit-comments.php?page=ct_check_spam_total")},error:function(e,t,c){jQuery("#ct_error_message").show(),jQuery("#cleantalk_ajax_error").html(t),jQuery("#cleantalk_js_func").html("Check comments"),setTimeout(ct_delete_all(_),3e3)},timeout:25e3})}jQuery(document).ready(function(){jQuery("#ct_allow_date_range").data({depended:".ct_date",state:!1}),ct_prev_accurate&&jQuery("#ct_accurate_check").prop("checked",!0),ct_prev_from&&(jQuery("#ct_allow_date_range").prop("checked",!0).data("state",!0),jQuery("#ct_date_range_from").removeProp("disabled").val(ct_prev_from),jQuery("#ct_date_range_till").removeProp("disabled").val(ct_prev_till)),jQuery("#ct_allow_date_range, #ct_accurate_check").on("change",function(){ct_toggle_depended(jQuery(this))}),jQuery.datepicker.setDefaults(jQuery.datepicker.regional.en);var a=jQuery("#ct_date_range_from, #ct_date_range_till").datepicker({dateFormat:"M d yy",maxDate:"+0D",changeMonth:!0,changeYear:!0,showAnim:"slideDown",onSelect:function(e){var t="ct_date_range_from"==this.id?"minDate":"maxDate",c=jQuery(this).data("datepicker"),_=jQuery.datepicker.parseDate(c.settings.dateFormat||jQuery.datepicker._defaults.dateFormat,e,c.settings);a.not(this).datepicker("option",t,_)}});function e(e){e=e||null,jQuery("#ct_allow_date_range").is(":checked")&&(ct_date_from=jQuery("#ct_date_range_from").val(),ct_date_till=jQuery("#ct_date_range_till").val(),""==ct_date_from||""==ct_date_till)?alert("Please, specify a date range."):(jQuery("#ct_accurate_check").is(":checked")&&(ct_accurate_check=!0),jQuery(".ct_to_hide").hide(),jQuery("#ct_working_message").show(),jQuery("#ct_preloader").show(),jQuery("#ct_pause").show(),ct_working=!0,e?(ct_show_info(),ct_send_comments()):ct_clear_comments())}jQuery("#ct_check_spam_button").click(function(){e(!(document.cookie="ct_paused_comments_check=0; path=/; samesite=lax"))}),jQuery("#ct_proceed_check_button").click(function(){e(!0)}),jQuery("#ct_pause").on("click",function(){ct_pause=!0;var e={accurate:ct_accurate_check,from:ct_date_from,till:ct_date_till};document.cookie="ct_paused_comments_check="+JSON.stringify(e)+"; path=/; samesite=lax"}),"1"===ctCommentsCheck.start&&(document.cookie="ct_comments_start_check=0; expires="+new Date(0).toUTCString()+"; path=/; samesite=lax",jQuery("#ct_check_spam_button").click()),jQuery(".ct_delete_all").click(function(e){return!!confirm(ctCommentsCheck.ct_confirm_deletion_all)&&void ct_delete_all(e)})});
|
2 |
+
//# sourceMappingURL=cleantalk-comments-checkspam.min.js.map
|
@@ -1 +1 @@
|
|
1 |
-
{"version":3,"sources":["cleantalk-comments-checkspam.js"],"names":["ct_working","String","prototype","printf","formatted","this","arg","arguments","before_formatted","substring","indexOf","after_formatted","length","ct_new_check","ct_cooling_down_flag","ct_close_animate","ct_accurate_check","ct_pause","ct_prev_accurate","ctCommentsCheck","ct_prev_from","ct_prev_till","ct_cool_down_time","ct_requests_counter","ct_max_requests","ct_ajax_nonce","ct_comments_total","ct_comments_checked","ct_comments_spam","ct_comments_bad","ct_unchecked","ct_date_from","ct_date_till","animate_comment","to","id","jQuery","fadeTo","ct_clear_comments","from","till","is","val","data","action","security","ajax","type","url","ajaxurl","success","msg","ct_show_info","ct_send_comments","ct_cooling_down_toggle","setTimeout","new_check","unchecked","parseJSON","parseInt","error","confirm","error_message","new_href","location","href","end","document","cookie","hide","checked","spam","bad","status_string","ct_status_string","ct_status_string_warning","html","jqXHR","textStatus","errorThrown","show","timeout","message","total","ct_toggle_depended","obj","secondary","depended","prop","removeProp","ct_delete_all","e","target","addClass","css","removeClass","ready","state","on","datepicker","setDefaults","regional","dates","dateFormat","maxDate","changeMonth","changeYear","showAnim","onSelect","selectedDate","option","instance","date","parseDate","settings","_defaults","not","ct_start_check","continue_check","alert","click","ct_check","accurate","JSON","stringify","start","Date","toUTCString","ct_confirm_deletion_all"],"mappings":"AAYA,IAAIA,aAXJC,OAAOC,UAAUC,OAAS,WACtB,IAAIC,EA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xBZ,EAAMc,IAAI/G,MAAM8F,WAAW,SAAUW,EAAQE,MAKhD,SAASK,EAAeC,GAEjBA,EAAiBA,GAAkB,KAEtClF,OAAO,wBAAwBK,GAAG,cAEpCV,aAAeK,OAAO,uBAAuBM,MAC7CV,aAAeI,OAAO,uBAAuBM,MAExB,IAAhBX,cAAsC,IAAhBC,cAC1BuF,MAAM,kCAKLnF,OAAO,sBAAsBK,GAAG,cAClCzB,mBAAoB,GAGrBoB,OAAO,eAAeiC,OACtBjC,OAAO,uBAAuB4C,OAC9B5C,OAAO,iBAAiB4C,OACxB5C,OAAO,aAAa4C,OAEpBhF,YAAW,EAERsH,GACFlE,eACAC,oBAEAf,qBAKFF,OAAO,yBAAyBoF,MAAM,WAErCH,IADAlD,SAASC,OAAS,yCAGnBhC,OAAO,4BAA4BoF,MAAM,WACxCH,GAAe,KAIhBjF,OAAO,aAAa8D,GAAG,QAAS,WAC/BjF,UAAW,EACX,IAAIwG,EAAW,CACdC,SAAY1G,kBACZuB,KAAYR,aACZS,KAAYR,cAEbmC,SAASC,OAAS,4BAA8BuD,KAAKC,UAAUH,GAAY,aAI/C,MAA1BtG,gBAAgB0G,QAClB1D,SAASC,OAAS,sCAAwC,IAAI0D,KAAK,GAAGC,cAAgB,WACtF3F,OAAO,yBAAyBoF,SAIjCpF,OAAO,kBAAkBoF,MAAM,SAAU7B,GAExC,IAAK9B,QAAQ1C,gBAAgB6G,yBAC5B,OAAO,EAERtC,cAAeC"}
|
1 |
+
{"version":3,"file":"cleantalk-comments-checkspam.min.js","sources":["cleantalk-comments-checkspam.js"],"sourcesContent":["// Printf for JS\r\nString.prototype.printf = function(){\r\n var formatted = this;\r\n for( var arg in arguments ) {\r\n\t\tvar before_formatted = formatted.substring(0, formatted.indexOf(\"%s\", 0));\r\n\t\tvar after_formatted = formatted.substring(formatted.indexOf(\"%s\", 0)+2, formatted.length);\r\n\t\tformatted = before_formatted + arguments[arg] + after_formatted;\r\n }\r\n return formatted;\r\n};\r\n\r\n// Flags\r\nvar ct_working = false,\r\n\tct_new_check = true,\r\n\tct_cooling_down_flag = false,\r\n\tct_close_animate = true,\r\n\tct_accurate_check = false,\r\n\tct_pause = false,\r\n\tct_prev_accurate = ctCommentsCheck.ct_prev_accurate,\r\n\tct_prev_from = ctCommentsCheck.ct_prev_from,\t\r\n\tct_prev_till = ctCommentsCheck.ct_prev_till;\r\n// Settings\r\nvar ct_cool_down_time = 90000,\r\n\tct_requests_counter = 0,\r\n\tct_max_requests = 60;\r\n// Variables\r\nvar ct_ajax_nonce = ctCommentsCheck.ct_ajax_nonce,\r\n\tct_comments_total = 0,\r\n\tct_comments_checked = 0,\r\n\tct_comments_spam = 0,\r\n\tct_comments_bad = 0,\r\n\tct_unchecked = 'unset',\r\n\tct_date_from = 0,\r\n\tct_date_till = 0;\r\n\r\nfunction animate_comment(to,id){\r\n\tif(ct_close_animate){\r\n\t\tif(to==0.3){\r\n\t\t\tjQuery('#comment-'+id).fadeTo(200,to,function(){\r\n\t\t\t\tanimate_comment(1,id)\r\n\t\t\t});\r\n\t\t}else{\r\n\t\t\tjQuery('#comment-'+id).fadeTo(200,to,function(){\r\n\t\t\t\tanimate_comment(0.3,id)\r\n\t\t\t});\r\n\t\t}\r\n\t}else{\r\n\t\tct_close_animate=true;\r\n\t}\r\n}\r\n\r\nfunction ct_clear_comments(){\r\n\r\n\tvar from = 0, till = 0;\r\n\tif(jQuery('#ct_allow_date_range').is(':checked')) {\r\n\t\tfrom = jQuery('#ct_date_range_from').val();\r\n\t\ttill = jQuery('#ct_date_range_till').val();\r\n\t}\r\n\tvar data = {\r\n\t\t'action' : 'ajax_clear_comments',\r\n\t\t'security' : ct_ajax_nonce,\r\n\t\t'from' : from,\r\n\t\t'till' : till\r\n\t};\r\n\r\n\tjQuery.ajax({\r\n\t\ttype: \"POST\",\r\n\t\turl: ajaxurl,\r\n\t\tdata: data,\r\n\t\tsuccess: function(msg){\r\n\t\t\tct_show_info();\r\n\t\t\tct_send_comments();\r\n\t\t}\r\n\t});\r\n}\r\n\r\n//Continues the check after cooldown time\r\n//Called by ct_send_users();\r\nfunction ct_cooling_down_toggle(){\r\n\tct_cooling_down_flag = false;\r\n\tct_send_comments();\r\n\tct_show_info();\r\n}\r\n\r\nfunction ct_send_comments(){\r\n\t\r\n\tif(ct_cooling_down_flag === true)\r\n\t\treturn;\r\n\t\r\n\tif(ct_requests_counter >= ct_max_requests){\r\n\t\tsetTimeout(ct_cooling_down_toggle, ct_cool_down_time);\r\n\t\tct_requests_counter = 0;\r\n\t\tct_cooling_down_flag = true;\r\n\t\treturn;\r\n\t}else{\r\n\t\tct_requests_counter++;\r\n\t}\r\n\t\r\n\tvar data = {\r\n\t\t'action': 'ajax_check_comments',\r\n\t\t'security': ct_ajax_nonce,\r\n\t\t'new_check': ct_new_check,\r\n\t\t'unchecked': ct_unchecked\r\n\t};\r\n\t\r\n\tif(ct_accurate_check)\r\n\t\tdata['accurate_check'] = true;\r\n\t\r\n\tif(ct_date_from && ct_date_till){\r\n\t\tdata['from'] = ct_date_from;\r\n\t\tdata['till'] = ct_date_till;\r\n\t}\r\n\t\r\n\tjQuery.ajax({\r\n\t\ttype: \"POST\",\r\n\t\turl: ajaxurl,\r\n\t\tdata: data,\r\n\t\tsuccess: function(msg){\r\n\t\t\t\r\n\t\t\tmsg = jQuery.parseJSON(msg);\r\n\t\t\t\r\n\t\t\tif(parseInt(msg.error)){\r\n\t\t\t\tct_working=false;\r\n\t\t\t\tif(!confirm(msg.error_message+\". Do you want to proceed?\")){\r\n\t\t\t\t\tvar new_href = 'edit-comments.php?page=ct_check_spam';\r\n\t\t\t\t\tif(ct_date_from != 0 && ct_date_till != 0)\r\n\t\t\t\t\t\tnew_href+='&from='+ct_date_from+'&till='+ct_date_till;\r\n\t\t\t\t\tlocation.href = new_href;\r\n\t\t\t\t}else\r\n\t\t\t\t\tct_send_comments();\r\n\t\t\t}else{\r\n\t\t\t\tct_new_check = false;\r\n\t\t\t\tif(parseInt(msg.end) == 1 || ct_pause === true){\r\n\t\t\t\t\tif(parseInt(msg.end) == 1)\r\n\t\t\t\t\t\tdocument.cookie = 'ct_paused_comments_check=0; path=/; samesite=lax';\r\n\t\t\t\t\tct_working=false;\r\n\t\t\t\t\tjQuery('#ct_working_message').hide();\r\n\t\t\t\t\tvar new_href = 'edit-comments.php?page=ct_check_spam';\r\n\t\t\t\t\tif(ct_date_from != 0 && ct_date_till != 0)\r\n\t\t\t\t\t\tnew_href+='&from='+ct_date_from+'&till='+ct_date_till;\r\n\t\t\t\t\tlocation.href = new_href;\r\n\t\t\t\t}else if(parseInt(msg.end) == 0){\r\n\t\t\t\t\tct_comments_checked += msg.checked;\r\n\t\t\t\t\tct_comments_spam += msg.spam;\r\n\t\t\t\t\tct_comments_bad += msg.bad;\r\n\t\t\t\t\tct_unchecked = ct_comments_total - ct_comments_checked - ct_comments_bad;\r\n\t\t\t\t\tvar status_string = String(ctCommentsCheck.ct_status_string);\r\n\t\t\t\t\tvar status_string = status_string.printf(ct_comments_checked, ct_comments_spam, ct_comments_bad);\r\n\t\t\t\t\tif(parseInt(ct_comments_spam) > 0)\r\n\t\t\t\t\t\tstatus_string += ctCommentsCheck.ct_status_string_warning;\r\n\t\t\t\t\tjQuery('#ct_checking_status').html(status_string);\r\n\t\t\t\t\tjQuery('#ct_error_message').hide();\r\n\t\t\t\t\t// If DB woks not properly\r\n\t\t\t\t\tif(+ct_comments_total < ct_comments_checked + ct_comments_bad){\r\n\t\t\t\t\t\tdocument.cookie = 'ct_comments_start_check=1; path=/; samesite=lax';\r\n\t\t\t\t\t\tdocument.cookie = 'ct_comments_safe_check=1; path=/; samesite=lax';\r\n\t\t\t\t\t\tlocation.href = 'edit-comments.php?page=ct_check_spam';\r\n\t\t\t\t\t}\r\n\t\t\t\t\tct_send_comments();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t},\r\n error: function(jqXHR, textStatus, errorThrown) {\r\n\t\t\tjQuery('#ct_error_message').show();\r\n\t\t\tjQuery('#cleantalk_ajax_error').html(textStatus);\r\n\t\t\tjQuery('#cleantalk_js_func').html('Check comments');\r\n\t\t\tsetTimeout(ct_send_comments(), 3000); \r\n },\r\n timeout: 25000\r\n\t});\r\n}\r\nfunction ct_show_info(){\r\n\t\r\n\tif(ct_working){\r\n\t\t\r\n\t\tif(ct_cooling_down_flag == true){\r\n\t\t\tjQuery('#ct_cooling_notice').html('Waiting for API to cool down. (About a minute)');\r\n\t\t\tjQuery('#ct_cooling_notice').show();\r\n\t\t\treturn;\t\t\t\r\n\t\t}else{\r\n\t\t\tjQuery('#ct_cooling_notice').hide();\r\n\t\t}\r\n\t\t\r\n\t\tif(!ct_comments_total){\r\n\t\t\t\r\n\t\t\tvar data = {\r\n\t\t\t\t'action': 'ajax_info_comments',\r\n\t\t\t\t'security': ct_ajax_nonce\r\n\t\t\t};\r\n\t\t\t\r\n\t\t\tif(ct_date_from && ct_date_till){\r\n\t\t\t\tdata['from'] = ct_date_from;\r\n\t\t\t\tdata['till'] = ct_date_till;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tjQuery.ajax({\r\n\t\t\t\ttype: \"POST\",\r\n\t\t\t\turl: ajaxurl,\r\n\t\t\t\tdata: data,\r\n\t\t\t\tsuccess: function(msg){\r\n\t\t\t\t\tmsg = jQuery.parseJSON(msg);\r\n\t\t\t\t\tjQuery('#ct_checking_status').html(msg.message);\r\n\t\t\t\t\tct_comments_total = msg.total;\r\n\t\t\t\t\tct_comments_spam = msg.spam;\r\n\t\t\t\t\tct_comments_checked = msg.checked;\r\n\t\t\t\t\tct_comments_bad = msg.bad;\r\n\t\t\t\t},\r\n\t\t\t\terror: function(jqXHR, textStatus, errorThrown) {\r\n\t\t\t\t\tjQuery('#ct_error_message').show();\r\n\t\t\t\t\tjQuery('#cleantalk_ajax_error').html(textStatus);\r\n\t\t\t\t\tjQuery('#cleantalk_js_func').html('Check comments');\r\n\t\t\t\t\tsetTimeout(ct_show_info(), 3000); \r\n\t\t\t\t},\r\n\t\t\t\ttimeout: 15000\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n}\r\n\r\n// Function to toggle dependences\r\nfunction ct_toggle_depended(obj, secondary){\r\n\r\n secondary = secondary || null;\r\n\r\n\tvar depended = jQuery(obj.data('depended')),\r\n\t\tstate = obj.data('state');\r\n\t\t\r\n\tif(!state && !secondary){\r\n\t\tobj.data('state', true);\r\n\t\tdepended.removeProp('disabled');\r\n\t}else{\r\n\t\tobj.data('state', false);\r\n\t\tdepended.prop('disabled', true);\r\n\t\tdepended.removeProp('checked');\r\n\t\tif(depended.data('depended'))\r\n\t\t\tct_toggle_depended(depended, true);\r\n\t}\r\n}\r\n\r\nfunction ct_delete_all( e ) {\r\n\r\n\tvar data = {\r\n\t\t'action': 'ajax_delete_all',\r\n\t\t'security': ct_ajax_nonce\r\n\t};\r\n\r\n\tjQuery('.' + e.target.id).addClass('disabled');\r\n\tjQuery('.spinner').css('visibility', 'visible');\r\n\tjQuery.ajax({\r\n\t\ttype: \"POST\",\r\n\t\turl: ajaxurl,\r\n\t\tdata: data,\r\n\t\tsuccess: function( msg ){\r\n\t\t\tif( msg > 0 ){\r\n\t\t\t\tjQuery('#cleantalk_comments_left').html(msg);\r\n\t\t\t\tct_delete_all( e );\r\n\t\t\t}else{\r\n\t\t\t\tjQuery('.' + e.target.id).removeClass('disabled');\r\n\t\t\t\tjQuery('.spinner').css('visibility', 'hidden');\r\n\t\t\t\tlocation.href='edit-comments.php?page=ct_check_spam_total';\r\n\t\t\t}\r\n\t\t},\r\n\t\terror: function(jqXHR, textStatus, errorThrown) {\r\n\t\t\tjQuery('#ct_error_message').show();\r\n\t\t\tjQuery('#cleantalk_ajax_error').html(textStatus);\r\n\t\t\tjQuery('#cleantalk_js_func').html('Check comments');\r\n\t\t\tsetTimeout(ct_delete_all( e ), 3000);\r\n\t\t},\r\n\t\ttimeout: 25000\r\n\t});\r\n\r\n}\r\n\r\njQuery(document).ready(function(){\r\n\r\n\t// Setting dependences\r\n\t// jQuery('#ct_accurate_check') .data({'depended': '#ct_allow_date_range', 'state': false});\r\n\tjQuery('#ct_allow_date_range').data({'depended': '.ct_date', 'state': false});\r\n\t\r\n\t// Prev check parameters\r\n\tif(ct_prev_accurate){\r\n\t\tjQuery(\"#ct_accurate_check\").prop('checked', true);\r\n\t}\r\n\tif(ct_prev_from){\r\n\t\tjQuery(\"#ct_allow_date_range\").prop('checked', true).data('state', true);\r\n\t\tjQuery(\"#ct_date_range_from\").removeProp('disabled').val(ct_prev_from);\r\n\t\tjQuery(\"#ct_date_range_till\").removeProp('disabled').val(ct_prev_till);\r\n\t}\r\n\t\r\n\t// Toggle dependences\r\n\tjQuery(\"#ct_allow_date_range, #ct_accurate_check\").on('change', function(){\r\n\t\tct_toggle_depended(jQuery(this));\r\n\t});\r\n\r\n jQuery.datepicker.setDefaults(jQuery.datepicker.regional['en']);\r\n\tvar dates = jQuery('#ct_date_range_from, #ct_date_range_till').datepicker(\r\n\t\t{\r\n\t\t\tdateFormat: 'M d yy',\r\n\t\t\tmaxDate:\"+0D\",\r\n\t\t\tchangeMonth:true,\r\n\t\t\tchangeYear:true,\r\n\t\t\tshowAnim: 'slideDown',\r\n\t\t\tonSelect: function(selectedDate){\r\n\t\t\tvar option = this.id == \"ct_date_range_from\" ? \"minDate\" : \"maxDate\",\r\n\t\t\t\tinstance = jQuery( this ).data( \"datepicker\" ),\r\n\t\t\t\tdate = jQuery.datepicker.parseDate(\r\n\t\t\t\t\tinstance.settings.dateFormat || jQuery.datepicker._defaults.dateFormat,\r\n\t\t\t\t\tselectedDate, instance.settings);\r\n\t\t\t\tdates.not(this).datepicker(\"option\", option, date);\r\n\t\t\t}\r\n\t\t}\r\n\t);\r\n\t\r\n\tfunction ct_start_check(continue_check){\r\n\r\n continue_check = continue_check || null;\r\n\r\n\t\tif(jQuery('#ct_allow_date_range').is(':checked')){\r\n\t\t\t\r\n\t\t\tct_date_from = jQuery('#ct_date_range_from').val(),\r\n\t\t\tct_date_till = jQuery('#ct_date_range_till').val();\r\n\t\t\t\t\t\t\r\n\t\t\tif(!(ct_date_from != '' && ct_date_till != '')){\r\n\t\t\t\talert('Please, specify a date range.');\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tif(jQuery('#ct_accurate_check').is(':checked')){\r\n\t\t\tct_accurate_check = true;\r\n\t\t}\r\n\t\t\r\n\t\tjQuery('.ct_to_hide').hide();\r\n\t\tjQuery('#ct_working_message').show();\r\n\t\tjQuery('#ct_preloader').show();\r\n\t\tjQuery('#ct_pause').show();\r\n\r\n\t\tct_working=true;\r\n\t\t\r\n\t\tif(continue_check){\r\n\t\t\tct_show_info();\r\n\t\t\tct_send_comments();\r\n\t\t}else\r\n\t\t\tct_clear_comments();\r\n\t\t\r\n\t}\r\n\t\r\n\t// Check comments\r\n\tjQuery(\"#ct_check_spam_button\").click(function(){\r\n\t\tdocument.cookie = 'ct_paused_comments_check=0; path=/; samesite=lax';\r\n\t\tct_start_check(false);\r\n\t});\r\n\tjQuery(\"#ct_proceed_check_button\").click(function(){\r\n\t\tct_start_check(true);\r\n\t});\r\n\r\n\t// Pause the check\r\n\tjQuery('#ct_pause').on('click', function(){\r\n\t\tct_pause = true;\r\n\t\tvar ct_check = {\r\n\t\t\t'accurate': ct_accurate_check,\r\n\t\t\t'from' : ct_date_from,\r\n\t\t\t'till' : ct_date_till\r\n\t\t};\r\n\t\tdocument.cookie = 'ct_paused_comments_check=' + JSON.stringify(ct_check) + '; path=/; samesite=lax';\r\n\t});\r\n\r\n\r\n\tif(ctCommentsCheck.start === '1'){\r\n\t\tdocument.cookie = 'ct_comments_start_check=0; expires=' + new Date(0).toUTCString() + '; path=/; samesite=lax';\r\n\t\tjQuery('#ct_check_spam_button').click();\t\r\n\t}\r\n\r\n\t// Delete all spam comments\r\n\tjQuery(\".ct_delete_all\").click(function( e ){\r\n\r\n\t\tif (!confirm(ctCommentsCheck.ct_confirm_deletion_all))\r\n\t\t\treturn false;\r\n\r\n\t\tct_delete_all( e );\r\n\r\n\t});\r\n\r\n});"],"names":["ct_working","String","prototype","printf","formatted","this","arg","arguments","before_formatted","substring","indexOf","after_formatted","length","ct_new_check","ct_cooling_down_flag","ct_close_animate","ct_accurate_check","ct_pause","ct_prev_accurate","ctCommentsCheck","ct_prev_from","ct_prev_till","ct_cool_down_time","ct_requests_counter","ct_max_requests","ct_ajax_nonce","ct_comments_total","ct_comments_checked","ct_comments_spam","ct_comments_bad","ct_unchecked","ct_date_from","ct_date_till","animate_comment","to","id","jQuery","fadeTo","ct_clear_comments","from","till","is","val","data","action","security","ajax","type","url","ajaxurl","success","msg","ct_show_info","ct_send_comments","ct_cooling_down_toggle","setTimeout","new_check","unchecked","new_href","status_string","parseJSON","parseInt","error","confirm","error_message","location","href","end","document","cookie","hide","checked","spam","bad","ct_status_string","ct_status_string_warning","html","jqXHR","textStatus","errorThrown","show","timeout","message","total","ct_toggle_depended","obj","secondary","depended","prop","removeProp","ct_delete_all","e","target","addClass","css","removeClass","ready","state","on","datepicker","setDefaults","regional","dates","dateFormat","maxDate","changeMonth","changeYear","showAnim","onSelect","selectedDate","option","instance","date","parseDate","settings","_defaults","not","ct_start_check","continue_check","alert","click","ct_check","accurate","JSON","stringify","start","Date","toUTCString","ct_confirm_deletion_all"],"mappings":"AAYA,IAAIA,aAXJC,OAAOC,UAAUC,OAAS,WACtB,IAAIC,EAAYC,KAChB,IAAK,IAAIC,KAAOC,UAClB,IAAIC,EAAmBJ,EAAUK,UAAU,EAAGL,EAAUM,QAAQ,KAAM,IAClEC,EAAmBP,EAAUK,UAAUL,EAAUM,QAAQ,KAAM,GAAG,EAAGN,EAAUQ,QACnFR,EAAYI,EAAmBD,UAAUD,GAAOK,EAE9C,OAAOP,IAKVS,cAAe,EACfC,sBAAuB,EACvBC,kBAAmB,EACnBC,mBAAoB,EACpBC,UAAW,EACXC,iBAAmBC,gBAAgBD,iBACnCE,aAAeD,gBAAgBC,aAC/BC,aAAeF,gBAAgBE,aAE5BC,kBAAoB,I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AO,yBAAyBoF,MAAM,WAErCH,IADAjD,SAASC,OAAS,uDAGnBjC,OAAO,4BAA4BoF,MAAM,WACxCH,GAAe,KAIhBjF,OAAO,aAAa8D,GAAG,QAAS,WAC/BjF,UAAW,EACX,IAAIwG,EAAW,CACdC,SAAY1G,kBACZuB,KAAYR,aACZS,KAAYR,cAEboC,SAASC,OAAS,4BAA8BsD,KAAKC,UAAUH,GAAY,2BAI/C,MAA1BtG,gBAAgB0G,QAClBzD,SAASC,OAAS,sCAAwC,IAAIyD,KAAK,GAAGC,cAAgB,yBACtF3F,OAAO,yBAAyBoF,SAIjCpF,OAAO,kBAAkBoF,MAAM,SAAU7B,GAExC,QAAK5B,QAAQ5C,gBAAgB6G,+BAG7BtC,cAAeC"}
|
@@ -1,2 +1,2 @@
|
|
1 |
-
String.prototype.printf=function(){var e=this;for(var t in arguments)var c=e.substring(0,e.indexOf("%s",0)),
|
2 |
-
//# sourceMappingURL=cleantalk-users-checkspam.min.js.map
|
1 |
+
String.prototype.printf=function(){var e=this;for(var t in arguments)var c=e.substring(0,e.indexOf("%s",0)),a=e.substring(e.indexOf("%s",0)+2,e.length),e=c+arguments[t]+a;return e};var ct_working=!(document.cookie="ct_check_users__amount=100; path=/; samesite=lax"),ct_new_check=!0,ct_cooling_down_flag=!1,ct_close_animate=!0,ct_accurate_check=!1,ct_pause=!1,ct_prev_accurate=ctUsersCheck.ct_prev_accurate,ct_prev_from=ctUsersCheck.ct_prev_from,ct_prev_till=ctUsersCheck.ct_prev_till,ct_cool_down_time=9e4,ct_requests_counter=0,ct_max_requests=60,ct_ajax_nonce=ctUsersCheck.ct_ajax_nonce,ct_users_total=0,ct_users_checked=0,ct_users_spam=0,ct_users_bad=0,ct_unchecked="unset",ct_date_from=0,ct_date_till=0;function apbct_cookie__get(_,r){var s={};return"string"==typeof(_=_||null)&&(_=_.split()),"none"===(r=r||["apbct_","ct_"])&&(r=null),"string"==typeof r&&(r=r.split()),document.cookie.split(";").forEach(function(e,t,c){var a=e.trim().split("=");_&&_.forEach(function(e,t,c){a[0]===e&&(s[a[0]]=a[1])}),r&&r.forEach(function(e,t,c){0===a[0].indexOf(e)&&(s[a[0]]=a[1])})}),s}function apbct_get_cookie(e){var t=apbct_cookie__get(e,e);return"object"==typeof t&&void 0!==t[e]?t[e]:null}function animate_comment(e,t){ct_close_animate?.3===e?jQuery("#comment-"+t).fadeTo(200,e,function(){animate_comment(1,t)}):jQuery("#comment-"+t).fadeTo(200,e,function(){animate_comment(.3,t)}):ct_close_animate=!0}function ct_clear_users(){var e=0,t=0;jQuery("#ct_allow_date_range").is(":checked")&&(e=jQuery("#ct_date_range_from").val(),t=jQuery("#ct_date_range_till").val());var c={action:"ajax_clear_users",security:ct_ajax_nonce,from:e,till:t,no_cache:Math.random()};jQuery.ajax({type:"POST",url:ajaxurl,data:c,success:function(e){ct_show_users_info(),ct_send_users()}})}function ct_cooling_down_toggle(){ct_cooling_down_flag=!1,ct_send_users(),ct_show_users_info()}function ct_send_users(){if(!0!==ct_cooling_down_flag){if(ct_max_requests<=ct_requests_counter)return setTimeout(ct_cooling_down_toggle,ct_cool_down_time),void(ct_cooling_down_flag=!(ct_requests_counter=0));ct_requests_counter++;var a=apbct_get_cookie("ct_check_users__amount"),e={action:"ajax_check_users",security:ct_ajax_nonce,new_check:ct_new_check,unchecked:ct_unchecked,amount:a,no_cache:Math.random()};ct_accurate_check&&(e.accurate_check=!0),ct_date_from&&ct_date_till&&(e.from=ct_date_from,e.till=ct_date_till),jQuery.ajax({type:"POST",url:ajaxurl,data:e,success:function(e){var t,c;e=jQuery.parseJSON(e),parseInt(e.error)?(ct_working=!1,confirm(e.error_message+". Do you want to proceed?")?ct_send_users():(t="users.php?page=ct_check_users",0!=ct_date_from&&0!=ct_date_till&&(t+="&from="+ct_date_from+"&till="+ct_date_till),location.href=t)):(ct_new_check=!1,1==parseInt(e.end)||1==ct_pause?(1==parseInt(e.end)&&(document.cookie="ct_paused_users_check=0; path=/; samesite=lax"),ct_working=!1,jQuery("#ct_working_message").hide(),t="users.php?page=ct_check_users&ct_worked=1",0!=ct_date_from&&0!=ct_date_till&&(t+="&from="+ct_date_from+"&till="+ct_date_till),location.href=t):0==parseInt(e.end)&&(ct_users_checked=parseInt(ct_users_checked)+parseInt(e.checked),ct_users_spam=parseInt(ct_users_spam)+parseInt(e.spam),ct_users_bad=parseInt(ct_users_bad)+parseInt(e.bad),ct_unchecked=ct_users_total-ct_users_checked-ct_users_bad,c=(c=String(ctUsersCheck.ct_status_string)).printf(ct_users_checked,ct_users_spam,ct_users_bad),0<parseInt(ct_users_spam)&&(c+=ctUsersCheck.ct_status_string_warning),jQuery("#ct_checking_status").html(c),jQuery("#ct_error_message").hide(),ct_send_users()))},error:function(e,t,c){20<a&&(a-=20,document.cookie="ct_check_users__amount="+a+"; path=/; samesite=lax"),jQuery("#ct_error_message").show(),jQuery("#cleantalk_ajax_error").html(t),jQuery("#cleantalk_js_func").html("Check users"),setTimeout(ct_send_users(),3e3)},timeout:25e3})}}function ct_show_users_info(){if(ct_working){if(!0===ct_cooling_down_flag)return void jQuery("#ct_cooling_notice").html("Waiting for API to cool down. (About a minute)").show();var e;jQuery("#ct_cooling_notice").hide(),ct_users_total||(e={action:"ajax_info_users",security:ct_ajax_nonce,no_cache:Math.random()},ct_date_from&&ct_date_till&&(e.from=ct_date_from,e.till=ct_date_till),jQuery.ajax({type:"POST",url:ajaxurl,data:e,success:function(e){e=jQuery.parseJSON(e),jQuery("#ct_checking_status").html(e.message),ct_users_spam=e.spam,ct_users_checked=e.checked,ct_users_bad=e.bad},error:function(e,t,c){jQuery("#ct_error_message").show(),jQuery("#cleantalk_ajax_error").html(t),jQuery("#cleantalk_js_func").html("Show users"),setTimeout(ct_show_users_info(),3e3)},timeout:15e3}))}}function ct_toggle_depended(e,t){t=t||null;var c=jQuery(e.data("depended"));e.data("state")||t?(e.data("state",!1),c.prop("disabled",!0),c.removeProp("checked"),c.data("depended")&&ct_toggle_depended(c,!0)):(e.data("state",!0),c.removeProp("disabled"))}function ct_start_check(e){e=e||null,jQuery("#ct_allow_date_range").is(":checked")&&(ct_date_from=jQuery("#ct_date_range_from").val(),ct_date_till=jQuery("#ct_date_range_till").val(),""===ct_date_from||""===ct_date_till)?alert("Please, specify a date range."):(jQuery("#ct_accurate_check").is(":checked")&&(ct_accurate_check=!0),jQuery(".ct_to_hide").hide(),jQuery("#ct_working_message").show(),jQuery("#ct_preloader").show(),jQuery("#ct_pause").show(),ct_working=!0,e?(ct_show_users_info(),ct_send_users()):ct_clear_users())}function ct_delete_all_users(a){var t={action:"ajax_delete_all_users",security:ct_ajax_nonce,no_cache:Math.random()};jQuery("."+a.target.id).addClass("disabled"),jQuery(".spinner").css("visibility","visible"),jQuery.ajax({type:"POST",url:ajaxurl,data:t,success:function(e){0<e?(jQuery("#cleantalk_users_left").html(e),ct_delete_all_users(a,t)):(jQuery("."+a.target.id).removeClass("disabled"),jQuery(".spinner").css("visibility","hidden"),location.href="users.php?page=ct_check_users_total")},error:function(e,t,c){jQuery("#ct_error_message").show(),jQuery("#cleantalk_ajax_error").html(t),jQuery("#cleantalk_js_func").html("All users deleteion"),setTimeout(ct_delete_all_users(a),3e3)},timeout:25e3})}jQuery(document).ready(function(){jQuery("#ct_allow_date_range").data({depended:".ct_date",state:!1}),ct_prev_accurate&&jQuery("#ct_accurate_check").prop("checked",!0),ct_prev_from&&(jQuery("#ct_allow_date_range").prop("checked",!0).data("state",!0),jQuery("#ct_date_range_from").removeProp("disabled").val(ct_prev_from),jQuery("#ct_date_range_till").removeProp("disabled").val(ct_prev_till)),jQuery("#ct_allow_date_range, #ct_accurate_check").on("change",function(){ct_toggle_depended(jQuery(this))}),jQuery.datepicker.setDefaults(jQuery.datepicker.regional.en);var _=jQuery("#ct_date_range_from, #ct_date_range_till").datepicker({dateFormat:"M d yy",maxDate:"+0D",changeMonth:!0,changeYear:!0,showAnim:"slideDown",onSelect:function(e){var t="ct_date_range_from"==this.id?"minDate":"maxDate",c=jQuery(this).data("datepicker"),a=jQuery.datepicker.parseDate(c.settings.dateFormat||jQuery.datepicker._defaults.dateFormat,e,c.settings);_.not(this).datepicker("option",t,a)}});function t(t){t=t||null;var e={action:"ajax_insert_users",security:ct_ajax_nonce,no_cache:Math.random()};t&&(e.delete=!0),jQuery.ajax({type:"POST",url:ajaxurl,data:e,success:function(e){t?alert("Deleted "+e+" users"):alert("Inserted "+e+" users")}})}jQuery("#ct_check_spam_button").click(function(){ct_start_check(!(document.cookie="ct_paused_users_check=0; path=/; samesite=lax"))}),jQuery("#ct_proceed_check_button").click(function(){ct_start_check(!0)}),jQuery("#ct_pause").on("click",function(){ct_pause=!0;var e={accurate:ct_accurate_check,from:ct_date_from,till:ct_date_till};document.cookie="ct_paused_users_check="+JSON.stringify(e)+"; path=/; samesite=lax"}),jQuery(".cleantalk_delete_from_list_button").click(function(){ct_id=jQuery(this).attr("data-id");var e={action:"ajax_ct_approve_user",security:ct_ajax_nonce,id:ct_id,no_cache:Math.random()};jQuery.ajax({type:"POST",url:ajaxurl,data:e,success:function(e){jQuery("#comment-"+ct_id).fadeOut("slow",function(){jQuery("#comment-"+ct_id).remove()})}});e={action:"ct_feedback_user",security:ct_ajax_nonce,user_id:ct_id,status:"approve",no_cache:Math.random()};jQuery.ajax({type:"POST",url:ajaxurl,data:e,success:function(e){},error:function(e,t,c){},timeout:5e3})}),jQuery(".ct_get_csv_file").click(function(a){var e={action:"ajax_ct_get_csv_file",security:ct_ajax_nonce,filename:ctUsersCheck.ct_csv_filename,no_cache:Math.random()};jQuery("."+a.target.id).addClass("disabled"),jQuery(".spinner").css("visibility","visible"),jQuery.ajax({type:"POST",url:ajaxurl,data:e,success:function(e){var t,c;0===parseInt(e)?alert(ctUsersCheck.ct_bad_csv):(t=URL.createObjectURL(new Blob([e])),(c=document.createElement("a")).href=t,c.download=ctUsersCheck.ct_csv_filename+".csv",document.body.appendChild(c),c.click()),jQuery("."+a.target.id).removeClass("disabled"),jQuery(".spinner").css("visibility","hidden")}})}),jQuery(".ct_insert_users").click(function(e){t()}),jQuery(".ct_insert_users__delete").click(function(e){t(!0)}),jQuery(".ct_delete_all_users").click(function(e){return!!confirm(ctUsersCheck.ct_confirm_deletion_all)&&void ct_delete_all_users(e)})});
|
2 |
+
//# sourceMappingURL=cleantalk-users-checkspam.min.js.map
|
@@ -1 +1 @@
|
|
1 |
-
{"version":3,"file":"cleantalk-users-checkspam.min.js","sources":["cleantalk-users-checkspam.js"],"sourcesContent":["// Printf for JS\r\nString.prototype.printf = function(){\r\n var formatted = this;\r\n for( var arg in arguments ) {\r\n\t\tvar before_formatted = formatted.substring(0, formatted.indexOf(\"%s\", 0));\r\n\t\tvar after_formatted = formatted.substring(formatted.indexOf(\"%s\", 0)+2, formatted.length);\r\n\t\tformatted = before_formatted + arguments[arg] + after_formatted;\r\n }\r\n return formatted;\r\n};\r\n\r\n// Set deafult amount to check by request.\r\ndocument.cookie = \"ct_check_users__amount=\" + 100 + \"; path=/\";\r\n\r\n// Flags\r\nvar ct_working = false,\r\n\tct_new_check = true,\r\n\tct_cooling_down_flag = false,\r\n\tct_close_animate = true,\r\n\tct_accurate_check = false,\r\n\tct_pause = false,\r\n\tct_prev_accurate = ctUsersCheck.ct_prev_accurate,\r\n\tct_prev_from = ctUsersCheck.ct_prev_from,\t\r\n\tct_prev_till = ctUsersCheck.ct_prev_till;\r\n// Settings\r\nvar ct_cool_down_time = 90000,\r\n\tct_requests_counter = 0,\r\n\tct_max_requests = 60;\r\n// Variables\r\nvar ct_ajax_nonce = ctUsersCheck.ct_ajax_nonce,\r\n\tct_users_total = 0,\r\n\tct_users_checked = 0,\r\n\tct_users_spam = 0,\r\n\tct_users_bad = 0,\r\n\tct_unchecked = 'unset',\r\n\tct_date_from = 0,\r\n\tct_date_till = 0;\r\n\r\n/* Function: Reuturns cookie with prefix */\r\nfunction apbct_cookie__get(names, prefixes){\r\n\tvar cookie = {};\r\n\tnames = names || null;\r\n\tif(typeof names == 'string') names = names.split();\r\n\tprefixes = prefixes || ['apbct_', 'ct_'];\r\n\tif(prefixes === 'none') prefixes = null;\r\n\tif(typeof prefixes == 'string') prefixes = prefixes.split();\r\n\tdocument.cookie.split(';').forEach(function(item, i, arr){\r\n\t\tvar curr = item.trim().split('=');\r\n\t\t// Detect by full cookie name\r\n\t\tif(names){\r\n\t\t\tnames.forEach(function(name, i, all){\r\n\t\t\t\tif(curr[0] === name)\r\n\t\t\t\t\tcookie[curr[0]] = (curr[1]);\r\n\t\t\t});\r\n\t\t}\r\n\t\t// Detect by name prefix\r\n\t\tif(prefixes){\r\n\t\t\tprefixes.forEach(function(prefix, i, all){\r\n\t\t\t\tif(curr[0].indexOf(prefix) === 0)\r\n\t\t\t\t\tcookie[curr[0]] = (curr[1]);\r\n\t\t\t});\r\n\t\t}\r\n\t});\r\n\treturn cookie;\r\n}\r\n\r\nfunction apbct_get_cookie( name ){\r\n\tvar cookie = apbct_cookie__get( name, name );\r\n\tif(typeof cookie === 'object' && typeof cookie[name] != 'undefined'){\r\n\t\treturn cookie[name];\r\n\t}else\r\n\t\treturn null;\r\n}\r\n\r\nfunction animate_comment(to,id){\r\n\tif(ct_close_animate){\r\n\t\tif(to === 0.3){\r\n\t\t\tjQuery('#comment-'+id).fadeTo(200,to,function(){\r\n\t\t\t\tanimate_comment(1,id)\r\n\t\t\t});\r\n\t\t}else{\r\n\t\t\tjQuery('#comment-'+id).fadeTo(200,to,function(){\r\n\t\t\t\tanimate_comment(0.3,id)\r\n\t\t\t});\r\n\t\t}\r\n\t}else{\r\n\t\tct_close_animate=true;\r\n\t}\r\n}\r\n\r\nfunction ct_clear_users(){\r\n\r\n\tvar from = 0, till = 0;\r\n\tif(jQuery('#ct_allow_date_range').is(':checked')) {\r\n\t\tfrom = jQuery('#ct_date_range_from').val();\r\n\t\ttill = jQuery('#ct_date_range_till').val();\r\n\t}\r\n\tvar data = {\r\n\t\t'action' : 'ajax_clear_users',\r\n\t\t'security' : ct_ajax_nonce,\r\n\t\t'from' : from,\r\n\t\t'till' : till\r\n\t};\r\n\r\n\tjQuery.ajax({\r\n\t\ttype: \"POST\",\r\n\t\turl: ajaxurl,\r\n\t\tdata: data,\r\n\t\tsuccess: function(msg){\r\n\t\t\tct_show_users_info();\r\n\t\t\tct_send_users();\r\n\t\t}\r\n\t});\r\n\r\n}\r\n\r\n//Continues the check after cooldown time\r\n//Called by ct_send_users();\r\nfunction ct_cooling_down_toggle(){\r\n\tct_cooling_down_flag = false;\r\n\tct_send_users();\r\n\tct_show_users_info();\r\n}\r\n\r\nfunction ct_send_users(){\r\n\t\r\n\tif(ct_cooling_down_flag === true)\r\n\t\treturn;\r\n\t\r\n\tif(ct_requests_counter >= ct_max_requests){\r\n\t\tsetTimeout(ct_cooling_down_toggle, ct_cool_down_time);\r\n\t\tct_requests_counter = 0;\r\n\t\tct_cooling_down_flag = true;\r\n\t\treturn;\r\n\t}else{\r\n\t\tct_requests_counter++;\r\n\t}\r\n\r\n\tvar check_amount = apbct_get_cookie('ct_check_users__amount');\r\n\r\n\tvar data = {\r\n\t\taction: 'ajax_check_users',\r\n\t\tsecurity: ct_ajax_nonce,\r\n\t\tnew_check: ct_new_check,\r\n\t\tunchecked: ct_unchecked,\r\n\t\tamount: check_amount\r\n\t};\r\n\t\r\n\tif(ct_accurate_check)\r\n\t\tdata['accurate_check'] = true;\r\n\t\r\n\tif(ct_date_from && ct_date_till){\r\n\t\tdata['from'] = ct_date_from;\r\n\t\tdata['till'] = ct_date_till;\r\n\t}\r\n\t\r\n\tjQuery.ajax({\r\n\t\ttype: \"POST\",\r\n\t\turl: ajaxurl,\r\n\t\tdata: data,\r\n\t\tsuccess: function(msg){\r\n\t\t\t\r\n\t\t\tmsg = jQuery.parseJSON(msg);\r\n\t\t\t\r\n\t\t\tif(parseInt(msg.error)){\r\n\t\t\t\tct_working=false;\r\n\t\t\t\tif(!confirm(msg.error_message+\". Do you want to proceed?\")){\r\n\t\t\t\t\tvar new_href = 'users.php?page=ct_check_users';\r\n\t\t\t\t\tif(ct_date_from != 0 && ct_date_till != 0)\r\n\t\t\t\t\t\tnew_href+='&from='+ct_date_from+'&till='+ct_date_till;\r\n\t\t\t\t\tlocation.href = new_href;\r\n\t\t\t\t}else\r\n\t\t\t\t\tct_send_users();\r\n\t\t\t}else{\r\n\t\t\t\tct_new_check = false;\r\n\t\t\t\tif(parseInt(msg.end) == 1 || ct_pause == true){\r\n\t\t\t\t\tif(parseInt(msg.end) == 1)\r\n\t\t\t\t\t\tdocument.cookie = 'ct_paused_users_check=0; path=/';\r\n\t\t\t\t\tct_working=false;\r\n\t\t\t\t\tjQuery('#ct_working_message').hide();\r\n\t\t\t\t\tvar new_href = 'users.php?page=ct_check_users&ct_worked=1';\r\n\t\t\t\t\tif(ct_date_from != 0 && ct_date_till != 0)\r\n\t\t\t\t\t\tnew_href+='&from='+ct_date_from+'&till='+ct_date_till;\r\n\t\t\t\t\tlocation.href = new_href;\r\n\t\t\t\t}else if(parseInt(msg.end) == 0){\r\n\t\t\t\t\tct_users_checked = parseInt( ct_users_checked ) + parseInt( msg.checked );\r\n\t\t\t\t\tct_users_spam = parseInt( ct_users_spam ) + parseInt (msg.spam );\r\n\t\t\t\t\tct_users_bad = parseInt( ct_users_bad ) + parseInt( msg.bad );\r\n\t\t\t\t\tct_unchecked = ct_users_total - ct_users_checked - ct_users_bad;\r\n\t\t\t\t\tvar status_string = String(ctUsersCheck.ct_status_string);\r\n\t\t\t\t\tvar status_string = status_string.printf(ct_users_checked, ct_users_spam, ct_users_bad);\r\n\t\t\t\t\tif(parseInt(ct_users_spam) > 0)\r\n\t\t\t\t\t\tstatus_string += ctUsersCheck.ct_status_string_warning;\r\n\t\t\t\t\tjQuery('#ct_checking_status').html(status_string);\r\n\t\t\t\t\tjQuery('#ct_error_message').hide();\r\n\t\t\t\t\tct_send_users();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t},\r\n error: function(jqXHR, textStatus, errorThrown) {\r\n\t\t\tif(check_amount > 20){\r\n\t\t\t\tcheck_amount -= 20;\r\n\t\t\t\tdocument.cookie = \"ct_check_users__amount=\" + check_amount + \"; path=/\";\r\n\t\t\t}\r\n\t\t\tjQuery('#ct_error_message').show();\r\n\t\t\tjQuery('#cleantalk_ajax_error').html(textStatus);\r\n\t\t\tjQuery('#cleantalk_js_func').html('Check users');\r\n\t\t\tsetTimeout(ct_send_users(), 3000);\r\n },\r\n timeout: 25000\r\n\t});\r\n}\r\nfunction ct_show_users_info(){\r\n\t\r\n\tif( ct_working ){\r\n\t\t\r\n\t\tif(ct_cooling_down_flag === true){\r\n\t\t\tjQuery('#ct_cooling_notice').html('Waiting for API to cool down. (About a minute)').show();\r\n\t\t\treturn;\t\t\t\r\n\t\t}else{\r\n\t\t\tjQuery('#ct_cooling_notice').hide();\r\n\t\t}\r\n\t\t\r\n\t\tif( ! ct_users_total ){\r\n\t\t\t\r\n\t\t\tvar data = {\r\n\t\t\t\t'action': 'ajax_info_users',\r\n\t\t\t\t'security': ct_ajax_nonce\r\n\t\t\t};\r\n\t\t\t\r\n\t\t\tif( ct_date_from && ct_date_till ){\r\n\t\t\t\tdata['from'] = ct_date_from;\r\n\t\t\t\tdata['till'] = ct_date_till;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tjQuery.ajax({\r\n\t\t\t\ttype: \"POST\",\r\n\t\t\t\turl: ajaxurl,\r\n\t\t\t\tdata: data,\r\n\t\t\t\tsuccess: function(msg){\r\n\t\t\t\t\tmsg = jQuery.parseJSON(msg);\r\n\t\t\t\t\tjQuery('#ct_checking_status').html(msg.message);\r\n\t\t\t\t\tct_users_spam = msg.spam;\r\n\t\t\t\t\tct_users_checked = msg.checked;\r\n\t\t\t\t\tct_users_bad = msg.bad;\r\n\t\t\t\t},\r\n\t\t\t\terror: function (jqXHR, textStatus, errorThrown){\r\n\t\t\t\t\tjQuery('#ct_error_message').show();\r\n\t\t\t\t\tjQuery('#cleantalk_ajax_error').html(textStatus);\r\n\t\t\t\t\tjQuery('#cleantalk_js_func').html('Show users');\r\n\t\t\t\t\tsetTimeout(ct_show_users_info(), 3000);\r\n\t\t\t\t},\r\n\t\t\t\ttimeout: 15000\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n}\r\n// Function to toggle dependences\r\nfunction ct_toggle_depended(obj, secondary){\r\n\r\n secondary = secondary || null;\r\n\r\n\tvar depended = jQuery(obj.data('depended')),\r\n\t\tstate = obj.data('state');\r\n\t\t\r\n\tif(!state && !secondary){\r\n\t\tobj.data('state', true);\r\n\t\tdepended.removeProp('disabled');\r\n\t}else{\r\n\t\tobj.data('state', false);\r\n\t\tdepended.prop('disabled', true);\r\n\t\tdepended.removeProp('checked');\r\n\t\tif(depended.data('depended'))\r\n\t\t\tct_toggle_depended(depended, true);\r\n\t}\r\n}\r\n\r\n// Main function of checking\r\nfunction ct_start_check( continue_check ){\r\n\r\n\tcontinue_check = continue_check || null;\r\n\r\n\tif(jQuery('#ct_allow_date_range').is(':checked')){\r\n\r\n\t\tct_date_from = jQuery('#ct_date_range_from').val();\r\n\t\tct_date_till = jQuery('#ct_date_range_till').val();\r\n\r\n\t\tif(!(ct_date_from !== '' && ct_date_till !== '')){\r\n\t\t\talert('Please, specify a date range.');\r\n\t\t\treturn;\r\n\t\t}\r\n\t}\r\n\r\n\tif(jQuery('#ct_accurate_check').is(':checked')){\r\n\t\tct_accurate_check = true;\r\n\t}\r\n\r\n\tjQuery('.ct_to_hide').hide();\r\n\tjQuery('#ct_working_message').show();\r\n\tjQuery('#ct_preloader').show();\r\n\tjQuery('#ct_pause').show();\r\n\r\n\tct_working = true;\r\n\r\n\tif( continue_check ){\r\n\t\tct_show_users_info();\r\n\t\tct_send_users();\r\n\t} else {\r\n\t\tct_clear_users();\r\n\t}\r\n\r\n}\r\n\r\nfunction ct_delete_all_users( e ){\r\n\r\n\tvar data = {\r\n\t\t'action': 'ajax_delete_all_users',\r\n\t\t'security': ct_ajax_nonce\r\n\t};\r\n\r\n\tjQuery('.' + e.target.id).addClass('disabled');\r\n\tjQuery('.spinner').css('visibility', 'visible');\r\n\tjQuery.ajax({\r\n\t\ttype: \"POST\",\r\n\t\turl: ajaxurl,\r\n\t\tdata: data,\r\n\t\tsuccess: function( msg ){\r\n\t\t\tif( msg > 0 ){\r\n\t\t\t\tjQuery('#cleantalk_users_left').html(msg);\r\n\t\t\t\tct_delete_all_users( e, data );\r\n\t\t\t}else{\r\n\t\t\t\tjQuery('.' + e.target.id).removeClass('disabled');\r\n\t\t\t\tjQuery('.spinner').css('visibility', 'hidden');\r\n\t\t\t\tlocation.href='users.php?page=ct_check_users_total';\r\n\t\t\t}\r\n\t\t},\r\n\t\terror: function(jqXHR, textStatus, errorThrown) {\r\n\t\t\tjQuery('#ct_error_message').show();\r\n\t\t\tjQuery('#cleantalk_ajax_error').html(textStatus);\r\n\t\t\tjQuery('#cleantalk_js_func').html('All users deleteion');\r\n\t\t\tsetTimeout(ct_delete_all_users( e ), 3000);\r\n\t\t},\r\n\t\ttimeout: 25000\r\n\t});\r\n}\r\n\r\njQuery(document).ready(function(){\r\n\r\n\t// Setting dependences\r\n\t// jQuery('#ct_accurate_check') .data({'depended': '#ct_allow_date_range', 'state': false});\r\n\tjQuery('#ct_allow_date_range').data({'depended': '.ct_date', 'state': false});\r\n\t\r\n\t// Prev check parameters\r\n\tif(ct_prev_accurate){\r\n\t\tjQuery(\"#ct_accurate_check\").prop('checked', true);\r\n\t}\r\n\tif(ct_prev_from){\r\n\t\tjQuery(\"#ct_allow_date_range\").prop('checked', true).data('state', true);\r\n\t\tjQuery(\"#ct_date_range_from\").removeProp('disabled').val(ct_prev_from);\r\n\t\tjQuery(\"#ct_date_range_till\").removeProp('disabled').val(ct_prev_till);\r\n\t}\r\n\t\r\n\t// Toggle dependences\r\n\tjQuery(\"#ct_allow_date_range, #ct_accurate_check\").on('change', function(){\r\n\t\tct_toggle_depended(jQuery(this));\r\n\t});\r\n\r\n\tjQuery.datepicker.setDefaults(jQuery.datepicker.regional['en']);\r\n\tvar dates = jQuery('#ct_date_range_from, #ct_date_range_till').datepicker(\r\n\t\t{\r\n\t\t\tdateFormat: 'M d yy',\r\n\t\t\tmaxDate:\"+0D\",\r\n\t\t\tchangeMonth:true,\r\n\t\t\tchangeYear:true,\r\n\t\t\tshowAnim: 'slideDown',\r\n\t\t\tonSelect: function(selectedDate){\r\n\t\t\tvar option = this.id == \"ct_date_range_from\" ? \"minDate\" : \"maxDate\",\r\n\t\t\t\tinstance = jQuery( this ).data( \"datepicker\" ),\r\n\t\t\t\tdate = jQuery.datepicker.parseDate(\r\n\t\t\t\t\tinstance.settings.dateFormat || jQuery.datepicker._defaults.dateFormat,\r\n\t\t\t\t\tselectedDate, instance.settings);\r\n\t\t\t\tdates.not(this).datepicker(\"option\", option, date);\r\n\t\t\t}\r\n\t\t}\r\n\t);\r\n\t\r\n\t// Check users\r\n\tjQuery(\"#ct_check_spam_button\").click(function(){\r\n\t\tdocument.cookie = 'ct_paused_users_check=0; path=/';\r\n\t\tct_start_check(false);\r\n\t});\r\n\tjQuery(\"#ct_proceed_check_button\").click(function(){\r\n\t\tct_start_check(true);\r\n\t});\r\n\t\r\n\t// Pause the check\r\n\tjQuery('#ct_pause').on('click', function(){\r\n\t\tct_pause = true;\r\n\t\tvar ct_check = {\r\n\t\t\t'accurate': ct_accurate_check,\r\n\t\t\t'from' : ct_date_from,\r\n\t\t\t'till' : ct_date_till\r\n\t\t};\r\n\t\tdocument.cookie = 'ct_paused_users_check=' + JSON.stringify(ct_check) + '; path=/';\r\n\t});\r\n\t\t\r\n\t//Approve button\r\n\tjQuery(\".cleantalk_delete_from_list_button\").click(function(){\r\n\t\tct_id = jQuery(this).attr(\"data-id\");\r\n\t\t\r\n\t\t// Approving\r\n\t\tvar data = {\r\n\t\t\t'action': 'ajax_ct_approve_user',\r\n\t\t\t'security': ct_ajax_nonce,\r\n\t\t\t'id': ct_id\r\n\t\t};\r\n\t\tjQuery.ajax({\r\n\t\t\ttype: \"POST\",\r\n\t\t\turl: ajaxurl,\r\n\t\t\tdata: data,\r\n\t\t\tsuccess: function(msg){\r\n\t\t\t\tjQuery(\"#comment-\"+ct_id).fadeOut('slow', function(){\r\n\t\t\t\t\tjQuery(\"#comment-\"+ct_id).remove();\r\n\t\t\t\t});\r\n\t\t\t},\r\n\t\t});\r\n\t\t\r\n\t\t// Positive feedback\r\n\t\tvar data = {\r\n\t\t\t'action': 'ct_feedback_user',\r\n\t\t\t'security': ct_ajax_nonce,\r\n\t\t\t'user_id': ct_id,\r\n\t\t\t'status': 'approve'\r\n\t\t};\r\n\t\tjQuery.ajax({\r\n\t\t\ttype: \"POST\",\r\n\t\t\turl: ajaxurl,\r\n\t\t\tdata: data,\r\n\t\t\tsuccess: function(msg){\r\n\t\t\t\tif(msg == 1){\r\n\t\t\t\t\t// Success\r\n\t\t\t\t}\r\n\t\t\t\tif(msg == 0){\r\n\t\t\t\t\t// Error occurred\r\n\t\t\t\t}\r\n\t\t\t\tif(msg == 'no_hash'){\r\n\t\t\t\t\t// No hash\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\terror: function(jqXHR, textStatus, errorThrown) {\r\n\t\t\t\t\r\n\t\t\t},\r\n\t\t\ttimeout: 5000\r\n\t\t});\r\n\t\t\r\n\t});\r\n\t\r\n\t// Request to Download CSV file.\r\n\tjQuery(\".ct_get_csv_file\").click(function( e ){\r\n\t\tvar data = {\r\n\t\t\t'action': 'ajax_ct_get_csv_file',\r\n\t\t\t'security': ct_ajax_nonce,\r\n\t\t\t'filename': ctUsersCheck.ct_csv_filename\r\n\t\t};\r\n\t\tjQuery('.' + e.target.id).addClass('disabled');\r\n\t\tjQuery('.spinner').css('visibility', 'visible');\r\n\t\tjQuery.ajax({\r\n\t\t\ttype: \"POST\",\r\n\t\t\turl: ajaxurl,\r\n\t\t\tdata: data,\r\n\t\t\tsuccess: function(msg){\r\n\t\t\t\tif( parseInt(msg) === 0 ) {\r\n\t\t\t\t\talert(ctUsersCheck.ct_bad_csv);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tvar url = URL.createObjectURL(new Blob([msg]));\r\n\r\n\t\t\t\t\tvar dummy = document.createElement('a');\r\n\t\t\t\t\tdummy.href = url;\r\n\t\t\t\t\tdummy.download = ctUsersCheck.ct_csv_filename + '.csv';\r\n\r\n\t\t\t\t\tdocument.body.appendChild(dummy);\r\n\t\t\t\t\tdummy.click();\r\n\t\t\t\t}\r\n\t\t\t\tjQuery('.' + e.target.id).removeClass('disabled');\r\n\t\t\t\tjQuery('.spinner').css('visibility', 'hidden');\r\n\t\t\t}\r\n\t\t});\r\n\t});\r\n\r\n\t// Delete inserted users\r\n\tjQuery(\".ct_insert_users\").click(function( e ){\r\n\t\tct_insert_users();\r\n\t});\r\n\r\n\t// Insert users\r\n\tjQuery(\".ct_insert_users__delete\").click(function( e ){\r\n\t\tct_insert_users( true );\r\n\t});\r\n\r\n\t// Delete all spam users\r\n\tjQuery(\".ct_delete_all_users\").click(function( e ){\r\n\r\n\t\tif ( ! confirm( ctUsersCheck.ct_confirm_deletion_all ) )\r\n\t\t\treturn false;\r\n\r\n\t\tct_delete_all_users( e );\r\n\r\n\t});\r\n\r\n\tfunction ct_insert_users(delete_accounts){\r\n\r\n\t\tdelete_accounts = delete_accounts || null;\r\n\r\n\t\tvar data = {\r\n\t\t\t'action': 'ajax_insert_users',\r\n\t\t\t'security': ct_ajax_nonce\r\n\t\t};\r\n\r\n\t\tif(delete_accounts)\r\n\t\t\tdata['delete'] = true;\r\n\r\n\t\tjQuery.ajax({\r\n\t\t\ttype: \"POST\",\r\n\t\t\turl: ajaxurl,\r\n\t\t\tdata: data,\r\n\t\t\tsuccess: function(msg){\r\n\t\t\t\tif(delete_accounts)\r\n\t\t\t\t\talert('Deleted ' + msg + ' users');\r\n\t\t\t\telse\r\n\t\t\t\t\talert('Inserted ' + msg + ' users');\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n});"],"names":["String","prototype","printf","formatted","this","arg","arguments","before_formatted","substring","indexOf","after_formatted","length","ct_working","document","cookie","ct_new_check","ct_cooling_down_flag","ct_close_animate","ct_accurate_check","ct_pause","ct_prev_accurate","ctUsersCheck","ct_prev_from","ct_prev_till","ct_cool_down_time","ct_requests_counter","ct_max_requests","ct_ajax_nonce","ct_users_total","ct_users_checked","ct_users_spam","ct_users_bad","ct_unchecked","ct_date_from","ct_date_till","apbct_cookie__get","names","prefixes","split","forEach","item","i","arr","curr","trim","name","all","prefix","apbct_get_cookie","animate_comment","to","id","jQuery","fadeTo","ct_clear_users","from","till","is","val","data","action","security","ajax","type","url","ajaxurl","success","msg","ct_show_users_info","ct_send_users","ct_cooling_down_toggle","setTimeout","check_amount","new_check","unchecked","amount","new_href","status_string","parseJSON","parseInt","error","confirm","error_message","location","href","end","hide","checked","spam","bad","ct_status_string","ct_status_string_warning","html","jqXHR","textStatus","errorThrown","show","timeout","message","ct_toggle_depended","obj","secondary","depended","prop","removeProp","ct_start_check","continue_check","alert","ct_delete_all_users","e","target","addClass","css","removeClass","ready","state","on","datepicker","setDefaults","regional","dates","dateFormat","maxDate","changeMonth","changeYear","showAnim","onSelect","selectedDate","option","instance","date","parseDate","settings","_defaults","not","ct_insert_users","delete_accounts","click","ct_check","accurate","JSON","stringify","ct_id","attr","fadeOut","remove","user_id","status","filename","ct_csv_filename","dummy","ct_bad_csv","URL","createObjectURL","Blob","createElement","download","body","appendChild","ct_confirm_deletion_all"],"mappings":"AACAA,OAAOC,UAAUC,OAAS,WACtB,IAAIC,EAAYC,KAChB,IAAK,IAAIC,KAAOC,UAClB,IAAIC,EAAmBJ,EAAUK,UAAU,EAAGL,EAAUM,QAAQ,KAAM,IAClEC,EAAmBP,EAAUK,UAAUL,EAAUM,QAAQ,KAAM,GAAG,EAAGN,EAAUQ,QACnFR,EAAYI,EAAmBD,UAAUD,GAAOK,EAE9C,OAAOP,GAOX,IAAIS,aAHJC,SAASC,OAAS,sCAIjBC,cAAe,EACfC,sBAAuB,EACvBC,kBAAmB,EACnBC,mBAAoB,EACpBC,UAAW,EACXC,iBAAmBC,aAAaD,iBAChCE,aA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,SAAU5B,GAC1C0B,MAIDnF,OAAO,4BAA4BqF,MAAM,SAAU5B,GAClD0B,GAAiB,KAIlBnF,OAAO,wBAAwBqF,MAAM,SAAU5B,GAE9C,QAAO5B,QAAS5D,aAAa0I,+BAG7BnD,oBAAqBC"}
|
1 |
+
{"version":3,"file":"cleantalk-users-checkspam.min.js","sources":["cleantalk-users-checkspam.js"],"sourcesContent":["// Printf for JS\r\nString.prototype.printf = function(){\r\n var formatted = this;\r\n for( var arg in arguments ) {\r\n\t\tvar before_formatted = formatted.substring(0, formatted.indexOf(\"%s\", 0));\r\n\t\tvar after_formatted = formatted.substring(formatted.indexOf(\"%s\", 0)+2, formatted.length);\r\n\t\tformatted = before_formatted + arguments[arg] + after_formatted;\r\n }\r\n return formatted;\r\n};\r\n\r\n// Set deafult amount to check by request.\r\ndocument.cookie = \"ct_check_users__amount=\" + 100 + \"; path=/; samesite=lax\";\r\n\r\n// Flags\r\nvar ct_working = false,\r\n\tct_new_check = true,\r\n\tct_cooling_down_flag = false,\r\n\tct_close_animate = true,\r\n\tct_accurate_check = false,\r\n\tct_pause = false,\r\n\tct_prev_accurate = ctUsersCheck.ct_prev_accurate,\r\n\tct_prev_from = ctUsersCheck.ct_prev_from,\t\r\n\tct_prev_till = ctUsersCheck.ct_prev_till;\r\n// Settings\r\nvar ct_cool_down_time = 90000,\r\n\tct_requests_counter = 0,\r\n\tct_max_requests = 60;\r\n// Variables\r\nvar ct_ajax_nonce = ctUsersCheck.ct_ajax_nonce,\r\n\tct_users_total = 0,\r\n\tct_users_checked = 0,\r\n\tct_users_spam = 0,\r\n\tct_users_bad = 0,\r\n\tct_unchecked = 'unset',\r\n\tct_date_from = 0,\r\n\tct_date_till = 0;\r\n\r\n/* Function: Reuturns cookie with prefix */\r\nfunction apbct_cookie__get(names, prefixes){\r\n\tvar cookie = {};\r\n\tnames = names || null;\r\n\tif(typeof names == 'string') names = names.split();\r\n\tprefixes = prefixes || ['apbct_', 'ct_'];\r\n\tif(prefixes === 'none') prefixes = null;\r\n\tif(typeof prefixes == 'string') prefixes = prefixes.split();\r\n\tdocument.cookie.split(';').forEach(function(item, i, arr){\r\n\t\tvar curr = item.trim().split('=');\r\n\t\t// Detect by full cookie name\r\n\t\tif(names){\r\n\t\t\tnames.forEach(function(name, i, all){\r\n\t\t\t\tif(curr[0] === name)\r\n\t\t\t\t\tcookie[curr[0]] = (curr[1]);\r\n\t\t\t});\r\n\t\t}\r\n\t\t// Detect by name prefix\r\n\t\tif(prefixes){\r\n\t\t\tprefixes.forEach(function(prefix, i, all){\r\n\t\t\t\tif(curr[0].indexOf(prefix) === 0)\r\n\t\t\t\t\tcookie[curr[0]] = (curr[1]);\r\n\t\t\t});\r\n\t\t}\r\n\t});\r\n\treturn cookie;\r\n}\r\n\r\nfunction apbct_get_cookie( name ){\r\n\tvar cookie = apbct_cookie__get( name, name );\r\n\tif(typeof cookie === 'object' && typeof cookie[name] != 'undefined'){\r\n\t\treturn cookie[name];\r\n\t}else\r\n\t\treturn null;\r\n}\r\n\r\nfunction animate_comment(to,id){\r\n\tif(ct_close_animate){\r\n\t\tif(to === 0.3){\r\n\t\t\tjQuery('#comment-'+id).fadeTo(200,to,function(){\r\n\t\t\t\tanimate_comment(1,id)\r\n\t\t\t});\r\n\t\t}else{\r\n\t\t\tjQuery('#comment-'+id).fadeTo(200,to,function(){\r\n\t\t\t\tanimate_comment(0.3,id)\r\n\t\t\t});\r\n\t\t}\r\n\t}else{\r\n\t\tct_close_animate=true;\r\n\t}\r\n}\r\n\r\nfunction ct_clear_users(){\r\n\r\n\tvar from = 0, till = 0;\r\n\tif(jQuery('#ct_allow_date_range').is(':checked')) {\r\n\t\tfrom = jQuery('#ct_date_range_from').val();\r\n\t\ttill = jQuery('#ct_date_range_till').val();\r\n\t}\r\n\tvar data = {\r\n\t\t'action' : 'ajax_clear_users',\r\n\t\t'security' : ct_ajax_nonce,\r\n\t\t'from' : from,\r\n\t\t'till' : till,\r\n\t\t'no_cache': Math.random()\r\n\t};\r\n\r\n\tjQuery.ajax({\r\n\t\ttype: \"POST\",\r\n\t\turl: ajaxurl,\r\n\t\tdata: data,\r\n\t\tsuccess: function(msg){\r\n\t\t\tct_show_users_info();\r\n\t\t\tct_send_users();\r\n\t\t}\r\n\t});\r\n\r\n}\r\n\r\n//Continues the check after cooldown time\r\n//Called by ct_send_users();\r\nfunction ct_cooling_down_toggle(){\r\n\tct_cooling_down_flag = false;\r\n\tct_send_users();\r\n\tct_show_users_info();\r\n}\r\n\r\nfunction ct_send_users(){\r\n\t\r\n\tif(ct_cooling_down_flag === true)\r\n\t\treturn;\r\n\t\r\n\tif(ct_requests_counter >= ct_max_requests){\r\n\t\tsetTimeout(ct_cooling_down_toggle, ct_cool_down_time);\r\n\t\tct_requests_counter = 0;\r\n\t\tct_cooling_down_flag = true;\r\n\t\treturn;\r\n\t}else{\r\n\t\tct_requests_counter++;\r\n\t}\r\n\r\n\tvar check_amount = apbct_get_cookie('ct_check_users__amount');\r\n\r\n\tvar data = {\r\n\t\taction: 'ajax_check_users',\r\n\t\tsecurity: ct_ajax_nonce,\r\n\t\tnew_check: ct_new_check,\r\n\t\tunchecked: ct_unchecked,\r\n\t\tamount: check_amount,\r\n\t\t'no_cache': Math.random()\r\n\t};\r\n\t\r\n\tif(ct_accurate_check)\r\n\t\tdata['accurate_check'] = true;\r\n\t\r\n\tif(ct_date_from && ct_date_till){\r\n\t\tdata['from'] = ct_date_from;\r\n\t\tdata['till'] = ct_date_till;\r\n\t}\r\n\t\r\n\tjQuery.ajax({\r\n\t\ttype: \"POST\",\r\n\t\turl: ajaxurl,\r\n\t\tdata: data,\r\n\t\tsuccess: function(msg){\r\n\t\t\t\r\n\t\t\tmsg = jQuery.parseJSON(msg);\r\n\t\t\t\r\n\t\t\tif(parseInt(msg.error)){\r\n\t\t\t\tct_working=false;\r\n\t\t\t\tif(!confirm(msg.error_message+\". Do you want to proceed?\")){\r\n\t\t\t\t\tvar new_href = 'users.php?page=ct_check_users';\r\n\t\t\t\t\tif(ct_date_from != 0 && ct_date_till != 0)\r\n\t\t\t\t\t\tnew_href+='&from='+ct_date_from+'&till='+ct_date_till;\r\n\t\t\t\t\tlocation.href = new_href;\r\n\t\t\t\t}else\r\n\t\t\t\t\tct_send_users();\r\n\t\t\t}else{\r\n\t\t\t\tct_new_check = false;\r\n\t\t\t\tif(parseInt(msg.end) == 1 || ct_pause == true){\r\n\t\t\t\t\tif(parseInt(msg.end) == 1)\r\n\t\t\t\t\t\tdocument.cookie = 'ct_paused_users_check=0; path=/; samesite=lax';\r\n\t\t\t\t\tct_working=false;\r\n\t\t\t\t\tjQuery('#ct_working_message').hide();\r\n\t\t\t\t\tvar new_href = 'users.php?page=ct_check_users&ct_worked=1';\r\n\t\t\t\t\tif(ct_date_from != 0 && ct_date_till != 0)\r\n\t\t\t\t\t\tnew_href+='&from='+ct_date_from+'&till='+ct_date_till;\r\n\t\t\t\t\tlocation.href = new_href;\r\n\t\t\t\t}else if(parseInt(msg.end) == 0){\r\n\t\t\t\t\tct_users_checked = parseInt( ct_users_checked ) + parseInt( msg.checked );\r\n\t\t\t\t\tct_users_spam = parseInt( ct_users_spam ) + parseInt (msg.spam );\r\n\t\t\t\t\tct_users_bad = parseInt( ct_users_bad ) + parseInt( msg.bad );\r\n\t\t\t\t\tct_unchecked = ct_users_total - ct_users_checked - ct_users_bad;\r\n\t\t\t\t\tvar status_string = String(ctUsersCheck.ct_status_string);\r\n\t\t\t\t\tvar status_string = status_string.printf(ct_users_checked, ct_users_spam, ct_users_bad);\r\n\t\t\t\t\tif(parseInt(ct_users_spam) > 0)\r\n\t\t\t\t\t\tstatus_string += ctUsersCheck.ct_status_string_warning;\r\n\t\t\t\t\tjQuery('#ct_checking_status').html(status_string);\r\n\t\t\t\t\tjQuery('#ct_error_message').hide();\r\n\t\t\t\t\tct_send_users();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t},\r\n error: function(jqXHR, textStatus, errorThrown) {\r\n\t\t\tif(check_amount > 20){\r\n\t\t\t\tcheck_amount -= 20;\r\n\t\t\t\tdocument.cookie = \"ct_check_users__amount=\" + check_amount + \"; path=/; samesite=lax\";\r\n\t\t\t}\r\n\t\t\tjQuery('#ct_error_message').show();\r\n\t\t\tjQuery('#cleantalk_ajax_error').html(textStatus);\r\n\t\t\tjQuery('#cleantalk_js_func').html('Check users');\r\n\t\t\tsetTimeout(ct_send_users(), 3000);\r\n },\r\n timeout: 25000\r\n\t});\r\n}\r\nfunction ct_show_users_info(){\r\n\t\r\n\tif( ct_working ){\r\n\t\t\r\n\t\tif(ct_cooling_down_flag === true){\r\n\t\t\tjQuery('#ct_cooling_notice').html('Waiting for API to cool down. (About a minute)').show();\r\n\t\t\treturn;\t\t\t\r\n\t\t}else{\r\n\t\t\tjQuery('#ct_cooling_notice').hide();\r\n\t\t}\r\n\t\t\r\n\t\tif( ! ct_users_total ){\r\n\t\t\t\r\n\t\t\tvar data = {\r\n\t\t\t\t'action': 'ajax_info_users',\r\n\t\t\t\t'security': ct_ajax_nonce,\r\n\t\t\t\t'no_cache': Math.random()\r\n\t\t\t};\r\n\t\t\t\r\n\t\t\tif( ct_date_from && ct_date_till ){\r\n\t\t\t\tdata['from'] = ct_date_from;\r\n\t\t\t\tdata['till'] = ct_date_till;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tjQuery.ajax({\r\n\t\t\t\ttype: \"POST\",\r\n\t\t\t\turl: ajaxurl,\r\n\t\t\t\tdata: data,\r\n\t\t\t\tsuccess: function(msg){\r\n\t\t\t\t\tmsg = jQuery.parseJSON(msg);\r\n\t\t\t\t\tjQuery('#ct_checking_status').html(msg.message);\r\n\t\t\t\t\tct_users_spam = msg.spam;\r\n\t\t\t\t\tct_users_checked = msg.checked;\r\n\t\t\t\t\tct_users_bad = msg.bad;\r\n\t\t\t\t},\r\n\t\t\t\terror: function (jqXHR, textStatus, errorThrown){\r\n\t\t\t\t\tjQuery('#ct_error_message').show();\r\n\t\t\t\t\tjQuery('#cleantalk_ajax_error').html(textStatus);\r\n\t\t\t\t\tjQuery('#cleantalk_js_func').html('Show users');\r\n\t\t\t\t\tsetTimeout(ct_show_users_info(), 3000);\r\n\t\t\t\t},\r\n\t\t\t\ttimeout: 15000\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n}\r\n// Function to toggle dependences\r\nfunction ct_toggle_depended(obj, secondary){\r\n\r\n secondary = secondary || null;\r\n\r\n\tvar depended = jQuery(obj.data('depended')),\r\n\t\tstate = obj.data('state');\r\n\t\t\r\n\tif(!state && !secondary){\r\n\t\tobj.data('state', true);\r\n\t\tdepended.removeProp('disabled');\r\n\t}else{\r\n\t\tobj.data('state', false);\r\n\t\tdepended.prop('disabled', true);\r\n\t\tdepended.removeProp('checked');\r\n\t\tif(depended.data('depended'))\r\n\t\t\tct_toggle_depended(depended, true);\r\n\t}\r\n}\r\n\r\n// Main function of checking\r\nfunction ct_start_check( continue_check ){\r\n\r\n\tcontinue_check = continue_check || null;\r\n\r\n\tif(jQuery('#ct_allow_date_range').is(':checked')){\r\n\r\n\t\tct_date_from = jQuery('#ct_date_range_from').val();\r\n\t\tct_date_till = jQuery('#ct_date_range_till').val();\r\n\r\n\t\tif(!(ct_date_from !== '' && ct_date_till !== '')){\r\n\t\t\talert('Please, specify a date range.');\r\n\t\t\treturn;\r\n\t\t}\r\n\t}\r\n\r\n\tif(jQuery('#ct_accurate_check').is(':checked')){\r\n\t\tct_accurate_check = true;\r\n\t}\r\n\r\n\tjQuery('.ct_to_hide').hide();\r\n\tjQuery('#ct_working_message').show();\r\n\tjQuery('#ct_preloader').show();\r\n\tjQuery('#ct_pause').show();\r\n\r\n\tct_working = true;\r\n\r\n\tif( continue_check ){\r\n\t\tct_show_users_info();\r\n\t\tct_send_users();\r\n\t} else {\r\n\t\tct_clear_users();\r\n\t}\r\n\r\n}\r\n\r\nfunction ct_delete_all_users( e ){\r\n\r\n\tvar data = {\r\n\t\t'action': 'ajax_delete_all_users',\r\n\t\t'security': ct_ajax_nonce,\r\n\t\t'no_cache': Math.random()\r\n\t};\r\n\r\n\tjQuery('.' + e.target.id).addClass('disabled');\r\n\tjQuery('.spinner').css('visibility', 'visible');\r\n\tjQuery.ajax({\r\n\t\ttype: \"POST\",\r\n\t\turl: ajaxurl,\r\n\t\tdata: data,\r\n\t\tsuccess: function( msg ){\r\n\t\t\tif( msg > 0 ){\r\n\t\t\t\tjQuery('#cleantalk_users_left').html(msg);\r\n\t\t\t\tct_delete_all_users( e, data );\r\n\t\t\t}else{\r\n\t\t\t\tjQuery('.' + e.target.id).removeClass('disabled');\r\n\t\t\t\tjQuery('.spinner').css('visibility', 'hidden');\r\n\t\t\t\tlocation.href='users.php?page=ct_check_users_total';\r\n\t\t\t}\r\n\t\t},\r\n\t\terror: function(jqXHR, textStatus, errorThrown) {\r\n\t\t\tjQuery('#ct_error_message').show();\r\n\t\t\tjQuery('#cleantalk_ajax_error').html(textStatus);\r\n\t\t\tjQuery('#cleantalk_js_func').html('All users deleteion');\r\n\t\t\tsetTimeout(ct_delete_all_users( e ), 3000);\r\n\t\t},\r\n\t\ttimeout: 25000\r\n\t});\r\n}\r\n\r\njQuery(document).ready(function(){\r\n\r\n\t// Setting dependences\r\n\t// jQuery('#ct_accurate_check') .data({'depended': '#ct_allow_date_range', 'state': false});\r\n\tjQuery('#ct_allow_date_range').data({'depended': '.ct_date', 'state': false});\r\n\t\r\n\t// Prev check parameters\r\n\tif(ct_prev_accurate){\r\n\t\tjQuery(\"#ct_accurate_check\").prop('checked', true);\r\n\t}\r\n\tif(ct_prev_from){\r\n\t\tjQuery(\"#ct_allow_date_range\").prop('checked', true).data('state', true);\r\n\t\tjQuery(\"#ct_date_range_from\").removeProp('disabled').val(ct_prev_from);\r\n\t\tjQuery(\"#ct_date_range_till\").removeProp('disabled').val(ct_prev_till);\r\n\t}\r\n\t\r\n\t// Toggle dependences\r\n\tjQuery(\"#ct_allow_date_range, #ct_accurate_check\").on('change', function(){\r\n\t\tct_toggle_depended(jQuery(this));\r\n\t});\r\n\r\n\tjQuery.datepicker.setDefaults(jQuery.datepicker.regional['en']);\r\n\tvar dates = jQuery('#ct_date_range_from, #ct_date_range_till').datepicker(\r\n\t\t{\r\n\t\t\tdateFormat: 'M d yy',\r\n\t\t\tmaxDate:\"+0D\",\r\n\t\t\tchangeMonth:true,\r\n\t\t\tchangeYear:true,\r\n\t\t\tshowAnim: 'slideDown',\r\n\t\t\tonSelect: function(selectedDate){\r\n\t\t\tvar option = this.id == \"ct_date_range_from\" ? \"minDate\" : \"maxDate\",\r\n\t\t\t\tinstance = jQuery( this ).data( \"datepicker\" ),\r\n\t\t\t\tdate = jQuery.datepicker.parseDate(\r\n\t\t\t\t\tinstance.settings.dateFormat || jQuery.datepicker._defaults.dateFormat,\r\n\t\t\t\t\tselectedDate, instance.settings);\r\n\t\t\t\tdates.not(this).datepicker(\"option\", option, date);\r\n\t\t\t}\r\n\t\t}\r\n\t);\r\n\t\r\n\t// Check users\r\n\tjQuery(\"#ct_check_spam_button\").click(function(){\r\n\t\tdocument.cookie = 'ct_paused_users_check=0; path=/; samesite=lax';\r\n\t\tct_start_check(false);\r\n\t});\r\n\tjQuery(\"#ct_proceed_check_button\").click(function(){\r\n\t\tct_start_check(true);\r\n\t});\r\n\t\r\n\t// Pause the check\r\n\tjQuery('#ct_pause').on('click', function(){\r\n\t\tct_pause = true;\r\n\t\tvar ct_check = {\r\n\t\t\t'accurate': ct_accurate_check,\r\n\t\t\t'from' : ct_date_from,\r\n\t\t\t'till' : ct_date_till\r\n\t\t};\r\n\t\tdocument.cookie = 'ct_paused_users_check=' + JSON.stringify(ct_check) + '; path=/; samesite=lax';\r\n\t});\r\n\t\t\r\n\t//Approve button\r\n\tjQuery(\".cleantalk_delete_from_list_button\").click(function(){\r\n\t\tct_id = jQuery(this).attr(\"data-id\");\r\n\t\t\r\n\t\t// Approving\r\n\t\tvar data = {\r\n\t\t\t'action': 'ajax_ct_approve_user',\r\n\t\t\t'security': ct_ajax_nonce,\r\n\t\t\t'id': ct_id,\r\n\t\t\t'no_cache': Math.random()\r\n\t\t};\r\n\t\tjQuery.ajax({\r\n\t\t\ttype: \"POST\",\r\n\t\t\turl: ajaxurl,\r\n\t\t\tdata: data,\r\n\t\t\tsuccess: function(msg){\r\n\t\t\t\tjQuery(\"#comment-\"+ct_id).fadeOut('slow', function(){\r\n\t\t\t\t\tjQuery(\"#comment-\"+ct_id).remove();\r\n\t\t\t\t});\r\n\t\t\t},\r\n\t\t});\r\n\t\t\r\n\t\t// Positive feedback\r\n\t\tvar data = {\r\n\t\t\t'action': 'ct_feedback_user',\r\n\t\t\t'security': ct_ajax_nonce,\r\n\t\t\t'user_id': ct_id,\r\n\t\t\t'status': 'approve',\r\n\t\t\t'no_cache': Math.random()\r\n\t\t};\r\n\t\tjQuery.ajax({\r\n\t\t\ttype: \"POST\",\r\n\t\t\turl: ajaxurl,\r\n\t\t\tdata: data,\r\n\t\t\tsuccess: function(msg){\r\n\t\t\t\tif(msg == 1){\r\n\t\t\t\t\t// Success\r\n\t\t\t\t}\r\n\t\t\t\tif(msg == 0){\r\n\t\t\t\t\t// Error occurred\r\n\t\t\t\t}\r\n\t\t\t\tif(msg == 'no_hash'){\r\n\t\t\t\t\t// No hash\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\terror: function(jqXHR, textStatus, errorThrown) {\r\n\t\t\t\t\r\n\t\t\t},\r\n\t\t\ttimeout: 5000\r\n\t\t});\r\n\t\t\r\n\t});\r\n\t\r\n\t// Request to Download CSV file.\r\n\tjQuery(\".ct_get_csv_file\").click(function( e ){\r\n\t\tvar data = {\r\n\t\t\t'action': 'ajax_ct_get_csv_file',\r\n\t\t\t'security': ct_ajax_nonce,\r\n\t\t\t'filename': ctUsersCheck.ct_csv_filename,\r\n\t\t\t'no_cache': Math.random()\r\n\t\t};\r\n\t\tjQuery('.' + e.target.id).addClass('disabled');\r\n\t\tjQuery('.spinner').css('visibility', 'visible');\r\n\t\tjQuery.ajax({\r\n\t\t\ttype: \"POST\",\r\n\t\t\turl: ajaxurl,\r\n\t\t\tdata: data,\r\n\t\t\tsuccess: function(msg){\r\n\t\t\t\tif( parseInt(msg) === 0 ) {\r\n\t\t\t\t\talert(ctUsersCheck.ct_bad_csv);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tvar url = URL.createObjectURL(new Blob([msg]));\r\n\r\n\t\t\t\t\tvar dummy = document.createElement('a');\r\n\t\t\t\t\tdummy.href = url;\r\n\t\t\t\t\tdummy.download = ctUsersCheck.ct_csv_filename + '.csv';\r\n\r\n\t\t\t\t\tdocument.body.appendChild(dummy);\r\n\t\t\t\t\tdummy.click();\r\n\t\t\t\t}\r\n\t\t\t\tjQuery('.' + e.target.id).removeClass('disabled');\r\n\t\t\t\tjQuery('.spinner').css('visibility', 'hidden');\r\n\t\t\t}\r\n\t\t});\r\n\t});\r\n\r\n\t// Delete inserted users\r\n\tjQuery(\".ct_insert_users\").click(function( e ){\r\n\t\tct_insert_users();\r\n\t});\r\n\r\n\t// Insert users\r\n\tjQuery(\".ct_insert_users__delete\").click(function( e ){\r\n\t\tct_insert_users( true );\r\n\t});\r\n\r\n\t// Delete all spam users\r\n\tjQuery(\".ct_delete_all_users\").click(function( e ){\r\n\r\n\t\tif ( ! confirm( ctUsersCheck.ct_confirm_deletion_all ) )\r\n\t\t\treturn false;\r\n\r\n\t\tct_delete_all_users( e );\r\n\r\n\t});\r\n\r\n\tfunction ct_insert_users(delete_accounts){\r\n\r\n\t\tdelete_accounts = delete_accounts || null;\r\n\r\n\t\tvar data = {\r\n\t\t\t'action': 'ajax_insert_users',\r\n\t\t\t'security': ct_ajax_nonce,\r\n\t\t\t'no_cache': Math.random()\r\n\t\t};\r\n\r\n\t\tif(delete_accounts)\r\n\t\t\tdata['delete'] = true;\r\n\r\n\t\tjQuery.ajax({\r\n\t\t\ttype: \"POST\",\r\n\t\t\turl: ajaxurl,\r\n\t\t\tdata: data,\r\n\t\t\tsuccess: function(msg){\r\n\t\t\t\tif(delete_accounts)\r\n\t\t\t\t\talert('Deleted ' + msg + ' users');\r\n\t\t\t\telse\r\n\t\t\t\t\talert('Inserted ' + msg + ' users');\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n});"],"names":["String","prototype","printf","formatted","this","arg","arguments","before_formatted","substring","indexOf","after_formatted","length","ct_working","document","cookie","ct_new_check","ct_cooling_down_flag","ct_close_animate","ct_accurate_check","ct_pause","ct_prev_accurate","ctUsersCheck","ct_prev_from","ct_prev_till","ct_cool_down_time","ct_requests_counter","ct_max_requests","ct_ajax_nonce","ct_users_total","ct_users_checked","ct_users_spam","ct_users_bad","ct_unchecked","ct_date_from","ct_date_till","apbct_cookie__get","names","prefixes","split","forEach","item","i","arr","curr","trim","name","all","prefix","apbct_get_cookie","animate_comment","to","id","jQuery","fadeTo","ct_clear_users","from","till","is","val","data","action","security","no_cache","Math","random","ajax","type","url","ajaxurl","success","msg","ct_show_users_info","ct_send_users","ct_cooling_down_toggle","setTimeout","check_amount","new_check","unchecked","amount","new_href","status_string","parseJSON","parseInt","error","confirm","error_message","location","href","end","hide","checked","spam","bad","ct_status_string","ct_status_string_warning","html","jqXHR","textStatus","errorThrown","show","timeout","message","ct_toggle_depended","obj","secondary","depended","prop","removeProp","ct_start_check","continue_check","alert","ct_delete_all_users","e","target","addClass","css","removeClass","ready","state","on","datepicker","setDefaults","regional","dates","dateFormat","maxDate","changeMonth","changeYear","showAnim","onSelect","selectedDate","option","instance","date","parseDate","settings","_defaults","not","ct_insert_users","delete_accounts","click","ct_check","accurate","JSON","stringify","ct_id","attr","fadeOut","remove","user_id","status","filename","ct_csv_filename","dummy","ct_bad_csv","URL","createObjectURL","Blob","createElement","download","body","appendChild","ct_confirm_deletion_all"],"mappings":"AACAA,OAAOC,UAAUC,OAAS,WACtB,IAAIC,EAAYC,KAChB,IAAK,IAAIC,KAAOC,UAClB,IAAIC,EAAmBJ,EAAUK,UAAU,EAAGL,EAAUM,QAAQ,KAAM,IAClEC,EAAmBP,EAAUK,UAAUL,EAAUM,QAAQ,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QACLT,KAAMA,EACNU,QAAS,SAASC,GACjB,IAGKH,EAEAsF,EALiB,IAAlBvE,SAASZ,GACZwC,MAAMzF,aAAaqI,aAEfvF,EAAMwF,IAAIC,gBAAgB,IAAIC,KAAK,CAACvF,MAEpCmF,EAAQ5I,SAASiJ,cAAc,MAC7BvE,KAAOpB,EACbsF,EAAMM,SAAW1I,aAAamI,gBAAkB,OAEhD3I,SAASmJ,KAAKC,YAAYR,GAC1BA,EAAMb,SAEPxF,OAAO,IAAM4D,EAAEC,OAAO9D,IAAIiE,YAAY,YACtChE,OAAO,YAAY+D,IAAI,aAAc,eAMxC/D,OAAO,oBAAoBwF,MAAM,SAAU5B,GAC1C0B,MAIDtF,OAAO,4BAA4BwF,MAAM,SAAU5B,GAClD0B,GAAiB,KAIlBtF,OAAO,wBAAwBwF,MAAM,SAAU5B,GAE9C,QAAO5B,QAAS/D,aAAa6I,+BAG7BnD,oBAAqBC"}
|
@@ -1,2 +1,2 @@
|
|
1 |
-
function ct_is_email(
|
2 |
-
//# sourceMappingURL=cleantalk-users-editscreen.min.js.map
|
1 |
+
function ct_is_email(e){return e.search(/.*@.*\..*/)}function ct_is_ip(e){return e.search(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/)}jQuery(document).ready(function(){parseInt(ctUsersScreen.ct_show_check_links)&&(jQuery(".column-email a").each(function(){var e=jQuery(this).html();-1!==ct_is_email(e)&&jQuery(this).after(' <a href="https://cleantalk.org/blacklists/'+e+'" target="_blank" title="https://cleantalk.org/blacklists/'+e+'" class="ct_link_new_tab"><img src="'+ctUsersScreen.ct_img_src_new_tab+'"></a>')}),jQuery(".username.column-username").each(function(){var e=jQuery(this).siblings(".apbct_status").children("span"),t=e.attr("id"),c=e.text(),r=jQuery("<span>",{text:c}),s=jQuery("<i>",{class:"icon-ok"}),a=jQuery("<i>",{class:"icon-cancel",css:{color:"red"}});"apbct_not_checked"===t&&jQuery(this).children(".row-actions").before(s).before(r),"apbct_checked_not_spam"===t&&(s.attr("style","color:green;"),jQuery(this).children(".row-actions").before(s).before(r)),"apbct_checked_spam"===t&&jQuery(this).children(".row-actions").before(a).before(r)}))});
|
2 |
+
//# sourceMappingURL=cleantalk-users-editscreen.min.js.map
|
@@ -1 +1 @@
|
|
1 |
-
{"version":3,"
|
1 |
+
{"version":3,"file":"cleantalk-users-editscreen.min.js","sources":["cleantalk-users-editscreen.js"],"sourcesContent":["function ct_is_email(str){\r\n\treturn str.search(/.*@.*\\..*/);\r\n}\r\nfunction ct_is_ip(str){\r\n\treturn str.search(/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/);\r\n}\r\n\r\njQuery(document).ready(function(){\r\n\r\n\r\n\tif(parseInt(ctUsersScreen.ct_show_check_links)) {\r\n\r\n\t\t/* Shows link to blacklists near every email and IP address */\r\n\t\tjQuery('.column-email a').each(function(){\r\n\t\t\tvar ct_curr_str = jQuery(this).html();\r\n\t\t\tif( ct_is_email(ct_curr_str) !== -1 ){\r\n\t\t\t\tjQuery(this).after(' <a href=\"https://cleantalk.org/blacklists/'+ct_curr_str+'\" target=\"_blank\" title=\"https://cleantalk.org/blacklists/'+ct_curr_str+'\" class=\"ct_link_new_tab\"><img src=\"'+ctUsersScreen.ct_img_src_new_tab+'\"></a>');\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\t/* Show checked ico near avatar */\r\n\t\tjQuery('.username.column-username').each(function(){\r\n\r\n\t\t\tvar apbct_checking_el = jQuery(this).siblings('.apbct_status').children('span');\r\n\t\t\tvar apbct_checking_status = apbct_checking_el.attr('id');\r\n\t\t\tvar apbct_checking_status_text = apbct_checking_el.text();\r\n\r\n\t\t\tvar apbct_add_text_element = jQuery('<span>', {\r\n\t\t\t\ttext : apbct_checking_status_text\r\n\t\t\t});\r\n\t\t\tvar apbct_add_ico_ok = jQuery('<i>', {\r\n\t\t\t\tclass : 'icon-ok'\r\n\t\t\t});\r\n\t\t\tvar apbct_add_ico_cancel = jQuery('<i>', {\r\n\t\t\t\tclass : 'icon-cancel',\r\n\t\t\t\tcss : {\r\n\t\t\t\t\tcolor : 'red'\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t\tif( apbct_checking_status ==='apbct_not_checked' ) {\r\n\t\t\t\tjQuery(this).children('.row-actions').before(apbct_add_ico_ok).before(apbct_add_text_element);\r\n\t\t\t}\r\n\t\t\tif( apbct_checking_status ==='apbct_checked_not_spam' ) {\r\n\t\t\t\tapbct_add_ico_ok.attr('style', 'color:green;');\r\n\t\t\t\tjQuery(this).children('.row-actions').before(apbct_add_ico_ok).before(apbct_add_text_element);\r\n\t\t\t}\r\n\t\t\tif( apbct_checking_status ==='apbct_checked_spam' ) {\r\n\t\t\t\tjQuery(this).children('.row-actions').before(apbct_add_ico_cancel).before(apbct_add_text_element);\r\n\t\t\t}\r\n\r\n\t\t});\r\n\r\n\t}\r\n\r\n});"],"names":["ct_is_email","str","search","ct_is_ip","jQuery","document","ready","parseInt","ctUsersScreen","ct_show_check_links","each","ct_curr_str","this","html","after","ct_img_src_new_tab","apbct_checking_el","siblings","children","apbct_checking_status","attr","apbct_checking_status_text","text","apbct_add_text_element","apbct_add_ico_ok","class","apbct_add_ico_cancel","css","color","before"],"mappings":"AAAA,SAASA,YAAYC,GACpB,OAAOA,EAAIC,OAAO,aAEnB,SAASC,SAASF,GACjB,OAAOA,EAAIC,OAAO,wCAGnBE,OAAOC,UAAUC,MAAM,WAGnBC,SAASC,cAAcC,uBAGzBL,OAAO,mBAAmBM,KAAK,WAC9B,IAAIC,EAAcP,OAAOQ,MAAMC,QACG,IAA9Bb,YAAYW,IACfP,OAAOQ,MAAME,MAAM,mDAAmDH,EAAY,6DAA6DA,EAAY,uCAAuCH,cAAcO,mBAAmB,YAKrOX,OAAO,6BAA6BM,KAAK,WAExC,IAAIM,EAAoBZ,OAAOQ,MAAMK,SAAS,iBAAiBC,SAAS,QACpEC,EAAwBH,EAAkBI,KAAK,MAC/CC,EAA6BL,EAAkBM,OAE/CC,EAAyBnB,OAAO,SAAU,CAC7CkB,KAAOD,IAEJG,EAAmBpB,OAAO,MAAO,CACpCqB,MAAQ,YAELC,EAAuBtB,OAAO,MAAO,CACxCqB,MAAQ,cACRE,IAAM,CACLC,MAAQ,SAImB,sBAAzBT,GACHf,OAAOQ,MAAMM,SAAS,gBAAgBW,OAAOL,GAAkBK,OAAON,GAE1C,2BAAzBJ,IACHK,EAAiBJ,KAAK,QAAS,gBAC/BhB,OAAOQ,MAAMM,SAAS,gBAAgBW,OAAOL,GAAkBK,OAAON,IAE1C,uBAAzBJ,GACHf,OAAOQ,MAAMM,SAAS,gBAAgBW,OAAOH,GAAsBG,OAAON"}
|
@@ -1,2 +1,2 @@
|
|
1 |
-
function sendRequest(e,t,n){var c=createXMLHTTPObject();
|
2 |
-
//# sourceMappingURL=cleantalk_nocache.min.js.map
|
1 |
+
function sendRequest(e,t,n){var c,i=createXMLHTTPObject();i&&(c=n?"POST":"GET",e="https:"===location.protocol?e.replace("http:","https:"):e.replace("https:","http:"),i.open(c,e,!0),n&&i.setRequestHeader("Content-type","application/x-www-form-urlencoded"),i.onreadystatechange=function(){4==i.readyState&&(200!=i.status&&304!=i.status||t(i))},4!=i.readyState&&i.send(n))}"undefined"==typeof ctNocache&&(ctNocache.set_cookies_flag=!0,ctNocache.ajaxurl="/wp-admin/admin-ajax.php");var XMLHttpFactories=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}];function createXMLHTTPObject(){for(var e=!1,t=0;t<XMLHttpFactories.length;t++){try{e=XMLHttpFactories[t]()}catch(e){continue}break}return e}function ct_getCookie(e){var t=document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,"\\$1")+"=([^;]*)"));return t?decodeURIComponent(t[1]):void 0}function ct_setCookie(e,t){var n;return ctNocache.set_cookies_flag&&(document.cookie=e+" =; expires=Thu, 01 Jan 1970 00:00:01 GMT; path = /; samesite=lax",document.cookie=e+" =; expires=Thu, 01 Jan 1970 00:00:01 GMT; samesite=lax",(n=new Date).setDate(n.getDate()+1),setTimeout(function(){document.cookie=e+"="+t+"; expires="+n.toUTCString()+"; path = /; samesite=lax"},500)),null}function ct_callback(t){for(ct_cookie=t.responseText.trim(),ct_setCookie("ct_checkjs",ct_cookie),i=0;i<document.forms.length;i++)for(f=document.forms[i],j=0;j<f.elements.length;j++)e=f.elements[j],void 0!==e.name&&-1!=e.name.indexOf("ct_checkjs")&&(e.value=ct_cookie)}if(Date.now||(Date.now=function(){return(new Date).getTime()}),null==ct_nocache_executed){var ct_nocache_executed=!0,checkjs_cookie=ct_getCookie("ct_checkjs");if(null!=checkjs_cookie)for(i=0;i<document.forms.length;i++)for(f=document.forms[i],j=0;j<f.elements.length;j++)e=f.elements[j],void 0!==e.name&&-1!=e.name.indexOf("ct_checkjs")&&(e.value=checkjs_cookie);if(null==checkjs_cookie&&sendRequest(ctNocache.ajaxurl+"?"+Math.random(),ct_callback,"action=ct_get_cookie"),void 0!==ctNocache.info_flag&&ctNocache.info_flag){var cleantalk_user_info={},cleantalk_screen_info={};for(var prop in screen)navigator[prop]instanceof Object||""===screen[prop]||(cleantalk_screen_info[prop]=screen[prop]);cleantalk_user_info.screen=cleantalk_screen_info;for(var prev,cleantalk_plugins=Array(),cnt=0,i=0;i<navigator.plugins.length;i++){var plugin=navigator.plugins[i];prev!=(plugin=plugin.name+" "+(plugin.version||""))&&(cleantalk_plugins[cnt]=plugin,cnt++,prev=plugin)}cleantalk_user_info.plugins=cleantalk_plugins,cleantalk_user_info.timezone_offset=-(new Date).getTimezoneOffset()/60,cleantalk_user_info.datetime=Math.round((new Date).getTime()/1e3),cleantalk_user_info.browser_x=document.documentElement.clientWidth,cleantalk_user_info.browser_y=document.documentElement.clientHeight;var ua=navigator.userAgent.toLowerCase(),flashInstalled=0;if(void 0!==navigator.plugins&&"object"==typeof navigator.plugins["Shockwave Flash"])flashInstalled=1;else if(void 0!==window.ActiveXObject)try{new ActiveXObject("ShockwaveFlash.ShockwaveFlash")&&(flashInstalled=1)}catch(e){}cleantalk_user_info.is_flash=flashInstalled,isVisitedMain=-1,location.href!="http://"+location.hostname+"/"&&location.href!="https://"+location.hostname+"/"||(isVisitedMain=1,setTimeout(function(){document.cookie="ct_visited_main = 1; path = /; samesite=lax"},1500)),ct_visited_main=ct_getCookie("ct_visited_main"),isVisitedMain=null==ct_visited_main&&-1==isVisitedMain?0:1,cleantalk_user_info.is_main=isVisitedMain,setTimeout(function(){document.cookie="ct_user_info = "+escape(JSON.stringify(cleantalk_user_info))+"; path = /; samesite=lax"},1500)}}
|
2 |
+
//# sourceMappingURL=cleantalk_nocache.min.js.map
|
@@ -1 +1 @@
|
|
1 |
-
{"version":3,"sources":["cleantalk_nocache.js"],"names":["sendRequest","url","callback","postData","req","createXMLHTTPObject","method","location","protocol","replace","open","setRequestHeader","onreadystatechange","readyState","status","send","ctNocache","set_cookies_flag","ajaxurl","XMLHttpFactories","XMLHttpRequest","ActiveXObject","xmlhttp","i","length","e","ct_getCookie","name","matches","document","cookie","match","RegExp","decodeURIComponent","undefined","ct_setCookie","value","date","Date","setDate","getDate","setTimeout","toUTCString","ct_callback","ct_cookie","responseText","trim","forms","f","j","elements","indexOf","now","getTime","ct_nocache_executed","checkjs_cookie","Math","random","info_flag","cleantalk_user_info","cleantalk_screen_info","prop","screen","navigator","Object","prev","cleantalk_plugins","Array","cnt","plugins","plugin","version","timezone_offset","getTimezoneOffset","datetime","round","browser_x","documentElement","clientWidth","browser_y","clientHeight","ua","userAgent","toLowerCase","flashInstalled","window","is_flash","isVisitedMain","href","hostname","ct_visited_main","is_main","escape","JSON","stringify"],"mappings":"AAQA,SAASA,YAAYC,EAAIC,EAASC,GAC9B,IAAIC,EAAMC,sBACV,GAAKD,EAAL,CACA,IAAIE,EAAS,EAAa,OAAS,MAI/BL,EADa,WADFM,SAASC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oBe,SAAWlB,KAAKmB,OAAO,IAAIrC,MAAOe,UAAW,KAEjEM,oBAAoBiB,UAAU/C,SAASgD,gBAAgBC,YACvDnB,oBAAoBoB,UAAUlD,SAASgD,gBAAgBG,aAEvD,IAAIC,GAAKlB,UAAUmB,UAAUC,cACzBC,eAAiB,EACrB,QAA+B,IAApBrB,UAAiB,SAA8D,iBAAvCA,UAAUM,QAAQ,mBAEpEe,eAAiB,OAEb,QAAmC,IAAxBC,OAAOhE,cAEtB,IAEK,IAAIA,cAAc,mCAErB+D,eAAiB,GAEjB,MAAM3D,IAGTkC,oBAAoB2B,SAASF,eAE7BG,eAAe,EACZhF,SAASiF,MAAM,UAAUjF,SAASkF,SAAS,KAAOlF,SAASiF,MAAM,WAAWjF,SAASkF,SAAS,MAEhGF,cAAc,EACd9C,WAAW,WAAaZ,SAASC,OAAS,kCAAmC,OAI9E4D,gBAAkBhE,aAAa,mBAG9B6D,cAFmBrD,MAAjBwD,kBAA8C,GAAhBH,cAElB,EAIA,EAGf5B,oBAAoBgC,QAAQJ,cAE5B9C,WAAW,WAAaZ,SAASC,OAAS,kBAAkB8D,OAAOC,KAAKC,UAAUnC,sBAAsB,eAAgB","file":"cleantalk_nocache.min.js","sourcesContent":["/*\r\n Assign default values for backend variables.\r\n*/\r\nif (typeof ctNocache === 'undefined') {\r\n ctNocache.set_cookies_flag = true;\r\n ctNocache.ajaxurl = '/wp-admin/admin-ajax.php';\r\n}\r\n\r\nfunction sendRequest(url,callback,postData) {\r\n var req = createXMLHTTPObject();\r\n if (!req) return;\r\n var method = (postData) ? \"POST\" : \"GET\";\r\n \r\n var protocol = location.protocol;\r\n if (protocol === 'https:') {\r\n url = url.replace('http:', 'https:');\r\n } else {\r\n url = url.replace('https:', 'http:');\r\n }\r\n \r\n req.open(method,url,true);\r\n if (postData)\r\n req.setRequestHeader('Content-type','application/x-www-form-urlencoded');\r\n req.onreadystatechange = function () {\r\n if (req.readyState != 4) return;\r\n if (req.status != 200 && req.status != 304) {\r\n// alert('HTTP error ' + req.status);\r\n return;\r\n }\r\n callback(req);\r\n };\r\n if (req.readyState == 4) return;\r\n req.send(postData);\r\n}\r\n\r\nvar XMLHttpFactories = [\r\n function () {return new XMLHttpRequest()},\r\n function () {return new ActiveXObject(\"Msxml2.XMLHTTP\")},\r\n function () {return new ActiveXObject(\"Msxml3.XMLHTTP\")},\r\n function () {return new ActiveXObject(\"Microsoft.XMLHTTP\")}\r\n];\r\n\r\nfunction createXMLHTTPObject() {\r\n var xmlhttp = false;\r\n for (var i=0;i<XMLHttpFactories.length;i++) {\r\n try {\r\n xmlhttp = XMLHttpFactories[i]();\r\n }\r\n catch (e) {\r\n continue;\r\n }\r\n break;\r\n }\r\n return xmlhttp;\r\n}\r\n\r\nfunction ct_getCookie(name) {\r\n var matches = document.cookie.match(new RegExp(\r\n \"(?:^|; )\" + name.replace(/([\\.$?*|{}\\(\\)\\[\\]\\\\\\/\\+^])/g, '\\\\$1') + \"=([^;]*)\"\r\n ));\r\n return matches ? decodeURIComponent(matches[1]) : undefined;\r\n}\r\n\r\nfunction ct_setCookie(name, value)\r\n{\r\n if (ctNocache.set_cookies_flag) {\r\n document.cookie = name+\" =; expires=Thu, 01 Jan 1970 00:00:01 GMT; path = /\";\r\n document.cookie = name+\" =; expires=Thu, 01 Jan 1970 00:00:01 GMT\";\r\n \r\n var date = new Date;\r\n date.setDate(date.getDate() + 1);\r\n setTimeout(function() { document.cookie = name+\"=\" + value + \"; expires=\" + date.toUTCString() + \"; path = /;\"}, 500);\r\n }\r\n\r\n return null;\r\n}\r\n\r\nfunction ct_callback(req)\r\n{\r\n\tct_cookie = req.responseText.trim();\r\n\t//alert('Key value: ' + ct_cookie);\r\n\t\r\n\tct_setCookie('ct_checkjs', ct_cookie);\r\n\t\r\n\tfor(i=0;i<document.forms.length;i++)\r\n\t{\r\n\t\tf=document.forms[i];\r\n\t\tfor(j=0;j<f.elements.length;j++)\r\n\t\t{\r\n\t\t\te=f.elements[j];\r\n\t\t\tif(e.name!==undefined&&e.name.indexOf('ct_checkjs')!=-1)\r\n\t\t\t{\r\n\t\t\t\te.value=ct_cookie;\r\n\t\t\t\t//alert('Form #' + i + ', field ' + e.name + ' = ' + ct_cookie);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t//alert('Set cookie: \\n' + document.cookie);\r\n}\r\n\r\nif (!Date.now) {\r\n\tDate.now = function() { return new Date().getTime(); }\r\n}\r\n\r\nif(ct_nocache_executed==undefined)\r\n{\r\n\tvar ct_nocache_executed=true;\r\n\t\r\n\tvar checkjs_cookie=ct_getCookie('ct_checkjs');\r\n\t\r\n\tif(checkjs_cookie!=undefined)\r\n\t{\r\n\t\tfor(i=0;i<document.forms.length;i++)\r\n\t\t{\r\n\t\t\tf=document.forms[i];\r\n\t\t\tfor(j=0;j<f.elements.length;j++)\r\n\t\t\t{\r\n\t\t\t\te=f.elements[j];\r\n\t\t\t\tif(e.name!==undefined&&e.name.indexOf('ct_checkjs')!=-1)\r\n\t\t\t\t{\r\n\t\t\t\t\te.value=checkjs_cookie;\r\n\t\t\t\t\t//alert('Form #' + i + ', field ' + e.name + ' = ' + ct_cookie);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\t\r\n\t\r\n\tif(checkjs_cookie==undefined) //86400 is 24 hours\r\n\t{\r\n\t\tsendRequest(ctNocache.ajaxurl+'?'+Math.random(),ct_callback,'action=ct_get_cookie');\r\n\t}\r\n\t\r\n\tif(typeof ctNocache.info_flag !== 'undefined' && ctNocache.info_flag)\r\n\t{\r\n\t\r\n\t\tvar cleantalk_user_info={};\r\n\t\t\r\n\t\tvar cleantalk_screen_info={};\r\n\t\tfor(var prop in screen)\r\n\t\t{\r\n\t\t\tif (navigator[prop] instanceof Object || screen[prop]==='')\r\n\t\t\t\tcontinue;\r\n\t\t\tcleantalk_screen_info[prop]=screen[prop];\r\n\t\t}\r\n\t\t\r\n\t\tcleantalk_user_info.screen=cleantalk_screen_info;\r\n\t\t\r\n\t\tvar cleantalk_plugins=Array();\r\n\t\tvar prev;\r\n\t\tvar cnt=0;\r\n\t\tfor(var i=0;i<navigator.plugins.length;i++)\r\n\t\t{\r\n\t\t\tvar plugin = navigator.plugins[i];\r\n\t\t\tvar plugin = plugin.name+\" \"+(plugin.version || '')\r\n\t\t\tif (prev == plugin ) continue;\r\n\t\t\tcleantalk_plugins[cnt]=plugin;\r\n\t\t\tcnt++;\r\n\t\t\tprev = plugin;\r\n\t\t}\r\n\t\tcleantalk_user_info.plugins=cleantalk_plugins;\r\n\t\t\r\n\t\tcleantalk_user_info.timezone_offset = -new Date().getTimezoneOffset()/60;\r\n\t\tcleantalk_user_info.datetime = Math.round((new Date().getTime())/1000);\r\n\t\t\r\n\t\tcleantalk_user_info.browser_x=document.documentElement.clientWidth;\r\n\t\tcleantalk_user_info.browser_y=document.documentElement.clientHeight;\r\n\t\t\r\n\t\tvar ua = navigator.userAgent.toLowerCase();\r\n\t\tvar flashInstalled = 0;\r\n\t\tif (typeof(navigator.plugins)!=\"undefined\"&&typeof(navigator.plugins[\"Shockwave Flash\"])==\"object\")\r\n\t\t{\r\n\t\t\tflashInstalled = 1;\r\n\t\t}\r\n\t\telse if (typeof window.ActiveXObject != \"undefined\")\r\n\t\t{\r\n\t\t\ttry\r\n\t\t\t{\r\n\t\t\t\tif (new ActiveXObject(\"ShockwaveFlash.ShockwaveFlash\"))\r\n\t\t\t\t{\r\n\t\t\t\t\tflashInstalled = 1;\r\n\t\t\t\t}\r\n\t\t\t} catch(e) {};\r\n\t\t};\r\n\t\t\r\n\t\tcleantalk_user_info.is_flash=flashInstalled;\r\n\t\t\r\n\t\tisVisitedMain=-1;\r\n\t\tif(location.href=='http://'+location.hostname+'/' || location.href=='https://'+location.hostname+'/')\r\n\t\t{\r\n\t\t\tisVisitedMain=1;\r\n\t\t\tsetTimeout(function() { document.cookie = \"ct_visited_main = 1; path = /;\"}, 1500);\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\t\tct_visited_main = ct_getCookie('ct_visited_main');\r\n\t\tif(ct_visited_main==undefined && isVisitedMain==-1)\r\n\t\t{\r\n\t\t\tisVisitedMain=0;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tisVisitedMain=1;\r\n\t\t}\r\n\t\t\r\n\t\tcleantalk_user_info.is_main=isVisitedMain;\r\n\t\t\r\n\t\tsetTimeout(function() { document.cookie = \"ct_user_info = \"+escape(JSON.stringify(cleantalk_user_info))+\"; path = /;\"}, 1500);\r\n\t}\r\n}"]}
|
1 |
+
{"version":3,"file":"cleantalk_nocache.min.js","sources":["cleantalk_nocache.js"],"sourcesContent":["/*\r\n Assign default values for backend variables.\r\n*/\r\nif (typeof ctNocache === 'undefined') {\r\n ctNocache.set_cookies_flag = true;\r\n ctNocache.ajaxurl = '/wp-admin/admin-ajax.php';\r\n}\r\n\r\nfunction sendRequest(url,callback,postData) {\r\n var req = createXMLHTTPObject();\r\n if (!req) return;\r\n var method = (postData) ? \"POST\" : \"GET\";\r\n \r\n var protocol = location.protocol;\r\n if (protocol === 'https:') {\r\n url = url.replace('http:', 'https:');\r\n } else {\r\n url = url.replace('https:', 'http:');\r\n }\r\n \r\n req.open(method,url,true);\r\n if (postData)\r\n req.setRequestHeader('Content-type','application/x-www-form-urlencoded');\r\n req.onreadystatechange = function () {\r\n if (req.readyState != 4) return;\r\n if (req.status != 200 && req.status != 304) {\r\n// alert('HTTP error ' + req.status);\r\n return;\r\n }\r\n callback(req);\r\n };\r\n if (req.readyState == 4) return;\r\n req.send(postData);\r\n}\r\n\r\nvar XMLHttpFactories = [\r\n function () {return new XMLHttpRequest()},\r\n function () {return new ActiveXObject(\"Msxml2.XMLHTTP\")},\r\n function () {return new ActiveXObject(\"Msxml3.XMLHTTP\")},\r\n function () {return new ActiveXObject(\"Microsoft.XMLHTTP\")}\r\n];\r\n\r\nfunction createXMLHTTPObject() {\r\n var xmlhttp = false;\r\n for (var i=0;i<XMLHttpFactories.length;i++) {\r\n try {\r\n xmlhttp = XMLHttpFactories[i]();\r\n }\r\n catch (e) {\r\n continue;\r\n }\r\n break;\r\n }\r\n return xmlhttp;\r\n}\r\n\r\nfunction ct_getCookie(name) {\r\n var matches = document.cookie.match(new RegExp(\r\n \"(?:^|; )\" + name.replace(/([\\.$?*|{}\\(\\)\\[\\]\\\\\\/\\+^])/g, '\\\\$1') + \"=([^;]*)\"\r\n ));\r\n return matches ? decodeURIComponent(matches[1]) : undefined;\r\n}\r\n\r\nfunction ct_setCookie(name, value)\r\n{\r\n if (ctNocache.set_cookies_flag) {\r\n document.cookie = name+\" =; expires=Thu, 01 Jan 1970 00:00:01 GMT; path = /; samesite=lax\";\r\n document.cookie = name+\" =; expires=Thu, 01 Jan 1970 00:00:01 GMT; samesite=lax\";\r\n \r\n var date = new Date;\r\n date.setDate(date.getDate() + 1);\r\n setTimeout(function() { document.cookie = name+\"=\" + value + \"; expires=\" + date.toUTCString() + \"; path = /; samesite=lax\"}, 500);\r\n }\r\n\r\n return null;\r\n}\r\n\r\nfunction ct_callback(req)\r\n{\r\n\tct_cookie = req.responseText.trim();\r\n\t//alert('Key value: ' + ct_cookie);\r\n\t\r\n\tct_setCookie('ct_checkjs', ct_cookie);\r\n\t\r\n\tfor(i=0;i<document.forms.length;i++)\r\n\t{\r\n\t\tf=document.forms[i];\r\n\t\tfor(j=0;j<f.elements.length;j++)\r\n\t\t{\r\n\t\t\te=f.elements[j];\r\n\t\t\tif(e.name!==undefined&&e.name.indexOf('ct_checkjs')!=-1)\r\n\t\t\t{\r\n\t\t\t\te.value=ct_cookie;\r\n\t\t\t\t//alert('Form #' + i + ', field ' + e.name + ' = ' + ct_cookie);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t//alert('Set cookie: \\n' + document.cookie);\r\n}\r\n\r\nif (!Date.now) {\r\n\tDate.now = function() { return new Date().getTime(); }\r\n}\r\n\r\nif(ct_nocache_executed==undefined)\r\n{\r\n\tvar ct_nocache_executed=true;\r\n\t\r\n\tvar checkjs_cookie=ct_getCookie('ct_checkjs');\r\n\t\r\n\tif(checkjs_cookie!=undefined)\r\n\t{\r\n\t\tfor(i=0;i<document.forms.length;i++)\r\n\t\t{\r\n\t\t\tf=document.forms[i];\r\n\t\t\tfor(j=0;j<f.elements.length;j++)\r\n\t\t\t{\r\n\t\t\t\te=f.elements[j];\r\n\t\t\t\tif(e.name!==undefined&&e.name.indexOf('ct_checkjs')!=-1)\r\n\t\t\t\t{\r\n\t\t\t\t\te.value=checkjs_cookie;\r\n\t\t\t\t\t//alert('Form #' + i + ', field ' + e.name + ' = ' + ct_cookie);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\t\r\n\t\r\n\tif(checkjs_cookie==undefined) //86400 is 24 hours\r\n\t{\r\n\t\tsendRequest(ctNocache.ajaxurl+'?'+Math.random(),ct_callback,'action=ct_get_cookie');\r\n\t}\r\n\t\r\n\tif(typeof ctNocache.info_flag !== 'undefined' && ctNocache.info_flag)\r\n\t{\r\n\t\r\n\t\tvar cleantalk_user_info={};\r\n\t\t\r\n\t\tvar cleantalk_screen_info={};\r\n\t\tfor(var prop in screen)\r\n\t\t{\r\n\t\t\tif (navigator[prop] instanceof Object || screen[prop]==='')\r\n\t\t\t\tcontinue;\r\n\t\t\tcleantalk_screen_info[prop]=screen[prop];\r\n\t\t}\r\n\t\t\r\n\t\tcleantalk_user_info.screen=cleantalk_screen_info;\r\n\t\t\r\n\t\tvar cleantalk_plugins=Array();\r\n\t\tvar prev;\r\n\t\tvar cnt=0;\r\n\t\tfor(var i=0;i<navigator.plugins.length;i++)\r\n\t\t{\r\n\t\t\tvar plugin = navigator.plugins[i];\r\n\t\t\tvar plugin = plugin.name+\" \"+(plugin.version || '')\r\n\t\t\tif (prev == plugin ) continue;\r\n\t\t\tcleantalk_plugins[cnt]=plugin;\r\n\t\t\tcnt++;\r\n\t\t\tprev = plugin;\r\n\t\t}\r\n\t\tcleantalk_user_info.plugins=cleantalk_plugins;\r\n\t\t\r\n\t\tcleantalk_user_info.timezone_offset = -new Date().getTimezoneOffset()/60;\r\n\t\tcleantalk_user_info.datetime = Math.round((new Date().getTime())/1000);\r\n\t\t\r\n\t\tcleantalk_user_info.browser_x=document.documentElement.clientWidth;\r\n\t\tcleantalk_user_info.browser_y=document.documentElement.clientHeight;\r\n\t\t\r\n\t\tvar ua = navigator.userAgent.toLowerCase();\r\n\t\tvar flashInstalled = 0;\r\n\t\tif (typeof(navigator.plugins)!=\"undefined\"&&typeof(navigator.plugins[\"Shockwave Flash\"])==\"object\")\r\n\t\t{\r\n\t\t\tflashInstalled = 1;\r\n\t\t}\r\n\t\telse if (typeof window.ActiveXObject != \"undefined\")\r\n\t\t{\r\n\t\t\ttry\r\n\t\t\t{\r\n\t\t\t\tif (new ActiveXObject(\"ShockwaveFlash.ShockwaveFlash\"))\r\n\t\t\t\t{\r\n\t\t\t\t\tflashInstalled = 1;\r\n\t\t\t\t}\r\n\t\t\t} catch(e) {};\r\n\t\t};\r\n\t\t\r\n\t\tcleantalk_user_info.is_flash=flashInstalled;\r\n\t\t\r\n\t\tisVisitedMain=-1;\r\n\t\tif(location.href=='http://'+location.hostname+'/' || location.href=='https://'+location.hostname+'/')\r\n\t\t{\r\n\t\t\tisVisitedMain=1;\r\n\t\t\tsetTimeout(function() { document.cookie = \"ct_visited_main = 1; path = /; samesite=lax\"}, 1500);\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\t\tct_visited_main = ct_getCookie('ct_visited_main');\r\n\t\tif(ct_visited_main==undefined && isVisitedMain==-1)\r\n\t\t{\r\n\t\t\tisVisitedMain=0;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tisVisitedMain=1;\r\n\t\t}\r\n\t\t\r\n\t\tcleantalk_user_info.is_main=isVisitedMain;\r\n\t\t\r\n\t\tsetTimeout(function() { document.cookie = \"ct_user_info = \"+escape(JSON.stringify(cleantalk_user_info))+\"; path = /; samesite=lax\"}, 1500);\r\n\t}\r\n}"],"names":["sendRequest","url","callback","postData","method","req","createXMLHTTPObject","location","protocol","replace","open","setRequestHeader","onreadystatechange","readyState","status","send","ctNocache","set_cookies_flag","ajaxurl","XMLHttpFactories","XMLHttpRequest","ActiveXObject","xmlhttp","i","length","e","ct_getCookie","name","matches","document","cookie","match","RegExp","decodeURIComponent","undefined","ct_setCookie","value","date","Date","setDate","getDate","setTimeout","toUTCString","ct_callback","ct_cookie","responseText","trim","forms","f","j","elements","indexOf","now","getTime","ct_nocache_executed","checkjs_cookie","Math","random","info_flag","cleantalk_user_info","cleantalk_screen_info","prop","screen","navigator","Object","prev","cleantalk_plugins","Array","cnt","plugins","plugin","version","timezone_offset","getTimezoneOffset","datetime","round","browser_x","documentElement","clientWidth","browser_y","clientHeight","ua","userAgent","toLowerCase","flashInstalled","window","is_flash","isVisitedMain","href","hostname","ct_visited_main","is_main","escape","JSON","stringify"],"mappings":"AAQA,SAASA,YAAYC,EAAIC,EAASC,GAC9B,IAEIC,EAFAC,EAAMC,sBACLD,IACDD,EAAS,EAAa,OAAS,MAI/BH,EADa,WADFM,SAASC,SAEdP,EAAIQ,QAAQ,QAAS,UAErBR,EAAIQ,QAAQ,SAAU,SAGhCJ,EAAIK,KAAKN,EAAOH,GAAI,GAChBE,GACAE,EAAIM,iBAAiB,eAAe,qCACxCN,EAAIO,mBAAqB,WACC,GAAlBP,EAAIQ,aACU,KAAdR,EAAIS,QAA+B,KAAdT,EAAIS,QAI7BZ,EAASG,KAES,GAAlBA,EAAIQ,YACRR,EAAIU,KAAKZ,IA7BY,oBAAda,YACPA,UAAUC,kBAAmB,EAC7BD,UAAUE,QAAU,4BA8BxB,IAAIC,iBAAmB,CACnB,WAAa,OAAO,IAAIC,gBACxB,WAAa,OAAO,IAAIC,cAAc,mBACtC,WAAa,OAAO,IAAIA,cAAc,mBACtC,WAAa,OAAO,IAAIA,cAAc,uBAG1C,SAASf,sBAEL,IADA,IAAIgB,GAAU,EACLC,EAAE,EAAEA,EAAEJ,iBAAiBK,OAAOD,IAAK,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rD,MAAjBwD,kBAA8C,GAAhBH,cAElB,EAIA,EAGf5B,oBAAoBgC,QAAQJ,cAE5B9C,WAAW,WAAaZ,SAASC,OAAS,kBAAkB8D,OAAOC,KAAKC,UAAUnC,sBAAsB,4BAA6B"}
|
@@ -7,7 +7,7 @@ namespace Cleantalk\Antispam;
|
|
7 |
* Mostly contains wrappers for API methods. Check and send mehods.
|
8 |
* Compatible with any CMS.
|
9 |
*
|
10 |
-
* @version 3.
|
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
|
@@ -25,16 +25,18 @@ class API
|
|
25 |
*
|
26 |
* @param string $api_key
|
27 |
* @param null|string $out Data output type (JSON or file URL)
|
|
|
28 |
* @param boolean $do_check
|
29 |
*
|
30 |
* @return mixed|string|array('error' => STRING)
|
31 |
*/
|
32 |
-
static public function method__get_2s_blacklists_db($api_key, $out = null, $do_check = true)
|
33 |
{
|
34 |
$request = array(
|
35 |
'method_name' => '2s_blacklists_db',
|
36 |
'auth_key' => $api_key,
|
37 |
'out' => $out,
|
|
|
38 |
);
|
39 |
|
40 |
$result = static::send_request($request);
|
7 |
* Mostly contains wrappers for API methods. Check and send mehods.
|
8 |
* Compatible with any CMS.
|
9 |
*
|
10 |
+
* @version 3.3
|
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
|
25 |
*
|
26 |
* @param string $api_key
|
27 |
* @param null|string $out Data output type (JSON or file URL)
|
28 |
+
* @param string $version API method version
|
29 |
* @param boolean $do_check
|
30 |
*
|
31 |
* @return mixed|string|array('error' => STRING)
|
32 |
*/
|
33 |
+
static public function method__get_2s_blacklists_db($api_key, $out = null, $version = '1_0', $do_check = true)
|
34 |
{
|
35 |
$request = array(
|
36 |
'method_name' => '2s_blacklists_db',
|
37 |
'auth_key' => $api_key,
|
38 |
'out' => $out,
|
39 |
+
'version' => $version,
|
40 |
);
|
41 |
|
42 |
$result = static::send_request($request);
|
@@ -1,704 +1,745 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Cleantalk\Antispam;
|
4 |
-
|
5 |
-
/**
|
6 |
-
* CleanTalk Helper class.
|
7 |
-
* Compatible with any CMS.
|
8 |
-
*
|
9 |
-
* @package PHP Antispam by CleanTalk
|
10 |
-
* @subpackage Helper
|
11 |
-
* @Version 3.
|
12 |
-
* @author Cleantalk team (welcome@cleantalk.org)
|
13 |
-
* @copyright (C) 2014 CleanTalk team (http://cleantalk.org)
|
14 |
-
* @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
|
15 |
-
* @see https://github.com/CleanTalk/php-antispam
|
16 |
-
*/
|
17 |
-
class Helper
|
18 |
-
{
|
19 |
-
/**
|
20 |
-
* Default user agent for HTTP requests
|
21 |
-
*/
|
22 |
-
const AGENT = 'Cleatalk-Helper/3.2';
|
23 |
-
|
24 |
-
/**
|
25 |
-
* @var array Set of private networks IPv4 and IPv6
|
26 |
-
*/
|
27 |
-
public static $private_networks = array(
|
28 |
-
'v4' => array(
|
29 |
-
'10.0.0.0/8',
|
30 |
-
'100.64.0.0/10',
|
31 |
-
'172.16.0.0/12',
|
32 |
-
'192.168.0.0/16',
|
33 |
-
'127.0.0.1/32',
|
34 |
-
),
|
35 |
-
'v6' => array(
|
36 |
-
'0:0:0:0:0:0:0:1/128', // localhost
|
37 |
-
'0:0:0:0:0:0:a:1/128', // ::ffff:127.0.0.1
|
38 |
-
),
|
39 |
-
);
|
40 |
-
|
41 |
-
/**
|
42 |
-
* @var array Set of CleanTalk servers
|
43 |
-
*/
|
44 |
-
public static $cleantalks_servers = array(
|
45 |
-
// MODERATE
|
46 |
-
'moderate1.cleantalk.org' => '162.243.144.175',
|
47 |
-
'moderate2.cleantalk.org' => '159.203.121.181',
|
48 |
-
'moderate3.cleantalk.org' => '88.198.153.60',
|
49 |
-
'moderate4.cleantalk.org' => '159.69.51.30',
|
50 |
-
'moderate5.cleantalk.org' => '95.216.200.119',
|
51 |
-
'moderate6.cleantalk.org' => '138.68.234.8',
|
52 |
-
// APIX
|
53 |
-
'apix1.cleantalk.org' => '35.158.52.161',
|
54 |
-
'apix2.cleantalk.org' => '18.206.49.217',
|
55 |
-
'apix3.cleantalk.org' => '3.18.23.246',
|
56 |
-
//ns
|
57 |
-
'netserv2.cleantalk.org' => '178.63.60.214',
|
58 |
-
'netserv3.cleantalk.org' => '188.40.14.173',
|
59 |
-
);
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Getting arrays of IP (REMOTE_ADDR, X-Forwarded-For, X-Real-Ip, Cf_Connecting_Ip)
|
63 |
-
*
|
64 |
-
* @param array $ip_types Type of IP you want to receive
|
65 |
-
* @param bool $v4_only
|
66 |
-
*
|
67 |
-
* @return array|mixed|null
|
68 |
-
*/
|
69 |
-
static public function ip__get($ip_types = array('real', 'remote_addr', 'x_forwarded_for', 'x_real_ip', 'cloud_flare'), $v4_only = true)
|
70 |
-
{
|
71 |
-
$ips = array_flip($ip_types); // Result array with IPs
|
72 |
-
$headers = apache_request_headers();
|
73 |
-
|
74 |
-
// REMOTE_ADDR
|
75 |
-
if(isset($ips['remote_addr'])){
|
76 |
-
$ip_type = self::ip__validate( isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : '' );
|
77 |
-
if($ip_type){
|
78 |
-
$ips['remote_addr'] = ($ip_type == 'v6' ? self::ip__v6_normalize(isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : '' ) : isset( $_SERVER['REMOTE_ADDR'] )) ? $_SERVER['REMOTE_ADDR'] : '';
|
79 |
-
}
|
80 |
-
}
|
81 |
-
|
82 |
-
// X-Forwarded-For
|
83 |
-
if(isset($ips['x_forwarded_for'])){
|
84 |
-
if(isset($headers['X-Forwarded-For'])){
|
85 |
-
$tmp = explode(",", trim($headers['X-Forwarded-For']));
|
86 |
-
$tmp = trim($tmp[0]);
|
87 |
-
$ip_type = self::ip__validate($tmp);
|
88 |
-
if($ip_type){
|
89 |
-
$ips['x_forwarded_for'] = $ip_type == 'v6' ? self::ip__v6_normalize($tmp) : $tmp;
|
90 |
-
}
|
91 |
-
}
|
92 |
-
}
|
93 |
-
|
94 |
-
// X-Real-Ip
|
95 |
-
if(isset($ips['x_real_ip'])){
|
96 |
-
if(isset($headers['X-Real-Ip'])){
|
97 |
-
$tmp = explode(",", trim($headers['X-Real-Ip']));
|
98 |
-
$tmp = trim($tmp[0]);
|
99 |
-
$ip_type = self::ip__validate($tmp);
|
100 |
-
if($ip_type){
|
101 |
-
$ips['x_forwarded_for'] = $ip_type == 'v6' ? self::ip__v6_normalize($tmp) : $tmp;
|
102 |
-
}
|
103 |
-
}
|
104 |
-
}
|
105 |
-
|
106 |
-
// Cloud Flare
|
107 |
-
if(isset($ips['cloud_flare'])){
|
108 |
-
if(isset($headers['CF-Connecting-IP'], $headers['CF-IPCountry'], $headers['CF-RAY']) || isset($headers['Cf-Connecting-Ip'], $headers['Cf-Ipcountry'], $headers['Cf-Ray'])){
|
109 |
-
$tmp = isset($headers['CF-Connecting-IP']) ? $headers['CF-Connecting-IP'] : $headers['Cf-Connecting-Ip'];
|
110 |
-
$tmp = strpos($tmp, ',') !== false ? explode(',', $tmp) : (array)$tmp;
|
111 |
-
$ip_type = self::ip__validate(trim($tmp[0]));
|
112 |
-
if($ip_type){
|
113 |
-
$ips['real'] = $ip_type == 'v6' ? self::ip__v6_normalize(trim($tmp[0])) : trim($tmp[0]);
|
114 |
-
}
|
115 |
-
}
|
116 |
-
}
|
117 |
-
|
118 |
-
// Getting real IP from REMOTE_ADDR or Cf_Connecting_Ip if set or from (X-Forwarded-For, X-Real-Ip) if REMOTE_ADDR is local.
|
119 |
-
if(isset($ips['real'])){
|
120 |
-
|
121 |
-
// Detect IP type
|
122 |
-
$ip_type = self::ip__validate(isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : '');
|
123 |
-
if($ip_type)
|
124 |
-
$ips['real'] = ($ip_type == 'v6' ? self::ip__v6_normalize(isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : '' ) : isset( $_SERVER['REMOTE_ADDR'] )) ? $_SERVER['REMOTE_ADDR'] : '';
|
125 |
-
|
126 |
-
// Cloud Flare
|
127 |
-
if(isset($headers['CF-Connecting-IP'], $headers['CF-IPCountry'], $headers['CF-RAY']) || isset($headers['Cf-Connecting-Ip'], $headers['Cf-Ipcountry'], $headers['Cf-Ray'])){
|
128 |
-
$tmp = isset($headers['CF-Connecting-IP']) ? $headers['CF-Connecting-IP'] : $headers['Cf-Connecting-Ip'];
|
129 |
-
$tmp = strpos($tmp, ',') !== false ? explode(',', $tmp) : (array)$tmp;
|
130 |
-
$ip_type = self::ip__validate(trim($tmp[0]));
|
131 |
-
if($ip_type)
|
132 |
-
$ips['real'] = $ip_type == 'v6' ? self::ip__v6_normalize(trim($tmp[0])) : trim($tmp[0]);
|
133 |
-
|
134 |
-
// Sucury
|
135 |
-
}elseif(isset($headers['X-Sucuri-Clientip'], $headers['X-Sucuri-Country'])){
|
136 |
-
$ip_type = self::ip__validate($headers['X-Sucuri-Clientip']);
|
137 |
-
if($ip_type)
|
138 |
-
$ips['real'] = $ip_type == 'v6' ? self::ip__v6_normalize($headers['X-Sucuri-Clientip']) : $headers['X-Sucuri-Clientip'];
|
139 |
-
|
140 |
-
// OVH
|
141 |
-
}elseif(isset($headers['X-Cdn-Any-Ip'], $headers['Remote-Ip'])){
|
142 |
-
$ip_type = self::ip__validate($headers['X-Cdn-Any-Ip']);
|
143 |
-
if($ip_type)
|
144 |
-
$ips['real'] = $ip_type == 'v6' ? self::ip__v6_normalize($headers['X-Cdn-Any-Ip']) : $headers['X-Cdn-Any-Ip'];
|
145 |
-
|
146 |
-
// Incapsula proxy
|
147 |
-
}elseif(isset($headers['Incap-Client-Ip'])){
|
148 |
-
$ip_type = self::ip__validate($headers['Incap-Client-Ip']);
|
149 |
-
if($ip_type)
|
150 |
-
$ips['real'] = $ip_type == 'v6' ? self::ip__v6_normalize($headers['Incap-Client-Ip']) : $headers['Incap-Client-Ip'];
|
151 |
-
}
|
152 |
-
|
153 |
-
// Is private network
|
154 |
-
if($ip_type === false ||
|
155 |
-
($ip_type &&
|
156 |
-
(self::ip__is_private_network($ips['real'], $ip_type) ||
|
157 |
-
self::ip__mask_match(
|
158 |
-
$ips['real'],
|
159 |
-
(isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] . '/24' : '127.0.0.1/24'),
|
160 |
-
$ip_type
|
161 |
-
)
|
162 |
-
)
|
163 |
-
)
|
164 |
-
){
|
165 |
-
|
166 |
-
// X-Forwarded-For
|
167 |
-
if(isset($headers['X-Forwarded-For'])){
|
168 |
-
$tmp = explode(',', trim($headers['X-Forwarded-For']));
|
169 |
-
$tmp = trim($tmp[0]);
|
170 |
-
$ip_type = self::ip__validate($tmp);
|
171 |
-
if($ip_type)
|
172 |
-
$ips['real'] = $ip_type == 'v6' ? self::ip__v6_normalize($tmp) : $tmp;
|
173 |
-
|
174 |
-
// X-Real-Ip
|
175 |
-
}elseif(isset($headers['X-Real-Ip'])){
|
176 |
-
$tmp = explode(',', trim($headers['X-Real-Ip']));
|
177 |
-
$tmp = trim($tmp[0]);
|
178 |
-
$ip_type = self::ip__validate($tmp);
|
179 |
-
if($ip_type)
|
180 |
-
$ips['real'] = $ip_type == 'v6' ? self::ip__v6_normalize($tmp) : $tmp;
|
181 |
-
}
|
182 |
-
}
|
183 |
-
}
|
184 |
-
|
185 |
-
// Validating IPs
|
186 |
-
$result = array();
|
187 |
-
foreach($ips as $key => $ip){
|
188 |
-
$ip_version = self::ip__validate($ip);
|
189 |
-
if($ip && (($v4_only && $ip_version == 'v4') || !$v4_only)){
|
190 |
-
$result[$key] = $ip;
|
191 |
-
}
|
192 |
-
}
|
193 |
-
|
194 |
-
$result = array_unique($result);
|
195 |
-
return count($result) > 1
|
196 |
-
? $result
|
197 |
-
: (reset($result) !== false
|
198 |
-
? reset($result)
|
199 |
-
: null);
|
200 |
-
}
|
201 |
-
|
202 |
-
/**
|
203 |
-
* Checks if the IP is in private range
|
204 |
-
*
|
205 |
-
* @param string $ip
|
206 |
-
* @param string $ip_type
|
207 |
-
*
|
208 |
-
* @return bool
|
209 |
-
*/
|
210 |
-
static function ip__is_private_network($ip, $ip_type = 'v4')
|
211 |
-
{
|
212 |
-
return self::ip__mask_match($ip, self::$private_networks[$ip_type], $ip_type);
|
213 |
-
}
|
214 |
-
|
215 |
-
/**
|
216 |
-
* Check if the IP belong to mask. Recursive.
|
217 |
-
* Octet by octet for IPv4
|
218 |
-
* Hextet by hextet for IPv6
|
219 |
-
*
|
220 |
-
* @param string $ip
|
221 |
-
* @param string $cidr work to compare with
|
222 |
-
* @param string $ip_type IPv6 or IPv4
|
223 |
-
* @param int $xtet_count Recursive counter. Determs current part of address to check.
|
224 |
-
*
|
225 |
-
* @return bool
|
226 |
-
*/
|
227 |
-
static public function ip__mask_match($ip, $cidr, $ip_type = 'v4', $xtet_count = 0)
|
228 |
-
{
|
229 |
-
if(is_array($cidr)){
|
230 |
-
foreach($cidr as $curr_mask){
|
231 |
-
if(self::ip__mask_match($ip, $curr_mask, $ip_type)){
|
232 |
-
return true;
|
233 |
-
}
|
234 |
-
}
|
235 |
-
unset($curr_mask);
|
236 |
-
return false;
|
237 |
-
}
|
238 |
-
|
239 |
-
$xtet_base = ($ip_type == 'v4') ? 8 : 16;
|
240 |
-
|
241 |
-
// Calculate mask
|
242 |
-
$exploded = explode('/', $cidr);
|
243 |
-
$net_ip = $exploded[0];
|
244 |
-
$mask = $exploded[1];
|
245 |
-
|
246 |
-
// Exit condition
|
247 |
-
$xtet_end = ceil($mask / $xtet_base);
|
248 |
-
if($xtet_count == $xtet_end)
|
249 |
-
return true;
|
250 |
-
|
251 |
-
// Lenght of bits for comparsion
|
252 |
-
$mask = $mask - $xtet_base * $xtet_count >= $xtet_base ? $xtet_base : $mask - $xtet_base * $xtet_count;
|
253 |
-
|
254 |
-
// Explode by octets/hextets from IP and Net
|
255 |
-
$net_ip_xtets = explode($ip_type == 'v4' ? '.' : ':', $net_ip);
|
256 |
-
$ip_xtets = explode($ip_type == 'v4' ? '.' : ':', $ip);
|
257 |
-
|
258 |
-
// Standartizing. Getting current octets/hextets. Adding leading zeros.
|
259 |
-
$net_xtet = str_pad(decbin($ip_type == 'v4' ? $net_ip_xtets[$xtet_count] : @hexdec($net_ip_xtets[$xtet_count])), $xtet_base, 0, STR_PAD_LEFT);
|
260 |
-
$ip_xtet = str_pad(decbin($ip_type == 'v4' ? $ip_xtets[$xtet_count] : @hexdec($ip_xtets[$xtet_count])), $xtet_base, 0, STR_PAD_LEFT);
|
261 |
-
|
262 |
-
// Comparing bit by bit
|
263 |
-
for($i = 0, $result = true; $mask != 0; $mask--, $i++){
|
264 |
-
if($ip_xtet[$i] != $net_xtet[$i]){
|
265 |
-
$result = false;
|
266 |
-
break;
|
267 |
-
}
|
268 |
-
}
|
269 |
-
|
270 |
-
// Recursing. Moving to next octet/hextet.
|
271 |
-
if($result)
|
272 |
-
$result = self::ip__mask_match($ip, $cidr, $ip_type, $xtet_count + 1);
|
273 |
-
|
274 |
-
return $result;
|
275 |
-
|
276 |
-
}
|
277 |
-
|
278 |
-
/**
|
279 |
-
* Converts long mask like 4294967295 to number like 32
|
280 |
-
*
|
281 |
-
* @param int $long_mask
|
282 |
-
*
|
283 |
-
* @return int
|
284 |
-
*/
|
285 |
-
static function ip__mask__long_to_number($long_mask)
|
286 |
-
{
|
287 |
-
$num_mask = strpos((string)decbin($long_mask), '0');
|
288 |
-
return $num_mask === false ? 32 : $num_mask;
|
289 |
-
}
|
290 |
-
|
291 |
-
/**
|
292 |
-
* Validating IPv4, IPv6
|
293 |
-
*
|
294 |
-
* @param string $ip
|
295 |
-
*
|
296 |
-
* @return string|bool
|
297 |
-
*/
|
298 |
-
static public function ip__validate($ip)
|
299 |
-
{
|
300 |
-
if(!$ip) return false; // NULL || FALSE || '' || so on...
|
301 |
-
if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) && $ip != '0.0.0.0') return 'v4'; // IPv4
|
302 |
-
if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) && self::ip__v6_reduce($ip) != '0::0') return 'v6'; // IPv6
|
303 |
-
return false; // Unknown
|
304 |
-
}
|
305 |
-
|
306 |
-
/**
|
307 |
-
* Expand IPv6
|
308 |
-
*
|
309 |
-
* @param string $ip
|
310 |
-
*
|
311 |
-
* @return string IPv6
|
312 |
-
*/
|
313 |
-
static public function ip__v6_normalize($ip)
|
314 |
-
{
|
315 |
-
$ip = trim($ip);
|
316 |
-
// Searching for ::ffff:xx.xx.xx.xx patterns and turn it to IPv6
|
317 |
-
if(preg_match('/^::ffff:([0-9]{1,3}\.?){4}$/', $ip)){
|
318 |
-
$ip = dechex(sprintf("%u", ip2long(substr($ip, 7))));
|
319 |
-
$ip = '0:0:0:0:0:0:' . (strlen($ip) > 4 ? substr('abcde', 0, -4) : '0') . ':' . substr($ip, -4, 4);
|
320 |
-
// Normalizing hextets number
|
321 |
-
}elseif(strpos($ip, '::') !== false){
|
322 |
-
$ip = str_replace('::', str_repeat(':0', 8 - substr_count($ip, ':')) . ':', $ip);
|
323 |
-
$ip = strpos($ip, ':') === 0 ? '0' . $ip : $ip;
|
324 |
-
$ip = strpos(strrev($ip), ':') === 0 ? $ip . '0' : $ip;
|
325 |
-
}
|
326 |
-
// Simplifyng hextets
|
327 |
-
if(preg_match('/:0(?=[a-z0-9]+)/', $ip)){
|
328 |
-
$ip = preg_replace('/:0(?=[a-z0-9]+)/', ':', strtolower($ip));
|
329 |
-
$ip = self::ip__v6_normalize($ip);
|
330 |
-
}
|
331 |
-
return $ip;
|
332 |
-
}
|
333 |
-
|
334 |
-
/**
|
335 |
-
* Reduce IPv6
|
336 |
-
*
|
337 |
-
* @param string $ip
|
338 |
-
*
|
339 |
-
* @return string IPv6
|
340 |
-
*/
|
341 |
-
static public function ip__v6_reduce($ip)
|
342 |
-
{
|
343 |
-
if(strpos($ip, ':') !== false){
|
344 |
-
$ip = preg_replace('/:0{1,4}/', ':', $ip);
|
345 |
-
$ip = preg_replace('/:{2,}/', '::', $ip);
|
346 |
-
$ip = strpos($ip, '0') === 0 ? substr($ip, 1) : $ip;
|
347 |
-
}
|
348 |
-
return $ip;
|
349 |
-
}
|
350 |
-
|
351 |
-
/**
|
352 |
-
* Get URL form IP. Check if it's belong to cleantalk.
|
353 |
-
*
|
354 |
-
* @param string $ip
|
355 |
-
*
|
356 |
-
* @return false|int|string
|
357 |
-
*/
|
358 |
-
static public function ip__is_cleantalks($ip)
|
359 |
-
{
|
360 |
-
if(self::ip__validate($ip)){
|
361 |
-
$url = array_search($ip, self::$cleantalks_servers);
|
362 |
-
return $url
|
363 |
-
? true
|
364 |
-
: false;
|
365 |
-
}else
|
366 |
-
return false;
|
367 |
-
}
|
368 |
-
|
369 |
-
/**
|
370 |
-
* Get URL form IP. Check if it's belong to cleantalk.
|
371 |
-
*
|
372 |
-
* @param $ip
|
373 |
-
*
|
374 |
-
* @return false|int|string
|
375 |
-
*/
|
376 |
-
static public function ip__resolve__cleantalks($ip)
|
377 |
-
{
|
378 |
-
if(self::ip__validate($ip)){
|
379 |
-
$url = array_search($ip, self::$cleantalks_servers);
|
380 |
-
return $url
|
381 |
-
? $url
|
382 |
-
: self::ip__resolve($ip);
|
383 |
-
}else
|
384 |
-
return $ip;
|
385 |
-
}
|
386 |
-
|
387 |
-
/**
|
388 |
-
* Get URL form IP
|
389 |
-
*
|
390 |
-
* @param $ip
|
391 |
-
*
|
392 |
-
* @return string
|
393 |
-
*/
|
394 |
-
static public function ip__resolve($ip)
|
395 |
-
{
|
396 |
-
if(self::ip__validate($ip)){
|
397 |
-
$url = gethostbyaddr($ip);
|
398 |
-
if($url)
|
399 |
-
return $url;
|
400 |
-
}
|
401 |
-
return $ip;
|
402 |
-
}
|
403 |
-
|
404 |
-
/**
|
405 |
-
* Resolve DNS to IP
|
406 |
-
*
|
407 |
-
* @param $host
|
408 |
-
* @param bool $out
|
409 |
-
*
|
410 |
-
* @return bool
|
411 |
-
*/
|
412 |
-
static public function dns__resolve($host, $out = false)
|
413 |
-
{
|
414 |
-
|
415 |
-
// Get DNS records about URL
|
416 |
-
if(function_exists('dns_get_record')){
|
417 |
-
$records = dns_get_record($host, DNS_A);
|
418 |
-
if($records !== false){
|
419 |
-
$out = $records[0]['ip'];
|
420 |
-
}
|
421 |
-
}
|
422 |
-
|
423 |
-
// Another try if first failed
|
424 |
-
if(!$out && function_exists('gethostbynamel')){
|
425 |
-
$records = gethostbynamel($host);
|
426 |
-
if($records !== false){
|
427 |
-
$out = $records[0];
|
428 |
-
}
|
429 |
-
}
|
430 |
-
|
431 |
-
return $out;
|
432 |
-
|
433 |
-
}
|
434 |
-
|
435 |
-
/**
|
436 |
-
* Function sends raw http request
|
437 |
-
*
|
438 |
-
* May use 4 presets(combining possible):
|
439 |
-
* get_code - getting only HTTP response code
|
440 |
-
* async - async requests
|
441 |
-
* get - GET-request
|
442 |
-
* ssl - use SSL
|
443 |
-
*
|
444 |
-
* @param string $url URL
|
445 |
-
* @param array $data POST|GET indexed array with data to send
|
446 |
-
* @param string|array $presets String or Array with presets: get_code, async, get, ssl, dont_split_to_array
|
447 |
-
* @param array $opts Optional option for CURL connection
|
448 |
-
*
|
449 |
-
* @return array|bool (array || array('error' => true))
|
450 |
-
*/
|
451 |
-
static public function http__request($url, $data = array(), $presets = null, $opts = array())
|
452 |
-
{
|
453 |
-
if(function_exists('curl_init')){
|
454 |
-
|
455 |
-
$ch = curl_init();
|
456 |
-
|
457 |
-
if(!empty($data)){
|
458 |
-
// If $data scalar converting it to array
|
459 |
-
$data = is_string($data) || is_int($data) ? array($data => 1) : $data;
|
460 |
-
// Build query
|
461 |
-
$opts[CURLOPT_POSTFIELDS] = $data;
|
462 |
-
}
|
463 |
-
|
464 |
-
// Merging OBLIGATORY options with GIVEN options
|
465 |
-
$opts = self::array_merge__save_numeric_keys(
|
466 |
-
array(
|
467 |
-
CURLOPT_URL => $url,
|
468 |
-
CURLOPT_RETURNTRANSFER => true,
|
469 |
-
CURLOPT_CONNECTTIMEOUT_MS => 3000,
|
470 |
-
CURLOPT_FORBID_REUSE => true,
|
471 |
-
CURLOPT_USERAGENT => self::AGENT . '; ' . ( isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : 'UNKNOWN_HOST' ),
|
472 |
-
CURLOPT_POST => true,
|
473 |
-
CURLOPT_SSL_VERIFYPEER => false,
|
474 |
-
CURLOPT_SSL_VERIFYHOST => 0,
|
475 |
-
CURLOPT_HTTPHEADER => array('Expect:'), // Fix for large data and old servers http://php.net/manual/ru/function.curl-setopt.php#82418
|
476 |
-
CURLOPT_FOLLOWLOCATION => true,
|
477 |
-
CURLOPT_MAXREDIRS => 5,
|
478 |
-
),
|
479 |
-
$opts
|
480 |
-
);
|
481 |
-
|
482 |
-
// Use presets
|
483 |
-
$presets = is_array($presets) ? $presets : explode(' ', $presets);
|
484 |
-
foreach($presets as $preset){
|
485 |
-
|
486 |
-
switch($preset){
|
487 |
-
|
488 |
-
// Do not follow redirects
|
489 |
-
case 'dont_follow_redirects':
|
490 |
-
$opts[CURLOPT_FOLLOWLOCATION] = false;
|
491 |
-
$opts[CURLOPT_MAXREDIRS] = 0;
|
492 |
-
break;
|
493 |
-
|
494 |
-
// Get headers only
|
495 |
-
case 'get_code':
|
496 |
-
$opts[CURLOPT_HEADER] = true;
|
497 |
-
$opts[CURLOPT_NOBODY] = true;
|
498 |
-
break;
|
499 |
-
|
500 |
-
// Make a request, don't wait for an answer
|
501 |
-
case 'async':
|
502 |
-
$opts[CURLOPT_CONNECTTIMEOUT_MS] = 1000;
|
503 |
-
$opts[CURLOPT_TIMEOUT_MS] = 500;
|
504 |
-
break;
|
505 |
-
|
506 |
-
case 'get':
|
507 |
-
$opts[CURLOPT_URL] .= $data ? '?' . str_replace("&", "&", http_build_query($data)) : '';
|
508 |
-
$opts[CURLOPT_CUSTOMREQUEST] = 'GET';
|
509 |
-
$opts[CURLOPT_POST] = false;
|
510 |
-
$opts[CURLOPT_POSTFIELDS] = null;
|
511 |
-
break;
|
512 |
-
|
513 |
-
case 'ssl':
|
514 |
-
$opts[CURLOPT_SSL_VERIFYPEER] = true;
|
515 |
-
$opts[CURLOPT_SSL_VERIFYHOST] = 2;
|
516 |
-
if(defined('CLEANTALK_CASERT_PATH') && CLEANTALK_CASERT_PATH)
|
517 |
-
$opts[CURLOPT_CAINFO] = CLEANTALK_CASERT_PATH;
|
518 |
-
break;
|
519 |
-
|
520 |
-
default:
|
521 |
-
|
522 |
-
break;
|
523 |
-
}
|
524 |
-
|
525 |
-
}
|
526 |
-
unset($preset);
|
527 |
-
|
528 |
-
curl_setopt_array($ch, $opts);
|
529 |
-
$result = curl_exec($ch);
|
530 |
-
|
531 |
-
// RETURN if async request
|
532 |
-
if(in_array('async', $presets))
|
533 |
-
return true;
|
534 |
-
|
535 |
-
if($result){
|
536 |
-
|
537 |
-
if(strpos($result, PHP_EOL) !== false && !in_array('dont_split_to_array', $presets))
|
538 |
-
$result = explode(PHP_EOL, $result);
|
539 |
-
|
540 |
-
// Get code crossPHP method
|
541 |
-
if(in_array('get_code', $presets)){
|
542 |
-
$curl_info = curl_getinfo($ch);
|
543 |
-
$result = $curl_info['http_code'];
|
544 |
-
}
|
545 |
-
curl_close($ch);
|
546 |
-
$out = $result;
|
547 |
-
}else
|
548 |
-
$out = array('error' => curl_error($ch));
|
549 |
-
}else
|
550 |
-
$out = array('error' => 'CURL_NOT_INSTALLED');
|
551 |
-
|
552 |
-
/**
|
553 |
-
* Getting HTTP-response code without cURL
|
554 |
-
*/
|
555 |
-
if($presets && ($presets == 'get_code' || (is_array($presets) && in_array('get_code', $presets)))
|
556 |
-
&& isset($out['error']) && $out['error'] == 'CURL_NOT_INSTALLED'
|
557 |
-
){
|
558 |
-
$headers = get_headers($url);
|
559 |
-
$out = (int)preg_replace('/.*(\d{3}).*/', '$1', $headers[0]);
|
560 |
-
}
|
561 |
-
|
562 |
-
return $out;
|
563 |
-
}
|
564 |
-
|
565 |
-
/**
|
566 |
-
* Merging arrays without reseting numeric keys
|
567 |
-
*
|
568 |
-
* @param array $arr1 One-dimentional array
|
569 |
-
* @param array $arr2 One-dimentional array
|
570 |
-
*
|
571 |
-
* @return array Merged array
|
572 |
-
*/
|
573 |
-
public static function array_merge__save_numeric_keys($arr1, $arr2)
|
574 |
-
{
|
575 |
-
foreach($arr2 as $key => $val){
|
576 |
-
$arr1[$key] = $val;
|
577 |
-
}
|
578 |
-
return $arr1;
|
579 |
-
}
|
580 |
-
|
581 |
-
/**
|
582 |
-
* Merging arrays without reseting numeric keys recursive
|
583 |
-
*
|
584 |
-
* @param array $arr1 One-dimentional array
|
585 |
-
* @param array $arr2 One-dimentional array
|
586 |
-
*
|
587 |
-
* @return array Merged array
|
588 |
-
*/
|
589 |
-
public static function array_merge__save_numeric_keys__recursive($arr1, $arr2)
|
590 |
-
{
|
591 |
-
foreach($arr2 as $key => $val){
|
592 |
-
|
593 |
-
// Array | array => array
|
594 |
-
if(isset($arr1[$key]) && is_array($arr1[$key]) && is_array($val)){
|
595 |
-
$arr1[$key] = self::array_merge__save_numeric_keys__recursive($arr1[$key], $val);
|
596 |
-
|
597 |
-
// Scalar | array => array
|
598 |
-
}elseif(isset($arr1[$key]) && !is_array($arr1[$key]) && is_array($val)){
|
599 |
-
$tmp = $arr1[$key] =
|
600 |
-
$arr1[$key] = $val;
|
601 |
-
$arr1[$key][] = $tmp;
|
602 |
-
|
603 |
-
// array | scalar => array
|
604 |
-
}elseif(isset($arr1[$key]) && is_array($arr1[$key]) && !is_array($val)){
|
605 |
-
$arr1[$key][] = $val;
|
606 |
-
|
607 |
-
// scalar | scalar => scalar
|
608 |
-
}else{
|
609 |
-
$arr1[$key] = $val;
|
610 |
-
}
|
611 |
-
}
|
612 |
-
return $arr1;
|
613 |
-
}
|
614 |
-
|
615 |
-
/**
|
616 |
-
* Function removing non UTF8 characters from array|string|object
|
617 |
-
*
|
618 |
-
* @param array|object|string $data
|
619 |
-
*
|
620 |
-
* @return array|object|string
|
621 |
-
*/
|
622 |
-
public static function removeNonUTF8($data)
|
623 |
-
{
|
624 |
-
// Array || object
|
625 |
-
if(is_array($data) || is_object($data)){
|
626 |
-
foreach($data as $key => &$val){
|
627 |
-
$val = self::removeNonUTF8($val);
|
628 |
-
}
|
629 |
-
unset($key, $val);
|
630 |
-
|
631 |
-
//String
|
632 |
-
}else{
|
633 |
-
if(!preg_match('//u', $data))
|
634 |
-
$data = 'Nulled. Not UTF8 encoded or malformed.';
|
635 |
-
}
|
636 |
-
return $data;
|
637 |
-
}
|
638 |
-
|
639 |
-
/**
|
640 |
-
* Function convert anything to UTF8 and removes non UTF8 characters
|
641 |
-
*
|
642 |
-
* @param array|object|string $obj
|
643 |
-
* @param string $data_codepage
|
644 |
-
*
|
645 |
-
* @return mixed(array|object|string)
|
646 |
-
*/
|
647 |
-
public static function toUTF8($obj, $data_codepage = null)
|
648 |
-
{
|
649 |
-
// Array || object
|
650 |
-
if(is_array($obj) || is_object($obj)){
|
651 |
-
foreach($obj as $key => &$val){
|
652 |
-
$val = self::toUTF8($val, $data_codepage);
|
653 |
-
}
|
654 |
-
unset($key, $val);
|
655 |
-
|
656 |
-
//String
|
657 |
-
}else{
|
658 |
-
if(!preg_match('//u', $obj) && function_exists('mb_detect_encoding') && function_exists('mb_convert_encoding')){
|
659 |
-
$encoding = mb_detect_encoding($obj);
|
660 |
-
$encoding = $encoding ? $encoding : $data_codepage;
|
661 |
-
if($encoding)
|
662 |
-
$obj = mb_convert_encoding($obj, 'UTF-8', $encoding);
|
663 |
-
}
|
664 |
-
}
|
665 |
-
return $obj;
|
666 |
-
}
|
667 |
-
|
668 |
-
/**
|
669 |
-
* Function convert from UTF8
|
670 |
-
*
|
671 |
-
* @param array|object|string $obj
|
672 |
-
* @param string $data_codepage
|
673 |
-
*
|
674 |
-
* @return mixed (array|object|string)
|
675 |
-
*/
|
676 |
-
public static function fromUTF8($obj, $data_codepage = null)
|
677 |
-
{
|
678 |
-
// Array || object
|
679 |
-
if(is_array($obj) || is_object($obj)){
|
680 |
-
foreach($obj as $key => &$val){
|
681 |
-
$val = self::fromUTF8($val, $data_codepage);
|
682 |
-
}
|
683 |
-
unset($key, $val);
|
684 |
-
|
685 |
-
//String
|
686 |
-
}else{
|
687 |
-
if(preg_match('u', $obj) && function_exists('mb_convert_encoding') && $data_codepage !== null)
|
688 |
-
$obj = mb_convert_encoding($obj, $data_codepage, 'UTF-8');
|
689 |
-
}
|
690 |
-
return $obj;
|
691 |
-
}
|
692 |
-
|
693 |
-
/**
|
694 |
-
* Checks if the string is JSON type
|
695 |
-
*
|
696 |
-
* @param string
|
697 |
-
*
|
698 |
-
* @return bool
|
699 |
-
*/
|
700 |
-
static public function is_json($string)
|
701 |
-
{
|
702 |
-
return is_string($string) && is_array(json_decode($string, true)) ? true : false;
|
703 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
704 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Cleantalk\Antispam;
|
4 |
+
|
5 |
+
/**
|
6 |
+
* CleanTalk Helper class.
|
7 |
+
* Compatible with any CMS.
|
8 |
+
*
|
9 |
+
* @package PHP Antispam by CleanTalk
|
10 |
+
* @subpackage Helper
|
11 |
+
* @Version 3.3
|
12 |
+
* @author Cleantalk team (welcome@cleantalk.org)
|
13 |
+
* @copyright (C) 2014 CleanTalk team (http://cleantalk.org)
|
14 |
+
* @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
|
15 |
+
* @see https://github.com/CleanTalk/php-antispam
|
16 |
+
*/
|
17 |
+
class Helper
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* Default user agent for HTTP requests
|
21 |
+
*/
|
22 |
+
const AGENT = 'Cleatalk-Helper/3.2';
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @var array Set of private networks IPv4 and IPv6
|
26 |
+
*/
|
27 |
+
public static $private_networks = array(
|
28 |
+
'v4' => array(
|
29 |
+
'10.0.0.0/8',
|
30 |
+
'100.64.0.0/10',
|
31 |
+
'172.16.0.0/12',
|
32 |
+
'192.168.0.0/16',
|
33 |
+
'127.0.0.1/32',
|
34 |
+
),
|
35 |
+
'v6' => array(
|
36 |
+
'0:0:0:0:0:0:0:1/128', // localhost
|
37 |
+
'0:0:0:0:0:0:a:1/128', // ::ffff:127.0.0.1
|
38 |
+
),
|
39 |
+
);
|
40 |
+
|
41 |
+
/**
|
42 |
+
* @var array Set of CleanTalk servers
|
43 |
+
*/
|
44 |
+
public static $cleantalks_servers = array(
|
45 |
+
// MODERATE
|
46 |
+
'moderate1.cleantalk.org' => '162.243.144.175',
|
47 |
+
'moderate2.cleantalk.org' => '159.203.121.181',
|
48 |
+
'moderate3.cleantalk.org' => '88.198.153.60',
|
49 |
+
'moderate4.cleantalk.org' => '159.69.51.30',
|
50 |
+
'moderate5.cleantalk.org' => '95.216.200.119',
|
51 |
+
'moderate6.cleantalk.org' => '138.68.234.8',
|
52 |
+
// APIX
|
53 |
+
'apix1.cleantalk.org' => '35.158.52.161',
|
54 |
+
'apix2.cleantalk.org' => '18.206.49.217',
|
55 |
+
'apix3.cleantalk.org' => '3.18.23.246',
|
56 |
+
//ns
|
57 |
+
'netserv2.cleantalk.org' => '178.63.60.214',
|
58 |
+
'netserv3.cleantalk.org' => '188.40.14.173',
|
59 |
+
);
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Getting arrays of IP (REMOTE_ADDR, X-Forwarded-For, X-Real-Ip, Cf_Connecting_Ip)
|
63 |
+
*
|
64 |
+
* @param array $ip_types Type of IP you want to receive
|
65 |
+
* @param bool $v4_only
|
66 |
+
*
|
67 |
+
* @return array|mixed|null
|
68 |
+
*/
|
69 |
+
static public function ip__get($ip_types = array('real', 'remote_addr', 'x_forwarded_for', 'x_real_ip', 'cloud_flare'), $v4_only = true)
|
70 |
+
{
|
71 |
+
$ips = array_flip($ip_types); // Result array with IPs
|
72 |
+
$headers = apache_request_headers();
|
73 |
+
|
74 |
+
// REMOTE_ADDR
|
75 |
+
if(isset($ips['remote_addr'])){
|
76 |
+
$ip_type = self::ip__validate( isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : '' );
|
77 |
+
if($ip_type){
|
78 |
+
$ips['remote_addr'] = ($ip_type == 'v6' ? self::ip__v6_normalize(isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : '' ) : isset( $_SERVER['REMOTE_ADDR'] )) ? $_SERVER['REMOTE_ADDR'] : '';
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
// X-Forwarded-For
|
83 |
+
if(isset($ips['x_forwarded_for'])){
|
84 |
+
if(isset($headers['X-Forwarded-For'])){
|
85 |
+
$tmp = explode(",", trim($headers['X-Forwarded-For']));
|
86 |
+
$tmp = trim($tmp[0]);
|
87 |
+
$ip_type = self::ip__validate($tmp);
|
88 |
+
if($ip_type){
|
89 |
+
$ips['x_forwarded_for'] = $ip_type == 'v6' ? self::ip__v6_normalize($tmp) : $tmp;
|
90 |
+
}
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
// X-Real-Ip
|
95 |
+
if(isset($ips['x_real_ip'])){
|
96 |
+
if(isset($headers['X-Real-Ip'])){
|
97 |
+
$tmp = explode(",", trim($headers['X-Real-Ip']));
|
98 |
+
$tmp = trim($tmp[0]);
|
99 |
+
$ip_type = self::ip__validate($tmp);
|
100 |
+
if($ip_type){
|
101 |
+
$ips['x_forwarded_for'] = $ip_type == 'v6' ? self::ip__v6_normalize($tmp) : $tmp;
|
102 |
+
}
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
+
// Cloud Flare
|
107 |
+
if(isset($ips['cloud_flare'])){
|
108 |
+
if(isset($headers['CF-Connecting-IP'], $headers['CF-IPCountry'], $headers['CF-RAY']) || isset($headers['Cf-Connecting-Ip'], $headers['Cf-Ipcountry'], $headers['Cf-Ray'])){
|
109 |
+
$tmp = isset($headers['CF-Connecting-IP']) ? $headers['CF-Connecting-IP'] : $headers['Cf-Connecting-Ip'];
|
110 |
+
$tmp = strpos($tmp, ',') !== false ? explode(',', $tmp) : (array)$tmp;
|
111 |
+
$ip_type = self::ip__validate(trim($tmp[0]));
|
112 |
+
if($ip_type){
|
113 |
+
$ips['real'] = $ip_type == 'v6' ? self::ip__v6_normalize(trim($tmp[0])) : trim($tmp[0]);
|
114 |
+
}
|
115 |
+
}
|
116 |
+
}
|
117 |
+
|
118 |
+
// Getting real IP from REMOTE_ADDR or Cf_Connecting_Ip if set or from (X-Forwarded-For, X-Real-Ip) if REMOTE_ADDR is local.
|
119 |
+
if(isset($ips['real'])){
|
120 |
+
|
121 |
+
// Detect IP type
|
122 |
+
$ip_type = self::ip__validate(isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : '');
|
123 |
+
if($ip_type)
|
124 |
+
$ips['real'] = ($ip_type == 'v6' ? self::ip__v6_normalize(isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : '' ) : isset( $_SERVER['REMOTE_ADDR'] )) ? $_SERVER['REMOTE_ADDR'] : '';
|
125 |
+
|
126 |
+
// Cloud Flare
|
127 |
+
if(isset($headers['CF-Connecting-IP'], $headers['CF-IPCountry'], $headers['CF-RAY']) || isset($headers['Cf-Connecting-Ip'], $headers['Cf-Ipcountry'], $headers['Cf-Ray'])){
|
128 |
+
$tmp = isset($headers['CF-Connecting-IP']) ? $headers['CF-Connecting-IP'] : $headers['Cf-Connecting-Ip'];
|
129 |
+
$tmp = strpos($tmp, ',') !== false ? explode(',', $tmp) : (array)$tmp;
|
130 |
+
$ip_type = self::ip__validate(trim($tmp[0]));
|
131 |
+
if($ip_type)
|
132 |
+
$ips['real'] = $ip_type == 'v6' ? self::ip__v6_normalize(trim($tmp[0])) : trim($tmp[0]);
|
133 |
+
|
134 |
+
// Sucury
|
135 |
+
}elseif(isset($headers['X-Sucuri-Clientip'], $headers['X-Sucuri-Country'])){
|
136 |
+
$ip_type = self::ip__validate($headers['X-Sucuri-Clientip']);
|
137 |
+
if($ip_type)
|
138 |
+
$ips['real'] = $ip_type == 'v6' ? self::ip__v6_normalize($headers['X-Sucuri-Clientip']) : $headers['X-Sucuri-Clientip'];
|
139 |
+
|
140 |
+
// OVH
|
141 |
+
}elseif(isset($headers['X-Cdn-Any-Ip'], $headers['Remote-Ip'])){
|
142 |
+
$ip_type = self::ip__validate($headers['X-Cdn-Any-Ip']);
|
143 |
+
if($ip_type)
|
144 |
+
$ips['real'] = $ip_type == 'v6' ? self::ip__v6_normalize($headers['X-Cdn-Any-Ip']) : $headers['X-Cdn-Any-Ip'];
|
145 |
+
|
146 |
+
// Incapsula proxy
|
147 |
+
}elseif(isset($headers['Incap-Client-Ip'])){
|
148 |
+
$ip_type = self::ip__validate($headers['Incap-Client-Ip']);
|
149 |
+
if($ip_type)
|
150 |
+
$ips['real'] = $ip_type == 'v6' ? self::ip__v6_normalize($headers['Incap-Client-Ip']) : $headers['Incap-Client-Ip'];
|
151 |
+
}
|
152 |
+
|
153 |
+
// Is private network
|
154 |
+
if($ip_type === false ||
|
155 |
+
($ip_type &&
|
156 |
+
(self::ip__is_private_network($ips['real'], $ip_type) ||
|
157 |
+
self::ip__mask_match(
|
158 |
+
$ips['real'],
|
159 |
+
(isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] . '/24' : '127.0.0.1/24'),
|
160 |
+
$ip_type
|
161 |
+
)
|
162 |
+
)
|
163 |
+
)
|
164 |
+
){
|
165 |
+
|
166 |
+
// X-Forwarded-For
|
167 |
+
if(isset($headers['X-Forwarded-For'])){
|
168 |
+
$tmp = explode(',', trim($headers['X-Forwarded-For']));
|
169 |
+
$tmp = trim($tmp[0]);
|
170 |
+
$ip_type = self::ip__validate($tmp);
|
171 |
+
if($ip_type)
|
172 |
+
$ips['real'] = $ip_type == 'v6' ? self::ip__v6_normalize($tmp) : $tmp;
|
173 |
+
|
174 |
+
// X-Real-Ip
|
175 |
+
}elseif(isset($headers['X-Real-Ip'])){
|
176 |
+
$tmp = explode(',', trim($headers['X-Real-Ip']));
|
177 |
+
$tmp = trim($tmp[0]);
|
178 |
+
$ip_type = self::ip__validate($tmp);
|
179 |
+
if($ip_type)
|
180 |
+
$ips['real'] = $ip_type == 'v6' ? self::ip__v6_normalize($tmp) : $tmp;
|
181 |
+
}
|
182 |
+
}
|
183 |
+
}
|
184 |
+
|
185 |
+
// Validating IPs
|
186 |
+
$result = array();
|
187 |
+
foreach($ips as $key => $ip){
|
188 |
+
$ip_version = self::ip__validate($ip);
|
189 |
+
if($ip && (($v4_only && $ip_version == 'v4') || !$v4_only)){
|
190 |
+
$result[$key] = $ip;
|
191 |
+
}
|
192 |
+
}
|
193 |
+
|
194 |
+
$result = array_unique($result);
|
195 |
+
return count($result) > 1
|
196 |
+
? $result
|
197 |
+
: (reset($result) !== false
|
198 |
+
? reset($result)
|
199 |
+
: null);
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Checks if the IP is in private range
|
204 |
+
*
|
205 |
+
* @param string $ip
|
206 |
+
* @param string $ip_type
|
207 |
+
*
|
208 |
+
* @return bool
|
209 |
+
*/
|
210 |
+
static function ip__is_private_network($ip, $ip_type = 'v4')
|
211 |
+
{
|
212 |
+
return self::ip__mask_match($ip, self::$private_networks[$ip_type], $ip_type);
|
213 |
+
}
|
214 |
+
|
215 |
+
/**
|
216 |
+
* Check if the IP belong to mask. Recursive.
|
217 |
+
* Octet by octet for IPv4
|
218 |
+
* Hextet by hextet for IPv6
|
219 |
+
*
|
220 |
+
* @param string $ip
|
221 |
+
* @param string $cidr work to compare with
|
222 |
+
* @param string $ip_type IPv6 or IPv4
|
223 |
+
* @param int $xtet_count Recursive counter. Determs current part of address to check.
|
224 |
+
*
|
225 |
+
* @return bool
|
226 |
+
*/
|
227 |
+
static public function ip__mask_match($ip, $cidr, $ip_type = 'v4', $xtet_count = 0)
|
228 |
+
{
|
229 |
+
if(is_array($cidr)){
|
230 |
+
foreach($cidr as $curr_mask){
|
231 |
+
if(self::ip__mask_match($ip, $curr_mask, $ip_type)){
|
232 |
+
return true;
|
233 |
+
}
|
234 |
+
}
|
235 |
+
unset($curr_mask);
|
236 |
+
return false;
|
237 |
+
}
|
238 |
+
|
239 |
+
$xtet_base = ($ip_type == 'v4') ? 8 : 16;
|
240 |
+
|
241 |
+
// Calculate mask
|
242 |
+
$exploded = explode('/', $cidr);
|
243 |
+
$net_ip = $exploded[0];
|
244 |
+
$mask = $exploded[1];
|
245 |
+
|
246 |
+
// Exit condition
|
247 |
+
$xtet_end = ceil($mask / $xtet_base);
|
248 |
+
if($xtet_count == $xtet_end)
|
249 |
+
return true;
|
250 |
+
|
251 |
+
// Lenght of bits for comparsion
|
252 |
+
$mask = $mask - $xtet_base * $xtet_count >= $xtet_base ? $xtet_base : $mask - $xtet_base * $xtet_count;
|
253 |
+
|
254 |
+
// Explode by octets/hextets from IP and Net
|
255 |
+
$net_ip_xtets = explode($ip_type == 'v4' ? '.' : ':', $net_ip);
|
256 |
+
$ip_xtets = explode($ip_type == 'v4' ? '.' : ':', $ip);
|
257 |
+
|
258 |
+
// Standartizing. Getting current octets/hextets. Adding leading zeros.
|
259 |
+
$net_xtet = str_pad(decbin($ip_type == 'v4' ? $net_ip_xtets[$xtet_count] : @hexdec($net_ip_xtets[$xtet_count])), $xtet_base, 0, STR_PAD_LEFT);
|
260 |
+
$ip_xtet = str_pad(decbin($ip_type == 'v4' ? $ip_xtets[$xtet_count] : @hexdec($ip_xtets[$xtet_count])), $xtet_base, 0, STR_PAD_LEFT);
|
261 |
+
|
262 |
+
// Comparing bit by bit
|
263 |
+
for($i = 0, $result = true; $mask != 0; $mask--, $i++){
|
264 |
+
if($ip_xtet[$i] != $net_xtet[$i]){
|
265 |
+
$result = false;
|
266 |
+
break;
|
267 |
+
}
|
268 |
+
}
|
269 |
+
|
270 |
+
// Recursing. Moving to next octet/hextet.
|
271 |
+
if($result)
|
272 |
+
$result = self::ip__mask_match($ip, $cidr, $ip_type, $xtet_count + 1);
|
273 |
+
|
274 |
+
return $result;
|
275 |
+
|
276 |
+
}
|
277 |
+
|
278 |
+
/**
|
279 |
+
* Converts long mask like 4294967295 to number like 32
|
280 |
+
*
|
281 |
+
* @param int $long_mask
|
282 |
+
*
|
283 |
+
* @return int
|
284 |
+
*/
|
285 |
+
static function ip__mask__long_to_number($long_mask)
|
286 |
+
{
|
287 |
+
$num_mask = strpos((string)decbin($long_mask), '0');
|
288 |
+
return $num_mask === false ? 32 : $num_mask;
|
289 |
+
}
|
290 |
+
|
291 |
+
/**
|
292 |
+
* Validating IPv4, IPv6
|
293 |
+
*
|
294 |
+
* @param string $ip
|
295 |
+
*
|
296 |
+
* @return string|bool
|
297 |
+
*/
|
298 |
+
static public function ip__validate($ip)
|
299 |
+
{
|
300 |
+
if(!$ip) return false; // NULL || FALSE || '' || so on...
|
301 |
+
if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) && $ip != '0.0.0.0') return 'v4'; // IPv4
|
302 |
+
if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) && self::ip__v6_reduce($ip) != '0::0') return 'v6'; // IPv6
|
303 |
+
return false; // Unknown
|
304 |
+
}
|
305 |
+
|
306 |
+
/**
|
307 |
+
* Expand IPv6
|
308 |
+
*
|
309 |
+
* @param string $ip
|
310 |
+
*
|
311 |
+
* @return string IPv6
|
312 |
+
*/
|
313 |
+
static public function ip__v6_normalize($ip)
|
314 |
+
{
|
315 |
+
$ip = trim($ip);
|
316 |
+
// Searching for ::ffff:xx.xx.xx.xx patterns and turn it to IPv6
|
317 |
+
if(preg_match('/^::ffff:([0-9]{1,3}\.?){4}$/', $ip)){
|
318 |
+
$ip = dechex(sprintf("%u", ip2long(substr($ip, 7))));
|
319 |
+
$ip = '0:0:0:0:0:0:' . (strlen($ip) > 4 ? substr('abcde', 0, -4) : '0') . ':' . substr($ip, -4, 4);
|
320 |
+
// Normalizing hextets number
|
321 |
+
}elseif(strpos($ip, '::') !== false){
|
322 |
+
$ip = str_replace('::', str_repeat(':0', 8 - substr_count($ip, ':')) . ':', $ip);
|
323 |
+
$ip = strpos($ip, ':') === 0 ? '0' . $ip : $ip;
|
324 |
+
$ip = strpos(strrev($ip), ':') === 0 ? $ip . '0' : $ip;
|
325 |
+
}
|
326 |
+
// Simplifyng hextets
|
327 |
+
if(preg_match('/:0(?=[a-z0-9]+)/', $ip)){
|
328 |
+
$ip = preg_replace('/:0(?=[a-z0-9]+)/', ':', strtolower($ip));
|
329 |
+
$ip = self::ip__v6_normalize($ip);
|
330 |
+
}
|
331 |
+
return $ip;
|
332 |
+
}
|
333 |
+
|
334 |
+
/**
|
335 |
+
* Reduce IPv6
|
336 |
+
*
|
337 |
+
* @param string $ip
|
338 |
+
*
|
339 |
+
* @return string IPv6
|
340 |
+
*/
|
341 |
+
static public function ip__v6_reduce($ip)
|
342 |
+
{
|
343 |
+
if(strpos($ip, ':') !== false){
|
344 |
+
$ip = preg_replace('/:0{1,4}/', ':', $ip);
|
345 |
+
$ip = preg_replace('/:{2,}/', '::', $ip);
|
346 |
+
$ip = strpos($ip, '0') === 0 ? substr($ip, 1) : $ip;
|
347 |
+
}
|
348 |
+
return $ip;
|
349 |
+
}
|
350 |
+
|
351 |
+
/**
|
352 |
+
* Get URL form IP. Check if it's belong to cleantalk.
|
353 |
+
*
|
354 |
+
* @param string $ip
|
355 |
+
*
|
356 |
+
* @return false|int|string
|
357 |
+
*/
|
358 |
+
static public function ip__is_cleantalks($ip)
|
359 |
+
{
|
360 |
+
if(self::ip__validate($ip)){
|
361 |
+
$url = array_search($ip, self::$cleantalks_servers);
|
362 |
+
return $url
|
363 |
+
? true
|
364 |
+
: false;
|
365 |
+
}else
|
366 |
+
return false;
|
367 |
+
}
|
368 |
+
|
369 |
+
/**
|
370 |
+
* Get URL form IP. Check if it's belong to cleantalk.
|
371 |
+
*
|
372 |
+
* @param $ip
|
373 |
+
*
|
374 |
+
* @return false|int|string
|
375 |
+
*/
|
376 |
+
static public function ip__resolve__cleantalks($ip)
|
377 |
+
{
|
378 |
+
if(self::ip__validate($ip)){
|
379 |
+
$url = array_search($ip, self::$cleantalks_servers);
|
380 |
+
return $url
|
381 |
+
? $url
|
382 |
+
: self::ip__resolve($ip);
|
383 |
+
}else
|
384 |
+
return $ip;
|
385 |
+
}
|
386 |
+
|
387 |
+
/**
|
388 |
+
* Get URL form IP
|
389 |
+
*
|
390 |
+
* @param $ip
|
391 |
+
*
|
392 |
+
* @return string
|
393 |
+
*/
|
394 |
+
static public function ip__resolve($ip)
|
395 |
+
{
|
396 |
+
if(self::ip__validate($ip)){
|
397 |
+
$url = gethostbyaddr($ip);
|
398 |
+
if($url)
|
399 |
+
return $url;
|
400 |
+
}
|
401 |
+
return $ip;
|
402 |
+
}
|
403 |
+
|
404 |
+
/**
|
405 |
+
* Resolve DNS to IP
|
406 |
+
*
|
407 |
+
* @param $host
|
408 |
+
* @param bool $out
|
409 |
+
*
|
410 |
+
* @return bool
|
411 |
+
*/
|
412 |
+
static public function dns__resolve($host, $out = false)
|
413 |
+
{
|
414 |
+
|
415 |
+
// Get DNS records about URL
|
416 |
+
if(function_exists('dns_get_record')){
|
417 |
+
$records = dns_get_record($host, DNS_A);
|
418 |
+
if($records !== false){
|
419 |
+
$out = $records[0]['ip'];
|
420 |
+
}
|
421 |
+
}
|
422 |
+
|
423 |
+
// Another try if first failed
|
424 |
+
if(!$out && function_exists('gethostbynamel')){
|
425 |
+
$records = gethostbynamel($host);
|
426 |
+
if($records !== false){
|
427 |
+
$out = $records[0];
|
428 |
+
}
|
429 |
+
}
|
430 |
+
|
431 |
+
return $out;
|
432 |
+
|
433 |
+
}
|
434 |
+
|
435 |
+
/**
|
436 |
+
* Function sends raw http request
|
437 |
+
*
|
438 |
+
* May use 4 presets(combining possible):
|
439 |
+
* get_code - getting only HTTP response code
|
440 |
+
* async - async requests
|
441 |
+
* get - GET-request
|
442 |
+
* ssl - use SSL
|
443 |
+
*
|
444 |
+
* @param string $url URL
|
445 |
+
* @param array $data POST|GET indexed array with data to send
|
446 |
+
* @param string|array $presets String or Array with presets: get_code, async, get, ssl, dont_split_to_array
|
447 |
+
* @param array $opts Optional option for CURL connection
|
448 |
+
*
|
449 |
+
* @return array|bool (array || array('error' => true))
|
450 |
+
*/
|
451 |
+
static public function http__request($url, $data = array(), $presets = null, $opts = array())
|
452 |
+
{
|
453 |
+
if(function_exists('curl_init')){
|
454 |
+
|
455 |
+
$ch = curl_init();
|
456 |
+
|
457 |
+
if(!empty($data)){
|
458 |
+
// If $data scalar converting it to array
|
459 |
+
$data = is_string($data) || is_int($data) ? array($data => 1) : $data;
|
460 |
+
// Build query
|
461 |
+
$opts[CURLOPT_POSTFIELDS] = $data;
|
462 |
+
}
|
463 |
+
|
464 |
+
// Merging OBLIGATORY options with GIVEN options
|
465 |
+
$opts = self::array_merge__save_numeric_keys(
|
466 |
+
array(
|
467 |
+
CURLOPT_URL => $url,
|
468 |
+
CURLOPT_RETURNTRANSFER => true,
|
469 |
+
CURLOPT_CONNECTTIMEOUT_MS => 3000,
|
470 |
+
CURLOPT_FORBID_REUSE => true,
|
471 |
+
CURLOPT_USERAGENT => self::AGENT . '; ' . ( isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : 'UNKNOWN_HOST' ),
|
472 |
+
CURLOPT_POST => true,
|
473 |
+
CURLOPT_SSL_VERIFYPEER => false,
|
474 |
+
CURLOPT_SSL_VERIFYHOST => 0,
|
475 |
+
CURLOPT_HTTPHEADER => array('Expect:'), // Fix for large data and old servers http://php.net/manual/ru/function.curl-setopt.php#82418
|
476 |
+
CURLOPT_FOLLOWLOCATION => true,
|
477 |
+
CURLOPT_MAXREDIRS => 5,
|
478 |
+
),
|
479 |
+
$opts
|
480 |
+
);
|
481 |
+
|
482 |
+
// Use presets
|
483 |
+
$presets = is_array($presets) ? $presets : explode(' ', $presets);
|
484 |
+
foreach($presets as $preset){
|
485 |
+
|
486 |
+
switch($preset){
|
487 |
+
|
488 |
+
// Do not follow redirects
|
489 |
+
case 'dont_follow_redirects':
|
490 |
+
$opts[CURLOPT_FOLLOWLOCATION] = false;
|
491 |
+
$opts[CURLOPT_MAXREDIRS] = 0;
|
492 |
+
break;
|
493 |
+
|
494 |
+
// Get headers only
|
495 |
+
case 'get_code':
|
496 |
+
$opts[CURLOPT_HEADER] = true;
|
497 |
+
$opts[CURLOPT_NOBODY] = true;
|
498 |
+
break;
|
499 |
+
|
500 |
+
// Make a request, don't wait for an answer
|
501 |
+
case 'async':
|
502 |
+
$opts[CURLOPT_CONNECTTIMEOUT_MS] = 1000;
|
503 |
+
$opts[CURLOPT_TIMEOUT_MS] = 500;
|
504 |
+
break;
|
505 |
+
|
506 |
+
case 'get':
|
507 |
+
$opts[CURLOPT_URL] .= $data ? '?' . str_replace("&", "&", http_build_query($data)) : '';
|
508 |
+
$opts[CURLOPT_CUSTOMREQUEST] = 'GET';
|
509 |
+
$opts[CURLOPT_POST] = false;
|
510 |
+
$opts[CURLOPT_POSTFIELDS] = null;
|
511 |
+
break;
|
512 |
+
|
513 |
+
case 'ssl':
|
514 |
+
$opts[CURLOPT_SSL_VERIFYPEER] = true;
|
515 |
+
$opts[CURLOPT_SSL_VERIFYHOST] = 2;
|
516 |
+
if(defined('CLEANTALK_CASERT_PATH') && CLEANTALK_CASERT_PATH)
|
517 |
+
$opts[CURLOPT_CAINFO] = CLEANTALK_CASERT_PATH;
|
518 |
+
break;
|
519 |
+
|
520 |
+
default:
|
521 |
+
|
522 |
+
break;
|
523 |
+
}
|
524 |
+
|
525 |
+
}
|
526 |
+
unset($preset);
|
527 |
+
|
528 |
+
curl_setopt_array($ch, $opts);
|
529 |
+
$result = curl_exec($ch);
|
530 |
+
|
531 |
+
// RETURN if async request
|
532 |
+
if(in_array('async', $presets))
|
533 |
+
return true;
|
534 |
+
|
535 |
+
if($result){
|
536 |
+
|
537 |
+
if(strpos($result, PHP_EOL) !== false && !in_array('dont_split_to_array', $presets))
|
538 |
+
$result = explode(PHP_EOL, $result);
|
539 |
+
|
540 |
+
// Get code crossPHP method
|
541 |
+
if(in_array('get_code', $presets)){
|
542 |
+
$curl_info = curl_getinfo($ch);
|
543 |
+
$result = $curl_info['http_code'];
|
544 |
+
}
|
545 |
+
curl_close($ch);
|
546 |
+
$out = $result;
|
547 |
+
}else
|
548 |
+
$out = array('error' => curl_error($ch));
|
549 |
+
}else
|
550 |
+
$out = array('error' => 'CURL_NOT_INSTALLED');
|
551 |
+
|
552 |
+
/**
|
553 |
+
* Getting HTTP-response code without cURL
|
554 |
+
*/
|
555 |
+
if($presets && ($presets == 'get_code' || (is_array($presets) && in_array('get_code', $presets)))
|
556 |
+
&& isset($out['error']) && $out['error'] == 'CURL_NOT_INSTALLED'
|
557 |
+
){
|
558 |
+
$headers = get_headers($url);
|
559 |
+
$out = (int)preg_replace('/.*(\d{3}).*/', '$1', $headers[0]);
|
560 |
+
}
|
561 |
+
|
562 |
+
return $out;
|
563 |
+
}
|
564 |
+
|
565 |
+
/**
|
566 |
+
* Merging arrays without reseting numeric keys
|
567 |
+
*
|
568 |
+
* @param array $arr1 One-dimentional array
|
569 |
+
* @param array $arr2 One-dimentional array
|
570 |
+
*
|
571 |
+
* @return array Merged array
|
572 |
+
*/
|
573 |
+
public static function array_merge__save_numeric_keys($arr1, $arr2)
|
574 |
+
{
|
575 |
+
foreach($arr2 as $key => $val){
|
576 |
+
$arr1[$key] = $val;
|
577 |
+
}
|
578 |
+
return $arr1;
|
579 |
+
}
|
580 |
+
|
581 |
+
/**
|
582 |
+
* Merging arrays without reseting numeric keys recursive
|
583 |
+
*
|
584 |
+
* @param array $arr1 One-dimentional array
|
585 |
+
* @param array $arr2 One-dimentional array
|
586 |
+
*
|
587 |
+
* @return array Merged array
|
588 |
+
*/
|
589 |
+
public static function array_merge__save_numeric_keys__recursive($arr1, $arr2)
|
590 |
+
{
|
591 |
+
foreach($arr2 as $key => $val){
|
592 |
+
|
593 |
+
// Array | array => array
|
594 |
+
if(isset($arr1[$key]) && is_array($arr1[$key]) && is_array($val)){
|
595 |
+
$arr1[$key] = self::array_merge__save_numeric_keys__recursive($arr1[$key], $val);
|
596 |
+
|
597 |
+
// Scalar | array => array
|
598 |
+
}elseif(isset($arr1[$key]) && !is_array($arr1[$key]) && is_array($val)){
|
599 |
+
$tmp = $arr1[$key] =
|
600 |
+
$arr1[$key] = $val;
|
601 |
+
$arr1[$key][] = $tmp;
|
602 |
+
|
603 |
+
// array | scalar => array
|
604 |
+
}elseif(isset($arr1[$key]) && is_array($arr1[$key]) && !is_array($val)){
|
605 |
+
$arr1[$key][] = $val;
|
606 |
+
|
607 |
+
// scalar | scalar => scalar
|
608 |
+
}else{
|
609 |
+
$arr1[$key] = $val;
|
610 |
+
}
|
611 |
+
}
|
612 |
+
return $arr1;
|
613 |
+
}
|
614 |
+
|
615 |
+
/**
|
616 |
+
* Function removing non UTF8 characters from array|string|object
|
617 |
+
*
|
618 |
+
* @param array|object|string $data
|
619 |
+
*
|
620 |
+
* @return array|object|string
|
621 |
+
*/
|
622 |
+
public static function removeNonUTF8($data)
|
623 |
+
{
|
624 |
+
// Array || object
|
625 |
+
if(is_array($data) || is_object($data)){
|
626 |
+
foreach($data as $key => &$val){
|
627 |
+
$val = self::removeNonUTF8($val);
|
628 |
+
}
|
629 |
+
unset($key, $val);
|
630 |
+
|
631 |
+
//String
|
632 |
+
}else{
|
633 |
+
if(!preg_match('//u', $data))
|
634 |
+
$data = 'Nulled. Not UTF8 encoded or malformed.';
|
635 |
+
}
|
636 |
+
return $data;
|
637 |
+
}
|
638 |
+
|
639 |
+
/**
|
640 |
+
* Function convert anything to UTF8 and removes non UTF8 characters
|
641 |
+
*
|
642 |
+
* @param array|object|string $obj
|
643 |
+
* @param string $data_codepage
|
644 |
+
*
|
645 |
+
* @return mixed(array|object|string)
|
646 |
+
*/
|
647 |
+
public static function toUTF8($obj, $data_codepage = null)
|
648 |
+
{
|
649 |
+
// Array || object
|
650 |
+
if(is_array($obj) || is_object($obj)){
|
651 |
+
foreach($obj as $key => &$val){
|
652 |
+
$val = self::toUTF8($val, $data_codepage);
|
653 |
+
}
|
654 |
+
unset($key, $val);
|
655 |
+
|
656 |
+
//String
|
657 |
+
}else{
|
658 |
+
if(!preg_match('//u', $obj) && function_exists('mb_detect_encoding') && function_exists('mb_convert_encoding')){
|
659 |
+
$encoding = mb_detect_encoding($obj);
|
660 |
+
$encoding = $encoding ? $encoding : $data_codepage;
|
661 |
+
if($encoding)
|
662 |
+
$obj = mb_convert_encoding($obj, 'UTF-8', $encoding);
|
663 |
+
}
|
664 |
+
}
|
665 |
+
return $obj;
|
666 |
+
}
|
667 |
+
|
668 |
+
/**
|
669 |
+
* Function convert from UTF8
|
670 |
+
*
|
671 |
+
* @param array|object|string $obj
|
672 |
+
* @param string $data_codepage
|
673 |
+
*
|
674 |
+
* @return mixed (array|object|string)
|
675 |
+
*/
|
676 |
+
public static function fromUTF8($obj, $data_codepage = null)
|
677 |
+
{
|
678 |
+
// Array || object
|
679 |
+
if(is_array($obj) || is_object($obj)){
|
680 |
+
foreach($obj as $key => &$val){
|
681 |
+
$val = self::fromUTF8($val, $data_codepage);
|
682 |
+
}
|
683 |
+
unset($key, $val);
|
684 |
+
|
685 |
+
//String
|
686 |
+
}else{
|
687 |
+
if(preg_match('u', $obj) && function_exists('mb_convert_encoding') && $data_codepage !== null)
|
688 |
+
$obj = mb_convert_encoding($obj, $data_codepage, 'UTF-8');
|
689 |
+
}
|
690 |
+
return $obj;
|
691 |
+
}
|
692 |
+
|
693 |
+
/**
|
694 |
+
* Checks if the string is JSON type
|
695 |
+
*
|
696 |
+
* @param string
|
697 |
+
*
|
698 |
+
* @return bool
|
699 |
+
*/
|
700 |
+
static public function is_json($string)
|
701 |
+
{
|
702 |
+
return is_string($string) && is_array(json_decode($string, true)) ? true : false;
|
703 |
+
}
|
704 |
+
|
705 |
+
/**
|
706 |
+
* Universal method to adding cookies
|
707 |
+
*
|
708 |
+
* @param $name
|
709 |
+
* @param string $value
|
710 |
+
* @param int $expires
|
711 |
+
* @param string $path
|
712 |
+
* @param null $domain
|
713 |
+
* @param bool $secure
|
714 |
+
* @param bool $httponly
|
715 |
+
* @param string $samesite
|
716 |
+
*
|
717 |
+
* @return void
|
718 |
+
*/
|
719 |
+
public static function apbct_cookie__set ($name, $value = '', $expires = 0, $path = '', $domain = null, $secure = false, $httponly = false, $samesite = 'Lax' ) {
|
720 |
+
|
721 |
+
// For PHP 7.3+ and above
|
722 |
+
if( version_compare( phpversion(), '7.3.0', '>=' ) ){
|
723 |
+
|
724 |
+
$params = array(
|
725 |
+
'expires' => $expires,
|
726 |
+
'path' => $path,
|
727 |
+
'domain' => $domain,
|
728 |
+
'secure' => $secure,
|
729 |
+
'httponly' => $httponly,
|
730 |
+
);
|
731 |
+
|
732 |
+
if($samesite)
|
733 |
+
$params['samesite'] = $samesite;
|
734 |
+
|
735 |
+
setcookie( $name, $value, $params );
|
736 |
+
|
737 |
+
// For PHP 5.6 - 7.2
|
738 |
+
}else {
|
739 |
+
if($samesite)
|
740 |
+
$path = $path . '; samesite=' . $samesite;
|
741 |
+
setcookie( $name, $value, $expires, $path, $domain, $secure, $httponly );
|
742 |
+
}
|
743 |
+
|
744 |
+
}
|
745 |
}
|
@@ -256,7 +256,7 @@ class SFW
|
|
256 |
|
257 |
sleep(6);
|
258 |
|
259 |
-
$result = API::method__get_2s_blacklists_db($ct_key, 'multifiles');
|
260 |
|
261 |
if(empty($result['error'])){
|
262 |
|
@@ -271,47 +271,44 @@ class SFW
|
|
271 |
|
272 |
if(!$immediate) $pattenrs[] = 'async';
|
273 |
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
279 |
|
280 |
-
|
281 |
|
282 |
-
|
283 |
|
284 |
-
|
285 |
-
|
286 |
|
287 |
-
|
288 |
|
289 |
-
return Helper::http__request(
|
290 |
-
get_option('siteurl'),
|
291 |
-
array(
|
292 |
-
'spbc_remote_call_token' => md5($ct_key),
|
293 |
-
'spbc_remote_call_action' => 'sfw_update',
|
294 |
-
'plugin_name' => 'apbct',
|
295 |
-
'file_urls' => implode(',', $file_urls),
|
296 |
-
),
|
297 |
-
$pattenrs
|
298 |
-
);
|
299 |
-
}
|
300 |
-
}else {
|
301 |
return Helper::http__request(
|
302 |
-
get_option('siteurl'),
|
303 |
array(
|
304 |
'spbc_remote_call_token' => md5($ct_key),
|
305 |
'spbc_remote_call_action' => 'sfw_update',
|
306 |
'plugin_name' => 'apbct',
|
307 |
-
'file_urls' =>
|
308 |
),
|
309 |
$pattenrs
|
310 |
-
);
|
311 |
-
}
|
|
|
312 |
}else
|
313 |
return array('error' => 'ERROR_ALLOW_URL_FOPEN_DISABLED');
|
314 |
-
}
|
|
|
315 |
}else
|
316 |
return array('error' => 'BAD_RESPONSE');
|
317 |
}else
|
256 |
|
257 |
sleep(6);
|
258 |
|
259 |
+
$result = API::method__get_2s_blacklists_db($ct_key, 'multifiles', '2_0');
|
260 |
|
261 |
if(empty($result['error'])){
|
262 |
|
271 |
|
272 |
if(!$immediate) $pattenrs[] = 'async';
|
273 |
|
274 |
+
// Clear SFW table
|
275 |
+
$this->db->execute("TRUNCATE TABLE {$this->data_table};");
|
276 |
+
$this->db->set_query("SELECT COUNT(network) as cnt FROM {$this->data_table};")->fetch(); // Check if it is clear
|
277 |
+
if($this->db->result['cnt'] != 0){
|
278 |
+
$this->db->execute("DELETE FROM {$this->data_table};"); // Truncate table
|
279 |
+
$this->db->set_query("SELECT COUNT(network) as cnt FROM {$this->data_table};")->fetch(); // Check if it is clear
|
280 |
+
if($this->db->result['cnt'] != 0){
|
281 |
+
return array('error' => 'COULD_NOT_CLEAR_SFW_TABLE'); // throw an error
|
282 |
+
}
|
283 |
+
}
|
284 |
+
|
285 |
+
$gf = \gzopen($result['file_url'], 'rb');
|
286 |
|
287 |
+
if ($gf) {
|
288 |
|
289 |
+
$file_urls = array();
|
290 |
|
291 |
+
while( ! \gzeof($gf) )
|
292 |
+
$file_urls[] = trim( \gzgets($gf, 1024) );
|
293 |
|
294 |
+
\gzclose($gf);
|
295 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
296 |
return Helper::http__request(
|
297 |
+
get_option('siteurl'),
|
298 |
array(
|
299 |
'spbc_remote_call_token' => md5($ct_key),
|
300 |
'spbc_remote_call_action' => 'sfw_update',
|
301 |
'plugin_name' => 'apbct',
|
302 |
+
'file_urls' => implode(',', $file_urls),
|
303 |
),
|
304 |
$pattenrs
|
305 |
+
);
|
306 |
+
}else
|
307 |
+
return array('error' => 'COULD_NOT_OPEN_REMOTE_FILE_SFW');
|
308 |
}else
|
309 |
return array('error' => 'ERROR_ALLOW_URL_FOPEN_DISABLED');
|
310 |
+
}else
|
311 |
+
return array('error' => 'NO_FILE_URL_PROVIDED');
|
312 |
}else
|
313 |
return array('error' => 'BAD_RESPONSE');
|
314 |
}else
|
@@ -1,562 +1,565 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* CleanTalk Antispam State class
|
5 |
-
*
|
6 |
-
* @package Antiospam Plugin by CleanTalk
|
7 |
-
* @subpackage State
|
8 |
-
* @Version 2.0
|
9 |
-
* @author Cleantalk team (welcome@cleantalk.org)
|
10 |
-
* @copyright (C) 2014 CleanTalk team (http://cleantalk.org)
|
11 |
-
* @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
|
12 |
-
*/
|
13 |
-
|
14 |
-
/**
|
15 |
-
* COMMON
|
16 |
-
*
|
17 |
-
* @property string api_key
|
18 |
-
*
|
19 |
-
* STAND ALONE
|
20 |
-
*
|
21 |
-
* @property ArrayObject settings
|
22 |
-
* @property ArrayObject data
|
23 |
-
*
|
24 |
-
* @property mixed moderate_ip
|
25 |
-
* @property mixed|string plugin_version
|
26 |
-
* @property mixed|string db_prefix
|
27 |
-
* @property string settings_link
|
28 |
-
* @property int key_is_ok
|
29 |
-
* @property string logo__small__colored
|
30 |
-
* @property string logo__small
|
31 |
-
* @property string logo
|
32 |
-
* @property string plugin_name
|
33 |
-
* @property string base_name
|
34 |
-
* @property array|mixed errors
|
35 |
-
*
|
36 |
-
* NETWORK
|
37 |
-
* @property ArrayObject network_data
|
38 |
-
* @property ArrayObject network_settings
|
39 |
-
* @property mixed allow_custom_key
|
40 |
-
* @property bool white_label
|
41 |
-
* @property mixed moderate
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
public $
|
49 |
-
public $
|
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 |
-
|
89 |
-
|
90 |
-
'
|
91 |
-
|
92 |
-
|
93 |
-
'
|
94 |
-
'
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
'
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
'
|
115 |
-
|
116 |
-
|
117 |
-
'
|
118 |
-
'
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
'
|
128 |
-
'
|
129 |
-
|
130 |
-
//
|
131 |
-
'
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
//
|
136 |
-
'
|
137 |
-
|
138 |
-
|
139 |
-
'
|
140 |
-
'
|
141 |
-
'
|
142 |
-
'
|
143 |
-
'
|
144 |
-
|
145 |
-
//
|
146 |
-
'
|
147 |
-
|
148 |
-
|
149 |
-
'
|
150 |
-
'
|
151 |
-
|
152 |
-
|
153 |
-
'
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
'
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
'
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
'
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
'
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
'
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
'
|
210 |
-
'
|
211 |
-
'
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
'
|
219 |
-
'last_call' => 0,
|
220 |
-
),
|
221 |
-
'
|
222 |
-
'last_call' => 0,
|
223 |
-
),
|
224 |
-
'
|
225 |
-
'last_call' => 0,
|
226 |
-
),
|
227 |
-
'
|
228 |
-
'last_call' => 0,
|
229 |
-
),
|
230 |
-
'
|
231 |
-
'last_call' => 0,
|
232 |
-
),
|
233 |
-
'
|
234 |
-
'last_call' => 0,
|
235 |
-
),
|
236 |
-
'
|
237 |
-
'last_call' => 0,
|
238 |
-
),
|
239 |
-
'
|
240 |
-
'last_call' => 0,
|
241 |
-
),
|
242 |
-
'
|
243 |
-
'last_call' => 0,
|
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 |
-
|
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 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
*
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
*
|
417 |
-
*
|
418 |
-
* @param
|
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 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
if(isset($this->errors[$val]))
|
470 |
-
unset($this->errors[$val]);
|
471 |
-
}
|
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 |
-
*
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
}
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
public function
|
551 |
-
return \Cleantalk\Common\
|
552 |
-
}
|
553 |
-
public function
|
554 |
-
return \Cleantalk\Common\
|
555 |
-
}
|
556 |
-
public function
|
557 |
-
return \Cleantalk\Common\
|
558 |
-
}
|
559 |
-
public function
|
560 |
-
return \Cleantalk\Common\
|
561 |
-
}
|
562 |
-
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* CleanTalk Antispam State class
|
5 |
+
*
|
6 |
+
* @package Antiospam Plugin by CleanTalk
|
7 |
+
* @subpackage State
|
8 |
+
* @Version 2.0
|
9 |
+
* @author Cleantalk team (welcome@cleantalk.org)
|
10 |
+
* @copyright (C) 2014 CleanTalk team (http://cleantalk.org)
|
11 |
+
* @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
|
12 |
+
*/
|
13 |
+
|
14 |
+
/**
|
15 |
+
* COMMON
|
16 |
+
*
|
17 |
+
* @property string api_key
|
18 |
+
*
|
19 |
+
* STAND ALONE
|
20 |
+
*
|
21 |
+
* @property ArrayObject settings
|
22 |
+
* @property ArrayObject data
|
23 |
+
*
|
24 |
+
* @property mixed moderate_ip
|
25 |
+
* @property mixed|string plugin_version
|
26 |
+
* @property mixed|string db_prefix
|
27 |
+
* @property string settings_link
|
28 |
+
* @property int key_is_ok
|
29 |
+
* @property string logo__small__colored
|
30 |
+
* @property string logo__small
|
31 |
+
* @property string logo
|
32 |
+
* @property string plugin_name
|
33 |
+
* @property string base_name
|
34 |
+
* @property array|mixed errors
|
35 |
+
*
|
36 |
+
* NETWORK
|
37 |
+
* @property ArrayObject network_data
|
38 |
+
* @property ArrayObject network_settings
|
39 |
+
* @property mixed allow_custom_key
|
40 |
+
* @property bool white_label
|
41 |
+
* @property mixed moderate
|
42 |
+
*
|
43 |
+
* MISC
|
44 |
+
*
|
45 |
+
*/
|
46 |
+
class CleantalkState
|
47 |
+
{
|
48 |
+
public $user = null;
|
49 |
+
public $option_prefix = 'cleantalk';
|
50 |
+
public $storage = array();
|
51 |
+
public $integrations = array();
|
52 |
+
public $def_settings = array(
|
53 |
+
|
54 |
+
'spam_firewall' => 1,
|
55 |
+
'apikey' => '',
|
56 |
+
'autoPubRevelantMess' => 0,
|
57 |
+
|
58 |
+
/* Forms for protection */
|
59 |
+
'registrations_test' => 1,
|
60 |
+
'comments_test' => 1,
|
61 |
+
'contact_forms_test' => 1,
|
62 |
+
'general_contact_forms_test' => 1, // Antispam test for unsupported and untested contact forms
|
63 |
+
'wc_checkout_test' => 1, // WooCommerce checkout default test
|
64 |
+
'wc_register_from_order' => 1, // Woocommerce registration during checkout
|
65 |
+
'search_test' => 1, // Test deafult Wordpress form
|
66 |
+
'check_external' => 0,
|
67 |
+
'check_external__capture_buffer' => 0,
|
68 |
+
'check_internal' => 0,
|
69 |
+
|
70 |
+
/* Comments and messages */
|
71 |
+
'disable_comments__all' => 0,
|
72 |
+
'disable_comments__posts' => 0,
|
73 |
+
'disable_comments__pages' => 0,
|
74 |
+
'disable_comments__media' => 0,
|
75 |
+
'bp_private_messages' => 1, //buddyPress private messages test => ON
|
76 |
+
'check_comments_number' => 1,
|
77 |
+
'remove_old_spam' => 0,
|
78 |
+
'remove_comments_links' => 0, // Removes links from approved comments
|
79 |
+
'show_check_links' => 1, // Shows check link to Cleantalk's DB.
|
80 |
+
'manage_comments_on_public_page' => 0, // Allows to control comments on public page.
|
81 |
+
|
82 |
+
// Data processing
|
83 |
+
'protect_logged_in' => 1, // Do anit-spam tests to for logged in users.
|
84 |
+
'use_ajax' => 1,
|
85 |
+
'use_static_js_key' => -1,
|
86 |
+
'general_postdata_test' => 0, //CAPD
|
87 |
+
'set_cookies'=> 1, // Disable cookies generatation to be compatible with Varnish.
|
88 |
+
'set_cookies__sessions'=> 0, // Use alt sessions for cookies.
|
89 |
+
'ssl_on' => 0, // Secure connection to servers
|
90 |
+
'use_buitin_http_api' => 1, // Using Wordpress HTTP built in API
|
91 |
+
|
92 |
+
// Exclusions
|
93 |
+
'exclusions__urls' => '',
|
94 |
+
'exclusions__urls__use_regexp' => 0,
|
95 |
+
'exclusions__fields' => '',
|
96 |
+
'exclusions__fields__use_regexp' => 0,
|
97 |
+
'exclusions__roles' => array('Administrator'),
|
98 |
+
|
99 |
+
// Administrator Panel
|
100 |
+
'show_adminbar' => 1, // Show the admin bar.
|
101 |
+
'all_time_counter' => 0,
|
102 |
+
'daily_counter' => 0,
|
103 |
+
'sfw_counter' => 0,
|
104 |
+
|
105 |
+
//Others
|
106 |
+
'user_token' => '',
|
107 |
+
'collect_details' => 0, // Collect details about browser of the visitor.
|
108 |
+
'send_connection_reports' => 0, //Send connection reports to Cleantalk servers
|
109 |
+
'async_js' => 0,
|
110 |
+
'debug_ajax' => 0,
|
111 |
+
|
112 |
+
// GDPR
|
113 |
+
'gdpr_enabled' => 0,
|
114 |
+
'gdpr_text' => 'By using this form you agree with the storage and processing of your data by using the Privacy Policy on this website.',
|
115 |
+
|
116 |
+
// Msic
|
117 |
+
'store_urls' => 1,
|
118 |
+
'store_urls__sessions' => 1,
|
119 |
+
'comment_notify' => 1,
|
120 |
+
'comment_notify__roles' => array('administrator'),
|
121 |
+
'complete_deactivation' => 0,
|
122 |
+
);
|
123 |
+
|
124 |
+
public $def_data = array(
|
125 |
+
|
126 |
+
// Plugin data
|
127 |
+
'plugin_version' => APBCT_VERSION,
|
128 |
+
'js_keys' => array(), // Keys to do JavaScript antispam test
|
129 |
+
'js_keys_store_days' => 14, // JavaScript keys store days - 8 days now
|
130 |
+
'js_key_lifetime' => 86400, // JavaScript key life time in seconds - 1 day now
|
131 |
+
'last_remote_call' => 0, //Timestam of last remote call
|
132 |
+
|
133 |
+
// Antispam
|
134 |
+
'spam_store_days' => 15, // Days before delete comments from folder Spam
|
135 |
+
'relevance_test' => 0, // Test comment for relevance
|
136 |
+
'notice_api_errors' => 0, // Send API error notices to WP admin
|
137 |
+
|
138 |
+
// Account data
|
139 |
+
'service_id' => 0,
|
140 |
+
'moderate' => 0,
|
141 |
+
'moderate_ip' => 0,
|
142 |
+
'ip_license' => 0,
|
143 |
+
'spam_count' => 0,
|
144 |
+
'auto_update' => 0,
|
145 |
+
'user_token' => '', // User token for auto login into spam statistics
|
146 |
+
'license_trial' => 0,
|
147 |
+
|
148 |
+
// Notices
|
149 |
+
'notice_show' => 0,
|
150 |
+
'notice_trial' => 0,
|
151 |
+
'notice_renew' => 0,
|
152 |
+
'notice_review' => 0,
|
153 |
+
'notice_auto_update' => 0,
|
154 |
+
|
155 |
+
// Brief data
|
156 |
+
'brief_data' => array(
|
157 |
+
'spam_stat' => array(),
|
158 |
+
'top5_spam_ip' => array(),
|
159 |
+
),
|
160 |
+
|
161 |
+
'array_accepted' => array(),
|
162 |
+
'array_blocked' => array(),
|
163 |
+
'current_hour' => '',
|
164 |
+
'sfw_counter' => array(
|
165 |
+
'all' => 0,
|
166 |
+
'blocked' => 0,
|
167 |
+
),
|
168 |
+
'all_time_counter' => array(
|
169 |
+
'accepted' => 0,
|
170 |
+
'blocked' => 0,
|
171 |
+
),
|
172 |
+
'user_counter' => array(
|
173 |
+
'accepted' => 0,
|
174 |
+
'blocked' => 0,
|
175 |
+
// 'since' => date('d M'),
|
176 |
+
),
|
177 |
+
'connection_reports' => array(
|
178 |
+
'success' => 0,
|
179 |
+
'negative' => 0,
|
180 |
+
'negative_report' => array(),
|
181 |
+
// 'since' => date('d M'),
|
182 |
+
),
|
183 |
+
|
184 |
+
// A-B tests
|
185 |
+
'ab_test' => array(
|
186 |
+
'sfw_enabled' => false,
|
187 |
+
),
|
188 |
+
|
189 |
+
// Misc
|
190 |
+
'feedback_request' => '',
|
191 |
+
'key_is_ok' => 0,
|
192 |
+
'salt' => '',
|
193 |
+
);
|
194 |
+
|
195 |
+
public $def_network_settings = array(
|
196 |
+
|
197 |
+
// Key
|
198 |
+
'apikey' => '',
|
199 |
+
'allow_custom_key' => 1,
|
200 |
+
'allow_custom_settings' => 1,
|
201 |
+
|
202 |
+
// White label settings
|
203 |
+
'white_label' => 0,
|
204 |
+
'white_label__hoster_key' => '',
|
205 |
+
'white_label__plugin_name' => 'Anti-Spam by CleanTalk',
|
206 |
+
);
|
207 |
+
|
208 |
+
public $def_network_data = array(
|
209 |
+
'key_is_ok' => 0,
|
210 |
+
'moderate' => 0,
|
211 |
+
'valid' => 0,
|
212 |
+
'user_token' => '',
|
213 |
+
'service_id' => 0,
|
214 |
+
'auto_update' => 0,
|
215 |
+
);
|
216 |
+
|
217 |
+
public $def_remote_calls = array(
|
218 |
+
'close_renew_banner' => array(
|
219 |
+
'last_call' => 0,
|
220 |
+
),
|
221 |
+
'sfw_update' => array(
|
222 |
+
'last_call' => 0,
|
223 |
+
),
|
224 |
+
'sfw_send_logs' => array(
|
225 |
+
'last_call' => 0,
|
226 |
+
),
|
227 |
+
'update_plugin' => array(
|
228 |
+
'last_call' => 0,
|
229 |
+
),
|
230 |
+
'install_plugin' => array(
|
231 |
+
'last_call' => 0,
|
232 |
+
),
|
233 |
+
'activate_plugin' => array(
|
234 |
+
'last_call' => 0,
|
235 |
+
),
|
236 |
+
'insert_auth_key' => array(
|
237 |
+
'last_call' => 0,
|
238 |
+
),
|
239 |
+
'deactivate_plugin' => array(
|
240 |
+
'last_call' => 0,
|
241 |
+
),
|
242 |
+
'uninstall_plugin' => array(
|
243 |
+
'last_call' => 0,
|
244 |
+
),
|
245 |
+
'update_settings' => array(
|
246 |
+
'last_call' => 0,
|
247 |
+
),
|
248 |
+
);
|
249 |
+
|
250 |
+
public $def_stats = array(
|
251 |
+
'sfw' => array(
|
252 |
+
'last_send_time' => 0,
|
253 |
+
'last_send_amount' => 0,
|
254 |
+
'last_update_time' => 0,
|
255 |
+
'entries' => 0,
|
256 |
+
),
|
257 |
+
'last_sfw_block' => array(
|
258 |
+
'time' => 0,
|
259 |
+
'ip' => '',
|
260 |
+
),
|
261 |
+
'last_request' => array(
|
262 |
+
'time' => 0,
|
263 |
+
'server' => '',
|
264 |
+
),
|
265 |
+
'requests' => array(
|
266 |
+
'0' => array(
|
267 |
+
'amount' => 1,
|
268 |
+
'average_time' => 0,
|
269 |
+
),
|
270 |
+
)
|
271 |
+
);
|
272 |
+
|
273 |
+
/**
|
274 |
+
* CleantalkState constructor.
|
275 |
+
*
|
276 |
+
* @param string $option_prefix Database settings prefix
|
277 |
+
* @param array $options Array of strings. Types of settings you want to get.
|
278 |
+
* @param bool $wpms Is multisite?
|
279 |
+
*/
|
280 |
+
public function __construct($option_prefix, $options = array('settings'))
|
281 |
+
{
|
282 |
+
$this->option_prefix = $option_prefix;
|
283 |
+
|
284 |
+
// Network settings
|
285 |
+
$option = get_site_option($this->option_prefix.'_network_settings');
|
286 |
+
$option = is_array($option) ? array_merge($this->def_network_settings, $option) : $this->def_network_settings;
|
287 |
+
$this->network_settings = new ArrayObject($option);
|
288 |
+
|
289 |
+
// Network data
|
290 |
+
$option = get_site_option($this->option_prefix.'_network_data');
|
291 |
+
$option = is_array($option) ? array_merge($this->def_network_data, $option) : $this->def_network_data;
|
292 |
+
$this->network_data = new ArrayObject($option);
|
293 |
+
|
294 |
+
foreach($options as $option_name){
|
295 |
+
|
296 |
+
$option = get_option($this->option_prefix.'_'.$option_name);
|
297 |
+
|
298 |
+
// Setting default options
|
299 |
+
if($this->option_prefix.'_'.$option_name === 'cleantalk_settings'){
|
300 |
+
$option = is_array($option) ? array_merge($this->def_settings, $option) : $this->def_settings;
|
301 |
+
}
|
302 |
+
|
303 |
+
// Setting default data
|
304 |
+
if($this->option_prefix.'_'.$option_name === 'cleantalk_data'){
|
305 |
+
$option = is_array($option) ? array_merge($this->def_data, $option) : $this->def_data;
|
306 |
+
// Generate salt
|
307 |
+
$option['salt'] = empty($option['salt'])
|
308 |
+
? str_pad(rand(0, getrandmax()), 6, '0').str_pad(rand(0, getrandmax()), 6, '0')
|
309 |
+
: $option['salt'];
|
310 |
+
}
|
311 |
+
|
312 |
+
// Setting default errors
|
313 |
+
if($this->option_prefix.'_'.$option_name === 'cleantalk_errors'){
|
314 |
+
$option = $option ? $option : array();
|
315 |
+
}
|
316 |
+
|
317 |
+
// Default remote calls
|
318 |
+
if($this->option_prefix.'_'.$option_name === 'cleantalk_remote_calls'){
|
319 |
+
$option = is_array($option) ? array_merge($this->def_remote_calls, $option) : $this->def_remote_calls;
|
320 |
+
}
|
321 |
+
|
322 |
+
// Default statistics
|
323 |
+
if($this->option_prefix.'_'.$option_name === 'cleantalk_stats'){
|
324 |
+
$option = is_array($option) ? array_merge($this->def_stats, $option) : $this->def_stats;
|
325 |
+
}
|
326 |
+
|
327 |
+
$this->$option_name = is_array($option) ? new ArrayObject($option) : $option;
|
328 |
+
}
|
329 |
+
}
|
330 |
+
|
331 |
+
/**
|
332 |
+
* Get specified option from database
|
333 |
+
*
|
334 |
+
* @param string $option_name
|
335 |
+
*/
|
336 |
+
private function getOption($option_name)
|
337 |
+
{
|
338 |
+
$option = get_option('cleantalk_'.$option_name, null);
|
339 |
+
$this->$option_name = gettype($option) === 'array'
|
340 |
+
? new ArrayObject($option)
|
341 |
+
: $option;
|
342 |
+
}
|
343 |
+
|
344 |
+
/**
|
345 |
+
* Save option to database
|
346 |
+
*
|
347 |
+
* @param string $option_name
|
348 |
+
* @param bool $use_perfix
|
349 |
+
* @param bool $autoload Use autoload flag?
|
350 |
+
*/
|
351 |
+
public function save($option_name, $use_perfix = true, $autoload = true)
|
352 |
+
{
|
353 |
+
$option_name_to_save = $use_perfix ? $this->option_prefix.'_'.$option_name : $option_name;
|
354 |
+
$arr = array();
|
355 |
+
foreach($this->$option_name as $key => $value){
|
356 |
+
$arr[$key] = $value;
|
357 |
+
}
|
358 |
+
update_option($option_name_to_save, $arr, $autoload);
|
359 |
+
}
|
360 |
+
|
361 |
+
/**
|
362 |
+
* Save PREFIX_setting to DB.
|
363 |
+
*/
|
364 |
+
public function saveSettings()
|
365 |
+
{
|
366 |
+
update_option($this->option_prefix.'_settings', (array)$this->settings);
|
367 |
+
}
|
368 |
+
|
369 |
+
/**
|
370 |
+
* Save PREFIX_data to DB.
|
371 |
+
*/
|
372 |
+
public function saveData()
|
373 |
+
{
|
374 |
+
update_option($this->option_prefix.'_data', (array)$this->data);
|
375 |
+
}
|
376 |
+
|
377 |
+
/**
|
378 |
+
* Save PREFIX_error to DB.
|
379 |
+
*/
|
380 |
+
public function saveErrors()
|
381 |
+
{
|
382 |
+
update_option($this->option_prefix.'_errors', (array)$this->errors);
|
383 |
+
}
|
384 |
+
|
385 |
+
/**
|
386 |
+
* Save PREFIX_network_data to DB.
|
387 |
+
*/
|
388 |
+
public function saveNetworkData()
|
389 |
+
{
|
390 |
+
update_site_option($this->option_prefix.'_network_data', $this->network_data);
|
391 |
+
}
|
392 |
+
|
393 |
+
/**
|
394 |
+
* Save PREFIX_network_data to DB.
|
395 |
+
*/
|
396 |
+
public function saveNetworkSettings()
|
397 |
+
{
|
398 |
+
update_site_option($this->option_prefix.'_network_settings', $this->network_settings);
|
399 |
+
}
|
400 |
+
|
401 |
+
/**
|
402 |
+
* Unset and delete option from DB.
|
403 |
+
*
|
404 |
+
* @param string $option_name
|
405 |
+
* @param bool $use_prefix
|
406 |
+
*/
|
407 |
+
public function deleteOption($option_name, $use_prefix = false)
|
408 |
+
{
|
409 |
+
if($this->__isset($option_name)){
|
410 |
+
$this->__unset($option_name);
|
411 |
+
delete_option( ($use_prefix ? $this->option_prefix.'_' : '') . $option_name);
|
412 |
+
}
|
413 |
+
}
|
414 |
+
|
415 |
+
/**
|
416 |
+
* Prepares an adds an error to the plugin's data
|
417 |
+
*
|
418 |
+
* @param string $type Error type/subtype
|
419 |
+
* @param string|array $error Error
|
420 |
+
* @param string $major_type Error major type
|
421 |
+
* @param bool $set_time Do we need to set time of this error
|
422 |
+
*
|
423 |
+
* @returns null
|
424 |
+
*/
|
425 |
+
public function error_add($type, $error, $major_type = null, $set_time = true)
|
426 |
+
{
|
427 |
+
$error = is_array($error)
|
428 |
+
? $error['error']
|
429 |
+
: $error;
|
430 |
+
|
431 |
+
// Exceptions
|
432 |
+
if( ($type == 'send_logs' && $error == 'NO_LOGS_TO_SEND') ||
|
433 |
+
($type == 'send_firewall_logs' && $error == 'NO_LOGS_TO_SEND') ||
|
434 |
+
$error == 'LOG_FILE_NOT_EXISTS'
|
435 |
+
)
|
436 |
+
return;
|
437 |
+
|
438 |
+
$error = array(
|
439 |
+
'error' => $error,
|
440 |
+
'error_time' => $set_time ? current_time('timestamp') : null,
|
441 |
+
);
|
442 |
+
|
443 |
+
if(!empty($major_type)){
|
444 |
+
$this->errors[$major_type][$type] = $error;
|
445 |
+
}else{
|
446 |
+
$this->errors[$type] = $error;
|
447 |
+
}
|
448 |
+
|
449 |
+
$this->saveErrors();
|
450 |
+
}
|
451 |
+
|
452 |
+
/**
|
453 |
+
* Deletes an error from the plugin's data
|
454 |
+
*
|
455 |
+
* @param array|string $type Error type to delete
|
456 |
+
* @param bool $save_flag Do we need to save data after error was deleted
|
457 |
+
* @param string $major_type Error major type to delete
|
458 |
+
*
|
459 |
+
* @returns null
|
460 |
+
*/
|
461 |
+
public function error_delete($type, $save_flag = false, $major_type = null)
|
462 |
+
{
|
463 |
+
/** @noinspection DuplicatedCode */
|
464 |
+
if(is_string($type))
|
465 |
+
$type = explode(' ', $type);
|
466 |
+
|
467 |
+
foreach($type as $val){
|
468 |
+
if($major_type){
|
469 |
+
if(isset($this->errors[$major_type][$val]))
|
470 |
+
unset($this->errors[$major_type][$val]);
|
471 |
+
}else{
|
472 |
+
if(isset($this->errors[$val]))
|
473 |
+
unset($this->errors[$val]);
|
474 |
+
}
|
475 |
+
}
|
476 |
+
|
477 |
+
// Save if flag is set and there are changes
|
478 |
+
if($save_flag)
|
479 |
+
$this->saveErrors();
|
480 |
+
}
|
481 |
+
|
482 |
+
/**
|
483 |
+
* Deletes all errors from the plugin's data
|
484 |
+
*
|
485 |
+
* @param bool $save_flag Do we need to save data after all errors was deleted
|
486 |
+
*
|
487 |
+
* @returns null
|
488 |
+
*/
|
489 |
+
public function error_delete_all($save_flag = false)
|
490 |
+
{
|
491 |
+
$this->errors = array();
|
492 |
+
if($save_flag)
|
493 |
+
$this->saveErrors();
|
494 |
+
}
|
495 |
+
|
496 |
+
/**
|
497 |
+
* Magic.
|
498 |
+
* Add new variables to storage[NEW_VARIABLE]
|
499 |
+
* And duplicates it in storage['data'][NEW_VARIABLE]
|
500 |
+
*
|
501 |
+
* @param string $name
|
502 |
+
* @param mixed $value
|
503 |
+
*/
|
504 |
+
public function __set($name, $value)
|
505 |
+
{
|
506 |
+
$this->storage[$name] = $value;
|
507 |
+
if(isset($this->storage['data'][$name])){
|
508 |
+
$this->storage['data'][$name] = $value;
|
509 |
+
}
|
510 |
+
}
|
511 |
+
|
512 |
+
/**
|
513 |
+
* Magic.
|
514 |
+
* Search and get param from: storage, data, api_key, database
|
515 |
+
*
|
516 |
+
* @param $name
|
517 |
+
*
|
518 |
+
* @return mixed
|
519 |
+
*/
|
520 |
+
public function __get($name)
|
521 |
+
{
|
522 |
+
// First check in storage
|
523 |
+
if (isset($this->storage[$name])){
|
524 |
+
return $this->storage[$name];
|
525 |
+
|
526 |
+
// Then in data
|
527 |
+
}elseif(isset($this->storage['data'][$name])){
|
528 |
+
$this->$name = $this->storage['data'][$name];
|
529 |
+
return $this->storage['data'][$name];
|
530 |
+
|
531 |
+
// Otherwise try to get it from db settings table
|
532 |
+
// it will be arrayObject || scalar || null
|
533 |
+
}else{
|
534 |
+
$this->getOption($name);
|
535 |
+
return $this->storage[$name];
|
536 |
+
}
|
537 |
+
|
538 |
+
}
|
539 |
+
|
540 |
+
public function __isset($name)
|
541 |
+
{
|
542 |
+
return isset($this->storage[$name]);
|
543 |
+
}
|
544 |
+
|
545 |
+
public function __unset($name)
|
546 |
+
{
|
547 |
+
unset($this->storage[$name]);
|
548 |
+
}
|
549 |
+
|
550 |
+
public function server(){
|
551 |
+
return \Cleantalk\Common\Server::getInstance();
|
552 |
+
}
|
553 |
+
public function cookie(){
|
554 |
+
return \Cleantalk\Common\Cookie::getInstance();
|
555 |
+
}
|
556 |
+
public function request(){
|
557 |
+
return \Cleantalk\Common\Request::getInstance();
|
558 |
+
}
|
559 |
+
public function post(){
|
560 |
+
return \Cleantalk\Common\Post::getInstance();
|
561 |
+
}
|
562 |
+
public function get(){
|
563 |
+
return \Cleantalk\Common\Get::getInstance();
|
564 |
+
}
|
565 |
+
}
|
@@ -4,7 +4,7 @@ Tags: spam, antispam, woocommerce, comments, firewall
|
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 5.4
|
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.
|
@@ -574,6 +574,24 @@ If your website has forms that send data to external sources, you can enable opt
|
|
574 |
|
575 |
== Changelog ==
|
576 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
577 |
= 5.138.1 May 20 2020 =
|
578 |
* Fix: Ninja Forms. Spam submissions.
|
579 |
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 5.4
|
6 |
Requires PHP: 5.4
|
7 |
+
Stable tag: 5.139
|
8 |
License: GPLv2
|
9 |
|
10 |
Spam protection, anti-spam, firewall, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
|
574 |
|
575 |
== Changelog ==
|
576 |
|
577 |
+
= 5.139 Jun 02 2020 =
|
578 |
+
* Fix: Profile link fixed.
|
579 |
+
* Fix: WPMS plugin name fixed.
|
580 |
+
* Fix: WPMS plugin settings link fixed.
|
581 |
+
* Fix: Integration with Easy Forms for Mailchimp.
|
582 |
+
* Fix: JS check on the registration form.
|
583 |
+
* Fix: Double JS attaching on the login page.
|
584 |
+
* Fix: Clear SpamFireWall table. Throw error if failed.
|
585 |
+
* Upd: Cookies attr "samesite" added.
|
586 |
+
* New: Users checking result icons added.
|
587 |
+
* Upd: Whitelists support added for SFW.
|
588 |
+
* Fix: Clear users meta everywhere by complete deactivation.
|
589 |
+
* New: Comment notification updated - blacklist links added.
|
590 |
+
* Fix: PHP Warning in cleantalk-pluggable.php.
|
591 |
+
* Fix: White Label mode is not accessible if CLEANTALK_ACCESS_KEY is defined.
|
592 |
+
* Fix: Deprecated condition.
|
593 |
+
* Fix: Setting layout for the right to left direction languages.
|
594 |
+
|
595 |
= 5.138.1 May 20 2020 =
|
596 |
* Fix: Ninja Forms. Spam submissions.
|
597 |
|