Spam protection, AntiSpam, FireWall by CleanTalk - Version 5.151.1

Version Description

Dec 22 2020 = * Upd: Firewall now has it's own options, independent from the other. * Upd: New API server added. * Fix: Wrong count of blocked entries fixed * Fix: Skip logging for non-blocked requests. * Fix: SFW sending logs fixed. * Fix: SFW skip Customizer preview requests. * Fix: FW do logging an one passed request. * Fix: Logging exclusion moved to firewall class. * Fix: FW stats option fixed. * Upd: New API server added. * Fix: SFW logging logic fixed. * Fix: SFW sent logs structure fixed.

Download this release

Release Info

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

Code changes from version 5.151 to 5.151.1

cleantalk.php CHANGED
@@ -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.151
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: https://cleantalk.org
9
  Text Domain: cleantalk-spam-protect
@@ -67,7 +67,7 @@ if( !defined( 'CLEANTALK_PLUGIN_DIR' ) ){
67
 
68
  // Global ArrayObject with settings and other global varables
69
  global $apbct;
70
- $apbct = new \Cleantalk\ApbctWP\State('cleantalk', array('settings', 'data', 'debug', 'errors', 'remote_calls', 'stats'));
71
 
72
  $apbct->base_name = 'cleantalk-spam-protect/cleantalk.php';
73
 
@@ -90,7 +90,7 @@ if( !defined( 'CLEANTALK_PLUGIN_DIR' ) ){
90
  $apbct->data['user_counter']['since'] = isset($apbct->data['user_counter']['since']) ? $apbct->data['user_counter']['since'] : date('d M');
91
  $apbct->data['connection_reports']['since'] = isset($apbct->data['connection_reports']['since']) ? $apbct->data['user_counter']['since'] : date('d M');
92
 
93
- $apbct->firewall_updating = (bool) $apbct->data['firewall_updating_id'];
94
 
95
  $apbct->settings_link = is_network_admin() ? 'settings.php?page=cleantalk' : 'options-general.php?page=cleantalk';
96
 
@@ -241,7 +241,7 @@ if( !defined( 'CLEANTALK_PLUGIN_DIR' ) ){
241
  //add_action ('updated_option', 'apbct_after_options_updated', 10, 3);
242
 
243
  // Public actions
244
- if(!is_admin() && !apbct_is_ajax()){
245
 
246
  // Default search
247
  //add_filter( 'get_search_form', 'apbct_forms__search__addField' );
@@ -252,7 +252,6 @@ if( !defined( 'CLEANTALK_PLUGIN_DIR' ) ){
252
  if(isset($_GET['spbc_remote_call_token'], $_GET['spbc_remote_call_action'], $_GET['plugin_name']) && in_array($_GET['plugin_name'], array('antispam','anti-spam', 'apbct'))){
253
  apbct_remote_call__perform();
254
  }
255
-
256
  // SpamFireWall check
257
  if( $apbct->plugin_version == APBCT_VERSION && // Do not call with first start
258
  $apbct->settings['spam_firewall'] == 1 &&
@@ -1049,24 +1048,24 @@ function ct_sfw_update( $api_key = '', $immediate = false ){
1049
  // Prevent start another update at a time
1050
  if(
1051
  ! Get::get('firewall_updating_id') &&
1052
- $apbct->data['firewall_updating_id'] &&
1053
- time() - $apbct->data['firewall_updating_last_start'] < 60
1054
  ){
1055
  return true;
1056
  }
1057
 
1058
  // Check if the update performs right now. Blocks remote calls with different ID
1059
  if( Get::get('firewall_updating_id') &&
1060
- Get::get('firewall_updating_id') !== $apbct->data['firewall_updating_id']
1061
  ) {
1062
  return array( 'error' => 'FIREWALL_IS_UPDATING' );
1063
  }
1064
 
1065
  // Set new update ID
1066
- if( ! $apbct->data['firewall_updating_id'] || time() - $apbct->data['firewall_updating_last_start'] > 300 ){
1067
- $apbct->data['firewall_updating_id'] = md5( rand( 0, 100000 ) );
1068
- $apbct->data['firewall_updating_last_start'] = time();
1069
- $apbct->save( 'data' );
1070
  }
1071
 
1072
  $api_key = !empty($apbct->api_key) ? $apbct->api_key : $api_key;
@@ -1121,8 +1120,8 @@ function ct_sfw_update( $api_key = '', $immediate = false ){
1121
  //Increment sfw entries
1122
  $apbct->stats['sfw']['entries'] += $result;
1123
  $apbct->save('stats');
1124
- $apbct->data['firewall_update_percent'] = round( ( ( (int) $current_url + 1 ) / (int) $url_count ), 2) * 100;
1125
- $apbct->save('data');
1126
 
1127
  if ( $url_count > $current_url ) {
1128
  return Helper::http__request(
@@ -1135,7 +1134,7 @@ function ct_sfw_update( $api_key = '', $immediate = false ){
1135
  'url_count' => $url_count,
1136
  'current_url' => $current_url,
1137
  // Additional params
1138
- 'firewall_updating_id' => $apbct->data['firewall_updating_id'],
1139
  ),
1140
  array('get', 'async')
1141
  );
@@ -1148,9 +1147,10 @@ function ct_sfw_update( $api_key = '', $immediate = false ){
1148
 
1149
  //Files array is empty update sfw stats
1150
  $apbct->data['last_firewall_updated'] = current_time('timestamp');
1151
- $apbct->data['firewall_update_percent'] = 0;
1152
- $apbct->data['firewall_updating_id'] = null;
1153
  $apbct->save('data');
 
 
 
1154
 
1155
  //Files array is empty update sfw time
1156
  $apbct->stats['sfw']['last_update_time'] = time();
@@ -1176,7 +1176,7 @@ function ct_sfw_update( $api_key = '', $immediate = false ){
1176
  'spbc_remote_call_action' => 'sfw_update',
1177
  'plugin_name' => 'apbct',
1178
  // Additional params
1179
- 'firewall_updating_id' => $apbct->data['firewall_updating_id'],
1180
  ),
1181
  array( 'get','async' )
1182
  );
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.151.1
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: https://cleantalk.org
9
  Text Domain: cleantalk-spam-protect
67
 
68
  // Global ArrayObject with settings and other global varables
69
  global $apbct;
70
+ $apbct = new \Cleantalk\ApbctWP\State('cleantalk', array('settings', 'data', 'debug', 'errors', 'remote_calls', 'stats', 'fw_stats'));
71
 
72
  $apbct->base_name = 'cleantalk-spam-protect/cleantalk.php';
73
 
90
  $apbct->data['user_counter']['since'] = isset($apbct->data['user_counter']['since']) ? $apbct->data['user_counter']['since'] : date('d M');
91
  $apbct->data['connection_reports']['since'] = isset($apbct->data['connection_reports']['since']) ? $apbct->data['user_counter']['since'] : date('d M');
92
 
93
+ $apbct->firewall_updating = (bool) $apbct->fw_stats['firewall_updating_id'];
94
 
95
  $apbct->settings_link = is_network_admin() ? 'settings.php?page=cleantalk' : 'options-general.php?page=cleantalk';
96
 
241
  //add_action ('updated_option', 'apbct_after_options_updated', 10, 3);
242
 
243
  // Public actions
244
+ if( ! is_admin() && ! apbct_is_ajax() && ! apbct_is_customize_preview() ){
245
 
246
  // Default search
247
  //add_filter( 'get_search_form', 'apbct_forms__search__addField' );
252
  if(isset($_GET['spbc_remote_call_token'], $_GET['spbc_remote_call_action'], $_GET['plugin_name']) && in_array($_GET['plugin_name'], array('antispam','anti-spam', 'apbct'))){
253
  apbct_remote_call__perform();
254
  }
 
255
  // SpamFireWall check
256
  if( $apbct->plugin_version == APBCT_VERSION && // Do not call with first start
257
  $apbct->settings['spam_firewall'] == 1 &&
1048
  // Prevent start another update at a time
1049
  if(
1050
  ! Get::get('firewall_updating_id') &&
1051
+ $apbct->fw_stats['firewall_updating_id'] &&
1052
+ time() - $apbct->fw_stats['firewall_updating_last_start'] < 60
1053
  ){
1054
  return true;
1055
  }
1056
 
1057
  // Check if the update performs right now. Blocks remote calls with different ID
1058
  if( Get::get('firewall_updating_id') &&
1059
+ Get::get('firewall_updating_id') !== $apbct->fw_stats['firewall_updating_id']
1060
  ) {
1061
  return array( 'error' => 'FIREWALL_IS_UPDATING' );
1062
  }
1063
 
1064
  // Set new update ID
1065
+ if( ! $apbct->fw_stats['firewall_updating_id'] || time() - $apbct->fw_stats['firewall_updating_last_start'] > 300 ){
1066
+ $apbct->fw_stats['firewall_updating_id'] = md5( rand( 0, 100000 ) );
1067
+ $apbct->fw_stats['firewall_updating_last_start'] = time();
1068
+ $apbct->save( 'fw_stats' );
1069
  }
1070
 
1071
  $api_key = !empty($apbct->api_key) ? $apbct->api_key : $api_key;
1120
  //Increment sfw entries
1121
  $apbct->stats['sfw']['entries'] += $result;
1122
  $apbct->save('stats');
1123
+ $apbct->fw_stats['firewall_update_percent'] = round( ( ( (int) $current_url + 1 ) / (int) $url_count ), 2) * 100;
1124
+ $apbct->save('fw_stats');
1125
 
1126
  if ( $url_count > $current_url ) {
1127
  return Helper::http__request(
1134
  'url_count' => $url_count,
1135
  'current_url' => $current_url,
1136
  // Additional params
1137
+ 'firewall_updating_id' => $apbct->fw_stats['firewall_updating_id'],
1138
  ),
1139
  array('get', 'async')
1140
  );
1147
 
1148
  //Files array is empty update sfw stats
1149
  $apbct->data['last_firewall_updated'] = current_time('timestamp');
 
 
1150
  $apbct->save('data');
1151
+ $apbct->fw_stats['firewall_update_percent'] = 0;
1152
+ $apbct->fw_stats['firewall_updating_id'] = null;
1153
+ $apbct->save( 'fw_stats' );
1154
 
1155
  //Files array is empty update sfw time
1156
  $apbct->stats['sfw']['last_update_time'] = time();
1176
  'spbc_remote_call_action' => 'sfw_update',
1177
  'plugin_name' => 'apbct',
1178
  // Additional params
1179
+ 'firewall_updating_id' => $apbct->fw_stats['firewall_updating_id'],
1180
  ),
1181
  array( 'get','async' )
1182
  );
inc/cleantalk-pluggable.php CHANGED
@@ -1,311 +1,326 @@
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
- }
289
-
290
- /**
291
- * Checks if a comment contains disallowed characters or words.
292
- *
293
- * @param $author
294
- * @param $email
295
- * @param $url
296
- * @param $comment
297
- * @param $user_ip
298
- * @param $user_agent
299
- * @return bool
300
- */
301
- function apbct_wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent ) {
302
-
303
- global $wp_version;
304
-
305
- if( version_compare($wp_version, '5.5.0', '>=') ) {
306
- return wp_check_comment_disallowed_list( $author, $email, $url, $comment, $user_ip, $user_agent );
307
- } else {
308
- return wp_blacklist_check( $author, $email, $url, $comment, $user_ip, $user_agent );
309
- }
310
-
311
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ use Cleantalk\Variables\Server;
4
+
5
+ /**
6
+ * Getting current user by cookie
7
+ *
8
+ * @return WP_User|null
9
+ */
10
+ function apbct_wp_get_current_user(){
11
+
12
+ global $apbct, $current_user;
13
+
14
+ $user = null;
15
+
16
+ if(!(defined('XMLRPC_REQUEST') && XMLRPC_REQUEST)){
17
+
18
+ if(!empty($apbct->user)){
19
+ $user_id = is_object($current_user) && isset($current_user->ID) && !($current_user instanceof WP_User)
20
+ ? $current_user->ID
21
+ : null;
22
+ }else{
23
+ $user_id = empty($user_id) && defined('LOGGED_IN_COOKIE') && !empty($_COOKIE[LOGGED_IN_COOKIE])
24
+ ? apbct_wp_validate_auth_cookie($_COOKIE[LOGGED_IN_COOKIE], 'logged_in')
25
+ : null;
26
+ }
27
+
28
+ if($user_id){
29
+ $user = new WP_User($user_id);
30
+ }
31
+
32
+ }
33
+
34
+ return $user ? $user : $current_user;
35
+ }
36
+
37
+ function apbct_wp_set_current_user($user = null){
38
+
39
+ global $apbct;
40
+
41
+ if( $user instanceof WP_User ){
42
+ $apbct->user = $user;
43
+ return true;
44
+ }
45
+
46
+ return false;
47
+ }
48
+
49
+ /**
50
+ * Validates authentication cookie.
51
+ *
52
+ * The checks include making sure that the authentication cookie is set and
53
+ * pulling in the contents (if $cookie is not used).
54
+ *
55
+ * Makes sure the cookie is not expired. Verifies the hash in cookie is what is
56
+ * should be and compares the two.
57
+ *
58
+ * @param string $cookie Optional. If used, will validate contents instead of cookie's
59
+ * @param string $scheme Optional. The cookie scheme to use: auth, secure_auth, or logged_in
60
+ *
61
+ * @return false|int False if invalid cookie, User ID if valid.
62
+ * @global int $login_grace_period
63
+ *
64
+ */
65
+ function apbct_wp_validate_auth_cookie( $cookie = '', $scheme = '' ) {
66
+
67
+ $cookie_elements = apbct_wp_parse_auth_cookie($cookie, $scheme);
68
+
69
+ $scheme = $cookie_elements['scheme'];
70
+ $username = $cookie_elements['username'];
71
+ $hmac = $cookie_elements['hmac'];
72
+ $token = $cookie_elements['token'];
73
+ $expiration = $cookie_elements['expiration'];
74
+
75
+ // Allow a grace period for POST and Ajax requests
76
+ $expired = apbct_is_ajax() || apbct_is_post()
77
+ ? $expiration + HOUR_IN_SECONDS
78
+ : $cookie_elements['expiration'];
79
+
80
+ // Quick check to see if an honest cookie has expired
81
+ if($expired >= time()){
82
+ $user = apbct_wp_get_user_by('login', $username);
83
+ if($user){
84
+ $pass_frag = substr($user->user_pass, 8, 4);
85
+ $key = apbct_wp_hash($username . '|' . $pass_frag . '|' . $expiration . '|' . $token, $scheme);
86
+ // If ext/hash is not present, compat.php's hash_hmac() does not support sha256.
87
+ $algo = function_exists('hash') ? 'sha256' : 'sha1';
88
+ $hash = hash_hmac($algo, $username . '|' . $expiration . '|' . $token, $key);
89
+ if(hash_equals($hash, $hmac)){
90
+ $sessions = get_user_meta($user->ID, 'session_tokens', true);
91
+ $sessions = is_array($sessions) ? current($sessions) : $sessions;
92
+ if(is_array($sessions)){
93
+ if(is_int($sessions['expiration']) && $sessions['expiration'] > time()){
94
+ return $user->ID;
95
+ }else
96
+ return false;
97
+ }else
98
+ return false;
99
+ }else
100
+ return false;
101
+ }else
102
+ return false;
103
+ }else
104
+ return false;
105
+ }
106
+
107
+ /**
108
+ * Gets user by filed
109
+ *
110
+ * @param $field
111
+ * @param $value
112
+ *
113
+ * @return bool|WP_User
114
+ */
115
+ function apbct_wp_get_user_by($field, $value){
116
+
117
+ $userdata = WP_User::get_data_by($field, $value);
118
+
119
+ if(!$userdata)
120
+ return false;
121
+
122
+ $user = new WP_User;
123
+ $user->init($userdata);
124
+
125
+ return $user;
126
+ }
127
+
128
+ /**
129
+ * Get hash of given string.
130
+ *
131
+ * @param string $data Plain text to hash
132
+ * @param string $scheme Authentication scheme (auth, secure_auth, logged_in, nonce)
133
+ * @return string Hash of $data
134
+ */
135
+ function apbct_wp_hash( $data, $scheme = 'auth' ) {
136
+
137
+ $values = array(
138
+ 'key' => '',
139
+ 'salt' => '',
140
+ );
141
+
142
+ foreach(array('key', 'salt') as $type){
143
+ $const = strtoupper( "{$scheme}_{$type}");
144
+ if ( defined($const) && constant($const)){
145
+ $values[$type] = constant($const);
146
+ }elseif(!$values[$type]){
147
+ $values[$type] = get_site_option( "{$scheme}_{$type}");
148
+ if (!$values[$type]){
149
+ $values[$type] = '';
150
+ }
151
+ }
152
+ }
153
+
154
+ $salt = $values['key'] . $values['salt'];
155
+
156
+ return hash_hmac('md5', $data, $salt);
157
+ }
158
+
159
+ /**
160
+ * Parse a cookie into its components
161
+ *
162
+ * @param string $cookie
163
+ * @param string $scheme Optional. The cookie scheme to use: auth, secure_auth, or logged_in
164
+ *
165
+ * @return array|false Authentication cookie components
166
+ *
167
+ */
168
+ function apbct_wp_parse_auth_cookie($cookie = '', $scheme = '')
169
+ {
170
+ $cookie_elements = explode('|', $cookie);
171
+ if(count($cookie_elements) !== 4){
172
+ return false;
173
+ }
174
+
175
+ list($username, $expiration, $token, $hmac) = $cookie_elements;
176
+
177
+ return compact('username', 'expiration', 'token', 'hmac', 'scheme');
178
+ }
179
+
180
+ /**
181
+ * Checks if the plugin is active
182
+ *
183
+ * @param string $plugin relative path from plugin folder like cleantalk-spam-protect/cleantalk.php
184
+ *
185
+ * @return bool
186
+ */
187
+ function apbct_is_plugin_active( $plugin ) {
188
+ return in_array( $plugin, (array) get_option( 'active_plugins', array() ) ) || apbct_is_plugin_active_for_network( $plugin );
189
+ }
190
+
191
+ /**
192
+ * Checks if the plugin is active for network
193
+ *
194
+ * @param string $plugin relative path from plugin folder like cleantalk-spam-protect/cleantalk.php
195
+ *
196
+ * @return bool
197
+ */
198
+ function apbct_is_plugin_active_for_network( $plugin ){
199
+
200
+ if ( ! APBCT_WPMS )
201
+ return false;
202
+
203
+ $plugins = get_site_option( 'active_sitewide_plugins' );
204
+
205
+ return isset( $plugins[ $plugin ] )
206
+ ? true
207
+ : false;
208
+ }
209
+
210
+ /**
211
+ * Checks if the request is AJAX
212
+ *
213
+ * @return boolean
214
+ */
215
+ function apbct_is_ajax() {
216
+
217
+ return
218
+ (defined( 'DOING_AJAX' ) && DOING_AJAX) || // by standart WP functions
219
+ (apbct_get_server_variable( 'HTTP_X_REQUESTED_WITH' ) && strtolower(apbct_get_server_variable( 'HTTP_X_REQUESTED_WITH' )) == 'xmlhttprequest') || // by Request type
220
+ !empty($_POST['quform_ajax']) || // special. QForms
221
+ !empty($_POST['iphorm_ajax']); // special. IPHorm
222
+
223
+ }
224
+
225
+ /**
226
+ * Checks if the user is logged in
227
+ *
228
+ * @return bool
229
+ */
230
+ function apbct_is_user_logged_in(){
231
+ $siteurl = get_site_option( 'siteurl' );
232
+ $cookiehash = $siteurl ? md5( $siteurl ) : '';
233
+ return count($_COOKIE) && isset($_COOKIE['wordpress_logged_in_'.$cookiehash]);
234
+ }
235
+
236
+ /*
237
+ * GETTING SERVER VARIABLES BY VARIOUS WAYS
238
+ */
239
+ function apbct_get_server_variable( $server_variable_name ){
240
+
241
+ $var_name = strtoupper( $server_variable_name );
242
+
243
+ if( function_exists( 'filter_input' ) )
244
+ $value = filter_input( INPUT_SERVER, $var_name );
245
+
246
+ if( empty( $value ) )
247
+ $value = isset( $_SERVER[ $var_name ] ) ? $_SERVER[ $var_name ] : '';
248
+
249
+ // Convert to upper case for REQUEST_METHOD
250
+ if( in_array( $server_variable_name, array( 'REQUEST_METHOD' ) ) )
251
+ $value = strtoupper( $value );
252
+
253
+ // Convert HTML chars for HTTP_USER_AGENT, HTTP_USER_AGENT, SERVER_NAME
254
+ if( in_array( $server_variable_name, array( 'HTTP_USER_AGENT', 'HTTP_USER_AGENT', 'SERVER_NAME' ) ) )
255
+ $value = htmlspecialchars( $value );
256
+
257
+ return $value;
258
+ }
259
+
260
+ function apbct_is_post(){
261
+ return apbct_get_server_variable('REQUEST_METHOD') === 'POST';
262
+ }
263
+
264
+ function apbct_is_get(){
265
+ return apbct_get_server_variable('REQUEST_METHOD') === 'GET';
266
+ }
267
+
268
+ function apbct_is_in_referer( $str ){
269
+ return stripos( apbct_get_server_variable('HTTP_REFERER'), $str ) !== false;
270
+ }
271
+
272
+ function apbct_is_in_uri( $str ){
273
+ return stripos( apbct_get_server_variable('REQUEST_URI'), $str ) !== false;
274
+ }
275
+
276
+ /*
277
+ * Checking if current request is a cron job
278
+ * Support for wordpress < 4.8.0
279
+ *
280
+ * @return bool
281
+ */
282
+ function apbct_wp_doing_cron() {
283
+
284
+ if( function_exists( 'wp_doing_cron' ) ) {
285
+ return wp_doing_cron();
286
+ } else {
287
+ return ( defined( 'DOING_CRON' ) && DOING_CRON );
288
+ }
289
+
290
+ }
291
+
292
+ /**
293
+ * Checks if a comment contains disallowed characters or words.
294
+ *
295
+ * @param $author
296
+ * @param $email
297
+ * @param $url
298
+ * @param $comment
299
+ * @param $user_ip
300
+ * @param $user_agent
301
+ * @return bool
302
+ */
303
+ function apbct_wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent ) {
304
+
305
+ global $wp_version;
306
+
307
+ if( version_compare($wp_version, '5.5.0', '>=') ) {
308
+ return wp_check_comment_disallowed_list( $author, $email, $url, $comment, $user_ip, $user_agent );
309
+ } else {
310
+ return wp_blacklist_check( $author, $email, $url, $comment, $user_ip, $user_agent );
311
+ }
312
+
313
+ }
314
+
315
+ /**
316
+ * Check if the site is being previewed in the Customizer.
317
+ * We can not use is_customize_preview() - the function must be called from init hook.
318
+ *
319
+ * @return bool
320
+ */
321
+ function apbct_is_customize_preview() {
322
+
323
+ // Maybe not enough to check the Customizer preview
324
+ $uri = parse_url(Server::get('REQUEST_URI'));
325
+ return $uri && isset( $uri['query'] ) && strpos( $uri['query'], 'customize_changeset_uuid' ) !== false;
326
+ }
inc/cleantalk-public.php CHANGED
@@ -3499,7 +3499,7 @@ function ct_contact_form_validate() {
3499
  wp_die("<h1>".__('Spam protection by CleanTalk', 'cleantalk-spam-protect')."</h1><h2>".$ct_result->comment."</h2>", '', array('response' => 403, "back_link" => true, "text_direction" => 'ltr'));
3500
  // Caldera Contact Forms
3501
  }elseif(isset($_POST['action']) && $_POST['action'] == 'cf_process_ajax_submit'){
3502
- print json_encode("<h3 style='color: red;'><red>".$ct_result->comment);
3503
  die();
3504
  // Mailster
3505
  }elseif(isset($_POST['_referer'], $_POST['formid'], $_POST['email'])){
3499
  wp_die("<h1>".__('Spam protection by CleanTalk', 'cleantalk-spam-protect')."</h1><h2>".$ct_result->comment."</h2>", '', array('response' => 403, "back_link" => true, "text_direction" => 'ltr'));
3500
  // Caldera Contact Forms
3501
  }elseif(isset($_POST['action']) && $_POST['action'] == 'cf_process_ajax_submit'){
3502
+ print "<h3 style='color: red;'><red>".$ct_result->comment."</red></h3>";
3503
  die();
3504
  // Mailster
3505
  }elseif(isset($_POST['_referer'], $_POST['formid'], $_POST['email'])){
inc/cleantalk-settings.php CHANGED
@@ -1088,7 +1088,7 @@ function apbct_settings__field__statistics() {
1088
  $apbct->stats['sfw']['last_update_time'] ? date('M d Y H:i:s', $apbct->stats['sfw']['last_update_time']) : __('unknown', 'cleantalk-spam-protect'),
1089
  isset($sfw_netwoks_amount[0]['cnt']) ? $sfw_netwoks_amount[0]['cnt'] : __('unknown', 'cleantalk-spam-protect')
1090
  );
1091
- echo $apbct->data['firewall_updating_id'] ? ' ' . __('Under updating now:', 'cleantalk-spam-protect') . ' ' . $apbct->data['firewall_update_percent'] . '%' : '';
1092
  echo '<br>';
1093
 
1094
  // SFW last sent logs
1088
  $apbct->stats['sfw']['last_update_time'] ? date('M d Y H:i:s', $apbct->stats['sfw']['last_update_time']) : __('unknown', 'cleantalk-spam-protect'),
1089
  isset($sfw_netwoks_amount[0]['cnt']) ? $sfw_netwoks_amount[0]['cnt'] : __('unknown', 'cleantalk-spam-protect')
1090
  );
1091
+ echo $apbct->fw_stats['firewall_updating_id'] ? ' ' . __('Under updating now:', 'cleantalk-spam-protect') . ' ' . $apbct->fw_stats['firewall_update_percent'] . '%' : '';
1092
  echo '<br>';
1093
 
1094
  // SFW last sent logs
inc/cleantalk-updater.php CHANGED
@@ -706,3 +706,11 @@ function apbct_update_to_5_150_1() {
706
 
707
  apbct_activation__create_tables( $sqls, $apbct->db_prefix );
708
  }
 
 
 
 
 
 
 
 
706
 
707
  apbct_activation__create_tables( $sqls, $apbct->db_prefix );
708
  }
709
+
710
+ function apbct_update_to_5_151_1 () {
711
+ global $apbct;
712
+ $apbct->fw_stats['firewall_updating_id'] = $apbct->data['firewall_updating_id'];
713
+ $apbct->fw_stats['firewall_update_percent'] = $apbct->data['firewall_update_percent'];
714
+ $apbct->fw_stats['firewall_updating_last_start'] = $apbct->data['firewall_updating_last_start'];
715
+ $apbct->save('fw_stats');
716
+ }
js/cleantalk-comments-checkspam.min.js CHANGED
@@ -1,2 +1,2 @@
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)),a=e.substring(e.indexOf("%s",0)+2,e.length),e=c+arguments[t]+a;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_spam_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_trash_all(a){var e={action:"ajax_trash_all",security:ct_ajax_nonce};jQuery("."+a.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_trash_all(a)):(jQuery("."+a.target.id).removeClass("disabled"),jQuery(".spinner").css("visibility","hidden"),location.href="edit-comments.php?page=ct_check_spam")},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_trash_all(a),3e3)},timeout:25e3})}function ct_spam_all(a){var e={action:"ajax_spam_all",security:ct_ajax_nonce};jQuery("."+a.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_spam_all(a)):(jQuery("."+a.target.id).removeClass("disabled"),jQuery(".spinner").css("visibility","hidden"),location.href="edit-comments.php?page=ct_check_spam")},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_spam_all(a),3e3)},timeout:25e3})}jQuery(document).ready(function(){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").on("change",function(){document.cookie="ct_spam_dates_from="+jQuery("#ct_date_range_from").val()+"; path=/; samesite=lax",document.cookie="ct_spam_dates_till="+jQuery("#ct_date_range_till").val()+"; path=/; samesite=lax",this.checked?(document.cookie="ct_spam_dates_allowed=1; path=/; samesite=lax",jQuery(".ct_date").prop("checked",!0).removeProp("disabled")):(document.cookie="ct_spam_dates_allowed=0; path=/; samesite=lax",jQuery(".ct_date").prop("disabled",!0).removeProp("checked"))}),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),document.cookie="ct_spam_dates_from="+jQuery("#ct_date_range_from").val()+"; path=/; samesite=lax",document.cookie="ct_spam_dates_till="+jQuery("#ct_date_range_till").val()+"; path=/; samesite=lax"}});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_spam_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_spam_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_trash_all").click(function(e){return!!confirm(ctCommentsCheck.ct_confirm_trash_all)&&void ct_trash_all(e)}),jQuery(".ct_spam_all").click(function(e){return!!confirm(ctCommentsCheck.ct_confirm_spam_all)&&void ct_spam_all(e)})});
2
  //# sourceMappingURL=cleantalk-comments-checkspam.min.js.map
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)),a=e.substring(e.indexOf("%s",0)+2,e.length),e=c+arguments[t]+a;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_spam_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_trash_all(a){var e={action:"ajax_trash_all",security:ct_ajax_nonce};jQuery("."+a.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_trash_all(a)):(jQuery("."+a.target.id).removeClass("disabled"),jQuery(".spinner").css("visibility","hidden"),location.href="edit-comments.php?page=ct_check_spam")},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_trash_all(a),3e3)},timeout:25e3})}function ct_spam_all(a){var e={action:"ajax_spam_all",security:ct_ajax_nonce};jQuery("."+a.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_spam_all(a)):(jQuery("."+a.target.id).removeClass("disabled"),jQuery(".spinner").css("visibility","hidden"),location.href="edit-comments.php?page=ct_check_spam")},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_spam_all(a),3e3)},timeout:25e3})}jQuery(document).ready(function(){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").on("change",function(){document.cookie="ct_spam_dates_from="+jQuery("#ct_date_range_from").val()+"; path=/; samesite=lax",document.cookie="ct_spam_dates_till="+jQuery("#ct_date_range_till").val()+"; path=/; samesite=lax",this.checked?(document.cookie="ct_spam_dates_allowed=1; path=/; samesite=lax",jQuery(".ct_date").prop("checked",!0).attr("disabled",!1)):(document.cookie="ct_spam_dates_allowed=0; path=/; samesite=lax",jQuery(".ct_date").prop("disabled",!0).attr("disabled",!0))}),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),document.cookie="ct_spam_dates_from="+jQuery("#ct_date_range_from").val()+"; path=/; samesite=lax",document.cookie="ct_spam_dates_till="+jQuery("#ct_date_range_till").val()+"; path=/; samesite=lax"}});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_spam_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_spam_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_trash_all").click(function(e){return!!confirm(ctCommentsCheck.ct_confirm_trash_all)&&void ct_trash_all(e)}),jQuery(".ct_spam_all").click(function(e){return!!confirm(ctCommentsCheck.ct_confirm_spam_all)&&void ct_spam_all(e)})});
2
  //# sourceMappingURL=cleantalk-comments-checkspam.min.js.map
js/cleantalk-comments-checkspam.min.js.map CHANGED
@@ -1 +1 @@
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_spam_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_trash_all( e ) {\r\n\r\n\tvar data = {\r\n\t\t'action': 'ajax_trash_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_trash_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';\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_trash_all( e ), 3000);\r\n\t\t},\r\n\t\ttimeout: 25000\r\n\t});\r\n\r\n}\r\n\r\nfunction ct_spam_all( e ) {\r\n\r\n\tvar data = {\r\n\t\t'action': 'ajax_spam_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_spam_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';\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_spam_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\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\").on('change', function(){\r\n\t\tdocument.cookie = 'ct_spam_dates_from='+ jQuery('#ct_date_range_from').val() +'; path=/; samesite=lax';\r\n\t\tdocument.cookie = 'ct_spam_dates_till='+ jQuery('#ct_date_range_till').val() +'; path=/; samesite=lax';\r\n\t\tif( this.checked ) {\r\n\t\t\tdocument.cookie = 'ct_spam_dates_allowed=1; path=/; samesite=lax';\r\n\t\t\tjQuery('.ct_date').prop('checked', true).removeProp('disabled');\r\n\t\t} else {\r\n\t\t\tdocument.cookie = 'ct_spam_dates_allowed=0; path=/; samesite=lax';\r\n\t\t\tjQuery('.ct_date').prop('disabled', true).removeProp('checked');\r\n\t\t}\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\tdocument.cookie = 'ct_spam_dates_from='+ jQuery('#ct_date_range_from').val() +'; path=/; samesite=lax';\r\n\t\t\t\tdocument.cookie = 'ct_spam_dates_till='+ jQuery('#ct_date_range_till').val() +'; path=/; samesite=lax';\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_spam_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_spam_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_trash_all\").click(function( e ){\r\n\r\n\t\tif (!confirm(ctCommentsCheck.ct_confirm_trash_all))\r\n\t\t\treturn false;\r\n\r\n\t\tct_trash_all( e );\r\n\r\n\t});\r\n\r\n\t// Mark as spam all spam comments\r\n\tjQuery(\".ct_spam_all\").click(function( e ){\r\n\r\n\t\tif (!confirm(ctCommentsCheck.ct_confirm_spam_all))\r\n\t\t\treturn false;\r\n\r\n\t\tct_spam_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_trash_all","e","target","addClass","css","removeClass","ct_spam_all","ready","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_trash_all","ct_confirm_spam_all"],"mappings":"AAYA,IAAIA,aAXJC,OAAOC,UAAUC,OAAS,WACtB,IAAIC,EAAYC,KAChB,IAAK,IAAIC,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BAAyBoF,MAAM,WAErCH,IADAjD,SAASC,OAAS,mDAGnBjC,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,wBAA0BsD,KAAKC,UAAUH,GAAY,2BAI3C,MAA1BtG,gBAAgB0G,QAClBzD,SAASC,OAAS,sCAAwC,IAAIyD,KAAK,GAAGC,cAAgB,yBACtF3F,OAAO,yBAAyBoF,SAIjCpF,OAAO,iBAAiBoF,MAAM,SAAU7B,GAEvC,QAAK5B,QAAQ5C,gBAAgB6G,4BAG7BtC,aAAcC,KAKfvD,OAAO,gBAAgBoF,MAAM,SAAU7B,GAEtC,QAAK5B,QAAQ5C,gBAAgB8G,2BAG7BjC,YAAaL"}
1
+ {"version":3,"file":"cleantalk-comments-checkspam.min.js","sources":["cleantalk-comments-checkspam.js"],"sourcesContent":["// Printf for JS\nString.prototype.printf = function(){\n var formatted = this;\n for( var arg in arguments ) {\n\t\tvar before_formatted = formatted.substring(0, formatted.indexOf(\"%s\", 0));\n\t\tvar after_formatted = formatted.substring(formatted.indexOf(\"%s\", 0)+2, formatted.length);\n\t\tformatted = before_formatted + arguments[arg] + after_formatted;\n }\n return formatted;\n};\n\n// Flags\nvar ct_working = false,\n\tct_new_check = true,\n\tct_cooling_down_flag = false,\n\tct_close_animate = true,\n\tct_accurate_check = false,\n\tct_pause = false,\n\tct_prev_accurate = ctCommentsCheck.ct_prev_accurate,\n\tct_prev_from = ctCommentsCheck.ct_prev_from,\t\n\tct_prev_till = ctCommentsCheck.ct_prev_till;\n// Settings\nvar ct_cool_down_time = 90000,\n\tct_requests_counter = 0,\n\tct_max_requests = 60;\n// Variables\nvar ct_ajax_nonce = ctCommentsCheck.ct_ajax_nonce,\n\tct_comments_total = 0,\n\tct_comments_checked = 0,\n\tct_comments_spam = 0,\n\tct_comments_bad = 0,\n\tct_unchecked = 'unset',\n\tct_date_from = 0,\n\tct_date_till = 0;\n\nfunction animate_comment(to,id){\n\tif(ct_close_animate){\n\t\tif(to==0.3){\n\t\t\tjQuery('#comment-'+id).fadeTo(200,to,function(){\n\t\t\t\tanimate_comment(1,id)\n\t\t\t});\n\t\t}else{\n\t\t\tjQuery('#comment-'+id).fadeTo(200,to,function(){\n\t\t\t\tanimate_comment(0.3,id)\n\t\t\t});\n\t\t}\n\t}else{\n\t\tct_close_animate=true;\n\t}\n}\n\nfunction ct_clear_comments(){\n\n\tvar from = 0, till = 0;\n\tif(jQuery('#ct_allow_date_range').is(':checked')) {\n\t\tfrom = jQuery('#ct_date_range_from').val();\n\t\ttill = jQuery('#ct_date_range_till').val();\n\t}\n\tvar data = {\n\t\t'action' : 'ajax_clear_comments',\n\t\t'security' : ct_ajax_nonce,\n\t\t'from' : from,\n\t\t'till' : till\n\t};\n\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\turl: ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function(msg){\n\t\t\tct_show_info();\n\t\t\tct_send_comments();\n\t\t}\n\t});\n}\n\n//Continues the check after cooldown time\n//Called by ct_send_users();\nfunction ct_cooling_down_toggle(){\n\tct_cooling_down_flag = false;\n\tct_send_comments();\n\tct_show_info();\n}\n\nfunction ct_send_comments(){\n\t\n\tif(ct_cooling_down_flag === true)\n\t\treturn;\n\t\n\tif(ct_requests_counter >= ct_max_requests){\n\t\tsetTimeout(ct_cooling_down_toggle, ct_cool_down_time);\n\t\tct_requests_counter = 0;\n\t\tct_cooling_down_flag = true;\n\t\treturn;\n\t}else{\n\t\tct_requests_counter++;\n\t}\n\t\n\tvar data = {\n\t\t'action': 'ajax_check_comments',\n\t\t'security': ct_ajax_nonce,\n\t\t'new_check': ct_new_check,\n\t\t'unchecked': ct_unchecked\n\t};\n\t\n\tif(ct_accurate_check)\n\t\tdata['accurate_check'] = true;\n\t\n\tif(ct_date_from && ct_date_till){\n\t\tdata['from'] = ct_date_from;\n\t\tdata['till'] = ct_date_till;\n\t}\n\t\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\turl: ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function(msg){\n\t\t\t\n\t\t\tmsg = jQuery.parseJSON(msg);\n\t\t\t\n\t\t\tif(parseInt(msg.error)){\n\t\t\t\tct_working=false;\n\t\t\t\tif(!confirm(msg.error_message+\". Do you want to proceed?\")){\n\t\t\t\t\tvar new_href = 'edit-comments.php?page=ct_check_spam';\n\t\t\t\t\tif(ct_date_from != 0 && ct_date_till != 0)\n\t\t\t\t\t\tnew_href+='&from='+ct_date_from+'&till='+ct_date_till;\n\t\t\t\t\tlocation.href = new_href;\n\t\t\t\t}else\n\t\t\t\t\tct_send_comments();\n\t\t\t}else{\n\t\t\t\tct_new_check = false;\n\t\t\t\tif(parseInt(msg.end) == 1 || ct_pause === true){\n\t\t\t\t\tif(parseInt(msg.end) == 1)\n\t\t\t\t\t\tdocument.cookie = 'ct_paused_spam_check=0; path=/; samesite=lax';\n\t\t\t\t\tct_working=false;\n\t\t\t\t\tjQuery('#ct_working_message').hide();\n\t\t\t\t\tvar new_href = 'edit-comments.php?page=ct_check_spam';\n\t\t\t\t\tif(ct_date_from != 0 && ct_date_till != 0)\n\t\t\t\t\t\tnew_href+='&from='+ct_date_from+'&till='+ct_date_till;\n\t\t\t\t\tlocation.href = new_href;\n\t\t\t\t}else if(parseInt(msg.end) == 0){\n\t\t\t\t\tct_comments_checked += msg.checked;\n\t\t\t\t\tct_comments_spam += msg.spam;\n\t\t\t\t\tct_comments_bad += msg.bad;\n\t\t\t\t\tct_unchecked = ct_comments_total - ct_comments_checked - ct_comments_bad;\n\t\t\t\t\tvar status_string = String(ctCommentsCheck.ct_status_string);\n\t\t\t\t\tvar status_string = status_string.printf(ct_comments_checked, ct_comments_spam, ct_comments_bad);\n\t\t\t\t\tif(parseInt(ct_comments_spam) > 0)\n\t\t\t\t\t\tstatus_string += ctCommentsCheck.ct_status_string_warning;\n\t\t\t\t\tjQuery('#ct_checking_status').html(status_string);\n\t\t\t\t\tjQuery('#ct_error_message').hide();\n\t\t\t\t\t// If DB woks not properly\n\t\t\t\t\tif(+ct_comments_total < ct_comments_checked + ct_comments_bad){\n\t\t\t\t\t\tdocument.cookie = 'ct_comments_start_check=1; path=/; samesite=lax';\n\t\t\t\t\t\tdocument.cookie = 'ct_comments_safe_check=1; path=/; samesite=lax';\n\t\t\t\t\t\tlocation.href = 'edit-comments.php?page=ct_check_spam';\n\t\t\t\t\t}\n\t\t\t\t\tct_send_comments();\n\t\t\t\t}\n\t\t\t}\n\t\t},\n error: function(jqXHR, textStatus, errorThrown) {\n\t\t\tjQuery('#ct_error_message').show();\n\t\t\tjQuery('#cleantalk_ajax_error').html(textStatus);\n\t\t\tjQuery('#cleantalk_js_func').html('Check comments');\n\t\t\tsetTimeout(ct_send_comments(), 3000); \n },\n timeout: 25000\n\t});\n}\nfunction ct_show_info(){\n\t\n\tif(ct_working){\n\t\t\n\t\tif(ct_cooling_down_flag == true){\n\t\t\tjQuery('#ct_cooling_notice').html('Waiting for API to cool down. (About a minute)');\n\t\t\tjQuery('#ct_cooling_notice').show();\n\t\t\treturn;\t\t\t\n\t\t}else{\n\t\t\tjQuery('#ct_cooling_notice').hide();\n\t\t}\n\t\t\n\t\tif(!ct_comments_total){\n\t\t\t\n\t\t\tvar data = {\n\t\t\t\t'action': 'ajax_info_comments',\n\t\t\t\t'security': ct_ajax_nonce\n\t\t\t};\n\t\t\t\n\t\t\tif(ct_date_from && ct_date_till){\n\t\t\t\tdata['from'] = ct_date_from;\n\t\t\t\tdata['till'] = ct_date_till;\n\t\t\t}\n\t\t\t\n\t\t\tjQuery.ajax({\n\t\t\t\ttype: \"POST\",\n\t\t\t\turl: ajaxurl,\n\t\t\t\tdata: data,\n\t\t\t\tsuccess: function(msg){\n\t\t\t\t\tmsg = jQuery.parseJSON(msg);\n\t\t\t\t\tjQuery('#ct_checking_status').html(msg.message);\n\t\t\t\t\tct_comments_total = msg.total;\n\t\t\t\t\tct_comments_spam = msg.spam;\n\t\t\t\t\tct_comments_checked = msg.checked;\n\t\t\t\t\tct_comments_bad = msg.bad;\n\t\t\t\t},\n\t\t\t\terror: function(jqXHR, textStatus, errorThrown) {\n\t\t\t\t\tjQuery('#ct_error_message').show();\n\t\t\t\t\tjQuery('#cleantalk_ajax_error').html(textStatus);\n\t\t\t\t\tjQuery('#cleantalk_js_func').html('Check comments');\n\t\t\t\t\tsetTimeout(ct_show_info(), 3000); \n\t\t\t\t},\n\t\t\t\ttimeout: 15000\n\t\t\t});\n\t\t}\n\t}\n}\n\n// Function to toggle dependences\nfunction ct_toggle_depended(obj, secondary){\n\n secondary = secondary || null;\n\n\tvar depended = jQuery(obj.data('depended')),\n\t\tstate = obj.data('state');\n\t\t\n\tif(!state && !secondary){\n\t\tobj.data('state', true);\n\t\tdepended.removeProp('disabled');\n\t}else{\n\t\tobj.data('state', false);\n\t\tdepended.prop('disabled', true);\n\t\tdepended.removeProp('checked');\n\t\tif(depended.data('depended'))\n\t\t\tct_toggle_depended(depended, true);\n\t}\n}\n\nfunction ct_trash_all( e ) {\n\n\tvar data = {\n\t\t'action': 'ajax_trash_all',\n\t\t'security': ct_ajax_nonce\n\t};\n\n\tjQuery('.' + e.target.id).addClass('disabled');\n\tjQuery('.spinner').css('visibility', 'visible');\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\turl: ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function( msg ){\n\t\t\tif( msg > 0 ){\n\t\t\t\tjQuery('#cleantalk_comments_left').html(msg);\n\t\t\t\tct_trash_all( e );\n\t\t\t}else{\n\t\t\t\tjQuery('.' + e.target.id).removeClass('disabled');\n\t\t\t\tjQuery('.spinner').css('visibility', 'hidden');\n\t\t\t\tlocation.href='edit-comments.php?page=ct_check_spam';\n\t\t\t}\n\t\t},\n\t\terror: function(jqXHR, textStatus, errorThrown) {\n\t\t\tjQuery('#ct_error_message').show();\n\t\t\tjQuery('#cleantalk_ajax_error').html(textStatus);\n\t\t\tjQuery('#cleantalk_js_func').html('Check comments');\n\t\t\tsetTimeout(ct_trash_all( e ), 3000);\n\t\t},\n\t\ttimeout: 25000\n\t});\n\n}\n\nfunction ct_spam_all( e ) {\n\n\tvar data = {\n\t\t'action': 'ajax_spam_all',\n\t\t'security': ct_ajax_nonce\n\t};\n\n\tjQuery('.' + e.target.id).addClass('disabled');\n\tjQuery('.spinner').css('visibility', 'visible');\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\turl: ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function( msg ){\n\t\t\tif( msg > 0 ){\n\t\t\t\tjQuery('#cleantalk_comments_left').html(msg);\n\t\t\t\tct_spam_all( e );\n\t\t\t}else{\n\t\t\t\tjQuery('.' + e.target.id).removeClass('disabled');\n\t\t\t\tjQuery('.spinner').css('visibility', 'hidden');\n\t\t\t\tlocation.href='edit-comments.php?page=ct_check_spam';\n\t\t\t}\n\t\t},\n\t\terror: function(jqXHR, textStatus, errorThrown) {\n\t\t\tjQuery('#ct_error_message').show();\n\t\t\tjQuery('#cleantalk_ajax_error').html(textStatus);\n\t\t\tjQuery('#cleantalk_js_func').html('Check comments');\n\t\t\tsetTimeout(ct_spam_all( e ), 3000);\n\t\t},\n\t\ttimeout: 25000\n\t});\n\n}\n\njQuery(document).ready(function(){\n\t\n\t// Prev check parameters\n\tif(ct_prev_accurate){\n\t\tjQuery(\"#ct_accurate_check\").prop('checked', true);\n\t}\n\tif(ct_prev_from){\n\t\tjQuery(\"#ct_allow_date_range\").prop('checked', true).data('state', true);\n\t\tjQuery(\"#ct_date_range_from\").removeProp('disabled').val(ct_prev_from);\n\t\tjQuery(\"#ct_date_range_till\").removeProp('disabled').val(ct_prev_till);\n\t}\n\t\n\t// Toggle dependences\n\tjQuery(\"#ct_allow_date_range\").on('change', function(){\n\t\tdocument.cookie = 'ct_spam_dates_from='+ jQuery('#ct_date_range_from').val() +'; path=/; samesite=lax';\n\t\tdocument.cookie = 'ct_spam_dates_till='+ jQuery('#ct_date_range_till').val() +'; path=/; samesite=lax';\n\t\tif( this.checked ) {\n\t\t\tdocument.cookie = 'ct_spam_dates_allowed=1; path=/; samesite=lax';\n\t\t\tjQuery('.ct_date').prop('checked', true).attr('disabled',false);\n\t\t} else {\n\t\t\tdocument.cookie = 'ct_spam_dates_allowed=0; path=/; samesite=lax';\n\t\t\tjQuery('.ct_date').prop('disabled', true).attr('disabled',true);\n\t\t}\n\t});\n\n jQuery.datepicker.setDefaults(jQuery.datepicker.regional['en']);\n\tvar dates = jQuery('#ct_date_range_from, #ct_date_range_till').datepicker(\n\t\t{\n\t\t\tdateFormat: 'M d yy',\n\t\t\tmaxDate:\"+0D\",\n\t\t\tchangeMonth:true,\n\t\t\tchangeYear:true,\n\t\t\tshowAnim: 'slideDown',\n\t\t\tonSelect: function(selectedDate){\n\t\t\tvar option = this.id == \"ct_date_range_from\" ? \"minDate\" : \"maxDate\",\n\t\t\t\tinstance = jQuery( this ).data( \"datepicker\" ),\n\t\t\t\tdate = jQuery.datepicker.parseDate(\n\t\t\t\t\tinstance.settings.dateFormat || jQuery.datepicker._defaults.dateFormat,\n\t\t\t\t\tselectedDate, instance.settings);\n\t\t\t\tdates.not(this).datepicker(\"option\", option, date);\n\t\t\t\tdocument.cookie = 'ct_spam_dates_from='+ jQuery('#ct_date_range_from').val() +'; path=/; samesite=lax';\n\t\t\t\tdocument.cookie = 'ct_spam_dates_till='+ jQuery('#ct_date_range_till').val() +'; path=/; samesite=lax';\n\t\t\t}\n\t\t}\n\t);\n\t\n\tfunction ct_start_check(continue_check){\n\n continue_check = continue_check || null;\n\n\t\tif(jQuery('#ct_allow_date_range').is(':checked')){\n\t\t\t\n\t\t\tct_date_from = jQuery('#ct_date_range_from').val();\n\t\t\tct_date_till = jQuery('#ct_date_range_till').val();\n\t\t\t\t\t\t\n\t\t\tif(!(ct_date_from != '' && ct_date_till != '')){\n\t\t\t\talert('Please, specify a date range.');\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t\n\t\tif(jQuery('#ct_accurate_check').is(':checked')){\n\t\t\tct_accurate_check = true;\n\t\t}\n\t\t\n\t\tjQuery('.ct_to_hide').hide();\n\t\tjQuery('#ct_working_message').show();\n\t\tjQuery('#ct_preloader').show();\n\t\tjQuery('#ct_pause').show();\n\n\t\tct_working=true;\n\t\t\n\t\tif(continue_check){\n\t\t\tct_show_info();\n\t\t\tct_send_comments();\n\t\t}else\n\t\t\tct_clear_comments();\n\t\t\n\t}\n\t\n\t// Check comments\n\tjQuery(\"#ct_check_spam_button\").click(function(){\n\t\tdocument.cookie = 'ct_paused_spam_check=0; path=/; samesite=lax';\n\t\tct_start_check(false);\n\t});\n\tjQuery(\"#ct_proceed_check_button\").click(function(){\n\t\tct_start_check(true);\n\t});\n\n\t// Pause the check\n\tjQuery('#ct_pause').on('click', function(){\n\t\tct_pause = true;\n\t\tvar ct_check = {\n\t\t\t'accurate': ct_accurate_check,\n\t\t\t'from' : ct_date_from,\n\t\t\t'till' : ct_date_till\n\t\t};\n\t\tdocument.cookie = 'ct_paused_spam_check=' + JSON.stringify(ct_check) + '; path=/; samesite=lax';\n\t});\n\n\n\tif(ctCommentsCheck.start === '1'){\n\t\tdocument.cookie = 'ct_comments_start_check=0; expires=' + new Date(0).toUTCString() + '; path=/; samesite=lax';\n\t\tjQuery('#ct_check_spam_button').click();\t\n\t}\n\n\t// Delete all spam comments\n\tjQuery(\".ct_trash_all\").click(function( e ){\n\n\t\tif (!confirm(ctCommentsCheck.ct_confirm_trash_all))\n\t\t\treturn false;\n\n\t\tct_trash_all( e );\n\n\t});\n\n\t// Mark as spam all spam comments\n\tjQuery(\".ct_spam_all\").click(function( e ){\n\n\t\tif (!confirm(ctCommentsCheck.ct_confirm_spam_all))\n\t\t\treturn false;\n\n\t\tct_spam_all( e );\n\n\t});\n\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_trash_all","e","target","addClass","css","removeClass","ct_spam_all","ready","on","attr","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_trash_all","ct_confirm_spam_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,IACvBC,oBAAsB,EACtBC,gBAAkB,GAEfC,cAAgBN,gBAAgBM,cACnCC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AEvC,QAAK5B,QAAQ5C,gBAAgB8G,4BAG7BvC,aAAcC,KAKfvD,OAAO,gBAAgBqF,MAAM,SAAU9B,GAEtC,QAAK5B,QAAQ5C,gBAAgB+G,2BAG7BlC,YAAaL"}
js/cleantalk-users-checkspam.min.js CHANGED
@@ -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)),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")},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(){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").on("change",function(){document.cookie="ct_users_dates_from="+jQuery("#ct_date_range_from").val()+"; path=/; samesite=lax",document.cookie="ct_users_dates_till="+jQuery("#ct_date_range_till").val()+"; path=/; samesite=lax",this.checked?(document.cookie="ct_users_dates_allowed=1; path=/; samesite=lax",jQuery(".ct_date").prop("checked",!0).removeProp("disabled")):(document.cookie="ct_users_dates_allowed=0; path=/; samesite=lax",jQuery(".ct_date").prop("disabled",!0).removeProp("checked"))}),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),document.cookie="ct_users_dates_from="+jQuery("#ct_date_range_from").val()+"; path=/; samesite=lax",document.cookie="ct_users_dates_till="+jQuery("#ct_date_range_till").val()+"; path=/; samesite=lax"}});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
+ 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")},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(){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").on("change",function(){document.cookie="ct_users_dates_from="+jQuery("#ct_date_range_from").val()+"; path=/; samesite=lax",document.cookie="ct_users_dates_till="+jQuery("#ct_date_range_till").val()+"; path=/; samesite=lax",this.checked?(document.cookie="ct_users_dates_allowed=1; path=/; samesite=lax",jQuery(".ct_date").prop("checked",!0).attr("disabled",!1)):(document.cookie="ct_users_dates_allowed=0; path=/; samesite=lax",jQuery(".ct_date").prop("disabled",!0).attr("disabled",!0))}),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),document.cookie="ct_users_dates_from="+jQuery("#ct_date_range_from").val()+"; path=/; samesite=lax",document.cookie="ct_users_dates_till="+jQuery("#ct_date_range_till").val()+"; path=/; samesite=lax"}});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
js/cleantalk-users-checkspam.min.js.map CHANGED
@@ -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=/; 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';\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\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\").on('change', function(){\r\n\t\tdocument.cookie = 'ct_users_dates_from='+ jQuery('#ct_date_range_from').val() +'; path=/; samesite=lax';\r\n\t\tdocument.cookie = 'ct_users_dates_till='+ jQuery('#ct_date_range_till').val() +'; path=/; samesite=lax';\r\n\t\tif( this.checked ) {\r\n\t\t\tdocument.cookie = 'ct_users_dates_allowed=1; path=/; samesite=lax';\r\n\t\t\tjQuery('.ct_date').prop('checked', true).removeProp('disabled');\r\n\t\t} else {\r\n\t\t\tdocument.cookie = 'ct_users_dates_allowed=0; path=/; samesite=lax';\r\n\t\t\tjQuery('.ct_date').prop('disabled', true).removeProp('checked');\r\n\t\t}\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\tdocument.cookie = 'ct_users_dates_from='+ jQuery('#ct_date_range_from').val() +'; path=/; samesite=lax';\r\n\t\t\t\tdocument.cookie = 'ct_users_dates_till='+ jQuery('#ct_date_range_till').val() +'; path=/; samesite=lax';\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","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","createOb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AQ,WACzC9F,OAAO,YAAY4F,OAAOG,cAMzBxF,EAAO,CACVC,OAAU,mBACVC,SAAYlC,cACZyH,QAAWJ,MACXK,OAAU,UACVvF,SAAYC,KAAKC,UAElBZ,OAAOa,KAAK,CACXC,KAAM,OACNC,IAAKC,QACLT,KAAMA,EACNU,QAAS,SAASC,KAWlBa,MAAO,SAASa,EAAOC,EAAYC,KAGnCE,QAAS,QAMXhD,OAAO,oBAAoBuF,MAAM,SAAU3B,GAC1C,IAAIrD,EAAO,CACVC,OAAU,uBACVC,SAAYlC,cACZ2H,SAAYjI,aAAakI,gBACzBzF,SAAYC,KAAKC,UAElBZ,OAAO,IAAM4D,EAAEC,OAAO9D,IAAI+D,SAAS,YACnC9D,OAAO,YAAY+D,IAAI,aAAc,WACrC/D,OAAOa,KAAK,CACXC,KAAM,OACNC,IAAKC,QACLT,KAAMA,EACNU,QAAS,SAASC,GACjB,IAGKH,EAEAqF,EALiB,IAAlBtE,SAASZ,GACZwC,MAAMzF,aAAaoI,aAEftF,EAAMuF,IAAIC,gBAAgB,IAAIC,KAAK,CAACtF,MAEpCkF,EAAQ3I,SAASgJ,cAAc,MAC7BtE,KAAOpB,EACbqF,EAAMM,SAAWzI,aAAakI,gBAAkB,OAEhD1I,SAASkJ,KAAKC,YAAYR,GAC1BA,EAAMb,SAEPvF,OAAO,IAAM4D,EAAEC,OAAO9D,IAAIiE,YAAY,YACtChE,OAAO,YAAY+D,IAAI,aAAc,eAMxC/D,OAAO,oBAAoBuF,MAAM,SAAU3B,GAC1CyB,MAIDrF,OAAO,4BAA4BuF,MAAM,SAAU3B,GAClDyB,GAAiB,KAIlBrF,OAAO,wBAAwBuF,MAAM,SAAU3B,GAE9C,QAAO5B,QAAS/D,aAAa4I,+BAG7BlD,oBAAqBC"}
1
+ {"version":3,"file":"cleantalk-users-checkspam.min.js","sources":["cleantalk-users-checkspam.js"],"sourcesContent":["// Printf for JS\nString.prototype.printf = function(){\n var formatted = this;\n for( var arg in arguments ) {\n\t\tvar before_formatted = formatted.substring(0, formatted.indexOf(\"%s\", 0));\n\t\tvar after_formatted = formatted.substring(formatted.indexOf(\"%s\", 0)+2, formatted.length);\n\t\tformatted = before_formatted + arguments[arg] + after_formatted;\n }\n return formatted;\n};\n\n// Set deafult amount to check by request.\ndocument.cookie = \"ct_check_users__amount=\" + 100 + \"; path=/; samesite=lax\";\n\n// Flags\nvar ct_working = false,\n\tct_new_check = true,\n\tct_cooling_down_flag = false,\n\tct_close_animate = true,\n\tct_accurate_check = false,\n\tct_pause = false,\n\tct_prev_accurate = ctUsersCheck.ct_prev_accurate,\n\tct_prev_from = ctUsersCheck.ct_prev_from,\t\n\tct_prev_till = ctUsersCheck.ct_prev_till;\n// Settings\nvar ct_cool_down_time = 90000,\n\tct_requests_counter = 0,\n\tct_max_requests = 60;\n// Variables\nvar ct_ajax_nonce = ctUsersCheck.ct_ajax_nonce,\n\tct_users_total = 0,\n\tct_users_checked = 0,\n\tct_users_spam = 0,\n\tct_users_bad = 0,\n\tct_unchecked = 'unset',\n\tct_date_from = 0,\n\tct_date_till = 0;\n\n/* Function: Reuturns cookie with prefix */\nfunction apbct_cookie__get(names, prefixes){\n\tvar cookie = {};\n\tnames = names || null;\n\tif(typeof names == 'string') names = names.split();\n\tprefixes = prefixes || ['apbct_', 'ct_'];\n\tif(prefixes === 'none') prefixes = null;\n\tif(typeof prefixes == 'string') prefixes = prefixes.split();\n\tdocument.cookie.split(';').forEach(function(item, i, arr){\n\t\tvar curr = item.trim().split('=');\n\t\t// Detect by full cookie name\n\t\tif(names){\n\t\t\tnames.forEach(function(name, i, all){\n\t\t\t\tif(curr[0] === name)\n\t\t\t\t\tcookie[curr[0]] = (curr[1]);\n\t\t\t});\n\t\t}\n\t\t// Detect by name prefix\n\t\tif(prefixes){\n\t\t\tprefixes.forEach(function(prefix, i, all){\n\t\t\t\tif(curr[0].indexOf(prefix) === 0)\n\t\t\t\t\tcookie[curr[0]] = (curr[1]);\n\t\t\t});\n\t\t}\n\t});\n\treturn cookie;\n}\n\nfunction apbct_get_cookie( name ){\n\tvar cookie = apbct_cookie__get( name, name );\n\tif(typeof cookie === 'object' && typeof cookie[name] != 'undefined'){\n\t\treturn cookie[name];\n\t}else\n\t\treturn null;\n}\n\nfunction animate_comment(to,id){\n\tif(ct_close_animate){\n\t\tif(to === 0.3){\n\t\t\tjQuery('#comment-'+id).fadeTo(200,to,function(){\n\t\t\t\tanimate_comment(1,id)\n\t\t\t});\n\t\t}else{\n\t\t\tjQuery('#comment-'+id).fadeTo(200,to,function(){\n\t\t\t\tanimate_comment(0.3,id)\n\t\t\t});\n\t\t}\n\t}else{\n\t\tct_close_animate=true;\n\t}\n}\n\nfunction ct_clear_users(){\n\n\tvar from = 0, till = 0;\n\tif(jQuery('#ct_allow_date_range').is(':checked')) {\n\t\tfrom = jQuery('#ct_date_range_from').val();\n\t\ttill = jQuery('#ct_date_range_till').val();\n\t}\n\tvar data = {\n\t\t'action' : 'ajax_clear_users',\n\t\t'security' : ct_ajax_nonce,\n\t\t'from' : from,\n\t\t'till' : till,\n\t\t'no_cache': Math.random()\n\t};\n\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\turl: ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function(msg){\n\t\t\tct_show_users_info();\n\t\t\tct_send_users();\n\t\t}\n\t});\n\n}\n\n//Continues the check after cooldown time\n//Called by ct_send_users();\nfunction ct_cooling_down_toggle(){\n\tct_cooling_down_flag = false;\n\tct_send_users();\n\tct_show_users_info();\n}\n\nfunction ct_send_users(){\n\t\n\tif(ct_cooling_down_flag === true)\n\t\treturn;\n\t\n\tif(ct_requests_counter >= ct_max_requests){\n\t\tsetTimeout(ct_cooling_down_toggle, ct_cool_down_time);\n\t\tct_requests_counter = 0;\n\t\tct_cooling_down_flag = true;\n\t\treturn;\n\t}else{\n\t\tct_requests_counter++;\n\t}\n\n\tvar check_amount = apbct_get_cookie('ct_check_users__amount');\n\n\tvar data = {\n\t\taction: 'ajax_check_users',\n\t\tsecurity: ct_ajax_nonce,\n\t\tnew_check: ct_new_check,\n\t\tunchecked: ct_unchecked,\n\t\tamount: check_amount,\n\t\t'no_cache': Math.random()\n\t};\n\t\n\tif(ct_accurate_check)\n\t\tdata['accurate_check'] = true;\n\t\n\tif(ct_date_from && ct_date_till){\n\t\tdata['from'] = ct_date_from;\n\t\tdata['till'] = ct_date_till;\n\t}\n\t\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\turl: ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function(msg){\n\t\t\t\n\t\t\tmsg = jQuery.parseJSON(msg);\n\t\t\t\n\t\t\tif(parseInt(msg.error)){\n\t\t\t\tct_working=false;\n\t\t\t\tif(!confirm(msg.error_message+\". Do you want to proceed?\")){\n\t\t\t\t\tvar new_href = 'users.php?page=ct_check_users';\n\t\t\t\t\tif(ct_date_from != 0 && ct_date_till != 0)\n\t\t\t\t\t\tnew_href+='&from='+ct_date_from+'&till='+ct_date_till;\n\t\t\t\t\tlocation.href = new_href;\n\t\t\t\t}else\n\t\t\t\t\tct_send_users();\n\t\t\t}else{\n\t\t\t\tct_new_check = false;\n\t\t\t\tif(parseInt(msg.end) == 1 || ct_pause == true){\n\t\t\t\t\tif(parseInt(msg.end) == 1)\n\t\t\t\t\t\tdocument.cookie = 'ct_paused_users_check=0; path=/; samesite=lax';\n\t\t\t\t\tct_working=false;\n\t\t\t\t\tjQuery('#ct_working_message').hide();\n\t\t\t\t\tvar new_href = 'users.php?page=ct_check_users&ct_worked=1';\n\t\t\t\t\tif(ct_date_from != 0 && ct_date_till != 0)\n\t\t\t\t\t\tnew_href+='&from='+ct_date_from+'&till='+ct_date_till;\n\t\t\t\t\tlocation.href = new_href;\n\t\t\t\t}else if(parseInt(msg.end) == 0){\n\t\t\t\t\tct_users_checked = parseInt( ct_users_checked ) + parseInt( msg.checked );\n\t\t\t\t\tct_users_spam = parseInt( ct_users_spam ) + parseInt (msg.spam );\n\t\t\t\t\tct_users_bad = parseInt( ct_users_bad ) + parseInt( msg.bad );\n\t\t\t\t\tct_unchecked = ct_users_total - ct_users_checked - ct_users_bad;\n\t\t\t\t\tvar status_string = String(ctUsersCheck.ct_status_string);\n\t\t\t\t\tvar status_string = status_string.printf(ct_users_checked, ct_users_spam, ct_users_bad);\n\t\t\t\t\tif(parseInt(ct_users_spam) > 0)\n\t\t\t\t\t\tstatus_string += ctUsersCheck.ct_status_string_warning;\n\t\t\t\t\tjQuery('#ct_checking_status').html(status_string);\n\t\t\t\t\tjQuery('#ct_error_message').hide();\n\t\t\t\t\tct_send_users();\n\t\t\t\t}\n\t\t\t}\n\t\t},\n error: function(jqXHR, textStatus, errorThrown) {\n\t\t\tif(check_amount > 20){\n\t\t\t\tcheck_amount -= 20;\n\t\t\t\tdocument.cookie = \"ct_check_users__amount=\" + check_amount + \"; path=/; samesite=lax\";\n\t\t\t}\n\t\t\tjQuery('#ct_error_message').show();\n\t\t\tjQuery('#cleantalk_ajax_error').html(textStatus);\n\t\t\tjQuery('#cleantalk_js_func').html('Check users');\n\t\t\tsetTimeout(ct_send_users(), 3000);\n },\n timeout: 25000\n\t});\n}\nfunction ct_show_users_info(){\n\t\n\tif( ct_working ){\n\t\t\n\t\tif(ct_cooling_down_flag === true){\n\t\t\tjQuery('#ct_cooling_notice').html('Waiting for API to cool down. (About a minute)').show();\n\t\t\treturn;\t\t\t\n\t\t}else{\n\t\t\tjQuery('#ct_cooling_notice').hide();\n\t\t}\n\t\t\n\t\tif( ! ct_users_total ){\n\t\t\t\n\t\t\tvar data = {\n\t\t\t\t'action': 'ajax_info_users',\n\t\t\t\t'security': ct_ajax_nonce,\n\t\t\t\t'no_cache': Math.random()\n\t\t\t};\n\t\t\t\n\t\t\tif( ct_date_from && ct_date_till ){\n\t\t\t\tdata['from'] = ct_date_from;\n\t\t\t\tdata['till'] = ct_date_till;\n\t\t\t}\n\t\t\t\n\t\t\tjQuery.ajax({\n\t\t\t\ttype: \"POST\",\n\t\t\t\turl: ajaxurl,\n\t\t\t\tdata: data,\n\t\t\t\tsuccess: function(msg){\n\t\t\t\t\tmsg = jQuery.parseJSON(msg);\n\t\t\t\t\tjQuery('#ct_checking_status').html(msg.message);\n\t\t\t\t\tct_users_spam = msg.spam;\n\t\t\t\t\tct_users_checked = msg.checked;\n\t\t\t\t\tct_users_bad = msg.bad;\n\t\t\t\t},\n\t\t\t\terror: function (jqXHR, textStatus, errorThrown){\n\t\t\t\t\tjQuery('#ct_error_message').show();\n\t\t\t\t\tjQuery('#cleantalk_ajax_error').html(textStatus);\n\t\t\t\t\tjQuery('#cleantalk_js_func').html('Show users');\n\t\t\t\t\tsetTimeout(ct_show_users_info(), 3000);\n\t\t\t\t},\n\t\t\t\ttimeout: 15000\n\t\t\t});\n\t\t}\n\t}\n}\n// Function to toggle dependences\nfunction ct_toggle_depended(obj, secondary){\n\n secondary = secondary || null;\n\n\tvar depended = jQuery(obj.data('depended')),\n\t\tstate = obj.data('state');\n\t\t\n\tif(!state && !secondary){\n\t\tobj.data('state', true);\n\t\tdepended.removeProp('disabled');\n\t}else{\n\t\tobj.data('state', false);\n\t\tdepended.prop('disabled', true);\n\t\tdepended.removeProp('checked');\n\t\tif(depended.data('depended'))\n\t\t\tct_toggle_depended(depended, true);\n\t}\n}\n\n// Main function of checking\nfunction ct_start_check( continue_check ){\n\n\tcontinue_check = continue_check || null;\n\n\tif(jQuery('#ct_allow_date_range').is(':checked')){\n\n\t\tct_date_from = jQuery('#ct_date_range_from').val();\n\t\tct_date_till = jQuery('#ct_date_range_till').val();\n\n\t\tif(!(ct_date_from !== '' && ct_date_till !== '')){\n\t\t\talert('Please, specify a date range.');\n\t\t\treturn;\n\t\t}\n\t}\n\n\tif(jQuery('#ct_accurate_check').is(':checked')){\n\t\tct_accurate_check = true;\n\t}\n\n\tjQuery('.ct_to_hide').hide();\n\tjQuery('#ct_working_message').show();\n\tjQuery('#ct_preloader').show();\n\tjQuery('#ct_pause').show();\n\n\tct_working = true;\n\n\tif( continue_check ){\n\t\tct_show_users_info();\n\t\tct_send_users();\n\t} else {\n\t\tct_clear_users();\n\t}\n\n}\n\nfunction ct_delete_all_users( e ){\n\n\tvar data = {\n\t\t'action': 'ajax_delete_all_users',\n\t\t'security': ct_ajax_nonce,\n\t\t'no_cache': Math.random()\n\t};\n\n\tjQuery('.' + e.target.id).addClass('disabled');\n\tjQuery('.spinner').css('visibility', 'visible');\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\turl: ajaxurl,\n\t\tdata: data,\n\t\tsuccess: function( msg ){\n\t\t\tif( msg > 0 ){\n\t\t\t\tjQuery('#cleantalk_users_left').html(msg);\n\t\t\t\tct_delete_all_users( e, data );\n\t\t\t}else{\n\t\t\t\tjQuery('.' + e.target.id).removeClass('disabled');\n\t\t\t\tjQuery('.spinner').css('visibility', 'hidden');\n\t\t\t\tlocation.href='users.php?page=ct_check_users';\n\t\t\t}\n\t\t},\n\t\terror: function(jqXHR, textStatus, errorThrown) {\n\t\t\tjQuery('#ct_error_message').show();\n\t\t\tjQuery('#cleantalk_ajax_error').html(textStatus);\n\t\t\tjQuery('#cleantalk_js_func').html('All users deleteion');\n\t\t\tsetTimeout(ct_delete_all_users( e ), 3000);\n\t\t},\n\t\ttimeout: 25000\n\t});\n}\n\njQuery(document).ready(function(){\n\n\t// Setting dependences\n\t\n\t// Prev check parameters\n\tif(ct_prev_accurate){\n\t\tjQuery(\"#ct_accurate_check\").prop('checked', true);\n\t}\n\tif(ct_prev_from){\n\t\tjQuery(\"#ct_allow_date_range\").prop('checked', true).data('state', true);\n\t\tjQuery(\"#ct_date_range_from\").removeProp('disabled').val(ct_prev_from);\n\t\tjQuery(\"#ct_date_range_till\").removeProp('disabled').val(ct_prev_till);\n\t}\n\t\n\t// Toggle dependences\n\tjQuery(\"#ct_allow_date_range\").on('change', function(){\n\t\tdocument.cookie = 'ct_users_dates_from='+ jQuery('#ct_date_range_from').val() +'; path=/; samesite=lax';\n\t\tdocument.cookie = 'ct_users_dates_till='+ jQuery('#ct_date_range_till').val() +'; path=/; samesite=lax';\n\t\tif( this.checked ) {\n\t\t\tdocument.cookie = 'ct_users_dates_allowed=1; path=/; samesite=lax';\n\t\t\tjQuery('.ct_date').prop('checked', true).attr('disabled',false);\n\t\t} else {\n\t\t\tdocument.cookie = 'ct_users_dates_allowed=0; path=/; samesite=lax';\n\t\t\tjQuery('.ct_date').prop('disabled', true).attr('disabled',true);\n\t\t}\n\t});\n\n\tjQuery.datepicker.setDefaults(jQuery.datepicker.regional['en']);\n\tvar dates = jQuery('#ct_date_range_from, #ct_date_range_till').datepicker(\n\t\t{\n\t\t\tdateFormat: 'M d yy',\n\t\t\tmaxDate:\"+0D\",\n\t\t\tchangeMonth:true,\n\t\t\tchangeYear:true,\n\t\t\tshowAnim: 'slideDown',\n\t\t\tonSelect: function(selectedDate){\n\t\t\tvar option = this.id == \"ct_date_range_from\" ? \"minDate\" : \"maxDate\",\n\t\t\t\tinstance = jQuery( this ).data( \"datepicker\" ),\n\t\t\t\tdate = jQuery.datepicker.parseDate(\n\t\t\t\t\tinstance.settings.dateFormat || jQuery.datepicker._defaults.dateFormat,\n\t\t\t\t\tselectedDate, instance.settings);\n\t\t\t\tdates.not(this).datepicker(\"option\", option, date);\n\t\t\t\tdocument.cookie = 'ct_users_dates_from='+ jQuery('#ct_date_range_from').val() +'; path=/; samesite=lax';\n\t\t\t\tdocument.cookie = 'ct_users_dates_till='+ jQuery('#ct_date_range_till').val() +'; path=/; samesite=lax';\n\t\t\t}\n\t\t}\n\t);\n\t\n\t// Check users\n\tjQuery(\"#ct_check_spam_button\").click(function(){\n\t\tdocument.cookie = 'ct_paused_users_check=0; path=/; samesite=lax';\n\t\tct_start_check(false);\n\t});\n\tjQuery(\"#ct_proceed_check_button\").click(function(){\n\t\tct_start_check(true);\n\t});\n\t\n\t// Pause the check\n\tjQuery('#ct_pause').on('click', function(){\n\t\tct_pause = true;\n\t\tvar ct_check = {\n\t\t\t'accurate': ct_accurate_check,\n\t\t\t'from' : ct_date_from,\n\t\t\t'till' : ct_date_till\n\t\t};\n\t\tdocument.cookie = 'ct_paused_users_check=' + JSON.stringify(ct_check) + '; path=/; samesite=lax';\n\t});\n\t\t\n\t//Approve button\n\tjQuery(\".cleantalk_delete_from_list_button\").click(function(){\n\t\tct_id = jQuery(this).attr(\"data-id\");\n\t\t\n\t\t// Approving\n\t\tvar data = {\n\t\t\t'action': 'ajax_ct_approve_user',\n\t\t\t'security': ct_ajax_nonce,\n\t\t\t'id': ct_id,\n\t\t\t'no_cache': Math.random()\n\t\t};\n\t\tjQuery.ajax({\n\t\t\ttype: \"POST\",\n\t\t\turl: ajaxurl,\n\t\t\tdata: data,\n\t\t\tsuccess: function(msg){\n\t\t\t\tjQuery(\"#comment-\"+ct_id).fadeOut('slow', function(){\n\t\t\t\t\tjQuery(\"#comment-\"+ct_id).remove();\n\t\t\t\t});\n\t\t\t},\n\t\t});\n\t\t\n\t\t// Positive feedback\n\t\tvar data = {\n\t\t\t'action': 'ct_feedback_user',\n\t\t\t'security': ct_ajax_nonce,\n\t\t\t'user_id': ct_id,\n\t\t\t'status': 'approve',\n\t\t\t'no_cache': Math.random()\n\t\t};\n\t\tjQuery.ajax({\n\t\t\ttype: \"POST\",\n\t\t\turl: ajaxurl,\n\t\t\tdata: data,\n\t\t\tsuccess: function(msg){\n\t\t\t\tif(msg == 1){\n\t\t\t\t\t// Success\n\t\t\t\t}\n\t\t\t\tif(msg == 0){\n\t\t\t\t\t// Error occurred\n\t\t\t\t}\n\t\t\t\tif(msg == 'no_hash'){\n\t\t\t\t\t// No hash\n\t\t\t\t}\n\t\t\t},\n\t\t\terror: function(jqXHR, textStatus, errorThrown) {\n\t\t\t\t\n\t\t\t},\n\t\t\ttimeout: 5000\n\t\t});\n\t\t\n\t});\n\t\n\t// Request to Download CSV file.\n\tjQuery(\".ct_get_csv_file\").click(function( e ){\n\t\tvar data = {\n\t\t\t'action': 'ajax_ct_get_csv_file',\n\t\t\t'security': ct_ajax_nonce,\n\t\t\t'filename': ctUsersCheck.ct_csv_filename,\n\t\t\t'no_cache': Math.random()\n\t\t};\n\t\tjQuery('.' + e.target.id).addClass('disabled');\n\t\tjQuery('.spinner').css('visibility', 'visible');\n\t\tjQuery.ajax({\n\t\t\ttype: \"POST\",\n\t\t\turl: ajaxurl,\n\t\t\tdata: data,\n\t\t\tsuccess: function(msg){\n\t\t\t\tif( parseInt(msg) === 0 ) {\n\t\t\t\t\talert(ctUsersCheck.ct_bad_csv);\n\t\t\t\t} else {\n\t\t\t\t\tvar url = URL.createObjectURL(new Blob([msg]));\n\n\t\t\t\t\tvar dummy = document.createElement('a');\n\t\t\t\t\tdummy.href = url;\n\t\t\t\t\tdummy.download = ctUsersCheck.ct_csv_filename + '.csv';\n\n\t\t\t\t\tdocument.body.appendChild(dummy);\n\t\t\t\t\tdummy.click();\n\t\t\t\t}\n\t\t\t\tjQuery('.' + e.target.id).removeClass('disabled');\n\t\t\t\tjQuery('.spinner').css('visibility', 'hidden');\n\t\t\t}\n\t\t});\n\t});\n\n\t// Delete inserted users\n\tjQuery(\".ct_insert_users\").click(function( e ){\n\t\tct_insert_users();\n\t});\n\n\t// Insert users\n\tjQuery(\".ct_insert_users__delete\").click(function( e ){\n\t\tct_insert_users( true );\n\t});\n\n\t// Delete all spam users\n\tjQuery(\".ct_delete_all_users\").click(function( e ){\n\n\t\tif ( ! confirm( ctUsersCheck.ct_confirm_deletion_all ) )\n\t\t\treturn false;\n\n\t\tct_delete_all_users( e );\n\n\t});\n\n\tfunction ct_insert_users(delete_accounts){\n\n\t\tdelete_accounts = delete_accounts || null;\n\n\t\tvar data = {\n\t\t\t'action': 'ajax_insert_users',\n\t\t\t'security': ct_ajax_nonce,\n\t\t\t'no_cache': Math.random()\n\t\t};\n\n\t\tif(delete_accounts)\n\t\t\tdata['delete'] = true;\n\n\t\tjQuery.ajax({\n\t\t\ttype: \"POST\",\n\t\t\turl: ajaxurl,\n\t\t\tdata: data,\n\t\t\tsuccess: function(msg){\n\t\t\t\tif(delete_accounts)\n\t\t\t\t\talert('Deleted ' + msg + ' users');\n\t\t\t\telse\n\t\t\t\t\talert('Inserted ' + msg + ' users');\n\t\t\t}\n\t\t});\n\t}\n\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","on","attr","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","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,QAA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,SAASa,EAAOC,EAAYC,KAGnCE,QAAS,QAMXhD,OAAO,oBAAoBwF,MAAM,SAAU5B,GAC1C,IAAIrD,EAAO,CACVC,OAAU,uBACVC,SAAYlC,cACZ2H,SAAYjI,aAAakI,gBACzBzF,SAAYC,KAAKC,UAElBZ,OAAO,IAAM4D,EAAEC,OAAO9D,IAAI+D,SAAS,YACnC9D,OAAO,YAAY+D,IAAI,aAAc,WACrC/D,OAAOa,KAAK,CACXC,KAAM,OACNC,IAAKC,QACLT,KAAMA,EACNU,QAAS,SAASC,GACjB,IAGKH,EAEAqF,EALiB,IAAlBtE,SAASZ,GACZwC,MAAMzF,aAAaoI,aAEftF,EAAMuF,IAAIC,gBAAgB,IAAIC,KAAK,CAACtF,MAEpCkF,EAAQ3I,SAASgJ,cAAc,MAC7BtE,KAAOpB,EACbqF,EAAMM,SAAWzI,aAAakI,gBAAkB,OAEhD1I,SAASkJ,KAAKC,YAAYR,GAC1BA,EAAMZ,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,aAAa4I,+BAG7BlD,oBAAqBC"}
lib/Cleantalk/Antispam/Integrations.php CHANGED
@@ -1,88 +1,88 @@
1
- <?php
2
-
3
-
4
- namespace Cleantalk\Antispam;
5
-
6
-
7
- class Integrations
8
- {
9
-
10
- private $integrations = array();
11
-
12
- private $integration;
13
-
14
- public function __construct( $integrations )
15
- {
16
- $this->integrations = $integrations;
17
-
18
- foreach( $this->integrations as $integration_name => $integration_info ) {
19
- if( $integration_info['ajax'] ) {
20
- add_action( 'wp_ajax_' . $integration_info['hook'], array( $this, 'checkSpam' ), 1 );
21
- add_action( 'wp_ajax_nopriv_' . $integration_info['hook'], array( $this, 'checkSpam' ), 1 );
22
- } else {
23
- add_action( $integration_info['hook'], array( $this, 'checkSpam' ) );
24
- }
25
- }
26
- }
27
-
28
- public function checkSpam( $argument )
29
- {
30
- global $cleantalk_executed;
31
-
32
- // Getting current integration name
33
- $current_integration = $this->get_current_integration_triggered( current_filter() );
34
- if( $current_integration ) {
35
- // Instantiate the integration object
36
- $class = '\\Cleantalk\\Antispam\\Integrations\\' . $current_integration;
37
- if( class_exists( $class )) {
38
- $this->integration = new $class();
39
- if( ! ( $this->integration instanceof \Cleantalk\Antispam\Integrations\IntegrationBase ) ) {
40
- // @ToDo have to handle an error
41
- do_action( 'apbct_skipped_request', __FILE__ . ' -> ' . __FUNCTION__ . '():' . __LINE__, array('Integration is not instanse of IntegrationBase class.') );
42
- return;
43
- }
44
- // Run data collecting for spam checking
45
- $data = $this->integration->getDataForChecking( $argument );
46
- if( ! is_null( $data ) ) {
47
- // Go spam checking
48
- $base_call_result = apbct_base_call(
49
- array(
50
- 'message' => !empty( $data['message'] ) ? json_encode( $data['message'] ) : '',
51
- 'sender_email' => !empty( $data['email'] ) ? $data['email'] : '',
52
- 'sender_nickname' => !empty( $data['nickname'] ) ? $data['nickname'] : '',
53
- 'post_info' => array(
54
- 'comment_type' => 'contact_form_wordpress_' . strtolower($current_integration),
55
- 'post_url' => apbct_get_server_variable( 'HTTP_REFERER' ), // Page URL must be an previous page
56
- ),
57
- ),
58
- isset( $data['register'] ) ? true : false
59
- );
60
-
61
- $ct_result = $base_call_result['ct_result'];
62
-
63
- $cleantalk_executed = true;
64
-
65
- if ($ct_result->allow == 0) {
66
- // Do blocking if it is a spam
67
- $this->integration->doBlock( $ct_result->comment );
68
- }
69
- } else {
70
- // @ToDo have to handle an error
71
- return;
72
- }
73
- }
74
- }
75
- }
76
-
77
- private function get_current_integration_triggered( $hook )
78
- {
79
- if( $hook !== false ) {
80
- foreach( $this->integrations as $integration_name => $integration_info ) {
81
- if( strpos( $hook, $integration_info['hook'] ) !== false ) {
82
- return $integration_name;
83
- }
84
- }
85
- }
86
- return false;
87
- }
88
  }
1
+ <?php
2
+
3
+
4
+ namespace Cleantalk\Antispam;
5
+
6
+
7
+ class Integrations
8
+ {
9
+
10
+ private $integrations = array();
11
+
12
+ private $integration;
13
+
14
+ public function __construct( $integrations )
15
+ {
16
+ $this->integrations = $integrations;
17
+
18
+ foreach( $this->integrations as $integration_name => $integration_info ) {
19
+ if( $integration_info['ajax'] ) {
20
+ add_action( 'wp_ajax_' . $integration_info['hook'], array( $this, 'checkSpam' ), 1 );
21
+ add_action( 'wp_ajax_nopriv_' . $integration_info['hook'], array( $this, 'checkSpam' ), 1 );
22
+ } else {
23
+ add_action( $integration_info['hook'], array( $this, 'checkSpam' ) );
24
+ }
25
+ }
26
+ }
27
+
28
+ public function checkSpam( $argument )
29
+ {
30
+ global $cleantalk_executed;
31
+
32
+ // Getting current integration name
33
+ $current_integration = $this->get_current_integration_triggered( current_filter() );
34
+ if( $current_integration ) {
35
+ // Instantiate the integration object
36
+ $class = '\\Cleantalk\\Antispam\\Integrations\\' . $current_integration;
37
+ if( class_exists( $class )) {
38
+ $this->integration = new $class();
39
+ if( ! ( $this->integration instanceof \Cleantalk\Antispam\Integrations\IntegrationBase ) ) {
40
+ // @ToDo have to handle an error
41
+ do_action( 'apbct_skipped_request', __FILE__ . ' -> ' . __FUNCTION__ . '():' . __LINE__, array('Integration is not instanse of IntegrationBase class.') );
42
+ return;
43
+ }
44
+ // Run data collecting for spam checking
45
+ $data = $this->integration->getDataForChecking( $argument );
46
+ if( ! is_null( $data ) ) {
47
+ // Go spam checking
48
+ $base_call_result = apbct_base_call(
49
+ array(
50
+ 'message' => !empty( $data['message'] ) ? json_encode( $data['message'] ) : '',
51
+ 'sender_email' => !empty( $data['email'] ) ? $data['email'] : '',
52
+ 'sender_nickname' => !empty( $data['nickname'] ) ? $data['nickname'] : '',
53
+ 'post_info' => array(
54
+ 'comment_type' => 'contact_form_wordpress_' . strtolower($current_integration),
55
+ 'post_url' => apbct_get_server_variable( 'HTTP_REFERER' ), // Page URL must be an previous page
56
+ ),
57
+ ),
58
+ isset( $data['register'] ) ? true : false
59
+ );
60
+
61
+ $ct_result = $base_call_result['ct_result'];
62
+
63
+ $cleantalk_executed = true;
64
+
65
+ if ($ct_result->allow == 0) {
66
+ // Do blocking if it is a spam
67
+ $this->integration->doBlock( $ct_result->comment );
68
+ }
69
+ } else {
70
+ // @ToDo have to handle an error
71
+ return;
72
+ }
73
+ }
74
+ }
75
+ }
76
+
77
+ private function get_current_integration_triggered( $hook )
78
+ {
79
+ if( $hook !== false ) {
80
+ foreach( $this->integrations as $integration_name => $integration_info ) {
81
+ if( strpos( $hook, $integration_info['hook'] ) !== false ) {
82
+ return $integration_name;
83
+ }
84
+ }
85
+ }
86
+ return false;
87
+ }
88
  }
lib/Cleantalk/ApbctWP/FindSpam/CommentsChecker.php CHANGED
@@ -1,537 +1,537 @@
1
- <?php
2
-
3
- namespace Cleantalk\ApbctWP\FindSpam;
4
-
5
- class CommentsChecker extends Checker
6
- {
7
-
8
- public function __construct() {
9
-
10
- parent::__construct();
11
-
12
- $this->page_title = esc_html__( 'Check comments for spam', 'cleantalk-spam-protect');
13
- $this->page_script_name = 'edit-comments.php';
14
- $this->page_slug = 'spam';
15
-
16
- // Preparing data
17
- if(!empty($_COOKIE['ct_paused_comments_check']))
18
- $prev_check = json_decode(stripslashes($_COOKIE['ct_paused_comments_check']), true);
19
-
20
- wp_enqueue_script( 'ct_comments_checkspam', plugins_url('/cleantalk-spam-protect/js/cleantalk-comments-checkspam.min.js'), array( 'jquery', 'jqueryui' ), APBCT_VERSION );
21
- wp_localize_script( 'ct_comments_checkspam', 'ctCommentsCheck', array(
22
- 'ct_ajax_nonce' => wp_create_nonce('ct_secret_nonce'),
23
- 'ct_prev_accurate' => !empty($prev_check['accurate']) ? true : false,
24
- 'ct_prev_from' => !empty($prev_check['from']) ? $prev_check['from'] : false,
25
- 'ct_prev_till' => !empty($prev_check['till']) ? $prev_check['till'] : false,
26
- 'ct_timeout_confirm' => __('Failed from timeout. Going to check comments again.', 'cleantalk-spam-protect'),
27
- 'ct_confirm_trash_all' => __('Trash all spam comments from the list?', 'cleantalk-spam-protect'),
28
- 'ct_confirm_spam_all' => __('Mark as spam all comments from the list?', 'cleantalk-spam-protect'),
29
- 'ct_comments_added_after' => __('comments', 'cleantalk-spam-protect'),
30
- 'ct_status_string' => __('Checked %s, found %s spam comments and %s bad comments (without IP or email).', 'cleantalk-spam-protect'),
31
- 'ct_status_string_warning' => '<p>'.__('Please do backup of WordPress database before delete any accounts!', 'cleantalk-spam-protect').'</p>',
32
- 'start' => !empty($_COOKIE['ct_comments_start_check']) ? true : false,
33
- ));
34
-
35
- }
36
-
37
- public function getCurrentScanPage() {
38
-
39
- $this->list_table = new \Cleantalk\ApbctWP\FindSpam\ListTable\CommentsScan();
40
-
41
- $this->getCurrentScanPanel( $this );
42
- echo '<form action="" method="POST">';
43
- $this->list_table->display();
44
- echo '</form>';
45
-
46
- }
47
-
48
- public function getSpamLogsPage(){
49
-
50
- $this->list_table = new \Cleantalk\ApbctWP\FindSpam\ListTable\CommentsLogs();
51
-
52
- echo '<form action="" method="POST">';
53
- $this->list_table->display();
54
- echo '</form>';
55
-
56
- }
57
-
58
- /**
59
- * Getting a count of total comments of the website and return formatted string about this.
60
- *
61
- * @return string
62
- */
63
- public static function get_count_text() {
64
-
65
- $res = wp_count_comments();
66
-
67
- if( $res->all ) {
68
- $text = sprintf( esc_html__ ('Total count of comments: %s.', 'cleantalk-spam-protect' ), $res->all );
69
- } else {
70
- $text = esc_html__( 'No comments found.', 'cleantalk-spam-protect' );
71
- }
72
-
73
- return $text;
74
-
75
- }
76
-
77
- /**
78
- * Get date last checked comment or date of the first comment
79
- *
80
- * @return string date "M j Y"
81
- */
82
- public static function lastCheckDate() {
83
-
84
- global $wpdb;
85
- $query = "SELECT * FROM " . APBCT_SPAMSCAN_LOGS . " WHERE scan_type = 'comments' ORDER BY start_time DESC";
86
- $res = $wpdb->get_row( $query, ARRAY_A );
87
-
88
- if ( $res ) {
89
-
90
- return date( "M j Y", strtotime( $res['start_time'] ) );
91
-
92
- } else {
93
-
94
- $params = array(
95
- 'fields' => 'ids',
96
- 'orderby' => 'comment_date_gmt',
97
- 'order' => 'ASC',
98
- 'number' => 1
99
- );
100
- $first_comment = get_comments( $params );
101
-
102
- return get_comment_date( "M j Y", current( $first_comment ) );
103
-
104
- }
105
-
106
- }
107
-
108
- public static function ct_ajax_check_comments(){
109
-
110
- check_ajax_referer( 'ct_secret_nonce', 'security' );
111
-
112
- global $wpdb, $apbct;
113
-
114
- if(isset($_POST['from'], $_POST['till'])){
115
- $from_date = date('Y-m-d', intval(strtotime($_POST['from'])));
116
- $till_date = date('Y-m-d', intval(strtotime($_POST['till'])));
117
- }
118
-
119
- // Gettings comments 100 unchecked comments
120
- if(isset($_COOKIE['ct_comments_safe_check'])){
121
- $c = $wpdb->get_results("
122
- SELECT comment_ID, comment_date_gmt, comment_author_IP, comment_author_email
123
- FROM {$wpdb->comments} as comm
124
- WHERE
125
- (comm.comment_approved = '1' OR comm.comment_approved = '0')
126
- AND NOT EXISTS(
127
- SELECT comment_id, meta_key
128
- FROM {$wpdb->commentmeta} as meta
129
- WHERE comm.comment_ID = meta.comment_id AND (meta_key = 'ct_checked' OR meta_key = 'ct_bad')
130
- )
131
- ORDER BY comment_date_gmt
132
- LIMIT 100",
133
- ARRAY_A
134
- );
135
- }else{
136
- $params = array(
137
- 'meta_query' => array(
138
- 'relation' => 'AND',
139
- array(
140
- 'key' => 'ct_checked_now',
141
- 'compare' => 'NOT EXISTS'
142
- ),
143
- array(
144
- 'key' => 'ct_checked',
145
- 'compare' => 'NOT EXISTS'
146
- ),
147
- array(
148
- 'key' => 'ct_bad',
149
- 'compare' => 'NOT EXISTS'
150
- )
151
- ),
152
- 'orderby' => 'comment_date_gmt',
153
- 'order' => 'ASC',
154
- 'number' => 100
155
- );
156
- if(isset($from_date, $till_date)){
157
- $params['date_query'] = array(
158
- 'column' => 'comment_date_gmt',
159
- 'after' => $from_date,
160
- 'before' => $till_date,
161
- 'inclusive' => true,
162
- );
163
- }
164
- $c = get_comments( $params );
165
- }
166
-
167
- $check_result = array(
168
- 'end' => 0,
169
- 'checked' => 0,
170
- 'spam' => 0,
171
- 'bad' => 0,
172
- 'error' => 0
173
- );
174
-
175
- if(sizeof($c)>0){
176
-
177
- // Coverting $c to objects
178
- if(is_array($c[0])){
179
- foreach($c as $key => $value){
180
- $c[$key] = (object)$value;
181
- } unset($key, $value);
182
- }
183
-
184
- if(!empty($_POST['accurate_check'])){
185
- // Leaving comments only with first comment's date. Unsetting others.
186
-
187
- foreach($c as $comment_index => $comment){
188
-
189
- if(!isset($curr_date))
190
- $curr_date = (substr($comment->comment_date_gmt, 0, 10) ? substr($comment->comment_date_gmt, 0, 10) : '');
191
-
192
- if(substr($comment->comment_date_gmt, 0, 10) != $curr_date)
193
- unset($c[$comment_index]);
194
-
195
- }
196
- unset($comment_index, $comment);
197
- }
198
-
199
- // Checking comments IP/Email. Gathering $data for check.
200
- $data = Array();
201
- for($i=0;$i<sizeof($c);$i++){
202
-
203
- $curr_ip = $c[$i]->comment_author_IP;
204
- $curr_email = $c[$i]->comment_author_email;
205
-
206
- // Check for identity
207
- $curr_ip = preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $curr_ip) === 1 ? $curr_ip : null;
208
- $curr_email = preg_match('/^\S+@\S+\.\S+$/', $curr_email) === 1 ? $curr_email : null;
209
-
210
- if(empty($curr_ip) && empty($curr_email)){
211
- $check_result['bad']++;
212
- update_comment_meta($c[$i]->comment_ID,'ct_bad','1');
213
- update_comment_meta($c[$i]->comment_ID,'ct_checked','1');
214
- update_comment_meta($c[$i]->comment_ID,'ct_checked_now','1');
215
- unset($c[$i]);
216
- }else{
217
- if(!empty($curr_ip))
218
- $data[] = $curr_ip;
219
- if(!empty($curr_email))
220
- $data[] = $curr_email;
221
- // Patch for empty IP/Email
222
- $c[$i]->comment_author_IP = empty($curr_ip) ? 'none' : $curr_ip;
223
- $c[$i]->comment_author_email = empty($curr_email) ? 'none' : $curr_email;
224
- }
225
- }
226
-
227
- // Recombining after checking and unsettting
228
- $c = array_values($c);
229
-
230
- // Drop if data empty and there's no comments to check
231
- if(count($data) == 0){
232
- if($_POST['unchecked'] === 0)
233
- $check_result['end'] = 1;
234
- print json_encode($check_result);
235
- die();
236
- }
237
-
238
- $result = \Cleantalk\ApbctWP\API::method__spam_check_cms($apbct->api_key, $data, !empty($_POST['accurate_check']) ? $curr_date : null);
239
-
240
- if(empty($result['error'])){
241
-
242
- for($i=0;$i<sizeof($c);$i++){
243
-
244
- $mark_spam_ip = false;
245
- $mark_spam_email = false;
246
-
247
- $check_result['checked']++;
248
- update_comment_meta($c[$i]->comment_ID,'ct_checked',date("Y-m-d H:m:s"));
249
- update_comment_meta( $c[$i]->comment_ID, 'ct_checked_now', date("Y-m-d H:m:s"), true) ;
250
-
251
- $uip=$c[$i]->comment_author_IP;
252
- $uim=$c[$i]->comment_author_email;
253
-
254
- if(isset($result[$uip]) && $result[$uip]['appears'] == 1)
255
- $mark_spam_ip = true;
256
-
257
- if(isset($result[$uim]) && $result[$uim]['appears'] == 1)
258
- $mark_spam_email = true;
259
-
260
- if ($mark_spam_ip || $mark_spam_email){
261
- $check_result['spam']++;
262
- update_comment_meta($c[$i]->comment_ID,'ct_marked_as_spam','1');
263
- }
264
- }
265
- print json_encode($check_result);
266
-
267
- }else{
268
- $check_result['error'] = 1;
269
- $check_result['error_message'] = $result['error'];
270
- echo json_encode($check_result);
271
- }
272
- }else{
273
-
274
- $check_result['end'] = 1;
275
-
276
- $log_data = static::get_log_data();
277
- static::writeSpamLog( 'comments', date("Y-m-d H:i:s"), $log_data['checked'], $log_data['spam'], $log_data['bad'] );
278
-
279
- print json_encode($check_result);
280
-
281
- }
282
-
283
- die;
284
- }
285
-
286
- public static function ct_ajax_info($direct_call = false){
287
-
288
- if (!$direct_call)
289
- check_ajax_referer( 'ct_secret_nonce', 'security' );
290
-
291
- // Checked comments
292
- $params_checked = array(
293
- 'meta_key' => 'ct_checked_now',
294
- 'orderby' => 'ct_checked_now'
295
- );
296
- $checked_comments = new \WP_Comment_Query($params_checked);
297
- $cnt_checked = count( $checked_comments->get_comments() );
298
-
299
- // Spam comments
300
- $params_spam = array(
301
- 'meta_query' => array(
302
- 'relation' => 'AND',
303
- array(
304
- 'key' => 'ct_marked_as_spam',
305
- 'compare' => 'EXISTS'
306
- ),
307
- array(
308
- 'key' => 'ct_checked_now',
309
- 'compare' => 'EXISTS'
310
- ),
311
- ),
312
- );
313
- $spam_comments = new \WP_Comment_Query($params_spam);
314
- $cnt_spam = count( $spam_comments->get_comments() );
315
-
316
- // Bad comments (without IP and Email)
317
- $params_bad = array(
318
- 'meta_query' => array(
319
- 'relation' => 'AND',
320
- array(
321
- 'key' => 'ct_bad',
322
- 'compare' => 'EXISTS'
323
- ),
324
- array(
325
- 'key' => 'ct_checked_now',
326
- 'compare' => 'EXISTS'
327
- ),
328
- ),
329
- );
330
- $bad_comments = new \WP_Comment_Query($params_bad);
331
- $cnt_bad = count( $bad_comments->get_comments() );
332
-
333
- $return = array(
334
- 'message' => '',
335
- 'spam' => $cnt_spam,
336
- 'checked' => $cnt_checked,
337
- 'bad' => $cnt_bad,
338
- );
339
-
340
- if( ! $direct_call ) {
341
- $return['message'] .= sprintf (
342
- esc_html__('Checked %s, found %s spam comments and %s bad comments (without IP or email)', 'cleantalk-spam-protect'),
343
- $cnt_checked,
344
- $cnt_spam,
345
- $cnt_bad
346
- );
347
- } else {
348
-
349
- global $wpdb;
350
-
351
- $query = "SELECT * FROM " . APBCT_SPAMSCAN_LOGS . " WHERE scan_type = 'comments' ORDER BY start_time DESC";
352
- $res = $wpdb->get_row( $query, ARRAY_A );
353
-
354
- if ( $res ) {
355
-
356
- $return['message'] .= sprintf (
357
- __("Last check %s: checked %s comments, found %s spam comments and %s bad comments (without IP or email).", 'cleantalk-spam-protect'),
358
- self::lastCheckDate(),
359
- $cnt_checked,
360
- $cnt_spam,
361
- $cnt_bad
362
- );
363
-
364
- } else {
365
- // Never checked
366
- $return['message'] = esc_html__( 'Never checked yet or no new spam.', 'cleantalk-spam-protect');
367
- }
368
-
369
- }
370
-
371
- $backup_notice = '&nbsp;';
372
- if ($cnt_spam > 0){
373
- $backup_notice = __("Please do backup of WordPress database before delete any comments!", 'cleantalk-spam-protect');
374
- }
375
- $return['message'] .= "<p>$backup_notice</p>";
376
-
377
- if($direct_call){
378
- return $return['message'];
379
- }else{
380
- echo json_encode($return);
381
- die();
382
- }
383
-
384
- }
385
-
386
- public static function ct_ajax_clear_comments(){
387
-
388
- check_ajax_referer( 'ct_secret_nonce', 'security' );
389
-
390
- global $wpdb;
391
- $wpdb->query("DELETE FROM {$wpdb->commentmeta} WHERE meta_key IN ('ct_checked_now')");
392
-
393
- if ( isset($_POST['from']) && isset($_POST['till']) ) {
394
- if ( preg_match('/[a-zA-Z]{3}\s{1}\d{1,2}\s{1}\d{4}/', $_POST['from'] ) && preg_match('/[a-zA-Z]{3}\s{1}\d{1,2}\s{1}\d{4}/', $_POST['till'] ) ) {
395
-
396
- $from = date('Y-m-d', intval(strtotime($_POST['from']))) . ' 00:00:00';
397
- $till = date('Y-m-d', intval(strtotime($_POST['till']))) . ' 23:59:59';
398
-
399
- $wpdb->query("DELETE FROM {$wpdb->commentmeta} WHERE
400
- meta_key IN ('ct_checked','ct_marked_as_spam','ct_bad')
401
- AND meta_value >= '{$from}'
402
- AND meta_value <= '{$till}';");
403
- die();
404
-
405
- } else {
406
- $wpdb->query("DELETE FROM {$wpdb->commentmeta} WHERE
407
- meta_key IN ('ct_checked','ct_marked_as_spam','ct_bad')");
408
- die();
409
- }
410
- }
411
-
412
- }
413
-
414
- private static function get_log_data() {
415
-
416
- // Checked users
417
- $params_spam = array(
418
- 'meta_key' => 'ct_checked_now',
419
- );
420
- $spam_comments = new \WP_Comment_Query($params_spam);
421
- $cnt_checked = count( $spam_comments->get_comments() );
422
-
423
- // Spam users
424
- $params_spam = array(
425
- 'meta_query' => array(
426
- 'relation' => 'AND',
427
- array(
428
- 'key' => 'ct_marked_as_spam',
429
- 'compare' => 'EXISTS'
430
- ),
431
- array(
432
- 'key' => 'ct_checked_now',
433
- 'compare' => 'EXISTS'
434
- ),
435
- ),
436
- );
437
- $spam_comments = new \WP_Comment_Query($params_spam);
438
- $cnt_spam = count( $spam_comments->get_comments() );
439
-
440
- // Bad users (without IP and Email)
441
- $params_bad = array(
442
- 'meta_query' => array(
443
- 'relation' => 'AND',
444
- array(
445
- 'key' => 'ct_bad',
446
- 'compare' => 'EXISTS'
447
- ),
448
- array(
449
- 'key' => 'ct_checked_now',
450
- 'compare' => 'EXISTS'
451
- ),
452
- ),
453
- );
454
- $spam_comments = new \WP_Comment_Query($params_bad);
455
- $cnt_bad = count( $spam_comments->get_comments() );
456
-
457
- return array(
458
- 'spam' => $cnt_spam,
459
- 'checked' => $cnt_checked,
460
- 'bad' => $cnt_bad,
461
- );
462
-
463
- }
464
-
465
- public static function ct_ajax_trash_all(){
466
-
467
- check_ajax_referer( 'ct_secret_nonce', 'security' );
468
-
469
- $args_spam = array(
470
- 'number'=>100,
471
- 'meta_query' => array(
472
- array(
473
- 'key' => 'ct_marked_as_spam',
474
- 'value' => '1',
475
- 'compare' => 'NUMERIC'
476
- )
477
- )
478
- );
479
- $c_spam = get_comments( $args_spam );
480
-
481
- $args_spam = array(
482
- 'count'=>true,
483
- 'meta_query' => array(
484
- Array(
485
- 'key' => 'ct_marked_as_spam',
486
- 'value' => '1',
487
- 'compare' => 'NUMERIC'
488
- )
489
- )
490
- );
491
- $cnt_all = get_comments($args_spam);
492
-
493
- for( $i=0; $i < sizeof( $c_spam ); $i++ ){
494
- wp_trash_comment( $c_spam[$i]->comment_ID );
495
- usleep(10000);
496
- }
497
- print $cnt_all;
498
- die();
499
- }
500
-
501
- public static function ct_ajax_spam_all(){
502
-
503
- check_ajax_referer( 'ct_secret_nonce', 'security' );
504
-
505
- $args_spam = array(
506
- 'number'=>100,
507
- 'meta_query' => array(
508
- array(
509
- 'key' => 'ct_marked_as_spam',
510
- 'value' => '1',
511
- 'compare' => 'NUMERIC'
512
- )
513
- )
514
- );
515
- $c_spam = get_comments( $args_spam );
516
-
517
- $args_spam = array(
518
- 'count'=>true,
519
- 'meta_query' => array(
520
- Array(
521
- 'key' => 'ct_marked_as_spam',
522
- 'value' => '1',
523
- 'compare' => 'NUMERIC'
524
- )
525
- )
526
- );
527
- $cnt_all = get_comments($args_spam);
528
-
529
- for( $i=0; $i < sizeof( $c_spam ); $i++ ){
530
- wp_spam_comment( $c_spam[$i]->comment_ID );
531
- usleep(10000);
532
- }
533
- print $cnt_all;
534
- die();
535
- }
536
-
537
  }
1
+ <?php
2
+
3
+ namespace Cleantalk\ApbctWP\FindSpam;
4
+
5
+ class CommentsChecker extends Checker
6
+ {
7
+
8
+ public function __construct() {
9
+
10
+ parent::__construct();
11
+
12
+ $this->page_title = esc_html__( 'Check comments for spam', 'cleantalk-spam-protect');
13
+ $this->page_script_name = 'edit-comments.php';
14
+ $this->page_slug = 'spam';
15
+
16
+ // Preparing data
17
+ if(!empty($_COOKIE['ct_paused_comments_check']))
18
+ $prev_check = json_decode(stripslashes($_COOKIE['ct_paused_comments_check']), true);
19
+
20
+ wp_enqueue_script( 'ct_comments_checkspam', plugins_url('/cleantalk-spam-protect/js/cleantalk-comments-checkspam.min.js'), array( 'jquery', 'jqueryui' ), APBCT_VERSION );
21
+ wp_localize_script( 'ct_comments_checkspam', 'ctCommentsCheck', array(
22
+ 'ct_ajax_nonce' => wp_create_nonce('ct_secret_nonce'),
23
+ 'ct_prev_accurate' => !empty($prev_check['accurate']) ? true : false,
24
+ 'ct_prev_from' => !empty($prev_check['from']) ? $prev_check['from'] : false,
25
+ 'ct_prev_till' => !empty($prev_check['till']) ? $prev_check['till'] : false,
26
+ 'ct_timeout_confirm' => __('Failed from timeout. Going to check comments again.', 'cleantalk-spam-protect'),
27
+ 'ct_confirm_trash_all' => __('Trash all spam comments from the list?', 'cleantalk-spam-protect'),
28
+ 'ct_confirm_spam_all' => __('Mark as spam all comments from the list?', 'cleantalk-spam-protect'),
29
+ 'ct_comments_added_after' => __('comments', 'cleantalk-spam-protect'),
30
+ 'ct_status_string' => __('Checked %s, found %s spam comments and %s bad comments (without IP or email).', 'cleantalk-spam-protect'),
31
+ 'ct_status_string_warning' => '<p>'.__('Please do backup of WordPress database before delete any accounts!', 'cleantalk-spam-protect').'</p>',
32
+ 'start' => !empty($_COOKIE['ct_comments_start_check']) ? true : false,
33
+ ));
34
+
35
+ }
36
+
37
+ public function getCurrentScanPage() {
38
+
39
+ $this->list_table = new \Cleantalk\ApbctWP\FindSpam\ListTable\CommentsScan();
40
+
41
+ $this->getCurrentScanPanel( $this );
42
+ echo '<form action="" method="POST">';
43
+ $this->list_table->display();
44
+ echo '</form>';
45
+
46
+ }
47
+
48
+ public function getSpamLogsPage(){
49
+
50
+ $this->list_table = new \Cleantalk\ApbctWP\FindSpam\ListTable\CommentsLogs();
51
+
52
+ echo '<form action="" method="POST">';
53
+ $this->list_table->display();
54
+ echo '</form>';
55
+
56
+ }
57
+
58
+ /**
59
+ * Getting a count of total comments of the website and return formatted string about this.
60
+ *
61
+ * @return string
62
+ */
63
+ public static function get_count_text() {
64
+
65
+ $res = wp_count_comments();
66
+
67
+ if( $res->all ) {
68
+ $text = sprintf( esc_html__ ('Total count of comments: %s.', 'cleantalk-spam-protect' ), $res->all );
69
+ } else {
70
+ $text = esc_html__( 'No comments found.', 'cleantalk-spam-protect' );
71
+ }
72
+
73
+ return $text;
74
+
75
+ }
76
+
77
+ /**
78
+ * Get date last checked comment or date of the first comment
79
+ *
80
+ * @return string date "M j Y"
81
+ */
82
+ public static function lastCheckDate() {
83
+
84
+ global $wpdb;
85
+ $query = "SELECT * FROM " . APBCT_SPAMSCAN_LOGS . " WHERE scan_type = 'comments' ORDER BY start_time DESC";
86
+ $res = $wpdb->get_row( $query, ARRAY_A );
87
+
88
+ if ( $res ) {
89
+
90
+ return date( "M j Y", strtotime( $res['start_time'] ) );
91
+
92
+ } else {
93
+
94
+ $params = array(
95
+ 'fields' => 'ids',
96
+ 'orderby' => 'comment_date_gmt',
97
+ 'order' => 'ASC',
98
+ 'number' => 1
99
+ );
100
+ $first_comment = get_comments( $params );
101
+
102
+ return get_comment_date( "M j Y", current( $first_comment ) );
103
+
104
+ }
105
+
106
+ }
107
+
108
+ public static function ct_ajax_check_comments(){
109
+
110
+ check_ajax_referer( 'ct_secret_nonce', 'security' );
111
+
112
+ global $wpdb, $apbct;
113
+
114
+ if(isset($_POST['from'], $_POST['till'])){
115
+ $from_date = date('Y-m-d', intval(strtotime($_POST['from'])));
116
+ $till_date = date('Y-m-d', intval(strtotime($_POST['till'])));
117
+ }
118
+
119
+ // Gettings comments 100 unchecked comments
120
+ if(isset($_COOKIE['ct_comments_safe_check'])){
121
+ $c = $wpdb->get_results("
122
+ SELECT comment_ID, comment_date_gmt, comment_author_IP, comment_author_email
123
+ FROM {$wpdb->comments} as comm
124
+ WHERE
125
+ (comm.comment_approved = '1' OR comm.comment_approved = '0')
126
+ AND NOT EXISTS(
127
+ SELECT comment_id, meta_key
128
+ FROM {$wpdb->commentmeta} as meta
129
+ WHERE comm.comment_ID = meta.comment_id AND (meta_key = 'ct_checked' OR meta_key = 'ct_bad')
130
+ )
131
+ ORDER BY comment_date_gmt
132
+ LIMIT 100",
133
+ ARRAY_A
134
+ );
135
+ }else{
136
+ $params = array(
137
+ 'meta_query' => array(
138
+ 'relation' => 'AND',
139
+ array(
140
+ 'key' => 'ct_checked_now',
141
+ 'compare' => 'NOT EXISTS'
142
+ ),
143
+ array(
144
+ 'key' => 'ct_checked',
145
+ 'compare' => 'NOT EXISTS'
146
+ ),
147
+ array(
148
+ 'key' => 'ct_bad',
149
+ 'compare' => 'NOT EXISTS'
150
+ )
151
+ ),
152
+ 'orderby' => 'comment_date_gmt',
153
+ 'order' => 'ASC',
154
+ 'number' => 100
155
+ );
156
+ if(isset($from_date, $till_date)){
157
+ $params['date_query'] = array(
158
+ 'column' => 'comment_date_gmt',
159
+ 'after' => $from_date,
160
+ 'before' => $till_date,
161
+ 'inclusive' => true,
162
+ );
163
+ }
164
+ $c = get_comments( $params );
165
+ }
166
+
167
+ $check_result = array(
168
+ 'end' => 0,
169
+ 'checked' => 0,
170
+ 'spam' => 0,
171
+ 'bad' => 0,
172
+ 'error' => 0
173
+ );
174
+
175
+ if(sizeof($c)>0){
176
+
177
+ // Coverting $c to objects
178
+ if(is_array($c[0])){
179
+ foreach($c as $key => $value){
180
+ $c[$key] = (object)$value;
181
+ } unset($key, $value);
182
+ }
183
+
184
+ if(!empty($_POST['accurate_check'])){
185
+ // Leaving comments only with first comment's date. Unsetting others.
186
+
187
+ foreach($c as $comment_index => $comment){
188
+
189
+ if(!isset($curr_date))
190
+ $curr_date = (substr($comment->comment_date_gmt, 0, 10) ? substr($comment->comment_date_gmt, 0, 10) : '');
191
+
192
+ if(substr($comment->comment_date_gmt, 0, 10) != $curr_date)
193
+ unset($c[$comment_index]);
194
+
195
+ }
196
+ unset($comment_index, $comment);
197
+ }
198
+
199
+ // Checking comments IP/Email. Gathering $data for check.
200
+ $data = Array();
201
+ for($i=0;$i<sizeof($c);$i++){
202
+
203
+ $curr_ip = $c[$i]->comment_author_IP;
204
+ $curr_email = $c[$i]->comment_author_email;
205
+
206
+ // Check for identity
207
+ $curr_ip = preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $curr_ip) === 1 ? $curr_ip : null;
208
+ $curr_email = preg_match('/^\S+@\S+\.\S+$/', $curr_email) === 1 ? $curr_email : null;
209
+
210
+ if(empty($curr_ip) && empty($curr_email)){
211
+ $check_result['bad']++;
212
+ update_comment_meta($c[$i]->comment_ID,'ct_bad','1');
213
+ update_comment_meta($c[$i]->comment_ID,'ct_checked','1');
214
+ update_comment_meta($c[$i]->comment_ID,'ct_checked_now','1');
215
+ unset($c[$i]);
216
+ }else{
217
+ if(!empty($curr_ip))
218
+ $data[] = $curr_ip;
219
+ if(!empty($curr_email))
220
+ $data[] = $curr_email;
221
+ // Patch for empty IP/Email
222
+ $c[$i]->comment_author_IP = empty($curr_ip) ? 'none' : $curr_ip;
223
+ $c[$i]->comment_author_email = empty($curr_email) ? 'none' : $curr_email;
224
+ }
225
+ }
226
+
227
+ // Recombining after checking and unsettting
228
+ $c = array_values($c);
229
+
230
+ // Drop if data empty and there's no comments to check
231
+ if(count($data) == 0){
232
+ if($_POST['unchecked'] === 0)
233
+ $check_result['end'] = 1;
234
+ print json_encode($check_result);
235
+ die();
236
+ }
237
+
238
+ $result = \Cleantalk\ApbctWP\API::method__spam_check_cms($apbct->api_key, $data, !empty($_POST['accurate_check']) ? $curr_date : null);
239
+
240
+ if(empty($result['error'])){
241
+
242
+ for($i=0;$i<sizeof($c);$i++){
243
+
244
+ $mark_spam_ip = false;
245
+ $mark_spam_email = false;
246
+
247
+ $check_result['checked']++;
248
+ update_comment_meta($c[$i]->comment_ID,'ct_checked',date("Y-m-d H:m:s"));
249
+ update_comment_meta( $c[$i]->comment_ID, 'ct_checked_now', date("Y-m-d H:m:s"), true) ;
250
+
251
+ $uip=$c[$i]->comment_author_IP;
252
+ $uim=$c[$i]->comment_author_email;
253
+
254
+ if(isset($result[$uip]) && isset( $result[$uim]['appears'] ) && $result[$uip]['appears'] == 1)
255
+ $mark_spam_ip = true;
256
+
257
+ if(isset($result[$uim]) && isset( $result[$uim]['appears'] ) && $result[$uim]['appears'] == 1)
258
+ $mark_spam_email = true;
259
+
260
+ if ($mark_spam_ip || $mark_spam_email){
261
+ $check_result['spam']++;
262
+ update_comment_meta($c[$i]->comment_ID,'ct_marked_as_spam','1');
263
+ }
264
+ }
265
+ print json_encode($check_result);
266
+
267
+ }else{
268
+ $check_result['error'] = 1;
269
+ $check_result['error_message'] = $result['error'];
270
+ echo json_encode($check_result);
271
+ }
272
+ }else{
273
+
274
+ $check_result['end'] = 1;
275
+
276
+ $log_data = static::get_log_data();
277
+ static::writeSpamLog( 'comments', date("Y-m-d H:i:s"), $log_data['checked'], $log_data['spam'], $log_data['bad'] );
278
+
279
+ print json_encode($check_result);
280
+
281
+ }
282
+
283
+ die;
284
+ }
285
+
286
+ public static function ct_ajax_info($direct_call = false){
287
+
288
+ if (!$direct_call)
289
+ check_ajax_referer( 'ct_secret_nonce', 'security' );
290
+
291
+ // Checked comments
292
+ $params_checked = array(
293
+ 'meta_key' => 'ct_checked_now',
294
+ 'orderby' => 'ct_checked_now'
295
+ );
296
+ $checked_comments = new \WP_Comment_Query($params_checked);
297
+ $cnt_checked = count( $checked_comments->get_comments() );
298
+
299
+ // Spam comments
300
+ $params_spam = array(
301
+ 'meta_query' => array(
302
+ 'relation' => 'AND',
303
+ array(
304
+ 'key' => 'ct_marked_as_spam',
305
+ 'compare' => 'EXISTS'
306
+ ),
307
+ array(
308
+ 'key' => 'ct_checked_now',
309
+ 'compare' => 'EXISTS'
310
+ ),
311
+ ),
312
+ );
313
+ $spam_comments = new \WP_Comment_Query($params_spam);
314
+ $cnt_spam = count( $spam_comments->get_comments() );
315
+
316
+ // Bad comments (without IP and Email)
317
+ $params_bad = array(
318
+ 'meta_query' => array(
319
+ 'relation' => 'AND',
320
+ array(
321
+ 'key' => 'ct_bad',
322
+ 'compare' => 'EXISTS'
323
+ ),
324
+ array(
325
+ 'key' => 'ct_checked_now',
326
+ 'compare' => 'EXISTS'
327
+ ),
328
+ ),
329
+ );
330
+ $bad_comments = new \WP_Comment_Query($params_bad);
331
+ $cnt_bad = count( $bad_comments->get_comments() );
332
+
333
+ $return = array(
334
+ 'message' => '',
335
+ 'spam' => $cnt_spam,
336
+ 'checked' => $cnt_checked,
337
+ 'bad' => $cnt_bad,
338
+ );
339
+
340
+ if( ! $direct_call ) {
341
+ $return['message'] .= sprintf (
342
+ esc_html__('Checked %s, found %s spam comments and %s bad comments (without IP or email)', 'cleantalk-spam-protect'),
343
+ $cnt_checked,
344
+ $cnt_spam,
345
+ $cnt_bad
346
+ );
347
+ } else {
348
+
349
+ global $wpdb;
350
+
351
+ $query = "SELECT * FROM " . APBCT_SPAMSCAN_LOGS . " WHERE scan_type = 'comments' ORDER BY start_time DESC";
352
+ $res = $wpdb->get_row( $query, ARRAY_A );
353
+
354
+ if ( $res ) {
355
+
356
+ $return['message'] .= sprintf (
357
+ __("Last check %s: checked %s comments, found %s spam comments and %s bad comments (without IP or email).", 'cleantalk-spam-protect'),
358
+ self::lastCheckDate(),
359
+ $cnt_checked,
360
+ $cnt_spam,
361
+ $cnt_bad
362
+ );
363
+
364
+ } else {
365
+ // Never checked
366
+ $return['message'] = esc_html__( 'Never checked yet or no new spam.', 'cleantalk-spam-protect');
367
+ }
368
+
369
+ }
370
+
371
+ $backup_notice = '&nbsp;';
372
+ if ($cnt_spam > 0){
373
+ $backup_notice = __("Please do backup of WordPress database before delete any comments!", 'cleantalk-spam-protect');
374
+ }
375
+ $return['message'] .= "<p>$backup_notice</p>";
376
+
377
+ if($direct_call){
378
+ return $return['message'];
379
+ }else{
380
+ echo json_encode($return);
381
+ die();
382
+ }
383
+
384
+ }
385
+
386
+ public static function ct_ajax_clear_comments(){
387
+
388
+ check_ajax_referer( 'ct_secret_nonce', 'security' );
389
+
390
+ global $wpdb;
391
+ $wpdb->query("DELETE FROM {$wpdb->commentmeta} WHERE meta_key IN ('ct_checked_now')");
392
+
393
+ if ( isset($_POST['from']) && isset($_POST['till']) ) {
394
+ if ( preg_match('/[a-zA-Z]{3}\s{1}\d{1,2}\s{1}\d{4}/', $_POST['from'] ) && preg_match('/[a-zA-Z]{3}\s{1}\d{1,2}\s{1}\d{4}/', $_POST['till'] ) ) {
395
+
396
+ $from = date('Y-m-d', intval(strtotime($_POST['from']))) . ' 00:00:00';
397
+ $till = date('Y-m-d', intval(strtotime($_POST['till']))) . ' 23:59:59';
398
+
399
+ $wpdb->query("DELETE FROM {$wpdb->commentmeta} WHERE
400
+ meta_key IN ('ct_checked','ct_marked_as_spam','ct_bad')
401
+ AND meta_value >= '{$from}'
402
+ AND meta_value <= '{$till}';");
403
+ die();
404
+
405
+ } else {
406
+ $wpdb->query("DELETE FROM {$wpdb->commentmeta} WHERE
407
+ meta_key IN ('ct_checked','ct_marked_as_spam','ct_bad')");
408
+ die();
409
+ }
410
+ }
411
+
412
+ }
413
+
414
+ private static function get_log_data() {
415
+
416
+ // Checked users
417
+ $params_spam = array(
418
+ 'meta_key' => 'ct_checked_now',
419
+ );
420
+ $spam_comments = new \WP_Comment_Query($params_spam);
421
+ $cnt_checked = count( $spam_comments->get_comments() );
422
+
423
+ // Spam users
424
+ $params_spam = array(
425
+ 'meta_query' => array(
426
+ 'relation' => 'AND',
427
+ array(
428
+ 'key' => 'ct_marked_as_spam',
429
+ 'compare' => 'EXISTS'
430
+ ),
431
+ array(
432
+ 'key' => 'ct_checked_now',
433
+ 'compare' => 'EXISTS'
434
+ ),
435
+ ),
436
+ );
437
+ $spam_comments = new \WP_Comment_Query($params_spam);
438
+ $cnt_spam = count( $spam_comments->get_comments() );
439
+
440
+ // Bad users (without IP and Email)
441
+ $params_bad = array(
442
+ 'meta_query' => array(
443
+ 'relation' => 'AND',
444
+ array(
445
+ 'key' => 'ct_bad',
446
+ 'compare' => 'EXISTS'
447
+ ),
448
+ array(
449
+ 'key' => 'ct_checked_now',
450
+ 'compare' => 'EXISTS'
451
+ ),
452
+ ),
453
+ );
454
+ $spam_comments = new \WP_Comment_Query($params_bad);
455
+ $cnt_bad = count( $spam_comments->get_comments() );
456
+
457
+ return array(
458
+ 'spam' => $cnt_spam,
459
+ 'checked' => $cnt_checked,
460
+ 'bad' => $cnt_bad,
461
+ );
462
+
463
+ }
464
+
465
+ public static function ct_ajax_trash_all(){
466
+
467
+ check_ajax_referer( 'ct_secret_nonce', 'security' );
468
+
469
+ $args_spam = array(
470
+ 'number'=>100,
471
+ 'meta_query' => array(
472
+ array(
473
+ 'key' => 'ct_marked_as_spam',
474
+ 'value' => '1',
475
+ 'compare' => 'NUMERIC'
476
+ )
477
+ )
478
+ );
479
+ $c_spam = get_comments( $args_spam );
480
+
481
+ $args_spam = array(
482
+ 'count'=>true,
483
+ 'meta_query' => array(
484
+ Array(
485
+ 'key' => 'ct_marked_as_spam',
486
+ 'value' => '1',
487
+ 'compare' => 'NUMERIC'
488
+ )
489
+ )
490
+ );
491
+ $cnt_all = get_comments($args_spam);
492
+
493
+ for( $i=0; $i < sizeof( $c_spam ); $i++ ){
494
+ wp_trash_comment( $c_spam[$i]->comment_ID );
495
+ usleep(10000);
496
+ }
497
+ print $cnt_all;
498
+ die();
499
+ }
500
+
501
+ public static function ct_ajax_spam_all(){
502
+
503
+ check_ajax_referer( 'ct_secret_nonce', 'security' );
504
+
505
+ $args_spam = array(
506
+ 'number'=>100,
507
+ 'meta_query' => array(
508
+ array(
509
+ 'key' => 'ct_marked_as_spam',
510
+ 'value' => '1',
511
+ 'compare' => 'NUMERIC'
512
+ )
513
+ )
514
+ );
515
+ $c_spam = get_comments( $args_spam );
516
+
517
+ $args_spam = array(
518
+ 'count'=>true,
519
+ 'meta_query' => array(
520
+ Array(
521
+ 'key' => 'ct_marked_as_spam',
522
+ 'value' => '1',
523
+ 'compare' => 'NUMERIC'
524
+ )
525
+ )
526
+ );
527
+ $cnt_all = get_comments($args_spam);
528
+
529
+ for( $i=0; $i < sizeof( $c_spam ); $i++ ){
530
+ wp_spam_comment( $c_spam[$i]->comment_ID );
531
+ usleep(10000);
532
+ }
533
+ print $cnt_all;
534
+ die();
535
+ }
536
+
537
  }
lib/Cleantalk/ApbctWP/Firewall/AntiCrawler.php CHANGED
@@ -202,6 +202,9 @@ class AntiCrawler extends \Cleantalk\Common\Firewall\FirewallModule{
202
  if( Cookie::get( 'apbct_anticrawler_passed' ) == 1 ){
203
  if( ! headers_sent() )
204
  \Cleantalk\Common\Helper::apbct_cookie__set( 'apbct_anticrawler_passed', '0', time() - 86400, '/', null, false, true, 'Lax' );
 
 
 
205
  }
206
 
207
  $results[] = array( 'ip' => $current_ip, 'is_personal' => false, 'status' => 'PASS_ANTICRAWLER', );
@@ -295,8 +298,13 @@ class AntiCrawler extends \Cleantalk\Common\Firewall\FirewallModule{
295
  * @param $status
296
  */
297
  public function update_log( $ip, $status ) {
298
-
299
- $id = md5( $ip . $status . $this->module_name );
 
 
 
 
 
300
  $time = time();
301
 
302
  $query = "INSERT INTO " . $this->db__table__logs . "
@@ -305,12 +313,13 @@ class AntiCrawler extends \Cleantalk\Common\Firewall\FirewallModule{
305
  ip = '$ip',
306
  status = '$status',
307
  all_entries = 1,
308
- blocked_entries = 1,
309
  entries_timestamp = '" . intval( $time ) . "',
310
  ua_id = " . $this->ua_id . ",
311
  ua_name = '" . Server::get('HTTP_USER_AGENT') . "'
312
  ON DUPLICATE KEY
313
  UPDATE
 
314
  all_entries = all_entries + 1,
315
  blocked_entries = blocked_entries" . ( strpos( $status, 'DENY' ) !== false ? ' + 1' : '' ) . ",
316
  entries_timestamp = '" . intval( $time ) . "',
202
  if( Cookie::get( 'apbct_anticrawler_passed' ) == 1 ){
203
  if( ! headers_sent() )
204
  \Cleantalk\Common\Helper::apbct_cookie__set( 'apbct_anticrawler_passed', '0', time() - 86400, '/', null, false, true, 'Lax' );
205
+
206
+ // Do logging an one passed request
207
+ $this->update_log( $current_ip, 'PASS_ANTICRAWLER' );
208
  }
209
 
210
  $results[] = array( 'ip' => $current_ip, 'is_personal' => false, 'status' => 'PASS_ANTICRAWLER', );
298
  * @param $status
299
  */
300
  public function update_log( $ip, $status ) {
301
+
302
+ if( strpos( '_UA', $status ) !== false ) {
303
+ $id_str = $ip . $this->module_name . '_UA';
304
+ } else {
305
+ $id_str = $ip . $this->module_name;
306
+ }
307
+ $id = md5( $id_str );
308
  $time = time();
309
 
310
  $query = "INSERT INTO " . $this->db__table__logs . "
313
  ip = '$ip',
314
  status = '$status',
315
  all_entries = 1,
316
+ blocked_entries = " . ( strpos( $status, 'DENY' ) !== false ? 1 : 0 ) . ",
317
  entries_timestamp = '" . intval( $time ) . "',
318
  ua_id = " . $this->ua_id . ",
319
  ua_name = '" . Server::get('HTTP_USER_AGENT') . "'
320
  ON DUPLICATE KEY
321
  UPDATE
322
+ status = '$status',
323
  all_entries = all_entries + 1,
324
  blocked_entries = blocked_entries" . ( strpos( $status, 'DENY' ) !== false ? ' + 1' : '' ) . ",
325
  entries_timestamp = '" . intval( $time ) . "',
lib/Cleantalk/ApbctWP/Firewall/AntiFlood.php CHANGED
@@ -1,216 +1,219 @@
1
- <?php
2
-
3
- namespace Cleantalk\ApbctWP\Firewall;
4
-
5
- use Cleantalk\Common\Helper as Helper;
6
- use Cleantalk\Variables\Cookie;
7
- use Cleantalk\Variables\Server;
8
-
9
- class AntiFlood extends \Cleantalk\Common\Firewall\FirewallModule{
10
-
11
- public $module_name = 'ANTIFLOOD';
12
-
13
- private $db__table__ac_logs;
14
-
15
- private $api_key = '';
16
- private $view_limit = 10;
17
- private $apbct = array();
18
- private $store_interval = 60;
19
- private $block_period = 30;
20
- private $chance_to_clean = 20;
21
-
22
- public $isExcluded = false;
23
-
24
- /**
25
- * AntiCrawler constructor.
26
- *
27
- * @param $log_table
28
- * @param $ac_logs_table
29
- * @param array $params
30
- */
31
- public function __construct( $log_table, $ac_logs_table, $params = array() ) {
32
-
33
- $this->db__table__logs = $log_table ?: null;
34
- $this->db__table__ac_logs = $ac_logs_table ?: null;
35
-
36
- foreach( $params as $param_name => $param ){
37
- $this->$param_name = isset( $this->$param_name ) ? $param : false;
38
- }
39
-
40
- $this->isExcluded = $this->check_exclusions();
41
- }
42
-
43
- /**
44
- * Use this method to execute main logic of the module.
45
- * @return array
46
- */
47
- public function check() {
48
-
49
- $results = array();
50
-
51
- $this->clear_table();
52
-
53
- $time = time() - $this->store_interval;
54
-
55
- foreach( $this->ip_array as $ip_origin => $current_ip ){
56
-
57
- // Passed
58
- if( Cookie::get( 'apbct_antiflood_passed' ) === md5( $current_ip . $this->api_key ) ){
59
-
60
- if( ! headers_sent() ){
61
- \Cleantalk\Common\Helper::apbct_cookie__set( 'apbct_antiflood_passed', '0', time() - 86400, '/', null, false, true, 'Lax' );
62
- }
63
-
64
- $results[] = array( 'ip' => $current_ip, 'is_personal' => false, 'status' => 'PASS_ANTIFLOOD', );
65
-
66
- return $results;
67
- }
68
-
69
-
70
- // @todo Rename ip column to sign. Use IP + UserAgent for it.
71
-
72
- $result = $this->db->fetch_all(
73
- "SELECT SUM(entries) as total_count"
74
- . ' FROM `' . $this->db__table__ac_logs . '`'
75
- . " WHERE ip = '$current_ip' AND interval_start > '$time';"
76
- );
77
-
78
- if( ! empty( $result ) && isset( $result[0]['total_count'] ) && $result[0]['total_count'] >= $this->view_limit ){
79
- $results[] = array( 'ip' => $current_ip, 'is_personal' => false, 'status' => 'DENY_ANTIFLOOD', );
80
- }
81
- }
82
-
83
- if( ! empty( $results ) ){
84
- // Do block page
85
- return $results;
86
- } else{
87
- // Do logging entries
88
- $this->update_ac_log();
89
- }
90
-
91
- return $results;
92
-
93
- }
94
-
95
- private function update_ac_log() {
96
-
97
- $interval_time = Helper::time__get_interval_start( $this->store_interval );
98
-
99
- // @todo Rename ip column to sign. Use IP + UserAgent for it.
100
-
101
- foreach( $this->ip_array as $ip_origin => $current_ip ){
102
- $id = md5( $current_ip . $interval_time );
103
- $this->db->execute(
104
- "INSERT INTO " . $this->db__table__ac_logs . " SET
105
- id = '$id',
106
- ip = '$current_ip',
107
- entries = 1,
108
- interval_start = $interval_time
109
- ON DUPLICATE KEY UPDATE
110
- ip = ip,
111
- entries = entries + 1,
112
- interval_start = $interval_time;"
113
- );
114
- }
115
-
116
- }
117
-
118
- public function clear_table() {
119
-
120
- if( rand( 0, 100 ) < $this->chance_to_clean ){
121
- $interval_start = \Cleantalk\ApbctWP\Helper::time__get_interval_start( $this->store_interval );
122
- $this->db->execute(
123
- 'DELETE
124
- FROM ' . $this->db__table__ac_logs . '
125
- WHERE interval_start < '. $interval_start .'
126
- LIMIT 100000;'
127
- );
128
- }
129
- }
130
-
131
- /**
132
- * Add entry to SFW log.
133
- * Writes to database.
134
- *
135
- * @param string $ip
136
- * @param $status
137
- */
138
- public function update_log( $ip, $status ) {
139
-
140
- $id = md5( $ip . $this->module_name );
141
- $time = time();
142
-
143
- $query = "INSERT INTO " . $this->db__table__logs . "
144
- SET
145
- id = '$id',
146
- ip = '$ip',
147
- status = '$status',
148
- all_entries = 1,
149
- blocked_entries = 1,
150
- entries_timestamp = '" . intval( $time ) . "',
151
- ua_name = '" . Server::get('HTTP_USER_AGENT') . "'
152
- ON DUPLICATE KEY
153
- UPDATE
154
- status = '$status',
155
- all_entries = all_entries + 1,
156
- blocked_entries = blocked_entries" . ( strpos( $status, 'DENY' ) !== false ? ' + 1' : '' ) . ",
157
- entries_timestamp = '" . intval( $time ) . "',
158
- ua_name = '" . Server::get('HTTP_USER_AGENT') . "'";
159
-
160
- $this->db->execute( $query );
161
- }
162
-
163
- public function _die( $result ) {
164
-
165
- parent::_die( $result );
166
-
167
- // File exists?
168
- if( file_exists( CLEANTALK_PLUGIN_DIR . 'lib/Cleantalk/ApbctWP/Firewall/die_page_antiflood.html' ) ){
169
-
170
- $sfw_die_page = file_get_contents( CLEANTALK_PLUGIN_DIR . 'lib/Cleantalk/ApbctWP/Firewall/die_page_antiflood.html' );
171
-
172
- // Translation
173
- $replaces = array(
174
- '{SFW_DIE_NOTICE_IP}' => __( 'Anti-Flood is activated for your IP', 'cleantalk-spam-protect' ),
175
- '{SFW_DIE_MAKE_SURE_JS_ENABLED}' => __( 'To continue working with the web site, please make sure that you have enabled JavaScript.', 'cleantalk-spam-protect' ),
176
- '{SFW_DIE_YOU_WILL_BE_REDIRECTED}' => sprintf( __( 'You will be automatically redirected to the requested page after %d seconds.', 'cleantalk-spam-protect' ), 30 ),
177
- '{CLEANTALK_TITLE}' => __( 'Antispam by CleanTalk', 'cleantalk-spam-protect' ),
178
- '{REMOTE_ADDRESS}' => $result['ip'],
179
- '{REQUEST_URI}' => Server::get( 'REQUEST_URI' ),
180
- '{SERVICE_ID}' => $this->apbct->data['service_id'],
181
- '{HOST}' => Server::get( 'HTTP_HOST' ),
182
- '{GENERATED}' => '<p>The page was generated at&nbsp;' . date( 'D, d M Y H:i:s' ) . "</p>",
183
- '{COOKIE_ANTIFLOOD_PASSED}' => md5( $this->api_key . $result['ip'] ),
184
- );
185
-
186
- foreach( $replaces as $place_holder => $replace ){
187
- $sfw_die_page = str_replace( $place_holder, $replace, $sfw_die_page );
188
- }
189
-
190
- wp_die( $sfw_die_page, 'Blacklisted', array( 'response' => 403 ) );
191
-
192
- } else{
193
- wp_die( "IP BLACKLISTED. Blocked by AntiFlood " . $result['ip'], 'Blacklisted', array( 'response' => 403 ) );
194
- }
195
-
196
- }
197
-
198
- private function check_exclusions() {
199
-
200
- $allowed_roles = array( 'administrator', 'editor' );
201
- $user = apbct_wp_get_current_user();
202
-
203
- if( ! $user ) {
204
- return false;
205
- }
206
-
207
- foreach( $allowed_roles as $role ) {
208
- if( in_array( $role, (array) $user->roles ) ) {
209
- return true;
210
- }
211
- }
212
-
213
- return false;
214
-
215
- }
 
 
 
216
  }
1
+ <?php
2
+
3
+ namespace Cleantalk\ApbctWP\Firewall;
4
+
5
+ use Cleantalk\Common\Helper as Helper;
6
+ use Cleantalk\Variables\Cookie;
7
+ use Cleantalk\Variables\Server;
8
+
9
+ class AntiFlood extends \Cleantalk\Common\Firewall\FirewallModule{
10
+
11
+ public $module_name = 'ANTIFLOOD';
12
+
13
+ private $db__table__ac_logs;
14
+
15
+ private $api_key = '';
16
+ private $view_limit = 10;
17
+ private $apbct = array();
18
+ private $store_interval = 60;
19
+ private $block_period = 30;
20
+ private $chance_to_clean = 20;
21
+
22
+ public $isExcluded = false;
23
+
24
+ /**
25
+ * AntiCrawler constructor.
26
+ *
27
+ * @param $log_table
28
+ * @param $ac_logs_table
29
+ * @param array $params
30
+ */
31
+ public function __construct( $log_table, $ac_logs_table, $params = array() ) {
32
+
33
+ $this->db__table__logs = $log_table ?: null;
34
+ $this->db__table__ac_logs = $ac_logs_table ?: null;
35
+
36
+ foreach( $params as $param_name => $param ){
37
+ $this->$param_name = isset( $this->$param_name ) ? $param : false;
38
+ }
39
+
40
+ $this->isExcluded = $this->check_exclusions();
41
+ }
42
+
43
+ /**
44
+ * Use this method to execute main logic of the module.
45
+ * @return array
46
+ */
47
+ public function check() {
48
+
49
+ $results = array();
50
+
51
+ $this->clear_table();
52
+
53
+ $time = time() - $this->store_interval;
54
+
55
+ foreach( $this->ip_array as $ip_origin => $current_ip ){
56
+
57
+ // Passed
58
+ if( Cookie::get( 'apbct_antiflood_passed' ) === md5( $current_ip . $this->api_key ) ){
59
+
60
+ if( ! headers_sent() ){
61
+ \Cleantalk\Common\Helper::apbct_cookie__set( 'apbct_antiflood_passed', '0', time() - 86400, '/', null, false, true, 'Lax' );
62
+ }
63
+
64
+ // Do logging an one passed request
65
+ $this->update_log( $current_ip, 'PASS_ANTIFLOOD' );
66
+
67
+ $results[] = array( 'ip' => $current_ip, 'is_personal' => false, 'status' => 'PASS_ANTIFLOOD', );
68
+
69
+ return $results;
70
+ }
71
+
72
+
73
+ // @todo Rename ip column to sign. Use IP + UserAgent for it.
74
+
75
+ $result = $this->db->fetch_all(
76
+ "SELECT SUM(entries) as total_count"
77
+ . ' FROM `' . $this->db__table__ac_logs . '`'
78
+ . " WHERE ip = '$current_ip' AND interval_start > '$time';"
79
+ );
80
+
81
+ if( ! empty( $result ) && isset( $result[0]['total_count'] ) && $result[0]['total_count'] >= $this->view_limit ){
82
+ $results[] = array( 'ip' => $current_ip, 'is_personal' => false, 'status' => 'DENY_ANTIFLOOD', );
83
+ }
84
+ }
85
+
86
+ if( ! empty( $results ) ){
87
+ // Do block page
88
+ return $results;
89
+ } else{
90
+ // Do logging entries
91
+ $this->update_ac_log();
92
+ }
93
+
94
+ return $results;
95
+
96
+ }
97
+
98
+ private function update_ac_log() {
99
+
100
+ $interval_time = Helper::time__get_interval_start( $this->store_interval );
101
+
102
+ // @todo Rename ip column to sign. Use IP + UserAgent for it.
103
+
104
+ foreach( $this->ip_array as $ip_origin => $current_ip ){
105
+ $id = md5( $current_ip . $interval_time );
106
+ $this->db->execute(
107
+ "INSERT INTO " . $this->db__table__ac_logs . " SET
108
+ id = '$id',
109
+ ip = '$current_ip',
110
+ entries = 1,
111
+ interval_start = $interval_time
112
+ ON DUPLICATE KEY UPDATE
113
+ ip = ip,
114
+ entries = entries + 1,
115
+ interval_start = $interval_time;"
116
+ );
117
+ }
118
+
119
+ }
120
+
121
+ public function clear_table() {
122
+
123
+ if( rand( 0, 100 ) < $this->chance_to_clean ){
124
+ $interval_start = \Cleantalk\ApbctWP\Helper::time__get_interval_start( $this->store_interval );
125
+ $this->db->execute(
126
+ 'DELETE
127
+ FROM ' . $this->db__table__ac_logs . '
128
+ WHERE interval_start < '. $interval_start .'
129
+ LIMIT 100000;'
130
+ );
131
+ }
132
+ }
133
+
134
+ /**
135
+ * Add entry to SFW log.
136
+ * Writes to database.
137
+ *
138
+ * @param string $ip
139
+ * @param $status
140
+ */
141
+ public function update_log( $ip, $status ) {
142
+
143
+ $id = md5( $ip . $this->module_name );
144
+ $time = time();
145
+
146
+ $query = "INSERT INTO " . $this->db__table__logs . "
147
+ SET
148
+ id = '$id',
149
+ ip = '$ip',
150
+ status = '$status',
151
+ all_entries = 1,
152
+ blocked_entries = " . ( strpos( $status, 'DENY' ) !== false ? 1 : 0 ) . ",
153
+ entries_timestamp = '" . intval( $time ) . "',
154
+ ua_name = '" . Server::get('HTTP_USER_AGENT') . "'
155
+ ON DUPLICATE KEY
156
+ UPDATE
157
+ status = '$status',
158
+ all_entries = all_entries + 1,
159
+ blocked_entries = blocked_entries" . ( strpos( $status, 'DENY' ) !== false ? ' + 1' : '' ) . ",
160
+ entries_timestamp = '" . intval( $time ) . "',
161
+ ua_name = '" . Server::get('HTTP_USER_AGENT') . "'";
162
+
163
+ $this->db->execute( $query );
164
+ }
165
+
166
+ public function _die( $result ) {
167
+
168
+ parent::_die( $result );
169
+
170
+ // File exists?
171
+ if( file_exists( CLEANTALK_PLUGIN_DIR . 'lib/Cleantalk/ApbctWP/Firewall/die_page_antiflood.html' ) ){
172
+
173
+ $sfw_die_page = file_get_contents( CLEANTALK_PLUGIN_DIR . 'lib/Cleantalk/ApbctWP/Firewall/die_page_antiflood.html' );
174
+
175
+ // Translation
176
+ $replaces = array(
177
+ '{SFW_DIE_NOTICE_IP}' => __( 'Anti-Flood is activated for your IP', 'cleantalk-spam-protect' ),
178
+ '{SFW_DIE_MAKE_SURE_JS_ENABLED}' => __( 'To continue working with the web site, please make sure that you have enabled JavaScript.', 'cleantalk-spam-protect' ),
179
+ '{SFW_DIE_YOU_WILL_BE_REDIRECTED}' => sprintf( __( 'You will be automatically redirected to the requested page after %d seconds.', 'cleantalk-spam-protect' ), 30 ),
180
+ '{CLEANTALK_TITLE}' => __( 'Antispam by CleanTalk', 'cleantalk-spam-protect' ),
181
+ '{REMOTE_ADDRESS}' => $result['ip'],
182
+ '{REQUEST_URI}' => Server::get( 'REQUEST_URI' ),
183
+ '{SERVICE_ID}' => $this->apbct->data['service_id'],
184
+ '{HOST}' => Server::get( 'HTTP_HOST' ),
185
+ '{GENERATED}' => '<p>The page was generated at&nbsp;' . date( 'D, d M Y H:i:s' ) . "</p>",
186
+ '{COOKIE_ANTIFLOOD_PASSED}' => md5( $this->api_key . $result['ip'] ),
187
+ );
188
+
189
+ foreach( $replaces as $place_holder => $replace ){
190
+ $sfw_die_page = str_replace( $place_holder, $replace, $sfw_die_page );
191
+ }
192
+
193
+ wp_die( $sfw_die_page, 'Blacklisted', array( 'response' => 403 ) );
194
+
195
+ } else{
196
+ wp_die( "IP BLACKLISTED. Blocked by AntiFlood " . $result['ip'], 'Blacklisted', array( 'response' => 403 ) );
197
+ }
198
+
199
+ }
200
+
201
+ private function check_exclusions() {
202
+
203
+ $allowed_roles = array( 'administrator', 'editor' );
204
+ $user = apbct_wp_get_current_user();
205
+
206
+ if( ! $user ) {
207
+ return false;
208
+ }
209
+
210
+ foreach( $allowed_roles as $role ) {
211
+ if( in_array( $role, (array) $user->roles ) ) {
212
+ return true;
213
+ }
214
+ }
215
+
216
+ return false;
217
+
218
+ }
219
  }
lib/Cleantalk/ApbctWP/Firewall/SFW.php CHANGED
@@ -85,12 +85,13 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule {
85
 
86
  if( ! headers_sent() ){
87
  \Cleantalk\Common\Helper::apbct_cookie__set( 'ct_sfw_passed', '0', time() + 86400 * 3, '/', null, false, true, 'Lax' );
88
- }
89
-
90
- else {
91
  $results[] = array( 'ip' => $current_ip, 'is_personal' => false, 'status' => 'PASS_SFW__BY_COOKIE', );
92
  }
93
 
 
 
 
94
  if( $this->sfw_counter ){
95
  $this->apbct->data['sfw_counter']['all'] ++;
96
  $this->apbct->saveData();
@@ -156,10 +157,6 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule {
156
  * @param $status
157
  */
158
  public function update_log( $ip, $status ) {
159
-
160
- if( in_array( $status, array( 'PASS_SFW__BY_WHITELIST', 'PASS_SFW', 'PASS_ANTIFLOOD', 'PASS_ANTICRAWLER' ) ) ){
161
- return;
162
- }
163
 
164
  $id = md5( $ip . $this->module_name );
165
  $time = time();
@@ -170,7 +167,7 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule {
170
  ip = '$ip',
171
  status = '$status',
172
  all_entries = 1,
173
- blocked_entries = 1,
174
  entries_timestamp = '" . $time . "',
175
  ua_name = '" . Server::get('HTTP_USER_AGENT') . "'
176
  ON DUPLICATE KEY
@@ -323,22 +320,18 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule {
323
  $value['status'] = $value['status'] === 'PASS_ANTIFLOOD' ? 'FLOOD_PROTECTION' : $value['status'];
324
 
325
  $value['status'] = $value['status'] === 'PASS_SFW__BY_COOKIE' ? null : $value['status'];
 
326
  $value['status'] = $value['status'] === 'DENY_SFW' ? null : $value['status'];
327
-
328
- $row = array(
329
- trim( $value['ip'] ),
330
- $value['all_entries'],
331
- $value['all_entries'] - $value['blocked_entries'],
332
- $value['entries_timestamp'],
333
- );
334
-
335
- if( $value['status'] )
336
- $row[] = $value['status'];
337
 
338
- $row[] = $value['ua_name']; // User-Agent name
339
- $row[] = $value['ua_id']; // User-Agent ID
340
-
341
- $data[] = $row;
 
 
 
 
 
342
 
343
  }
344
  unset( $key, $value );
@@ -437,7 +430,7 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule {
437
  'url_count' => count( $lines ),
438
  'current_url' => 0,
439
  // Additional params
440
- 'firewall_updating_id' => $apbct->data['firewall_updating_id'],
441
  ),
442
  $patterns
443
  );
85
 
86
  if( ! headers_sent() ){
87
  \Cleantalk\Common\Helper::apbct_cookie__set( 'ct_sfw_passed', '0', time() + 86400 * 3, '/', null, false, true, 'Lax' );
88
+ } else {
 
 
89
  $results[] = array( 'ip' => $current_ip, 'is_personal' => false, 'status' => 'PASS_SFW__BY_COOKIE', );
90
  }
91
 
92
+ // Do logging an one passed request
93
+ $this->update_log( $current_ip, 'PASS_SFW' );
94
+
95
  if( $this->sfw_counter ){
96
  $this->apbct->data['sfw_counter']['all'] ++;
97
  $this->apbct->saveData();
157
  * @param $status
158
  */
159
  public function update_log( $ip, $status ) {
 
 
 
 
160
 
161
  $id = md5( $ip . $this->module_name );
162
  $time = time();
167
  ip = '$ip',
168
  status = '$status',
169
  all_entries = 1,
170
+ blocked_entries = " . ( strpos( $status, 'DENY' ) !== false ? 1 : 0 ) . ",
171
  entries_timestamp = '" . $time . "',
172
  ua_name = '" . Server::get('HTTP_USER_AGENT') . "'
173
  ON DUPLICATE KEY
320
  $value['status'] = $value['status'] === 'PASS_ANTIFLOOD' ? 'FLOOD_PROTECTION' : $value['status'];
321
 
322
  $value['status'] = $value['status'] === 'PASS_SFW__BY_COOKIE' ? null : $value['status'];
323
+ $value['status'] = $value['status'] === 'PASS_SFW' ? null : $value['status'];
324
  $value['status'] = $value['status'] === 'DENY_SFW' ? null : $value['status'];
 
 
 
 
 
 
 
 
 
 
325
 
326
+ $data[] = array(
327
+ trim( $value['ip'] ), // IP
328
+ $value['blocked_entries'], // Count showing of block pages
329
+ $value['all_entries'] - $value['blocked_entries'], // Count passed requests after block pages
330
+ $value['entries_timestamp'], // Last timestamp
331
+ $value['status'], // Status
332
+ $value['ua_name'], // User-Agent name
333
+ $value['ua_id'], // User-Agent ID
334
+ );
335
 
336
  }
337
  unset( $key, $value );
430
  'url_count' => count( $lines ),
431
  'current_url' => 0,
432
  // Additional params
433
+ 'firewall_updating_id' => $apbct->fw_stats['firewall_updating_id'],
434
  ),
435
  $patterns
436
  );
lib/Cleantalk/ApbctWP/State.php CHANGED
@@ -58,9 +58,9 @@ class State
58
  public $def_settings = array(
59
 
60
  'spam_firewall' => 1,
61
- 'sfw__anti_flood' => 0,
62
  'sfw__anti_flood__view_limit' => 10,
63
- 'sfw__anti_crawler' => 0,
64
  'sfw__anti_crawler_ua' => 1,
65
  'apikey' => '',
66
  'autoPubRevelantMess' => 0,
@@ -202,11 +202,6 @@ class State
202
  'key_is_ok' => 0,
203
  'salt' => '',
204
 
205
- //FireWall
206
- 'firewall_updating_id' => null,
207
- 'firewall_update_percent' => 0,
208
- 'firewall_updating_last_start' => 0,
209
-
210
  );
211
 
212
  public $def_network_settings = array(
@@ -290,6 +285,13 @@ class State
290
  ),
291
  )
292
  );
 
 
 
 
 
 
 
293
 
294
  /**
295
  * @param string $option_prefix Database settings prefix
@@ -341,6 +343,11 @@ class State
341
  if($this->option_prefix.'_'.$option_name === 'cleantalk_stats'){
342
  $option = is_array($option) ? array_merge($this->def_stats, $option) : $this->def_stats;
343
  }
 
 
 
 
 
344
 
345
  $this->$option_name = is_array($option) ? new ArrayObject($option) : $option;
346
  }
58
  public $def_settings = array(
59
 
60
  'spam_firewall' => 1,
61
+ 'sfw__anti_flood' => 1,
62
  'sfw__anti_flood__view_limit' => 10,
63
+ 'sfw__anti_crawler' => 1,
64
  'sfw__anti_crawler_ua' => 1,
65
  'apikey' => '',
66
  'autoPubRevelantMess' => 0,
202
  'key_is_ok' => 0,
203
  'salt' => '',
204
 
 
 
 
 
 
205
  );
206
 
207
  public $def_network_settings = array(
285
  ),
286
  )
287
  );
288
+
289
+ private $default_fw_stats = array(
290
+ 'firewall_updating' => false,
291
+ 'firewall_updating_id' => null,
292
+ 'firewall_update_percent' => 0,
293
+ 'firewall_updating_last_start' => 0,
294
+ );
295
 
296
  /**
297
  * @param string $option_prefix Database settings prefix
343
  if($this->option_prefix.'_'.$option_name === 'cleantalk_stats'){
344
  $option = is_array($option) ? array_merge($this->def_stats, $option) : $this->def_stats;
345
  }
346
+
347
+ // Default statistics
348
+ if($this->option_prefix.'_'.$option_name === 'cleantalk_fw_stats'){
349
+ $option = is_array($option) ? array_merge($this->default_fw_stats, $option) : $this->default_fw_stats;
350
+ }
351
 
352
  $this->$option_name = is_array($option) ? new ArrayObject($option) : $option;
353
  }
lib/Cleantalk/Common/Firewall.php CHANGED
@@ -128,6 +128,9 @@ class Firewall
128
  foreach ( $this->fw_modules as $module ) {
129
  if( array_key_exists( $module->module_name, $results ) ){
130
  foreach ( $results[$module->module_name] as $result ) {
 
 
 
131
  $module->update_log( $result['ip'], $result['status'] );
132
  }
133
  }
128
  foreach ( $this->fw_modules as $module ) {
129
  if( array_key_exists( $module->module_name, $results ) ){
130
  foreach ( $results[$module->module_name] as $result ) {
131
+ if( in_array( $result['status'], array( 'PASS_SFW__BY_WHITELIST', 'PASS_SFW', 'PASS_ANTIFLOOD', 'PASS_ANTICRAWLER', 'PASS_ANTICRAWLER_UA' ) ) ){
132
+ continue;
133
+ }
134
  $module->update_log( $result['ip'], $result['status'] );
135
  }
136
  }
lib/Cleantalk/Common/Helper.php CHANGED
@@ -55,6 +55,7 @@ class Helper
55
  'apix3.cleantalk.org' => '3.18.23.246',
56
  'apix4.cleantalk.org' => '44.227.90.42',
57
  'apix5.cleantalk.org' => '15.188.198.212',
 
58
  //ns
59
  'netserv2.cleantalk.org' => '178.63.60.214',
60
  'netserv3.cleantalk.org' => '188.40.14.173',
55
  'apix3.cleantalk.org' => '3.18.23.246',
56
  'apix4.cleantalk.org' => '44.227.90.42',
57
  'apix5.cleantalk.org' => '15.188.198.212',
58
+ 'apix6.cleantalk.org' => '54.219.94.72',
59
  //ns
60
  'netserv2.cleantalk.org' => '178.63.60.214',
61
  'netserv3.cleantalk.org' => '188.40.14.173',
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: spam, antispam, anti-spam, comments, firewall
4
  Requires at least: 3.0
5
  Tested up to: 5.6
6
  Requires PHP: 5.4
7
- Stable tag: 5.151
8
  License: GPLv2
9
 
10
  Spam protection, anti-spam, firewall, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
@@ -580,6 +580,20 @@ If your website has forms that send data to external sources, you can enable opt
580
 
581
  == Changelog ==
582
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
583
  = 5.151 Dec 17 2020 =
584
  * Mod: Cleantalk Alternative Sessions. Store time reduces to 1 day.
585
  * Fix: Unusable alternative cookies table clearing.
4
  Requires at least: 3.0
5
  Tested up to: 5.6
6
  Requires PHP: 5.4
7
+ Stable tag: 5.151.1
8
  License: GPLv2
9
 
10
  Spam protection, anti-spam, firewall, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
580
 
581
  == Changelog ==
582
 
583
+ = 5.151.1 Dec 22 2020 =
584
+ * Upd: Firewall now has it's own options, independent from the other.
585
+ * Upd: New API server added.
586
+ * Fix: Wrong count of blocked entries fixed
587
+ * Fix: Skip logging for non-blocked requests.
588
+ * Fix: SFW sending logs fixed.
589
+ * Fix: SFW skip Customizer preview requests.
590
+ * Fix: FW do logging an one passed request.
591
+ * Fix: Logging exclusion moved to firewall class.
592
+ * Fix: FW stats option fixed.
593
+ * Upd: New API server added.
594
+ * Fix: SFW logging logic fixed.
595
+ * Fix: SFW sent logs structure fixed.
596
+
597
  = 5.151 Dec 17 2020 =
598
  * Mod: Cleantalk Alternative Sessions. Store time reduces to 1 day.
599
  * Fix: Unusable alternative cookies table clearing.