Spam protection, AntiSpam, FireWall by CleanTalk - Version 5.128.1

Version Description

October 23 2019 = * Fix: Fatal error when using buffer output. * Fix: Translate domain for errors. * Code: Fix spelling in function name. * Fix: JS disabled error. * Upd: Comment edit screen updated. * Fix: Cleantalk\Arr::search() fixed.

Download this release

Release Info

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

Code changes from version 5.128 to 5.128.1

cleantalk.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Anti-Spam by CleanTalk
4
  Plugin URI: http://cleantalk.org
5
  Description: Max power, all-in-one, no Captcha, premium anti-spam plugin. No comment spam, no registration spam, no contact spam, protects any WordPress forms.
6
- Version: 5.128
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: http://cleantalk.org
9
  Text Domain: cleantalk
@@ -137,17 +137,6 @@ if( !defined( 'CLEANTALK_PLUGIN_DIR' ) ){
137
 
138
  }
139
  }
140
-
141
- /*
142
- * New structure
143
- */
144
- require_once( CLEANTALK_PLUGIN_DIR . 'inc/classCleantalkPublic.php' );
145
- add_action( 'init', array( 'classCleantalkPublic', 'init' ) );
146
-
147
- if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
148
- require_once( CLEANTALK_PLUGIN_DIR . 'inc/classCleantalkAdmin.php' );
149
- add_action( 'init', array( 'classCleantalkAdmin', 'init' ) );
150
- }
151
 
152
  //Delete cookie for admin trial notice
153
  add_action('wp_logout', 'apbct__hook__wp_logout__delete_trial_notice_cookie');
3
  Plugin Name: Anti-Spam by CleanTalk
4
  Plugin URI: http://cleantalk.org
5
  Description: Max power, all-in-one, no Captcha, premium anti-spam plugin. No comment spam, no registration spam, no contact spam, protects any WordPress forms.
6
+ Version: 5.128.1
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: http://cleantalk.org
9
  Text Domain: cleantalk
137
 
138
  }
139
  }
 
 
 
 
 
 
 
 
 
 
 
140
 
141
  //Delete cookie for admin trial notice
142
  add_action('wp_logout', 'apbct__hook__wp_logout__delete_trial_notice_cookie');
inc/cleantalk-admin.php CHANGED
@@ -1,722 +1,754 @@
1
- <?php
2
-
3
- require_once('cleantalk-settings.php');
4
-
5
- add_action( 'admin_bar_menu', 'apbct_admin__admin_bar__add', 999 );
6
-
7
- //Adding widjet
8
- function ct_dashboard_statistics_widget() {
9
-
10
- global $apbct;
11
-
12
- if(apbct_is_user_role_in(array('administrator'))){
13
- wp_add_dashboard_widget(
14
- 'ct_dashboard_statistics_widget',
15
- $apbct->plugin_name
16
- ."<div class='ct_widget_top_links'>"
17
- ."<img src='".plugins_url('/cleantalk-spam-protect/inc/images/preloader.gif')."' class='ct_preloader'>"
18
- .sprintf(__("%sRefresh%s", 'cleantalk'), "<a href='#ct_widget' class='ct_widget_refresh_link'>", "</a>")
19
- .sprintf(__("%sConfigure%s", 'cleantalk'), "<a href='{$apbct->settings_link}' class='ct_widget_settings_link'>", "</a>")
20
- ."</div>",
21
- 'ct_dashboard_statistics_widget_output'
22
- );
23
- }
24
- }
25
-
26
- // Outputs statistics widget content
27
- function ct_dashboard_statistics_widget_output( $post, $callback_args ) {
28
-
29
- global $apbct, $current_user;
30
-
31
- echo "<div id='ct_widget_wrapper'>";
32
- ?>
33
- <form id='ct_refresh_form' method='POST' action='#ct_widget'>
34
- <input type='hidden' name='ct_brief_refresh' value='1'>
35
- </form>
36
- <h4 class='ct_widget_block_header' style='margin-left: 12px;'><?php _e('7 days anti-spam stats', 'cleantalk'); ?></h4>
37
- <div class='ct_widget_block ct_widget_chart_wrapper'>
38
- <div id='ct_widget_chart'></div>
39
- </div>
40
- <h4 class='ct_widget_block_header'><?php _e('Top 5 spam IPs blocked', 'cleantalk'); ?></h4>
41
- <hr class='ct_widget_hr'>
42
- <?php
43
- if(!apbct_api_key__is_correct() || (isset($apbct->data['brief_data']['error_no']) && $apbct->data['brief_data']['error_no'] == 6)){
44
- ?> <div class='ct_widget_block'>
45
- <form action='<? echo $apbct->settings_link; ?>' method='POST'>
46
- <h2 class='ct_widget_activate_header'><?php _e('Get Access key to activate Anti-Spam protection!', 'cleantalk'); ?></h2>
47
- <input class='ct_widget_button ct_widget_activate_button' type='submit' name='get_apikey_auto' value='ACTIVATE' />
48
- </form>
49
- </div>
50
- <?php
51
- }elseif(!empty($apbct->data['brief_data']['error'])){
52
- echo '<div class="ct_widget_block">'
53
- .'<h2 class="ct_widget_activate_header">'
54
- .sprintf(__('Something went wrong! Error: "%s".', 'cleantalk'), "<u>{$apbct->brief_data['error']}</u>")
55
- .'</h2>';
56
- if($apbct->user_token && !$apbct->white_label){
57
- echo '<h2 class="ct_widget_activate_header">'
58
- .__('Please, visit your dashboard.', 'cleantalk')
59
- .'</h2>'
60
- .'<a target="_blank" href="https://cleantalk.org/my?user_token='.$apbct->user_token.'&cp_mode=antispam">'
61
- .'<input class="ct_widget_button ct_widget_activate_button ct_widget_resolve_button" type="button" value="VISIT CONTROL PANEL">'
62
- .'</a>';
63
- }
64
- echo '</div>';
65
- }
66
-
67
- if(apbct_api_key__is_correct() && empty($apbct->data['brief_data']['error'])){
68
- ?>
69
- <div class='ct_widget_block'>
70
- <table cellspacing="0">
71
- <tr>
72
- <th><?php _e('IP', 'cleantalk'); ?></th>
73
- <th><?php _e('Country', 'cleantalk'); ?></th>
74
- <th><?php _e('Block Count', 'cleantalk'); ?></th>
75
- </tr>
76
- <?php foreach($apbct->brief_data['top5_spam_ip'] as $val){ ?>
77
- <tr>
78
- <td><?php echo $val[0]; ?></td>
79
- <td><?php echo $val[1] ? "<img src='https://cleantalk.org/images/flags/".strtolower($val[1]).".png'>" : ''; ?>&nbsp;<?php
80
- echo $val[1]
81
- ? locale_get_display_region('sl-Latn-'.$val[1].'-nedis', substr(get_locale(), 0, 2))
82
- : 'Unknown'; ?></td>
83
- <td style='text-align: center;'><?php echo $val[2]; ?></td>
84
- </tr>
85
- <?php } ?>
86
- </table>
87
- <?php if($apbct->user_token){ ?>
88
- <a target='_blank' href='https://cleantalk.org/my?user_token=<?php echo $apbct->user_token; ?>&cp_mode=antispam'>
89
- <input class='ct_widget_button' id='ct_widget_button_view_all' type='button' value='View all'>
90
- </a>
91
- <?php } ?>
92
- </div>
93
-
94
- <?php
95
- }
96
- // Notice at the bottom
97
- if(isset($current_user) && in_array('administrator', $current_user->roles)){
98
-
99
- if($apbct->spam_count && $apbct->spam_count > 0){
100
- echo '<div class="ct_widget_wprapper_total_blocked">'
101
- .'<img src="'.$apbct->logo__small__colored.'" class="ct_widget_small_logo"/>'
102
- .'<span title="'.sprintf(__('This is the count from the %s\'s cloud and could be different to admin bar counters', 'cleantalk').'">', $apbct->plugin_name)
103
- .sprintf(
104
- /* translators: %s: Number of spam messages */
105
- __( '%s%s%s has blocked %s spam for all time. The statistics are automatically updated every 24 hours.', 'cleantalk'),
106
- !$apbct->white_label ? '<a href="https://cleantalk.org/my/?user_token='.$apbct->user_token.'&utm_source=wp-backend&utm_medium=dashboard_widget&cp_mode=antispam" target="_blank">' : '',
107
- $apbct->plugin_name,
108
- !$apbct->white_label ? '</a>' : '',
109
- number_format($apbct->data['spam_count'], 0, ',', ' ')
110
- )
111
- .'</span>'
112
- .(!$apbct->white_label
113
- ? '<br><br>'
114
- .'<b style="font-size: 16px;">'
115
- .sprintf(
116
- __('Do you like CleanTalk? %sPost your feedback here%s.', 'cleantalk'),
117
- '<u><a href="https://wordpress.org/support/plugin/cleantalk-spam-protect/reviews/#new-post" target="_blank">',
118
- '</a></u>'
119
- )
120
- .'</b>'
121
- : ''
122
- )
123
- .'</div>';
124
- }
125
- }
126
- echo '</div>';
127
- }
128
-
129
- /**
130
- * Admin action 'admin_init' - Add the admin settings and such
131
- */
132
- function apbct_admin__init(){
133
-
134
- global $apbct;
135
-
136
- // Getting dashboard widget statistics
137
- if(!empty($_POST['ct_brief_refresh'])){
138
- $apbct->data['brief_data'] = CleantalkAPI::method__get_antispam_report_breif($apbct->api_key);
139
- $apbct->saveData();
140
- }
141
-
142
- // Getting key like hoster. Only once!
143
- if(!is_main_site() && $apbct->white_label && empty($apbct->api_key)){
144
-
145
- $_POST['submit'] = 'get_key_auto';
146
- $settings = apbct_settings__validate(array());
147
- unset($_POST['submit']);
148
-
149
- if(!empty($settings['apikey'])){
150
- $apbct->settings['apikey'] = $settings['apikey'];
151
- $apbct->api_key = $settings['apikey'];
152
- $apbct->saveSettings();
153
- }
154
-
155
- }
156
-
157
- // AJAX actions
158
-
159
- // Settings
160
- add_action('wp_ajax_apbct_settings__get__long_description', 'apbct_settings__get__long_description'); // Long description
161
- }
162
-
163
- /**
164
- * Manage links in plugins list
165
- * @return array
166
- */
167
- function apbct_admin__plugin_action_links($links, $file) {
168
-
169
- global $apbct;
170
-
171
- $settings_link = '<a href="' . $apbct->settings_link . '">' . __( 'Settings' ) . '</a>';
172
-
173
- array_unshift( $links, $settings_link ); // before other links
174
- return $links;
175
- }
176
-
177
- /**
178
- * Manage links and plugins page
179
- * @return array
180
- */
181
- function apbct_admin__register_plugin_links($links, $file){
182
-
183
- global $apbct;
184
-
185
- //Return if it's not our plugin
186
- if ($file != $apbct->base_name)
187
- return $links;
188
-
189
- if($apbct->white_label){
190
- $links = array_slice($links, 0, 1);
191
- $links[] = "<script>jQuery('.plugin-title strong').each(function(i, item){
192
- if(jQuery(item).html() == 'Anti-Spam by CleanTalk')
193
- jQuery(item).html('{$apbct->plugin_name}');
194
- });</script>";
195
- return $links;
196
- }
197
-
198
- if(substr(get_locale(), 0, 2) != 'en')
199
- $links[] = '<a class="ct_meta_links ct_translate_links" href="'
200
- .sprintf('https://translate.wordpress.org/locale/%s/default/wp-plugins/cleantalk-spam-protect', substr(get_locale(), 0, 2))
201
- .'" target="_blank">'
202
- .__('Translate', 'cleantalk')
203
- .'</a>';
204
-
205
- $links[] = '<a class="ct_meta_links" href="'.$apbct->settings_link.'" target="_blank">' . __( 'Start here','cleantalk' ) . '</a>';
206
- $links[] = '<a class="ct_meta_links ct_faq_links" href="http://wordpress.org/plugins/cleantalk-spam-protect/faq/" target="_blank">' . __( 'FAQ','cleantalk' ) . '</a>';
207
- $links[] = '<a class="ct_meta_links ct_support_links"href="https://wordpress.org/support/plugin/cleantalk-spam-protect" target="_blank">' . __( 'Support','cleantalk' ) . '</a>';
208
- $trial = apbct_admin__badge__get_premium(false);
209
- if(!empty($trial))
210
- $links[] = apbct_admin__badge__get_premium(false);
211
-
212
- return $links;
213
- }
214
-
215
- /**
216
- * Admin action 'admin_enqueue_scripts' - Enqueue admin script of reloading admin page after needed AJAX events
217
- * @param string $hook URL of hooked page
218
- */
219
- function apbct_admin__enqueue_scripts($hook){
220
-
221
- global $apbct;
222
-
223
- // Scripts to all admin pages
224
- wp_enqueue_script('ct_admin_js_notices', plugins_url('/cleantalk-spam-protect/js/cleantalk-admin.min.js'), array(), APBCT_VERSION);
225
- wp_enqueue_style ('ct_admin_css', plugins_url('/cleantalk-spam-protect/css/cleantalk-admin.min.css'), array(), APBCT_VERSION, 'all');
226
-
227
- wp_localize_script( 'jquery', 'ctAdminCommon', array(
228
- '_ajax_nonce' => wp_create_nonce( 'ct_secret_nonce' ),
229
- '_ajax_url' => admin_url( 'admin-ajax.php' ),
230
- 'plugin_name' => $apbct->plugin_name,
231
- 'logo' => '<img src="' . $apbct->logo . '" alt="" height="" style="width: 17px; vertical-align: text-bottom;" />',
232
- 'logo_small' => '<img src="' . $apbct->logo__small . '" alt="" height="" style="width: 17px; vertical-align: text-bottom;" />',
233
- 'logo_small_colored' => '<img src="' . $apbct->logo__small__colored . '" alt="" height="" style="width: 17px; vertical-align: text-bottom;" />',
234
- ) );
235
-
236
- // DASHBOARD page JavaScript and CSS
237
- if($hook == 'index.php' && apbct_is_user_role_in(array('administrator'))){
238
-
239
- wp_enqueue_style('ct_admin_css_widget_dashboard', plugins_url('/cleantalk-spam-protect/css/cleantalk-dashboard-widget.min.css'), array(), APBCT_VERSION, 'all');
240
- wp_enqueue_style ('ct_icons', plugins_url('/cleantalk-spam-protect/css/cleantalk-icons.min.css'), array(), APBCT_VERSION, 'all');
241
-
242
- wp_enqueue_script('ct_gstatic_charts_loader', plugins_url('/cleantalk-spam-protect/js/cleantalk-dashboard-widget--google-charts.min.js'), array(), APBCT_VERSION);
243
- wp_enqueue_script('ct_admin_js_widget_dashboard', plugins_url('/cleantalk-spam-protect/js/cleantalk-dashboard-widget.min.js'), array('ct_gstatic_charts_loader'), APBCT_VERSION);
244
-
245
- // Preparing widget data
246
- // Parsing brief data 'spam_stat' {"yyyy-mm-dd": spam_count, "yyyy-mm-dd": spam_count} to [["yyyy-mm-dd", "spam_count"], ["yyyy-mm-dd", "spam_count"]]
247
- $to_chart = array();
248
-
249
- // Crunch. Response contains error.
250
- if(!empty($apbct->data['brief_data']['error']))
251
- $apbct->data['brief_data'] = array_merge($apbct->data['brief_data'], $apbct->def_data['brief_data']);
252
-
253
- foreach( $apbct->data['brief_data']['spam_stat'] as $key => $value ){
254
- $to_chart[] = array( $key, $value );
255
- } unset( $key, $value );
256
-
257
- wp_localize_script( 'jquery', 'apbctDashboardWidget', array(
258
- 'data' => $to_chart,
259
- ));
260
- }
261
-
262
- // SETTINGS's page JavaScript and CSS
263
- if( $hook == 'settings_page_cleantalk' ){
264
-
265
- // jQueryUI
266
- wp_enqueue_script('jqueryui', plugins_url('/cleantalk-spam-protect/js/jquery-ui.min.js'), array('jquery'), '1.12.1' );
267
- wp_enqueue_style('jqueryui_css', plugins_url('/cleantalk-spam-protect/css/jquery-ui.min.css'),array(), '1.21.1', 'all');
268
-
269
- wp_enqueue_script('cleantalk_admin_js_settings_page', plugins_url('/cleantalk-spam-protect/js/cleantalk-admin-settings-page.min.js'), array(), APBCT_VERSION);
270
- wp_enqueue_style('cleantalk_admin_css_settings_page', plugins_url('/cleantalk-spam-protect/css/cleantalk-admin-settings-page.min.css'), array(), APBCT_VERSION, 'all');
271
- wp_enqueue_style ('ct_icons', plugins_url('/cleantalk-spam-protect/css/cleantalk-icons.min.css'), array(), APBCT_VERSION, 'all');
272
-
273
- wp_localize_script( 'jquery', 'ctSettingsPage', array(
274
- 'ct_subtitle' => $apbct->ip_license ? __('Hosting AntiSpam', 'cleantalk') : '',
275
- 'ip_license' => $apbct->ip_license ? true : false,
276
- ));
277
- }
278
-
279
- // COMMENTS's page JavaScript and CSS
280
- if( $hook == 'comments_page_ct_check_spam' || $hook == 'edit-comments.php'){
281
-
282
- // Preparing data
283
- if(!empty($_COOKIE['ct_paused_comments_check']))
284
- $prev_check = json_decode(stripslashes($_COOKIE['ct_paused_comments_check']), true);
285
-
286
- // jQueryUI
287
- wp_enqueue_script('jqueryui', plugins_url('/cleantalk-spam-protect/js/jquery-ui.min.js'), array('jquery'), '1.12.1');
288
- wp_enqueue_style('jqueryui_css', plugins_url('/cleantalk-spam-protect/css/jquery-ui.min.css'),array(), '1.21.1', 'all');
289
-
290
- // CSS
291
- wp_enqueue_style('cleantalk_admin_css_settings_page', plugins_url('/cleantalk-spam-protect/css/cleantalk-spam-check.min.css'), array(), APBCT_VERSION, 'all');
292
-
293
- // CHECK COMMENTS page JavaScript
294
- if($hook == 'comments_page_ct_check_spam'){
295
- wp_enqueue_script('ct_comments_checkspam', plugins_url('/cleantalk-spam-protect/js/cleantalk-comments-checkspam.min.js'), array(), APBCT_VERSION);
296
- wp_localize_script( 'jquery', 'ctCommentsCheck', array(
297
- 'ct_ajax_nonce' => wp_create_nonce('ct_secret_nonce'),
298
- 'ct_prev_accurate' => !empty($prev_check['accurate']) ? true : false,
299
- 'ct_prev_from' => !empty($prev_check['from']) ? $prev_check['from'] : false,
300
- 'ct_prev_till' => !empty($prev_check['till']) ? $prev_check['till'] : false,
301
- 'ct_timeout_confirm' => __('Failed from timeout. Going to check comments again.', 'cleantalk'),
302
- 'ct_comments_added' => __('Added', 'cleantalk'),
303
- 'ct_comments_deleted' => __('Deleted', 'cleantalk'),
304
- 'ct_comments_added_after' => __('comments', 'cleantalk'),
305
- 'ct_confirm_deletion_all' => __('Delete all spam comments?', 'cleantalk'),
306
- 'ct_confirm_deletion_checked' => __('Delete checked comments?', 'cleantalk'),
307
- 'ct_status_string' => __('Total comments %s. Checked %s. Found %s spam comments. %s bad comments (without IP or email).', 'cleantalk'),
308
- 'ct_status_string_warning' => '<p>'.__('Please do backup of WordPress database before delete any accounts!', 'cleantalk').'</p>',
309
- 'start' => !empty($_COOKIE['ct_comments_start_check']) ? true : false,
310
- ));
311
- }
312
-
313
- // COMMENTS page JavaScript
314
- if($hook == 'edit-comments.php'){
315
- wp_enqueue_script('ct_comments_editscreen', plugins_url('/cleantalk-spam-protect/js/cleantalk-comments-editscreen.min.js'), array(), APBCT_VERSION);
316
- wp_localize_script( 'jquery', 'ctCommentsScreen', array(
317
- 'ct_ajax_nonce' => wp_create_nonce('ct_secret_nonce'),
318
- 'spambutton_text' => __("Find spam-comments", 'cleantalk'),
319
- 'ct_feedback_msg_whitelisted' => __("The sender has been whitelisted.", 'cleantalk'),
320
- 'ct_feedback_msg_blacklisted' => __("The sender has been blacklisted.", 'cleantalk'),
321
- 'ct_feedback_msg' => sprintf(__("Feedback has been sent to %sCleanTalk Dashboard%s.", 'cleantalk'), $apbct->user_token ? "<a target='_blank' href=https://cleantalk.org/my?user_token={$apbct->user_token}&cp_mode=antispam>" : '', $apbct->user_token ? "</a>" : ''),
322
- 'ct_show_check_links' => (bool)$apbct->settings['show_check_links'],
323
- 'ct_img_src_new_tab' => plugin_dir_url(__FILE__)."images/new_window.gif",
324
- ));
325
- }
326
- }
327
-
328
- // USERS's page JavaScript and CSS
329
- if( $hook == 'users_page_ct_check_users' || $hook == 'users.php'){
330
-
331
- // Preparing data
332
- $current_user = wp_get_current_user();
333
- if(!empty($_COOKIE['ct_paused_users_check']))
334
- $prev_check = json_decode(stripslashes($_COOKIE['ct_paused_users_check']), true);
335
-
336
- // jQueryUI
337
- wp_enqueue_script('jqueryui', plugins_url('/cleantalk-spam-protect/js/jquery-ui.min.js'), array('jquery'), '1.12.1');
338
- wp_enqueue_style('jqueryui_css', plugins_url('/cleantalk-spam-protect/css/jquery-ui.min.css'),array(), '1.21.1', 'all');
339
-
340
- // CSS
341
- wp_enqueue_style('cleantalk_admin_css_settings_page', plugins_url().'/cleantalk-spam-protect/css/cleantalk-spam-check.min.css', array(), APBCT_VERSION, 'all');
342
-
343
- // CHECK USERS page JavaScript
344
- if($hook == 'users_page_ct_check_users'){
345
- wp_enqueue_script('ct_users_checkspam', plugins_url('/cleantalk-spam-protect/js/cleantalk-users-checkspam.min.js'), array(), APBCT_VERSION);
346
- wp_localize_script( 'jquery', 'ctUsersCheck', array(
347
- 'ct_ajax_nonce' => wp_create_nonce('ct_secret_nonce'),
348
- 'ct_prev_accurate' => !empty($prev_check['accurate']) ? true : false,
349
- 'ct_prev_from' => !empty($prev_check['from']) ? $prev_check['from'] : false,
350
- 'ct_prev_till' => !empty($prev_check['till']) ? $prev_check['till'] : false,
351
- 'ct_timeout' => __('Failed from timeout. Going to check users again.', 'cleantalk'),
352
- 'ct_timeout_delete' => __('Failed from timeout. Going to run a new attempt to delete spam users.', 'cleantalk'),
353
- 'ct_inserted' => __('Inserted', 'cleantalk'),
354
- 'ct_deleted' => __('Deleted', 'cleantalk'),
355
- 'ct_iusers' => __('users.', 'cleantalk'),
356
- 'ct_confirm_deletion_all' => __('Delete all spam users?', 'cleantalk'),
357
- 'ct_confirm_deletion_checked' => __('Delete checked users?', 'cleantalk'),
358
- 'ct_csv_filename' => "user_check_by_".$current_user->user_login,
359
- 'ct_bad_csv' => __("File doesn't exist. File will be generated while checking. Please, press \"Check for spam\"."),
360
- 'ct_status_string' => __("Total users %s, checked %s, found %s spam users and %s bad users (without IP or email)", 'cleantalk'),
361
- 'ct_status_string_warning' => "<p>".__("Please do backup of WordPress database before delete any accounts!", 'cleantalk')."</p>"
362
- ));
363
- }
364
-
365
- // USERS page JavaScript
366
- if($hook == 'users.php'){
367
- wp_enqueue_script('ct_users_editscreen', plugins_url('/cleantalk-spam-protect/js/cleantalk-users-editscreen.min.js'), array(), APBCT_VERSION);
368
- wp_localize_script( 'jquery', 'ctUsersScreen', array(
369
- 'spambutton_text' => __("Find spam-users", 'cleantalk'),
370
- 'ct_show_check_links' => (bool)$apbct->settings['show_check_links'],
371
- 'ct_img_src_new_tab' => plugin_dir_url(__FILE__)."images/new_window.gif"
372
- ));
373
- }
374
-
375
- }
376
- }
377
-
378
- /**
379
- * Notice blog owner if plugin is used without Access key
380
- * @return bool
381
- */
382
- function apbct_admin__notice_message(){
383
-
384
- global $apbct;
385
-
386
- $page = get_current_screen();
387
-
388
- //General notice control flags
389
- $self_owned_key = ($apbct->moderate_ip == 0 && !defined('CLEANTALK_ACCESS_KEY') ? true : false);
390
- $is_dashboard = (is_network_admin() || is_admin() ? true : false);
391
- $is_admin = (current_user_can('activate_plugins') ? true : false);
392
-
393
- $page_is_ct_settings = (in_array($page->id, array('settings_page_cleantalk', 'settings_page_cleantalk-network', 'comments_page_ct_check_spam', 'users_page_ct_check_users')) ? true : false);
394
-
395
- //Misc
396
- $user_token = ($apbct->user_token ? '&user_token='.$apbct->user_token : '');
397
- $settings_link = (is_network_admin() ? 'settings.php?page=cleantalk' : 'options-general.php?page=cleantalk');
398
-
399
- if($self_owned_key && $is_dashboard && $is_admin){
400
- // Auto update notice
401
- /* Disabled at 09.09.2018
402
- if($apbct->notice_auto_update == 1 && $apbct->auto_update != -1 && empty($_COOKIE['apbct_update_banner_closed'])){
403
- $link = '<a href="http://cleantalk.org/help/cleantalk-auto-update" target="_blank">%s</a>';
404
- $button = sprintf($link, '<input type="button" class="button button-primary" value="'.__('Learn more', 'cleantalk').'" />');
405
- echo '<div class="error notice is-dismissible apbct_update_notice">'
406
- .'<h3>'
407
- .__('Do you know that Anti-Spam by CleanTalk has auto update option?', 'cleantalk')
408
- .'</br></br>'
409
- .$button
410
- .'</h3>'
411
- .'</div>';
412
- }
413
- */
414
- //Unable to get key automatically (if apbct_admin__init().getAutoKey() returns error)
415
- if ($apbct->notice_show && !empty($apbct->errors['get_key']) && !$apbct->white_label){
416
- echo '<div class="error">
417
- <h3>' . sprintf(__("Unable to get Access key automatically: %s", 'cleantalk'), $apbct->api_key).
418
- "<a target='__blank' style='margin-left: 10px' href='https://cleantalk.org/register?platform=wordpress&email=" . urlencode(ct_get_admin_email())."&website=" . urlencode(parse_url(get_option('siteurl'),PHP_URL_HOST))."'>".__('Get the Access key', 'cleantalk').'</a>
419
- </h3>
420
- </div>';
421
- }
422
-
423
- //key == "" || "enter key"
424
- if (!apbct_api_key__is_correct() && $apbct->moderate_ip == 0){
425
- echo "<div class='error'>"
426
- ."<h3>"
427
- .sprintf(__("Please enter Access Key in %s settings to enable anti spam protection!", 'cleantalk'), "<a href='{$settings_link}'>CleanTalk plugin</a>")
428
- ."</h3>"
429
- ."</div>";
430
- $apbct->notice_show = false;
431
- }
432
-
433
- //"Trial period ends" notice from apbct_admin__init().api_method__notice_paid_till()
434
- if ($apbct->notice_show && $apbct->notice_trial == 1 && $apbct->moderate_ip == 0 && !$apbct->white_label) {
435
- if(isset($_GET['page']) && in_array($_GET['page'], array('cleantalk', 'ct_check_spam', 'ct_check_users'))){
436
- echo '<div class="error">
437
- <h3>' . sprintf(__("%s trial period ends, please upgrade to %s!", 'cleantalk'),
438
- "<a href='{$settings_link}'>".$apbct->plugin_name."</a>",
439
- "<a href=\"http://cleantalk.org/my/bill/recharge?utm_source=wp-backend&utm_medium=cpc&utm_campaign=WP%20backend%20trial$user_token&cp_mode=antispam\" target=\"_blank\"><b>premium version</b></a>") .
440
- '</h3>
441
- </div>';
442
- $apbct->notice_show = false;
443
- }
444
- }
445
-
446
- //Renew notice from apbct_admin_init().api_method__notice_paid_till()
447
- if ($apbct->notice_show && $apbct->notice_renew == 1 && $apbct->moderate_ip == 0 && !$apbct->white_label) {
448
- $renew_link = "<a href=\"http://cleantalk.org/my/bill/recharge?utm_source=wp-backend&utm_medium=cpc&utm_campaign=WP%%20backend%%20renew$user_token&cp_mode=antispam\" target=\"_blank\">%s</a>";
449
- $button_html = sprintf($renew_link, '<input type="button" class="button button-primary" value="'.__('RENEW ANTI-SPAM', 'cleantalk').'" />');
450
- $link_html = sprintf($renew_link, "<b>".__('next year', 'cleantalk')."</b>");
451
-
452
- echo '<div class="updated">
453
- <h3>'.
454
- sprintf(__("Please renew your anti-spam license for %s.", 'cleantalk'), $link_html). '<br /><br />' . $button_html .
455
- '</h3>
456
- </div>';
457
- $apbct->notice_show = false;
458
- }
459
-
460
- //"Wrong access key" notice (if ct_update_option().METHOD_notice_validate_key returns a error)
461
- if ($apbct->notice_show && $page_is_ct_settings && !$apbct->data['key_is_ok'] && $apbct->moderate_ip == 0 && !$apbct->white_label){
462
- echo '<div class="error">
463
- <h3><b>'.
464
- __("Wrong <a href='{$settings_link}'><b style=\"color: #49C73B;\">Clean</b><b style=\"color: #349ebf;\">Talk</b> access key</a>! Please check it or ask <a target=\"_blank\" href=\"https://cleantalk.org/forum/\">support</a>.", 'cleantalk').
465
- '</b></h3>
466
- </div>';
467
- }
468
- }
469
-
470
- return true;
471
- }
472
-
473
- function apbct_admin__badge__get_premium($print = true, $out = ''){
474
-
475
- global $apbct;
476
-
477
- if($apbct->license_trial == 1 && $apbct->user_token){
478
- $out .= '<b style="display: inline-block; margin-top: 10px;">'
479
- .($print ? __('Make it right!', 'cleantalk').' ' : '')
480
- .sprintf(
481
- __('%sGet premium%s', 'cleantalk'),
482
- '<a href="https://cleantalk.org/my/bill/recharge?user_token='.$apbct->user_token.'" target="_blank">',
483
- '</a>'
484
- )
485
- .'</b>';
486
- }
487
-
488
- if($print)
489
- echo $out;
490
- else
491
- return $out;
492
- }
493
-
494
- function apbct_admin__admin_bar__add( $wp_admin_bar ) {
495
-
496
- global $apbct;
497
-
498
- if (current_user_can('activate_plugins') && $apbct->settings['show_adminbar'] == 1 && (apbct_api_key__is_correct($apbct->api_key) !== false || (defined('CLEANTALK_SHOW_ADMIN_BAR_FORCE') && CLEANTALK_SHOW_ADMIN_BAR_FORCE))) {
499
-
500
- //Reset or create user counter
501
- if(!empty($_GET['ct_reset_user_counter'])){
502
- $apbct->data['user_counter']['accepted'] = 0;
503
- $apbct->data['user_counter']['blocked'] = 0;
504
- $apbct->data['user_counter']['since'] = date('d M');
505
- $apbct->saveData();
506
- }
507
- //Reset or create all counters
508
- if(!empty($_GET['ct_reset_all_counters'])){
509
- $apbct->data['sfw_counter'] = array('all' => 0, 'blocked' => 0);
510
- $apbct->data['all_time_counter'] = array('accepted' => 0, 'blocked' => 0);
511
- $apbct->data['user_counter'] = array('all' => 0, 'accepted' => 0, 'blocked' => 0, 'since' => date('d M'));
512
- $apbct->data['array_accepted'] = array();
513
- $apbct->data['array_blocked'] = array();
514
- $apbct->data['current_hour'] = '';
515
- $apbct->saveData();
516
- }
517
- //Compile user's counter string
518
- $user_counter=Array('accepted'=>$apbct->data['user_counter']['accepted'], 'blocked'=>$apbct->data['user_counter']['blocked'], 'all'=>$apbct->data['user_counter']['accepted'] + $apbct->data['user_counter']['blocked'], 'since'=>$apbct->data['user_counter']['since']);
519
- //Previous version $user_counter_str='<span style="color: white;">Since '.$user_counter['since'].': ' .$user_counter['all']*/. '</span> / <span style="color: green;">' .$user_counter['accepted']. '</span> / <span style="color: red;">' .$user_counter['blocked']. '</span>';
520
- $user_counter_str='<span style="color: white;">' . __('Since', 'cleantalk') . '&nbsp;' . $user_counter['since'].': </span><span style="color: green;">' .$user_counter['accepted']. '</span> / <span style="color: red;">' .$user_counter['blocked']. '</span>';
521
-
522
- $all_time_counter_str='';
523
- //Don't compile if all time counter disabled
524
- if($apbct->settings['all_time_counter'] == 1){
525
- $all_time_counter=Array('accepted'=>$apbct->data['all_time_counter']['accepted'], 'blocked'=>$apbct->data['all_time_counter']['blocked'], 'all'=>$apbct->data['all_time_counter']['accepted'] + $apbct->data['all_time_counter']['blocked']);
526
- $all_time_counter_str='<span style="color: white;" title="'.__('All / Allowed / Blocked submissions. The number of submissions is being counted since CleanTalk plugin installation.', 'cleantalk').'"><span style="color: white;"> | ' . __('All', 'cleantalk') . ': ' .$all_time_counter['all']. '</span> / <span style="color: green;">' .$all_time_counter['accepted']. '</span> / <span style="color: red;">' .$all_time_counter['blocked']. '</span></span>';
527
- }
528
-
529
- $daily_counter_str='';
530
- //Don't compile if daily counter disabled
531
- if( $apbct->settings['daily_counter'] == 1){
532
- $daily_counter=Array('accepted'=>array_sum($apbct->data['array_accepted']), 'blocked'=>array_sum($apbct->data['array_blocked']), 'all'=>array_sum($apbct->data['array_accepted']) + array_sum($apbct->data['array_blocked']));
533
- //Previous version $daily_counter_str='<span style="color: white;" title="'.__('All / Allowed / Blocked submissions. The number of submissions for past 24 hours. ', 'cleantalk').'"><span style="color: white;"> | Day: ' .$daily_counter['all']. '</span> / <span style="color: green;">' .$daily_counter['accepted']. '</span> / <span style="color: red;">' .$daily_counter['blocked']. '</span></span>';
534
- $daily_counter_str='<span style="color: white;" title="'.__('Allowed / Blocked submissions. The number of submissions for past 24 hours. ', 'cleantalk').'"><span style="color: white;"> | ' . __('Day', 'cleantalk') . ': </span><span style="color: green;">' .$daily_counter['accepted']. '</span> / <span style="color: red;">' .$daily_counter['blocked']. '</span></span>';
535
- }
536
- $sfw_counter_str='';
537
- //Don't compile if SFW counter disabled
538
- if( $apbct->settings['sfw_counter'] == 1 && $apbct->settings['spam_firewall'] == 1){
539
- $sfw_counter=Array('all'=>$apbct->data['sfw_counter']['all'], 'blocked'=>$apbct->data['sfw_counter']['blocked']);
540
- $sfw_counter_str='<span style="color: white;" title="'.__('All / Blocked events. Access attempts regitred by SpamFireWall counted since the last plugin activation.', 'cleantalk').'"><span style="color: white;"> | SpamFireWall: ' .$sfw_counter['all']. '</span> / <span style="color: red;">' .$sfw_counter['blocked']. '</span></span>';
541
- }
542
-
543
- $args = array(
544
- 'id' => 'ct_parent_node',
545
- 'title' => '<img src="' . plugin_dir_url(__FILE__) . 'images/logo_small1.png" alt="" height="" style="margin-top:9px; float: left;" />'
546
- .'<div style="margin: auto 7px;" class="ab-item alignright">'
547
- .'<div class="ab-label" id="ct_stats">'
548
- .($apbct->notice_trial == 1
549
- ? "<span><a style='color: red;' href=\"http://cleantalk.org/my/bill/recharge?utm_source=wp-backend&utm_medium=cpc&utm_campaign=WP%20backend%20trial&user_token={$apbct->user_token}&cp_mode=antispam\" target=\"_blank\">Renew Anti-Spam</a></span>"
550
- : '<span style="color: white;" title="'.__('Allowed / Blocked submissions. The number of submissions is being counted since ', 'cleantalk').' '.$user_counter['since'].'">'.$user_counter_str.'</span> '.$daily_counter_str.$all_time_counter_str.$sfw_counter_str
551
- )
552
- .'</div>'
553
- .'</div>' //You could change widget string here by simply deleting variables
554
- );
555
- $wp_admin_bar->add_node( $args );
556
-
557
- // DASHBOARD LINK
558
- if(!$apbct->white_label){
559
- $wp_admin_bar->add_node( array(
560
- 'id' => 'ct_dashboard_link',
561
- 'title' => '<a href="https://cleantalk.org/my/?user_token='.$apbct->user_token.'&utm_source=wp-backend&utm_medium=admin-bar&cp_mode=antispam " target="_blank">CleanTalk '.__('dashboard', 'cleantalk').'</a>',
562
- 'parent' => 'ct_parent_node'
563
- ));
564
- }
565
-
566
- $wp_admin_bar->add_node( array(
567
- 'id' => 'ct_settings_link',
568
- 'title' => '<a href="'.$apbct->settings_link.'">'.__('Settings', 'cleantalk').'</a>',
569
- 'parent' => 'ct_parent_node'
570
- ));
571
-
572
- // add a child item to our parent item. Bulk checks.
573
- if(!is_network_admin()){
574
- $args = array(
575
- 'id' => 'ct_settings_bulk_comments',
576
- 'title' => '<hr style="margin-top: 7px;" /><a href="edit-comments.php?page=ct_check_spam" title="'.__('Bulk spam comments removal tool.', 'cleantalk').'">'.__('Check comments for spam', 'cleantalk').'</a>',
577
- 'parent' => 'ct_parent_node'
578
- );
579
- }
580
- $wp_admin_bar->add_node( $args );
581
-
582
- // add a child item to our parent item. Bulk checks.
583
- if(!is_network_admin()){
584
- $args = array(
585
- 'id' => 'ct_settings_bulk_users',
586
- 'title' => '<a href="users.php?page=ct_check_users" title="Bulk spam users removal tool.">'.__('Check users for spam', 'cleantalk').'</a>',
587
- 'parent' => 'ct_parent_node'
588
- );
589
- }
590
- $wp_admin_bar->add_node( $args );
591
-
592
- // User counter reset.
593
- $args = array(
594
- 'id' => 'ct_reset_counter',
595
- 'title' => '<hr style="margin-top: 7px;"><a href="?ct_reset_user_counter=1" title="Reset your personal counter of submissions.">'.__('Reset first counter', 'cleantalk').'</a>',
596
- 'parent' => 'ct_parent_node'
597
- );
598
- $wp_admin_bar->add_node( $args );// add a child item to our parent item. Counter reset.
599
-
600
- // Reset ALL counter
601
- $args = array(
602
- 'id' => 'ct_reset_counters_all',
603
- 'title' => '<a href="?ct_reset_all_counters=1" title="Reset all counters.">'.__('Reset all counters', 'cleantalk').'</a>',
604
- 'parent' => 'ct_parent_node'
605
- );
606
- $wp_admin_bar->add_node( $args );
607
-
608
- // Support link
609
- if(!$apbct->white_label){
610
- $wp_admin_bar->add_node( array(
611
- 'id' => 'ct_admin_bar_support_link',
612
- 'title' => '<hr style="margin-top: 7px;" /><a target="_blank" href="https://wordpress.org/support/plugin/cleantalk-spam-protect">'.__('Support', 'cleantalk').'</a>',
613
- 'parent' => 'ct_parent_node'
614
- ));
615
- }
616
- }
617
- }
618
-
619
- /**
620
- * Unmark bad words
621
- * @param string $message
622
- * @return string Cleat comment
623
- */
624
- function apbct_comment__unmark_red($message) {
625
- $message = preg_replace("/\<font rel\=\"cleantalk\" color\=\"\#FF1000\"\>(\S+)\<\/font>/iu", '$1', $message);
626
-
627
- return $message;
628
- }
629
-
630
- // Ajax action feedback form comments page.
631
- function apbct_comment__send_feedback($comment_id = null, $comment_status = null, $change_status = false, $direct_call = null){
632
-
633
- // For AJAX call
634
- check_ajax_referer('ct_secret_nonce', 'security');
635
- $comment_id = !empty($_POST['comment_id']) ? $_POST['comment_id'] : false;
636
- $comment_status = !empty($_POST['comment_status']) ? $_POST['comment_status'] : false;
637
- $change_status = !empty($_POST['change_status']) ? $_POST['change_status'] : false;
638
-
639
- // If enter params is empty exit
640
- if(!$comment_id || !$comment_status)
641
- die();
642
-
643
- // $comment = get_comment($comment_id, 'ARRAY_A');
644
- $hash = get_comment_meta($comment_id, 'ct_hash', true);
645
-
646
- // If we can send the feedback
647
- if($hash){
648
-
649
- // Approving
650
- if($comment_status == '1' || $comment_status == 'approve'){
651
- $result = ct_send_feedback($hash.":1");
652
- // $comment['comment_content'] = apbct_comment__unmark_red($comment['comment_content']);
653
- // wp_update_comment($comment);
654
- $result === true ? 1 : 0;
655
- }
656
-
657
- // Disapproving
658
- if($comment_status == 'spam'){
659
- $result = ct_send_feedback($hash.":0");
660
- $result === true ? 1 : 0;
661
- }
662
- }else{
663
- $result = 'no_hash';
664
- }
665
-
666
- // Changing comment status(folder) if flag is set. spam || approve
667
- if($change_status !== false)
668
- wp_set_comment_status($comment_id, $comment_status);
669
-
670
- if(!$direct_call){
671
- echo !empty($result) ? $result : 0;
672
- die();
673
- }else{
674
-
675
- }
676
- }
677
-
678
- // Ajax action feedback form user page.
679
- function apbct_user__send_feedback($user_id = null, $status = null, $direct_call = null){
680
-
681
- check_ajax_referer('ct_secret_nonce', 'security');
682
-
683
- if(!$direct_call){
684
- $user_id = $_POST['user_id'];
685
- $status = $_POST['status'];
686
- }
687
-
688
- $hash = get_user_meta($user_id, 'ct_hash', true);
689
-
690
- if($hash){
691
- if($status == 'approve' || $status == 1){
692
- $result = ct_send_feedback($hash.":1");
693
- $result === true ? 1 : 0;
694
- }
695
- if($status == 'spam' || $status == 'disapprove' || $status == 0){
696
- $result = ct_send_feedback($hash.":0");
697
- $result === true ? 1 : 0;
698
- }
699
- }else{
700
- $result = 'no_hash';
701
- }
702
-
703
- if(!$direct_call){
704
- echo !empty($result) ? $result : 0;
705
- die();
706
- }else{
707
-
708
- }
709
-
710
- }
711
-
712
- /**
713
- * Send feedback when user deleted
714
- * @return null
715
- */
716
- function apbct_user__delete__hook($user_id, $reassign = null){
717
-
718
- $hash = get_user_meta($user_id, 'ct_hash', true);
719
- if ($hash !== '') {
720
- ct_feedback($hash, 0);
721
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
722
  }
1
+ <?php
2
+
3
+ require_once('cleantalk-settings.php');
4
+
5
+ // Add buttons to comments list table
6
+ add_action( 'manage_comments_nav', 'apbct_add_buttons_to_comments_and_users', 10, 1 );
7
+ add_action( 'manage_users_extra_tablenav', 'apbct_add_buttons_to_comments_and_users', 10, 1 );
8
+
9
+ function apbct_add_buttons_to_comments_and_users( $unused_argument ) {
10
+
11
+ global $apbct;
12
+ $current_screen = get_current_screen();
13
+
14
+ if( 'users' == $current_screen->base ) {
15
+ $button_url = $current_screen->base . '.php?page=ct_check_users';
16
+ $button_description = 'users';
17
+ } elseif ( 'edit-comments' == $current_screen->base ) {
18
+ $button_url = $current_screen->base . '.php?page=ct_check_spam';
19
+ $button_description = 'comments';
20
+ } else {
21
+ return;
22
+ }
23
+
24
+ echo '
25
+ <a href="' . $button_url . '" class="button" style="margin:1px 0 0 0; display: inline-block;">
26
+ <img src="' . $apbct->logo__small__colored . '" alt="Cleantalk Antispam logo" height="" style="width: 17px; vertical-align: text-bottom;" />
27
+ ' . sprintf(__( 'Find spam %s', 'cleantalk' ), $button_description ) . '
28
+ </a>
29
+ <a href="https://cleantalk.org/my/show_requests?service_id=' . $apbct->data['service_id'] . '&int=week" target="_blank" class="button" style="margin:1px 0 0 0; display: inline-block;">
30
+ <img src="' . $apbct->logo__small__colored . '" alt="Cleantalk Antispam logo" height="" style="width: 17px; vertical-align: text-bottom;" />
31
+ ' . __( 'CleanTalk Anti-Spam Log', 'cleantalk' ) . '
32
+ </a>
33
+ ';
34
+
35
+ }
36
+
37
+ add_action( 'admin_bar_menu', 'apbct_admin__admin_bar__add', 999 );
38
+
39
+ //Adding widjet
40
+ function ct_dashboard_statistics_widget() {
41
+
42
+ global $apbct;
43
+
44
+ if(apbct_is_user_role_in(array('administrator'))){
45
+ wp_add_dashboard_widget(
46
+ 'ct_dashboard_statistics_widget',
47
+ $apbct->plugin_name
48
+ ."<div class='ct_widget_top_links'>"
49
+ ."<img src='".plugins_url('/cleantalk-spam-protect/inc/images/preloader.gif')."' class='ct_preloader'>"
50
+ .sprintf(__("%sRefresh%s", 'cleantalk'), "<a href='#ct_widget' class='ct_widget_refresh_link'>", "</a>")
51
+ .sprintf(__("%sConfigure%s", 'cleantalk'), "<a href='{$apbct->settings_link}' class='ct_widget_settings_link'>", "</a>")
52
+ ."</div>",
53
+ 'ct_dashboard_statistics_widget_output'
54
+ );
55
+ }
56
+ }
57
+
58
+ // Outputs statistics widget content
59
+ function ct_dashboard_statistics_widget_output( $post, $callback_args ) {
60
+
61
+ global $apbct, $current_user;
62
+
63
+ echo "<div id='ct_widget_wrapper'>";
64
+ ?>
65
+ <form id='ct_refresh_form' method='POST' action='#ct_widget'>
66
+ <input type='hidden' name='ct_brief_refresh' value='1'>
67
+ </form>
68
+ <h4 class='ct_widget_block_header' style='margin-left: 12px;'><?php _e('7 days anti-spam stats', 'cleantalk'); ?></h4>
69
+ <div class='ct_widget_block ct_widget_chart_wrapper'>
70
+ <div id='ct_widget_chart'></div>
71
+ </div>
72
+ <h4 class='ct_widget_block_header'><?php _e('Top 5 spam IPs blocked', 'cleantalk'); ?></h4>
73
+ <hr class='ct_widget_hr'>
74
+ <?php
75
+ if(!apbct_api_key__is_correct() || (isset($apbct->data['brief_data']['error_no']) && $apbct->data['brief_data']['error_no'] == 6)){
76
+ ?> <div class='ct_widget_block'>
77
+ <form action='<? echo $apbct->settings_link; ?>' method='POST'>
78
+ <h2 class='ct_widget_activate_header'><?php _e('Get Access key to activate Anti-Spam protection!', 'cleantalk'); ?></h2>
79
+ <input class='ct_widget_button ct_widget_activate_button' type='submit' name='get_apikey_auto' value='ACTIVATE' />
80
+ </form>
81
+ </div>
82
+ <?php
83
+ }elseif(!empty($apbct->data['brief_data']['error'])){
84
+ echo '<div class="ct_widget_block">'
85
+ .'<h2 class="ct_widget_activate_header">'
86
+ .sprintf(__('Something went wrong! Error: "%s".', 'cleantalk'), "<u>{$apbct->brief_data['error']}</u>")
87
+ .'</h2>';
88
+ if($apbct->user_token && !$apbct->white_label){
89
+ echo '<h2 class="ct_widget_activate_header">'
90
+ .__('Please, visit your dashboard.', 'cleantalk')
91
+ .'</h2>'
92
+ .'<a target="_blank" href="https://cleantalk.org/my?user_token='.$apbct->user_token.'&cp_mode=antispam">'
93
+ .'<input class="ct_widget_button ct_widget_activate_button ct_widget_resolve_button" type="button" value="VISIT CONTROL PANEL">'
94
+ .'</a>';
95
+ }
96
+ echo '</div>';
97
+ }
98
+
99
+ if(apbct_api_key__is_correct() && empty($apbct->data['brief_data']['error'])){
100
+ ?>
101
+ <div class='ct_widget_block'>
102
+ <table cellspacing="0">
103
+ <tr>
104
+ <th><?php _e('IP', 'cleantalk'); ?></th>
105
+ <th><?php _e('Country', 'cleantalk'); ?></th>
106
+ <th><?php _e('Block Count', 'cleantalk'); ?></th>
107
+ </tr>
108
+ <?php foreach($apbct->brief_data['top5_spam_ip'] as $val){ ?>
109
+ <tr>
110
+ <td><?php echo $val[0]; ?></td>
111
+ <td><?php echo $val[1] ? "<img src='https://cleantalk.org/images/flags/".strtolower($val[1]).".png'>" : ''; ?>&nbsp;<?php
112
+ echo $val[1]
113
+ ? locale_get_display_region('sl-Latn-'.$val[1].'-nedis', substr(get_locale(), 0, 2))
114
+ : 'Unknown'; ?></td>
115
+ <td style='text-align: center;'><?php echo $val[2]; ?></td>
116
+ </tr>
117
+ <?php } ?>
118
+ </table>
119
+ <?php if($apbct->user_token){ ?>
120
+ <a target='_blank' href='https://cleantalk.org/my?user_token=<?php echo $apbct->user_token; ?>&cp_mode=antispam'>
121
+ <input class='ct_widget_button' id='ct_widget_button_view_all' type='button' value='View all'>
122
+ </a>
123
+ <?php } ?>
124
+ </div>
125
+
126
+ <?php
127
+ }
128
+ // Notice at the bottom
129
+ if(isset($current_user) && in_array('administrator', $current_user->roles)){
130
+
131
+ if($apbct->spam_count && $apbct->spam_count > 0){
132
+ echo '<div class="ct_widget_wprapper_total_blocked">'
133
+ .'<img src="'.$apbct->logo__small__colored.'" class="ct_widget_small_logo"/>'
134
+ .'<span title="'.sprintf(__('This is the count from the %s\'s cloud and could be different to admin bar counters', 'cleantalk').'">', $apbct->plugin_name)
135
+ .sprintf(
136
+ /* translators: %s: Number of spam messages */
137
+ __( '%s%s%s has blocked %s spam for all time. The statistics are automatically updated every 24 hours.', 'cleantalk'),
138
+ !$apbct->white_label ? '<a href="https://cleantalk.org/my/?user_token='.$apbct->user_token.'&utm_source=wp-backend&utm_medium=dashboard_widget&cp_mode=antispam" target="_blank">' : '',
139
+ $apbct->plugin_name,
140
+ !$apbct->white_label ? '</a>' : '',
141
+ number_format($apbct->data['spam_count'], 0, ',', ' ')
142
+ )
143
+ .'</span>'
144
+ .(!$apbct->white_label
145
+ ? '<br><br>'
146
+ .'<b style="font-size: 16px;">'
147
+ .sprintf(
148
+ __('Do you like CleanTalk? %sPost your feedback here%s.', 'cleantalk'),
149
+ '<u><a href="https://wordpress.org/support/plugin/cleantalk-spam-protect/reviews/#new-post" target="_blank">',
150
+ '</a></u>'
151
+ )
152
+ .'</b>'
153
+ : ''
154
+ )
155
+ .'</div>';
156
+ }
157
+ }
158
+ echo '</div>';
159
+ }
160
+
161
+ /**
162
+ * Admin action 'admin_init' - Add the admin settings and such
163
+ */
164
+ function apbct_admin__init(){
165
+
166
+ global $apbct;
167
+
168
+ // Getting dashboard widget statistics
169
+ if(!empty($_POST['ct_brief_refresh'])){
170
+ $apbct->data['brief_data'] = CleantalkAPI::method__get_antispam_report_breif($apbct->api_key);
171
+ $apbct->saveData();
172
+ }
173
+
174
+ // Getting key like hoster. Only once!
175
+ if(!is_main_site() && $apbct->white_label && empty($apbct->api_key)){
176
+
177
+ $_POST['submit'] = 'get_key_auto';
178
+ $settings = apbct_settings__validate(array());
179
+ unset($_POST['submit']);
180
+
181
+ if(!empty($settings['apikey'])){
182
+ $apbct->settings['apikey'] = $settings['apikey'];
183
+ $apbct->api_key = $settings['apikey'];
184
+ $apbct->saveSettings();
185
+ }
186
+
187
+ }
188
+
189
+ // AJAX actions
190
+
191
+ // Settings
192
+ add_action('wp_ajax_apbct_settings__get__long_description', 'apbct_settings__get__long_description'); // Long description
193
+ }
194
+
195
+ /**
196
+ * Manage links in plugins list
197
+ * @return array
198
+ */
199
+ function apbct_admin__plugin_action_links($links, $file) {
200
+
201
+ global $apbct;
202
+
203
+ $settings_link = '<a href="' . $apbct->settings_link . '">' . __( 'Settings' ) . '</a>';
204
+
205
+ array_unshift( $links, $settings_link ); // before other links
206
+ return $links;
207
+ }
208
+
209
+ /**
210
+ * Manage links and plugins page
211
+ * @return array
212
+ */
213
+ function apbct_admin__register_plugin_links($links, $file){
214
+
215
+ global $apbct;
216
+
217
+ //Return if it's not our plugin
218
+ if ($file != $apbct->base_name)
219
+ return $links;
220
+
221
+ if($apbct->white_label){
222
+ $links = array_slice($links, 0, 1);
223
+ $links[] = "<script>jQuery('.plugin-title strong').each(function(i, item){
224
+ if(jQuery(item).html() == 'Anti-Spam by CleanTalk')
225
+ jQuery(item).html('{$apbct->plugin_name}');
226
+ });</script>";
227
+ return $links;
228
+ }
229
+
230
+ if(substr(get_locale(), 0, 2) != 'en')
231
+ $links[] = '<a class="ct_meta_links ct_translate_links" href="'
232
+ .sprintf('https://translate.wordpress.org/locale/%s/default/wp-plugins/cleantalk-spam-protect', substr(get_locale(), 0, 2))
233
+ .'" target="_blank">'
234
+ .__('Translate', 'cleantalk')
235
+ .'</a>';
236
+
237
+ $links[] = '<a class="ct_meta_links" href="'.$apbct->settings_link.'" target="_blank">' . __( 'Start here','cleantalk' ) . '</a>';
238
+ $links[] = '<a class="ct_meta_links ct_faq_links" href="http://wordpress.org/plugins/cleantalk-spam-protect/faq/" target="_blank">' . __( 'FAQ','cleantalk' ) . '</a>';
239
+ $links[] = '<a class="ct_meta_links ct_support_links"href="https://wordpress.org/support/plugin/cleantalk-spam-protect" target="_blank">' . __( 'Support','cleantalk' ) . '</a>';
240
+ $trial = apbct_admin__badge__get_premium(false);
241
+ if(!empty($trial))
242
+ $links[] = apbct_admin__badge__get_premium(false);
243
+
244
+ return $links;
245
+ }
246
+
247
+ /**
248
+ * Admin action 'admin_enqueue_scripts' - Enqueue admin script of reloading admin page after needed AJAX events
249
+ * @param string $hook URL of hooked page
250
+ */
251
+ function apbct_admin__enqueue_scripts($hook){
252
+
253
+ global $apbct;
254
+
255
+ // Scripts to all admin pages
256
+ wp_enqueue_script('ct_admin_js_notices', plugins_url('/cleantalk-spam-protect/js/cleantalk-admin.min.js'), array(), APBCT_VERSION);
257
+ wp_enqueue_style ('ct_admin_css', plugins_url('/cleantalk-spam-protect/css/cleantalk-admin.min.css'), array(), APBCT_VERSION, 'all');
258
+
259
+ wp_localize_script( 'jquery', 'ctAdminCommon', array(
260
+ '_ajax_nonce' => wp_create_nonce( 'ct_secret_nonce' ),
261
+ '_ajax_url' => admin_url( 'admin-ajax.php' ),
262
+ 'plugin_name' => $apbct->plugin_name,
263
+ 'logo' => '<img src="' . $apbct->logo . '" alt="" height="" style="width: 17px; vertical-align: text-bottom;" />',
264
+ 'logo_small' => '<img src="' . $apbct->logo__small . '" alt="" height="" style="width: 17px; vertical-align: text-bottom;" />',
265
+ 'logo_small_colored' => '<img src="' . $apbct->logo__small__colored . '" alt="" height="" style="width: 17px; vertical-align: text-bottom;" />',
266
+ ) );
267
+
268
+ // DASHBOARD page JavaScript and CSS
269
+ if($hook == 'index.php' && apbct_is_user_role_in(array('administrator'))){
270
+
271
+ wp_enqueue_style('ct_admin_css_widget_dashboard', plugins_url('/cleantalk-spam-protect/css/cleantalk-dashboard-widget.min.css'), array(), APBCT_VERSION, 'all');
272
+ wp_enqueue_style ('ct_icons', plugins_url('/cleantalk-spam-protect/css/cleantalk-icons.min.css'), array(), APBCT_VERSION, 'all');
273
+
274
+ wp_enqueue_script('ct_gstatic_charts_loader', plugins_url('/cleantalk-spam-protect/js/cleantalk-dashboard-widget--google-charts.min.js'), array(), APBCT_VERSION);
275
+ wp_enqueue_script('ct_admin_js_widget_dashboard', plugins_url('/cleantalk-spam-protect/js/cleantalk-dashboard-widget.min.js'), array('ct_gstatic_charts_loader'), APBCT_VERSION);
276
+
277
+ // Preparing widget data
278
+ // Parsing brief data 'spam_stat' {"yyyy-mm-dd": spam_count, "yyyy-mm-dd": spam_count} to [["yyyy-mm-dd", "spam_count"], ["yyyy-mm-dd", "spam_count"]]
279
+ $to_chart = array();
280
+
281
+ // Crunch. Response contains error.
282
+ if(!empty($apbct->data['brief_data']['error']))
283
+ $apbct->data['brief_data'] = array_merge($apbct->data['brief_data'], $apbct->def_data['brief_data']);
284
+
285
+ foreach( $apbct->data['brief_data']['spam_stat'] as $key => $value ){
286
+ $to_chart[] = array( $key, $value );
287
+ } unset( $key, $value );
288
+
289
+ wp_localize_script( 'jquery', 'apbctDashboardWidget', array(
290
+ 'data' => $to_chart,
291
+ ));
292
+ }
293
+
294
+ // SETTINGS's page JavaScript and CSS
295
+ if( $hook == 'settings_page_cleantalk' ){
296
+
297
+ // jQueryUI
298
+ wp_enqueue_script('jqueryui', plugins_url('/cleantalk-spam-protect/js/jquery-ui.min.js'), array('jquery'), '1.12.1' );
299
+ wp_enqueue_style('jqueryui_css', plugins_url('/cleantalk-spam-protect/css/jquery-ui.min.css'),array(), '1.21.1', 'all');
300
+
301
+ wp_enqueue_script('cleantalk_admin_js_settings_page', plugins_url('/cleantalk-spam-protect/js/cleantalk-admin-settings-page.min.js'), array(), APBCT_VERSION);
302
+ wp_enqueue_style('cleantalk_admin_css_settings_page', plugins_url('/cleantalk-spam-protect/css/cleantalk-admin-settings-page.min.css'), array(), APBCT_VERSION, 'all');
303
+ wp_enqueue_style ('ct_icons', plugins_url('/cleantalk-spam-protect/css/cleantalk-icons.min.css'), array(), APBCT_VERSION, 'all');
304
+
305
+ wp_localize_script( 'jquery', 'ctSettingsPage', array(
306
+ 'ct_subtitle' => $apbct->ip_license ? __('Hosting AntiSpam', 'cleantalk') : '',
307
+ 'ip_license' => $apbct->ip_license ? true : false,
308
+ ));
309
+ }
310
+
311
+ // COMMENTS's page JavaScript and CSS
312
+ if( $hook == 'comments_page_ct_check_spam' || $hook == 'edit-comments.php'){
313
+
314
+ // Preparing data
315
+ if(!empty($_COOKIE['ct_paused_comments_check']))
316
+ $prev_check = json_decode(stripslashes($_COOKIE['ct_paused_comments_check']), true);
317
+
318
+ // jQueryUI
319
+ wp_enqueue_script('jqueryui', plugins_url('/cleantalk-spam-protect/js/jquery-ui.min.js'), array('jquery'), '1.12.1');
320
+ wp_enqueue_style('jqueryui_css', plugins_url('/cleantalk-spam-protect/css/jquery-ui.min.css'),array(), '1.21.1', 'all');
321
+
322
+ // CSS
323
+ wp_enqueue_style('cleantalk_admin_css_settings_page', plugins_url('/cleantalk-spam-protect/css/cleantalk-spam-check.min.css'), array(), APBCT_VERSION, 'all');
324
+
325
+ // CHECK COMMENTS page JavaScript
326
+ if($hook == 'comments_page_ct_check_spam'){
327
+ wp_enqueue_script('ct_comments_checkspam', plugins_url('/cleantalk-spam-protect/js/cleantalk-comments-checkspam.min.js'), array(), APBCT_VERSION);
328
+ wp_localize_script( 'jquery', 'ctCommentsCheck', array(
329
+ 'ct_ajax_nonce' => wp_create_nonce('ct_secret_nonce'),
330
+ 'ct_prev_accurate' => !empty($prev_check['accurate']) ? true : false,
331
+ 'ct_prev_from' => !empty($prev_check['from']) ? $prev_check['from'] : false,
332
+ 'ct_prev_till' => !empty($prev_check['till']) ? $prev_check['till'] : false,
333
+ 'ct_timeout_confirm' => __('Failed from timeout. Going to check comments again.', 'cleantalk'),
334
+ 'ct_comments_added' => __('Added', 'cleantalk'),
335
+ 'ct_comments_deleted' => __('Deleted', 'cleantalk'),
336
+ 'ct_comments_added_after' => __('comments', 'cleantalk'),
337
+ 'ct_confirm_deletion_all' => __('Delete all spam comments?', 'cleantalk'),
338
+ 'ct_confirm_deletion_checked' => __('Delete checked comments?', 'cleantalk'),
339
+ 'ct_status_string' => __('Total comments %s. Checked %s. Found %s spam comments. %s bad comments (without IP or email).', 'cleantalk'),
340
+ 'ct_status_string_warning' => '<p>'.__('Please do backup of WordPress database before delete any accounts!', 'cleantalk').'</p>',
341
+ 'start' => !empty($_COOKIE['ct_comments_start_check']) ? true : false,
342
+ ));
343
+ }
344
+
345
+ // COMMENTS page JavaScript
346
+ if($hook == 'edit-comments.php'){
347
+ wp_enqueue_script('ct_comments_editscreen', plugins_url('/cleantalk-spam-protect/js/cleantalk-comments-editscreen.min.js'), array(), APBCT_VERSION);
348
+ wp_localize_script( 'jquery', 'ctCommentsScreen', array(
349
+ 'ct_ajax_nonce' => wp_create_nonce('ct_secret_nonce'),
350
+ 'spambutton_text' => __("Find spam comments", 'cleantalk'),
351
+ 'ct_feedback_msg_whitelisted' => __("The sender has been whitelisted.", 'cleantalk'),
352
+ 'ct_feedback_msg_blacklisted' => __("The sender has been blacklisted.", 'cleantalk'),
353
+ 'ct_feedback_msg' => sprintf(__("Feedback has been sent to %sCleanTalk Dashboard%s.", 'cleantalk'), $apbct->user_token ? "<a target='_blank' href=https://cleantalk.org/my?user_token={$apbct->user_token}&cp_mode=antispam>" : '', $apbct->user_token ? "</a>" : ''),
354
+ 'ct_show_check_links' => (bool)$apbct->settings['show_check_links'],
355
+ 'ct_img_src_new_tab' => plugin_dir_url(__FILE__)."images/new_window.gif",
356
+ ));
357
+ }
358
+ }
359
+
360
+ // USERS's page JavaScript and CSS
361
+ if( $hook == 'users_page_ct_check_users' || $hook == 'users.php'){
362
+
363
+ // Preparing data
364
+ $current_user = wp_get_current_user();
365
+ if(!empty($_COOKIE['ct_paused_users_check']))
366
+ $prev_check = json_decode(stripslashes($_COOKIE['ct_paused_users_check']), true);
367
+
368
+ // jQueryUI
369
+ wp_enqueue_script('jqueryui', plugins_url('/cleantalk-spam-protect/js/jquery-ui.min.js'), array('jquery'), '1.12.1');
370
+ wp_enqueue_style('jqueryui_css', plugins_url('/cleantalk-spam-protect/css/jquery-ui.min.css'),array(), '1.21.1', 'all');
371
+
372
+ // CSS
373
+ wp_enqueue_style('cleantalk_admin_css_settings_page', plugins_url().'/cleantalk-spam-protect/css/cleantalk-spam-check.min.css', array(), APBCT_VERSION, 'all');
374
+
375
+ // CHECK USERS page JavaScript
376
+ if($hook == 'users_page_ct_check_users'){
377
+ wp_enqueue_script('ct_users_checkspam', plugins_url('/cleantalk-spam-protect/js/cleantalk-users-checkspam.min.js'), array(), APBCT_VERSION);
378
+ wp_localize_script( 'jquery', 'ctUsersCheck', array(
379
+ 'ct_ajax_nonce' => wp_create_nonce('ct_secret_nonce'),
380
+ 'ct_prev_accurate' => !empty($prev_check['accurate']) ? true : false,
381
+ 'ct_prev_from' => !empty($prev_check['from']) ? $prev_check['from'] : false,
382
+ 'ct_prev_till' => !empty($prev_check['till']) ? $prev_check['till'] : false,
383
+ 'ct_timeout' => __('Failed from timeout. Going to check users again.', 'cleantalk'),
384
+ 'ct_timeout_delete' => __('Failed from timeout. Going to run a new attempt to delete spam users.', 'cleantalk'),
385
+ 'ct_inserted' => __('Inserted', 'cleantalk'),
386
+ 'ct_deleted' => __('Deleted', 'cleantalk'),
387
+ 'ct_iusers' => __('users.', 'cleantalk'),
388
+ 'ct_confirm_deletion_all' => __('Delete all spam users?', 'cleantalk'),
389
+ 'ct_confirm_deletion_checked' => __('Delete checked users?', 'cleantalk'),
390
+ 'ct_csv_filename' => "user_check_by_".$current_user->user_login,
391
+ 'ct_bad_csv' => __("File doesn't exist. File will be generated while checking. Please, press \"Check for spam\"."),
392
+ 'ct_status_string' => __("Total users %s, checked %s, found %s spam users and %s bad users (without IP or email)", 'cleantalk'),
393
+ 'ct_status_string_warning' => "<p>".__("Please do backup of WordPress database before delete any accounts!", 'cleantalk')."</p>"
394
+ ));
395
+ }
396
+
397
+ // USERS page JavaScript
398
+ if($hook == 'users.php'){
399
+ wp_enqueue_script('ct_users_editscreen', plugins_url('/cleantalk-spam-protect/js/cleantalk-users-editscreen.min.js'), array(), APBCT_VERSION);
400
+ wp_localize_script( 'jquery', 'ctUsersScreen', array(
401
+ 'spambutton_text' => __("Find spam-users", 'cleantalk'),
402
+ 'ct_show_check_links' => (bool)$apbct->settings['show_check_links'],
403
+ 'ct_img_src_new_tab' => plugin_dir_url(__FILE__)."images/new_window.gif"
404
+ ));
405
+ }
406
+
407
+ }
408
+ }
409
+
410
+ /**
411
+ * Notice blog owner if plugin is used without Access key
412
+ * @return bool
413
+ */
414
+ function apbct_admin__notice_message(){
415
+
416
+ global $apbct;
417
+
418
+ $page = get_current_screen();
419
+
420
+ //General notice control flags
421
+ $self_owned_key = ($apbct->moderate_ip == 0 && !defined('CLEANTALK_ACCESS_KEY') ? true : false);
422
+ $is_dashboard = (is_network_admin() || is_admin() ? true : false);
423
+ $is_admin = (current_user_can('activate_plugins') ? true : false);
424
+
425
+ $page_is_ct_settings = (in_array($page->id, array('settings_page_cleantalk', 'settings_page_cleantalk-network', 'comments_page_ct_check_spam', 'users_page_ct_check_users')) ? true : false);
426
+
427
+ //Misc
428
+ $user_token = ($apbct->user_token ? '&user_token='.$apbct->user_token : '');
429
+ $settings_link = (is_network_admin() ? 'settings.php?page=cleantalk' : 'options-general.php?page=cleantalk');
430
+
431
+ if($self_owned_key && $is_dashboard && $is_admin){
432
+ // Auto update notice
433
+ /* Disabled at 09.09.2018
434
+ if($apbct->notice_auto_update == 1 && $apbct->auto_update != -1 && empty($_COOKIE['apbct_update_banner_closed'])){
435
+ $link = '<a href="http://cleantalk.org/help/cleantalk-auto-update" target="_blank">%s</a>';
436
+ $button = sprintf($link, '<input type="button" class="button button-primary" value="'.__('Learn more', 'cleantalk').'" />');
437
+ echo '<div class="error notice is-dismissible apbct_update_notice">'
438
+ .'<h3>'
439
+ .__('Do you know that Anti-Spam by CleanTalk has auto update option?', 'cleantalk')
440
+ .'</br></br>'
441
+ .$button
442
+ .'</h3>'
443
+ .'</div>';
444
+ }
445
+ */
446
+ //Unable to get key automatically (if apbct_admin__init().getAutoKey() returns error)
447
+ if ($apbct->notice_show && !empty($apbct->errors['get_key']) && !$apbct->white_label){
448
+ echo '<div class="error">
449
+ <h3>' . sprintf(__("Unable to get Access key automatically: %s", 'cleantalk'), $apbct->api_key).
450
+ "<a target='__blank' style='margin-left: 10px' href='https://cleantalk.org/register?platform=wordpress&email=" . urlencode(ct_get_admin_email())."&website=" . urlencode(parse_url(get_option('siteurl'),PHP_URL_HOST))."'>".__('Get the Access key', 'cleantalk').'</a>
451
+ </h3>
452
+ </div>';
453
+ }
454
+
455
+ //key == "" || "enter key"
456
+ if (!apbct_api_key__is_correct() && $apbct->moderate_ip == 0){
457
+ echo "<div class='error'>"
458
+ ."<h3>"
459
+ .sprintf(__("Please enter Access Key in %s settings to enable anti spam protection!", 'cleantalk'), "<a href='{$settings_link}'>CleanTalk plugin</a>")
460
+ ."</h3>"
461
+ ."</div>";
462
+ $apbct->notice_show = false;
463
+ }
464
+
465
+ //"Trial period ends" notice from apbct_admin__init().api_method__notice_paid_till()
466
+ if ($apbct->notice_show && $apbct->notice_trial == 1 && $apbct->moderate_ip == 0 && !$apbct->white_label) {
467
+ if(isset($_GET['page']) && in_array($_GET['page'], array('cleantalk', 'ct_check_spam', 'ct_check_users'))){
468
+ echo '<div class="error">
469
+ <h3>' . sprintf(__("%s trial period ends, please upgrade to %s!", 'cleantalk'),
470
+ "<a href='{$settings_link}'>".$apbct->plugin_name."</a>",
471
+ "<a href=\"http://cleantalk.org/my/bill/recharge?utm_source=wp-backend&utm_medium=cpc&utm_campaign=WP%20backend%20trial$user_token&cp_mode=antispam\" target=\"_blank\"><b>premium version</b></a>") .
472
+ '</h3>
473
+ </div>';
474
+ $apbct->notice_show = false;
475
+ }
476
+ }
477
+
478
+ //Renew notice from apbct_admin_init().api_method__notice_paid_till()
479
+ if ($apbct->notice_show && $apbct->notice_renew == 1 && $apbct->moderate_ip == 0 && !$apbct->white_label) {
480
+ $renew_link = "<a href=\"http://cleantalk.org/my/bill/recharge?utm_source=wp-backend&utm_medium=cpc&utm_campaign=WP%%20backend%%20renew$user_token&cp_mode=antispam\" target=\"_blank\">%s</a>";
481
+ $button_html = sprintf($renew_link, '<input type="button" class="button button-primary" value="'.__('RENEW ANTI-SPAM', 'cleantalk').'" />');
482
+ $link_html = sprintf($renew_link, "<b>".__('next year', 'cleantalk')."</b>");
483
+
484
+ echo '<div class="updated">
485
+ <h3>'.
486
+ sprintf(__("Please renew your anti-spam license for %s.", 'cleantalk'), $link_html). '<br /><br />' . $button_html .
487
+ '</h3>
488
+ </div>';
489
+ $apbct->notice_show = false;
490
+ }
491
+
492
+ //"Wrong access key" notice (if ct_update_option().METHOD_notice_validate_key returns a error)
493
+ if ($apbct->notice_show && $page_is_ct_settings && !$apbct->data['key_is_ok'] && $apbct->moderate_ip == 0 && !$apbct->white_label){
494
+ echo '<div class="error">
495
+ <h3><b>'.
496
+ __("Wrong <a href='{$settings_link}'><b style=\"color: #49C73B;\">Clean</b><b style=\"color: #349ebf;\">Talk</b> access key</a>! Please check it or ask <a target=\"_blank\" href=\"https://cleantalk.org/forum/\">support</a>.", 'cleantalk').
497
+ '</b></h3>
498
+ </div>';
499
+ }
500
+ }
501
+
502
+ return true;
503
+ }
504
+
505
+ function apbct_admin__badge__get_premium($print = true, $out = ''){
506
+
507
+ global $apbct;
508
+
509
+ if($apbct->license_trial == 1 && $apbct->user_token){
510
+ $out .= '<b style="display: inline-block; margin-top: 10px;">'
511
+ .($print ? __('Make it right!', 'cleantalk').' ' : '')
512
+ .sprintf(
513
+ __('%sGet premium%s', 'cleantalk'),
514
+ '<a href="https://cleantalk.org/my/bill/recharge?user_token='.$apbct->user_token.'" target="_blank">',
515
+ '</a>'
516
+ )
517
+ .'</b>';
518
+ }
519
+
520
+ if($print)
521
+ echo $out;
522
+ else
523
+ return $out;
524
+ }
525
+
526
+ function apbct_admin__admin_bar__add( $wp_admin_bar ) {
527
+
528
+ global $apbct;
529
+
530
+ if (current_user_can('activate_plugins') && $apbct->settings['show_adminbar'] == 1 && (apbct_api_key__is_correct($apbct->api_key) !== false || (defined('CLEANTALK_SHOW_ADMIN_BAR_FORCE') && CLEANTALK_SHOW_ADMIN_BAR_FORCE))) {
531
+
532
+ //Reset or create user counter
533
+ if(!empty($_GET['ct_reset_user_counter'])){
534
+ $apbct->data['user_counter']['accepted'] = 0;
535
+ $apbct->data['user_counter']['blocked'] = 0;
536
+ $apbct->data['user_counter']['since'] = date('d M');
537
+ $apbct->saveData();
538
+ }
539
+ //Reset or create all counters
540
+ if(!empty($_GET['ct_reset_all_counters'])){
541
+ $apbct->data['sfw_counter'] = array('all' => 0, 'blocked' => 0);
542
+ $apbct->data['all_time_counter'] = array('accepted' => 0, 'blocked' => 0);
543
+ $apbct->data['user_counter'] = array('all' => 0, 'accepted' => 0, 'blocked' => 0, 'since' => date('d M'));
544
+ $apbct->data['array_accepted'] = array();
545
+ $apbct->data['array_blocked'] = array();
546
+ $apbct->data['current_hour'] = '';
547
+ $apbct->saveData();
548
+ }
549
+ //Compile user's counter string
550
+ $user_counter=Array('accepted'=>$apbct->data['user_counter']['accepted'], 'blocked'=>$apbct->data['user_counter']['blocked'], 'all'=>$apbct->data['user_counter']['accepted'] + $apbct->data['user_counter']['blocked'], 'since'=>$apbct->data['user_counter']['since']);
551
+ //Previous version $user_counter_str='<span style="color: white;">Since '.$user_counter['since'].': ' .$user_counter['all']*/. '</span> / <span style="color: green;">' .$user_counter['accepted']. '</span> / <span style="color: red;">' .$user_counter['blocked']. '</span>';
552
+ $user_counter_str='<span style="color: white;">' . __('Since', 'cleantalk') . '&nbsp;' . $user_counter['since'].': </span><span style="color: green;">' .$user_counter['accepted']. '</span> / <span style="color: red;">' .$user_counter['blocked']. '</span>';
553
+
554
+ $all_time_counter_str='';
555
+ //Don't compile if all time counter disabled
556
+ if($apbct->settings['all_time_counter'] == 1){
557
+ $all_time_counter=Array('accepted'=>$apbct->data['all_time_counter']['accepted'], 'blocked'=>$apbct->data['all_time_counter']['blocked'], 'all'=>$apbct->data['all_time_counter']['accepted'] + $apbct->data['all_time_counter']['blocked']);
558
+ $all_time_counter_str='<span style="color: white;" title="'.__('All / Allowed / Blocked submissions. The number of submissions is being counted since CleanTalk plugin installation.', 'cleantalk').'"><span style="color: white;"> | ' . __('All', 'cleantalk') . ': ' .$all_time_counter['all']. '</span> / <span style="color: green;">' .$all_time_counter['accepted']. '</span> / <span style="color: red;">' .$all_time_counter['blocked']. '</span></span>';
559
+ }
560
+
561
+ $daily_counter_str='';
562
+ //Don't compile if daily counter disabled
563
+ if( $apbct->settings['daily_counter'] == 1){
564
+ $daily_counter=Array('accepted'=>array_sum($apbct->data['array_accepted']), 'blocked'=>array_sum($apbct->data['array_blocked']), 'all'=>array_sum($apbct->data['array_accepted']) + array_sum($apbct->data['array_blocked']));
565
+ //Previous version $daily_counter_str='<span style="color: white;" title="'.__('All / Allowed / Blocked submissions. The number of submissions for past 24 hours. ', 'cleantalk').'"><span style="color: white;"> | Day: ' .$daily_counter['all']. '</span> / <span style="color: green;">' .$daily_counter['accepted']. '</span> / <span style="color: red;">' .$daily_counter['blocked']. '</span></span>';
566
+ $daily_counter_str='<span style="color: white;" title="'.__('Allowed / Blocked submissions. The number of submissions for past 24 hours. ', 'cleantalk').'"><span style="color: white;"> | ' . __('Day', 'cleantalk') . ': </span><span style="color: green;">' .$daily_counter['accepted']. '</span> / <span style="color: red;">' .$daily_counter['blocked']. '</span></span>';
567
+ }
568
+ $sfw_counter_str='';
569
+ //Don't compile if SFW counter disabled
570
+ if( $apbct->settings['sfw_counter'] == 1 && $apbct->settings['spam_firewall'] == 1){
571
+ $sfw_counter=Array('all'=>$apbct->data['sfw_counter']['all'], 'blocked'=>$apbct->data['sfw_counter']['blocked']);
572
+ $sfw_counter_str='<span style="color: white;" title="'.__('All / Blocked events. Access attempts regitred by SpamFireWall counted since the last plugin activation.', 'cleantalk').'"><span style="color: white;"> | SpamFireWall: ' .$sfw_counter['all']. '</span> / <span style="color: red;">' .$sfw_counter['blocked']. '</span></span>';
573
+ }
574
+
575
+ $args = array(
576
+ 'id' => 'ct_parent_node',
577
+ 'title' => '<img src="' . plugin_dir_url(__FILE__) . 'images/logo_small1.png" alt="" height="" style="margin-top:9px; float: left;" />'
578
+ .'<div style="margin: auto 7px;" class="ab-item alignright">'
579
+ .'<div class="ab-label" id="ct_stats">'
580
+ .($apbct->notice_trial == 1
581
+ ? "<span><a style='color: red;' href=\"http://cleantalk.org/my/bill/recharge?utm_source=wp-backend&utm_medium=cpc&utm_campaign=WP%20backend%20trial&user_token={$apbct->user_token}&cp_mode=antispam\" target=\"_blank\">Renew Anti-Spam</a></span>"
582
+ : '<span style="color: white;" title="'.__('Allowed / Blocked submissions. The number of submissions is being counted since ', 'cleantalk').' '.$user_counter['since'].'">'.$user_counter_str.'</span> '.$daily_counter_str.$all_time_counter_str.$sfw_counter_str
583
+ )
584
+ .'</div>'
585
+ .'</div>' //You could change widget string here by simply deleting variables
586
+ );
587
+ $wp_admin_bar->add_node( $args );
588
+
589
+ // DASHBOARD LINK
590
+ if(!$apbct->white_label){
591
+ $wp_admin_bar->add_node( array(
592
+ 'id' => 'ct_dashboard_link',
593
+ 'title' => '<a href="https://cleantalk.org/my/?user_token='.$apbct->user_token.'&utm_source=wp-backend&utm_medium=admin-bar&cp_mode=antispam " target="_blank">CleanTalk '.__('dashboard', 'cleantalk').'</a>',
594
+ 'parent' => 'ct_parent_node'
595
+ ));
596
+ }
597
+
598
+ $wp_admin_bar->add_node( array(
599
+ 'id' => 'ct_settings_link',
600
+ 'title' => '<a href="'.$apbct->settings_link.'">'.__('Settings', 'cleantalk').'</a>',
601
+ 'parent' => 'ct_parent_node'
602
+ ));
603
+
604
+ // add a child item to our parent item. Bulk checks.
605
+ if(!is_network_admin()){
606
+ $args = array(
607
+ 'id' => 'ct_settings_bulk_comments',
608
+ 'title' => '<hr style="margin-top: 7px;" /><a href="edit-comments.php?page=ct_check_spam" title="'.__('Bulk spam comments removal tool.', 'cleantalk').'">'.__('Check comments for spam', 'cleantalk').'</a>',
609
+ 'parent' => 'ct_parent_node'
610
+ );
611
+ }
612
+ $wp_admin_bar->add_node( $args );
613
+
614
+ // add a child item to our parent item. Bulk checks.
615
+ if(!is_network_admin()){
616
+ $args = array(
617
+ 'id' => 'ct_settings_bulk_users',
618
+ 'title' => '<a href="users.php?page=ct_check_users" title="Bulk spam users removal tool.">'.__('Check users for spam', 'cleantalk').'</a>',
619
+ 'parent' => 'ct_parent_node'
620
+ );
621
+ }
622
+ $wp_admin_bar->add_node( $args );
623
+
624
+ // User counter reset.
625
+ $args = array(
626
+ 'id' => 'ct_reset_counter',
627
+ 'title' => '<hr style="margin-top: 7px;"><a href="?ct_reset_user_counter=1" title="Reset your personal counter of submissions.">'.__('Reset first counter', 'cleantalk').'</a>',
628
+ 'parent' => 'ct_parent_node'
629
+ );
630
+ $wp_admin_bar->add_node( $args );// add a child item to our parent item. Counter reset.
631
+
632
+ // Reset ALL counter
633
+ $args = array(
634
+ 'id' => 'ct_reset_counters_all',
635
+ 'title' => '<a href="?ct_reset_all_counters=1" title="Reset all counters.">'.__('Reset all counters', 'cleantalk').'</a>',
636
+ 'parent' => 'ct_parent_node'
637
+ );
638
+ $wp_admin_bar->add_node( $args );
639
+
640
+ // Support link
641
+ if(!$apbct->white_label){
642
+ $wp_admin_bar->add_node( array(
643
+ 'id' => 'ct_admin_bar_support_link',
644
+ 'title' => '<hr style="margin-top: 7px;" /><a target="_blank" href="https://wordpress.org/support/plugin/cleantalk-spam-protect">'.__('Support', 'cleantalk').'</a>',
645
+ 'parent' => 'ct_parent_node'
646
+ ));
647
+ }
648
+ }
649
+ }
650
+
651
+ /**
652
+ * Unmark bad words
653
+ * @param string $message
654
+ * @return string Cleat comment
655
+ */
656
+ function apbct_comment__unmark_red($message) {
657
+ $message = preg_replace("/\<font rel\=\"cleantalk\" color\=\"\#FF1000\"\>(\S+)\<\/font>/iu", '$1', $message);
658
+
659
+ return $message;
660
+ }
661
+
662
+ // Ajax action feedback form comments page.
663
+ function apbct_comment__send_feedback($comment_id = null, $comment_status = null, $change_status = false, $direct_call = null){
664
+
665
+ // For AJAX call
666
+ check_ajax_referer('ct_secret_nonce', 'security');
667
+ $comment_id = !empty($_POST['comment_id']) ? $_POST['comment_id'] : false;
668
+ $comment_status = !empty($_POST['comment_status']) ? $_POST['comment_status'] : false;
669
+ $change_status = !empty($_POST['change_status']) ? $_POST['change_status'] : false;
670
+
671
+ // If enter params is empty exit
672
+ if(!$comment_id || !$comment_status)
673
+ die();
674
+
675
+ // $comment = get_comment($comment_id, 'ARRAY_A');
676
+ $hash = get_comment_meta($comment_id, 'ct_hash', true);
677
+
678
+ // If we can send the feedback
679
+ if($hash){
680
+
681
+ // Approving
682
+ if($comment_status == '1' || $comment_status == 'approve'){
683
+ $result = ct_send_feedback($hash.":1");
684
+ // $comment['comment_content'] = apbct_comment__unmark_red($comment['comment_content']);
685
+ // wp_update_comment($comment);
686
+ $result === true ? 1 : 0;
687
+ }
688
+
689
+ // Disapproving
690
+ if($comment_status == 'spam'){
691
+ $result = ct_send_feedback($hash.":0");
692
+ $result === true ? 1 : 0;
693
+ }
694
+ }else{
695
+ $result = 'no_hash';
696
+ }
697
+
698
+ // Changing comment status(folder) if flag is set. spam || approve
699
+ if($change_status !== false)
700
+ wp_set_comment_status($comment_id, $comment_status);
701
+
702
+ if(!$direct_call){
703
+ echo !empty($result) ? $result : 0;
704
+ die();
705
+ }else{
706
+
707
+ }
708
+ }
709
+
710
+ // Ajax action feedback form user page.
711
+ function apbct_user__send_feedback($user_id = null, $status = null, $direct_call = null){
712
+
713
+ check_ajax_referer('ct_secret_nonce', 'security');
714
+
715
+ if(!$direct_call){
716
+ $user_id = $_POST['user_id'];
717
+ $status = $_POST['status'];
718
+ }
719
+
720
+ $hash = get_user_meta($user_id, 'ct_hash', true);
721
+
722
+ if($hash){
723
+ if($status == 'approve' || $status == 1){
724
+ $result = ct_send_feedback($hash.":1");
725
+ $result === true ? 1 : 0;
726
+ }
727
+ if($status == 'spam' || $status == 'disapprove' || $status == 0){
728
+ $result = ct_send_feedback($hash.":0");
729
+ $result === true ? 1 : 0;
730
+ }
731
+ }else{
732
+ $result = 'no_hash';
733
+ }
734
+
735
+ if(!$direct_call){
736
+ echo !empty($result) ? $result : 0;
737
+ die();
738
+ }else{
739
+
740
+ }
741
+
742
+ }
743
+
744
+ /**
745
+ * Send feedback when user deleted
746
+ * @return null
747
+ */
748
+ function apbct_user__delete__hook($user_id, $reassign = null){
749
+
750
+ $hash = get_user_meta($user_id, 'ct_hash', true);
751
+ if ($hash !== '') {
752
+ ct_feedback($hash, 0);
753
+ }
754
  }
inc/cleantalk-common.php CHANGED
@@ -270,13 +270,17 @@ function apbct_exclusions_check__ip(){
270
 
271
  global $cleantalk_ip_exclusions;
272
 
273
- if(CleantalkHelper::ip__is_cleantalks($_SERVER['REMOTE_ADDR']))
274
- return true;
275
-
276
- if (!empty($cleantalk_ip_exclusions) && is_array($cleantalk_ip_exclusions)){
277
- foreach($cleantalk_ip_exclusions as $exclusion){
278
- if(stripos($_SERVER['REMOTE_ADDR'], $exclusion) !== false){
279
- return true;
 
 
 
 
280
  }
281
  }
282
  }
@@ -432,7 +436,7 @@ function ct_get_checkjs_value(){
432
  // Use static JS keys
433
  if(
434
  $apbct->settings['use_static_js_key'] == 1 ||
435
- ($apbct->settings['use_static_js_key'] == -1 && apbct_is_cache_plugins_persist())
436
  ){
437
  $key = hash('sha256', $apbct->api_key.ct_get_admin_email().$apbct->salt);
438
 
@@ -475,7 +479,7 @@ function ct_get_checkjs_value(){
475
  return $key;
476
  }
477
 
478
- function apbct_is_cache_plugins_persist(){
479
  return
480
  defined('WP_ROCKET_VERSION') || // WPRocket
481
  defined('LSCWP_DIR') || // LiteSpeed Cache
@@ -797,7 +801,7 @@ function ct_get_fields_any($arr, $message=array(), $email = null, $nickname = ar
797
  elseif(count($match_nickname) > 1)
798
  $nickname['nick'] = $value;
799
  else
800
- $nickname['name'] = $value;
801
 
802
  // Subject
803
  }elseif ($subject === null && preg_match("/subject/i", $key)){
270
 
271
  global $cleantalk_ip_exclusions;
272
 
273
+ if( isset( $_SERVER['REMOTE_ADDR'] ) ){
274
+
275
+ if( CleantalkHelper::ip__is_cleantalks( $_SERVER['REMOTE_ADDR'] ) ){
276
+ return true;
277
+ }
278
+
279
+ if( ! empty( $cleantalk_ip_exclusions ) && is_array( $cleantalk_ip_exclusions ) ){
280
+ foreach ( $cleantalk_ip_exclusions as $exclusion ){
281
+ if( stripos( $_SERVER['REMOTE_ADDR'], $exclusion ) !== false ){
282
+ return true;
283
+ }
284
  }
285
  }
286
  }
436
  // Use static JS keys
437
  if(
438
  $apbct->settings['use_static_js_key'] == 1 ||
439
+ ($apbct->settings['use_static_js_key'] == -1 && apbct_is_cache_plugins_exists())
440
  ){
441
  $key = hash('sha256', $apbct->api_key.ct_get_admin_email().$apbct->salt);
442
 
479
  return $key;
480
  }
481
 
482
+ function apbct_is_cache_plugins_exists(){
483
  return
484
  defined('WP_ROCKET_VERSION') || // WPRocket
485
  defined('LSCWP_DIR') || // LiteSpeed Cache
801
  elseif(count($match_nickname) > 1)
802
  $nickname['nick'] = $value;
803
  else
804
+ $message[$prev_name.$key] = $value;
805
 
806
  // Subject
807
  }elseif ($subject === null && preg_match("/subject/i", $key)){
inc/cleantalk-public.php CHANGED
@@ -350,8 +350,11 @@ function apbct_buffer__output(){
350
 
351
  $html = $dom->getElementsByTagName('html');
352
 
353
- echo gettype($html) == 'object'
354
- ? $html[0]->childNodes[0]->ownerDocument->saveHTML()
 
 
 
355
  : $apbct->buffer;
356
  }
357
 
@@ -1395,15 +1398,14 @@ function apbct_js_test($field_name = 'ct_checkjs', $data = null) {
1395
 
1396
  if($data && isset($data[$field_name])){
1397
 
1398
- $js_key = $data[$field_name];
1399
 
1400
  // Check static key
1401
  if(
1402
  $apbct->settings['use_static_js_key'] == 1 ||
1403
- ($apbct->settings['use_static_js_key'] == -1 && apbct_is_cache_plugins_persist())
1404
  ){
1405
- $ct_challenge = ct_get_checkjs_value();
1406
- $out = preg_match("/$ct_challenge/", $js_key) ? 1 : 0;
1407
 
1408
  // Random key check
1409
  }else{
350
 
351
  $html = $dom->getElementsByTagName('html');
352
 
353
+ echo gettype($html) == 'object' && !isset( $html[0], $html[0]->childNodes, $html[0]->childNodes[0] )
354
+ ? $html[0]
355
+ ->childNodes[0]
356
+ ->ownerDocument
357
+ ->saveHTML()
358
  : $apbct->buffer;
359
  }
360
 
1398
 
1399
  if($data && isset($data[$field_name])){
1400
 
1401
+ $js_key = trim($data[$field_name]);
1402
 
1403
  // Check static key
1404
  if(
1405
  $apbct->settings['use_static_js_key'] == 1 ||
1406
+ ($apbct->settings['use_static_js_key'] == -1 && apbct_is_cache_plugins_exists())
1407
  ){
1408
+ $out = ct_get_checkjs_value() === $js_key ? 1 : 0;
 
1409
 
1410
  // Random key check
1411
  }else{
inc/cleantalk-settings.php CHANGED
@@ -630,12 +630,12 @@ function apbct_settings__error__output($return = false){
630
 
631
  $error_texts = array(
632
  // Misc
633
- 'key_invalid' => __('Error occured while API key validating. Error: ', 'security-malware-firewall'),
634
- 'key_get' => __('Error occured while automatically gettings access key. Error: ', 'security-malware-firewall'),
635
- 'sfw_send_logs' => __('Error occured while sending sending SpamFireWall logs. Error: ', 'security-malware-firewall'),
636
- 'sfw_update' => __('Error occured while updating SpamFireWall local base. Error: ' , 'security-malware-firewall'),
637
- 'account_check' => __('Error occured while checking account status. Error: ', 'security-malware-firewall'),
638
- 'api' => __('Error occured while excuting API call. Error: ', 'security-malware-firewall'),
639
 
640
  // Validating settings
641
  'settings_validate' => 'Validate Settings',
@@ -643,7 +643,7 @@ function apbct_settings__error__output($return = false){
643
  'exclusions_fields' => 'Field Exclusions',
644
 
645
  // Unknown
646
- 'unknown' => __('Unknown error. Error: ', 'security-malware-firewall'),
647
  );
648
 
649
  $errors_out = array();
@@ -674,7 +674,7 @@ function apbct_settings__error__output($return = false){
674
 
675
  if(!empty($errors_out)){
676
  $out .= '<div id="apbctTopWarning" class="error" style="position: relative;">'
677
- .'<h3 style="display: inline-block;">'.__('Errors:', 'security-malware-firewall').'</h3>';
678
  foreach($errors_out as $value){
679
  $out .= '<h4>'.$value.'</h4>';
680
  }
@@ -859,7 +859,7 @@ function apbct_settings__field__apikey(){
859
  echo '<div>';
860
  echo '<input checked type="checkbox" id="license_agreed" onclick="apbctSettingsDependencies(\'apbct_setting---get_key_auto\');"/>';
861
  echo '<label for="spbc_license_agreed">';
862
- printf( __('I accept %sLicense Agreement%s.', 'security-malware-firewall'),
863
  '<a href="https://cleantalk.org/publicoffer" target="_blank" style="color:#66b;">',
864
  '</a>'
865
  );
630
 
631
  $error_texts = array(
632
  // Misc
633
+ 'key_invalid' => __('Error occured while API key validating. Error: ', 'cleantalk'),
634
+ 'key_get' => __('Error occured while automatically gettings access key. Error: ', 'cleantalk'),
635
+ 'sfw_send_logs' => __('Error occured while sending sending SpamFireWall logs. Error: ', 'cleantalk'),
636
+ 'sfw_update' => __('Error occured while updating SpamFireWall local base. Error: ' , 'cleantalk'),
637
+ 'account_check' => __('Error occured while checking account status. Error: ', 'cleantalk'),
638
+ 'api' => __('Error occured while excuting API call. Error: ', 'cleantalk'),
639
 
640
  // Validating settings
641
  'settings_validate' => 'Validate Settings',
643
  'exclusions_fields' => 'Field Exclusions',
644
 
645
  // Unknown
646
+ 'unknown' => __('Unknown error. Error: ', 'cleantalk'),
647
  );
648
 
649
  $errors_out = array();
674
 
675
  if(!empty($errors_out)){
676
  $out .= '<div id="apbctTopWarning" class="error" style="position: relative;">'
677
+ .'<h3 style="display: inline-block;">'.__('Errors:', 'cleantalk').'</h3>';
678
  foreach($errors_out as $value){
679
  $out .= '<h4>'.$value.'</h4>';
680
  }
859
  echo '<div>';
860
  echo '<input checked type="checkbox" id="license_agreed" onclick="apbctSettingsDependencies(\'apbct_setting---get_key_auto\');"/>';
861
  echo '<label for="spbc_license_agreed">';
862
+ printf( __('I accept %sLicense Agreement%s.', 'cleantalk'),
863
  '<a href="https://cleantalk.org/publicoffer" target="_blank" style="color:#66b;">',
864
  '</a>'
865
  );
js/cleantalk-comments-editscreen.min.js CHANGED
@@ -1,2 +1,2 @@
1
- function ct_is_email(e){return e.search(/.*@.*\..*/)}function ct_is_ip(e){return e.search(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/)}function ct_send_feedback_request(t,c,n){var e={action:"ct_feedback_comment",security:ctCommentsScreen.ct_ajax_nonce,comment_id:t,comment_status:c};jQuery.ajax({type:"POST",url:ajaxurl,data:e,success:function(e){ct_feedback_message_output(t,c,e,n)},error:function(e,t,c){console.log(e),console.log(t),console.log(c)},timeout:5e3})}function ct_feedback_message_output(e,t,c,n){1==c&&("approve"!=t||n||jQuery("tr#comment-"+e).html("").show().append("<td colspan='5'></td>").children("td").css("background","rgba(110,240,110,0.7)").append("<div class='spam-undo-inside'>"+ctCommentsScreen.ct_feedback_msg_whitelisted+" "+ctCommentsScreen.ct_feedback_msg+"</div>"),"spam"==t&&(jQuery("tr").is("#undo-"+e)?(jQuery("tr#undo-"+e).css("background","rgba(240,110,110,0.7)"),jQuery("tr#undo-"+e+" div.spam-undo-inside").append(" "+ctCommentsScreen.ct_feedback_msg_blacklisted+" "+ctCommentsScreen.ct_feedback_msg)):jQuery("tr#comment-"+e).html("").show().css("background","rgba(240,110,110,0.7)").append("<td colspan='5'></td>").children("td").append("<div class='spam-undo-inside'>"+ctCommentsScreen.ct_feedback_msg_blacklisted+" "+ctCommentsScreen.ct_feedback_msg+"</div>")))}jQuery(document).ready(function(){var t;jQuery("#post-query-submit").after('<a href="edit-comments.php?page=ct_check_spam" class="button" style="margin:1px 0 0 0; display: inline-block;">'+ctAdminCommon.logo_small_colored+"&nbsp;"+ctCommentsScreen.spambutton_text+"</a>&nbsp;"),parseInt(ctCommentsScreen.ct_show_check_links)&&jQuery(".column-author a, .comment-author a").each(function(){var e=jQuery(this).html();-1==ct_is_email(e)&&-1==ct_is_ip(e)||jQuery(this).after('&nbsp;<a href="https://cleantalk.org/blacklists/'+e+'" target="_blank" title="https://cleantalk.org/blacklists/'+e+'" class="ct_link_new_tab"><img src="'+ctCommentsScreen.ct_img_src_new_tab+'"></a>')}),jQuery("span.approve").on("click",function(){var e=jQuery(this).children("a").attr("href");e=e.match(/^comment\.php\?.*c=(\d*).*/),t=e[1],ct_send_feedback_request(undo_comment_id=t,"approve",0)}),jQuery("span.unapprove").on("click",function(){var e=jQuery(this).children("a").attr("href");e=e.match(/^comment\.php\?.*c=(\d*).*/),t=e[1],ct_send_feedback_request(undo_comment_id=t,"spam",0)}),jQuery("span.spam").on("click",function(){var e=jQuery(this).children("a").attr("href");e=e.match(/^comment\.php\?.*c=(\d*).*/),t=e[1],ct_send_feedback_request(undo_comment_id=t,"spam",0),setTimeout(function(){jQuery("tr#undo-"+t+" span.unspam a").click(function(){var e=jQuery(this).attr("href");e=e.match(/^comment\.php\?.*&c=(\d*).*/),ct_send_feedback_request(t=e[1],"approve",1)})},202)}),jQuery("span.unspam").on("click",function(){var e=jQuery(this).children("a").attr("href");e=e.match(/^comment\.php\?.*c=(\d*).*/),ct_send_feedback_request(t=e[1],"approve",0)}),jQuery("span.untrash a").on("click",function(){var e=jQuery(this).attr("href");e=e.match(/^comment\.php\?.*c=(\d*).*/),t=e[1],feedback_result=ct_send_feedback_request(t,"approve",0)})});
2
  //# sourceMappingURL=cleantalk-comments-editscreen.min.js.map
1
+ function ct_is_email(e){return e.search(/.*@.*\..*/)}function ct_is_ip(e){return e.search(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/)}function ct_send_feedback_request(t,c,n){var e={action:"ct_feedback_comment",security:ctCommentsScreen.ct_ajax_nonce,comment_id:t,comment_status:c};jQuery.ajax({type:"POST",url:ajaxurl,data:e,success:function(e){ct_feedback_message_output(t,c,e,n)},error:function(e,t,c){console.log(e),console.log(t),console.log(c)},timeout:5e3})}function ct_feedback_message_output(e,t,c,n){1==c&&("approve"!=t||n||jQuery("tr#comment-"+e).html("").show().append("<td colspan='5'></td>").children("td").css("background","rgba(110,240,110,0.7)").append("<div class='spam-undo-inside'>"+ctCommentsScreen.ct_feedback_msg_whitelisted+" "+ctCommentsScreen.ct_feedback_msg+"</div>"),"spam"==t&&(jQuery("tr").is("#undo-"+e)?(jQuery("tr#undo-"+e).css("background","rgba(240,110,110,0.7)"),jQuery("tr#undo-"+e+" div.spam-undo-inside").append(" "+ctCommentsScreen.ct_feedback_msg_blacklisted+" "+ctCommentsScreen.ct_feedback_msg)):jQuery("tr#comment-"+e).html("").show().css("background","rgba(240,110,110,0.7)").append("<td colspan='5'></td>").children("td").append("<div class='spam-undo-inside'>"+ctCommentsScreen.ct_feedback_msg_blacklisted+" "+ctCommentsScreen.ct_feedback_msg+"</div>")))}jQuery(document).ready(function(){var t;parseInt(ctCommentsScreen.ct_show_check_links)&&jQuery(".column-author a, .comment-author a").each(function(){var e=jQuery(this).html();-1==ct_is_email(e)&&-1==ct_is_ip(e)||jQuery(this).after('&nbsp;<a href="https://cleantalk.org/blacklists/'+e+'" target="_blank" title="https://cleantalk.org/blacklists/'+e+'" class="ct_link_new_tab"><img src="'+ctCommentsScreen.ct_img_src_new_tab+'"></a>')}),jQuery("span.approve").on("click",function(){var e=jQuery(this).children("a").attr("href");e=e.match(/^comment\.php\?.*c=(\d*).*/),t=e[1],ct_send_feedback_request(undo_comment_id=t,"approve",0)}),jQuery("span.unapprove").on("click",function(){var e=jQuery(this).children("a").attr("href");e=e.match(/^comment\.php\?.*c=(\d*).*/),t=e[1],ct_send_feedback_request(undo_comment_id=t,"spam",0)}),jQuery("span.spam").on("click",function(){var e=jQuery(this).children("a").attr("href");e=e.match(/^comment\.php\?.*c=(\d*).*/),t=e[1],ct_send_feedback_request(undo_comment_id=t,"spam",0),setTimeout(function(){jQuery("tr#undo-"+t+" span.unspam a").click(function(){var e=jQuery(this).attr("href");e=e.match(/^comment\.php\?.*&c=(\d*).*/),ct_send_feedback_request(t=e[1],"approve",1)})},202)}),jQuery("span.unspam").on("click",function(){var e=jQuery(this).children("a").attr("href");e=e.match(/^comment\.php\?.*c=(\d*).*/),ct_send_feedback_request(t=e[1],"approve",0)}),jQuery("span.untrash a").on("click",function(){var e=jQuery(this).attr("href");e=e.match(/^comment\.php\?.*c=(\d*).*/),t=e[1],feedback_result=ct_send_feedback_request(t,"approve",0)})});
2
  //# sourceMappingURL=cleantalk-comments-editscreen.min.js.map
js/cleantalk-comments-editscreen.min.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["cleantalk-comments-editscreen.js"],"names":["ct_is_email","str","search","ct_is_ip","ct_send_feedback_request","ct_comment_id","ct_comment_status","ct_undo","data","action","security","ctCommentsScreen","ct_ajax_nonce","comment_id","comment_status","jQuery","ajax","type","url","ajaxurl","success","msg","ct_feedback_message_output","error","jqXHR","textStatus","errorThrown","console","log","timeout","ct_result","html","show","append","children","css","ct_feedback_msg_whitelisted","ct_feedback_msg","is","ct_feedback_msg_blacklisted","document","ready","after","ctAdminCommon","logo_small_colored","spambutton_text","parseInt","ct_show_check_links","each","ct_curr_str","this","ct_img_src_new_tab","on","result","attr","match","undo_comment_id","setTimeout","click","feedback_result"],"mappings":"AAAA,SAASA,YAAYC,GACpB,OAAOA,EAAIC,OAAO,aAEnB,SAASC,SAASF,GACjB,OAAOA,EAAIC,OAAO,wCA2EnB,SAASE,yBAAyBC,EAAeC,EAAmBC,GAEnE,IAAIC,EAAO,CACVC,OAAU,sBACVC,SAAYC,iBAAiBC,cAC7BC,WAAcR,EACdS,eAAkBR,GAGnBS,OAAOC,KAAK,CACXC,KAAM,OACNC,IAAKC,QACLX,KAAMA,EACNY,QAAS,SAASC,GACjBC,2BAA2BjB,EAAeC,EAAmBe,EAAKd,IAE7DgB,MAAO,SAASC,EAAOC,EAAYC,GACxCC,QAAQC,IAAIJ,GACZG,QAAQC,IAAIH,GACZE,QAAQC,IAAIF,IAEPG,QAAS,MAKjB,SAASP,2BAA2BjB,EAAeC,EAAmBwB,EAAWvB,GAChE,GAAbuB,IACsB,WAArBxB,GAAmCC,GACrCQ,OAAO,cAAcV,GACnB0B,KAAK,IACLC,OACAC,OAAO,yBAAyBC,SAAS,MACxCC,IAAI,aAAc,yBAClBF,OAAO,iCAAiCtB,iBAAiByB,4BAA4B,IAAIzB,iBAAiB0B,gBAAgB,UAEtG,QAArB/B,IACCS,OAAO,MAAMuB,GAAG,SAASjC,IAC3BU,OAAO,WAAWV,GAChB8B,IAAI,aAAc,yBACpBpB,OAAO,WAAWV,EAAc,yBAC9B4B,OAAO,IAAItB,iBAAiB4B,4BAA4B,IAAI5B,iBAAiB0B,kBAE/EtB,OAAO,cAAcV,GACpB0B,KAAK,IACLC,OACAG,IAAI,aAAc,yBAClBF,OAAO,yBAAyBC,SAAS,MACxCD,OAAO,iCAAiCtB,iBAAiB4B,4BAA4B,IAAI5B,iBAAiB0B,gBAAgB,YAxHhItB,OAAOyB,UAAUC,MAAM,WAetB,IAAIpC,EAZJU,OAAO,sBAAsB2B,MAAM,kHAAkHC,cAAcC,mBAAmB,SAASjC,iBAAiBkC,gBAAgB,cAG7NC,SAASnC,iBAAiBoC,sBAC5BhC,OAAO,uCAAuCiC,KAAK,WAClD,IAAIC,EAAclC,OAAOmC,MAAMnB,QACC,GAA7B/B,YAAYiD,KAAgD,GAA1B9C,SAAS8C,IAC7ClC,OAAOmC,MAAMR,MAAM,mDAAmDO,EAAY,6DAA6DA,EAAY,uCAAuCtC,iBAAiBwC,mBAAmB,YAQzOpC,OAAO,gBAAgBqC,GAAG,QAAS,WAClC,IAAIC,EAAStC,OAAOmC,MAAMhB,SAAS,KAAKoB,KAAK,QAC7CD,EAASA,EAAOE,MAAM,8BACtBlD,EAAgBgD,EAAO,GAEvBjD,yBADAoD,gBAAkBnD,EACsB,UAAW,KAIpDU,OAAO,kBAAkBqC,GAAG,QAAS,WACpC,IAAIC,EAAStC,OAAOmC,MAAMhB,SAAS,KAAKoB,KAAK,QAC7CD,EAASA,EAAOE,MAAM,8BACtBlD,EAAgBgD,EAAO,GAEvBjD,yBADAoD,gBAAkBnD,EACsB,OAAQ,KAIjDU,OAAO,aAAaqC,GAAG,QAAS,WAC/B,IAAIC,EAAStC,OAAOmC,MAAMhB,SAAS,KAAKoB,KAAK,QAC7CD,EAASA,EAAOE,MAAM,8BACtBlD,EAAgBgD,EAAO,GAEvBjD,yBADAoD,gBAAkBnD,EACsB,OAAQ,GAEhDoD,WAAW,WACV1C,OAAO,WAAWV,EAAc,kBAAkBqD,MAAM,WACvD,IAAIL,EAAStC,OAAOmC,MAAMI,KAAK,QAC/BD,EAASA,EAAOE,MAAM,+BAEtBnD,yBADAC,EAAgBgD,EAAO,GACiB,UAAW,MAElD,OAKJtC,OAAO,eAAeqC,GAAG,QAAS,WACjC,IAAIC,EAAStC,OAAOmC,MAAMhB,SAAS,KAAKoB,KAAK,QAC7CD,EAASA,EAAOE,MAAM,8BAEtBnD,yBADAC,EAAgBgD,EAAO,GACiB,UAAW,KAIpDtC,OAAO,kBAAkBqC,GAAG,QAAS,WACpC,IAAIC,EAAStC,OAAOmC,MAAMI,KAAK,QAC/BD,EAASA,EAAOE,MAAM,8BACtBlD,EAAgBgD,EAAO,GACvBM,gBAAkBvD,yBAAyBC,EAAe,UAAW","file":"cleantalk-comments-editscreen.min.js","sourcesContent":["function ct_is_email(str){\r\n\treturn str.search(/.*@.*\\..*/);\r\n}\r\nfunction ct_is_ip(str){\r\n\treturn str.search(/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/);\r\n}\r\n\r\njQuery(document).ready(function(){\r\n\t\r\n\t/* Shows \"Find spam users\" button */\r\n\tjQuery('#post-query-submit').after('<a href=\"edit-comments.php?page=ct_check_spam\" class=\"button\" style=\"margin:1px 0 0 0; display: inline-block;\">'+ctAdminCommon.logo_small_colored+'&nbsp;'+ctCommentsScreen.spambutton_text+'</a>&nbsp;');\r\n\r\n\t/* Shows link to blacklists near every email and IP address */\r\n\tif(parseInt(ctCommentsScreen.ct_show_check_links))\r\n\t\tjQuery('.column-author a, .comment-author a').each(function(){\r\n\t\t\tvar ct_curr_str = jQuery(this).html();\r\n\t\t\tif(ct_is_email(ct_curr_str) != -1 || ct_is_ip(ct_curr_str) != -1){\r\n\t\t\t\tjQuery(this).after('&nbsp;<a href=\"https://cleantalk.org/blacklists/'+ct_curr_str+'\" target=\"_blank\" title=\"https://cleantalk.org/blacklists/'+ct_curr_str+'\" class=\"ct_link_new_tab\"><img src=\"'+ctCommentsScreen.ct_img_src_new_tab+'\"></a>');\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\t/* Feedback for comments */\r\n\tvar ct_comment_id;\r\n\t\r\n\t// For approved\r\n\tjQuery('span.approve').on('click', function(){\r\n\t\tvar result = jQuery(this).children('a').attr('href');\r\n\t\tresult = result.match(/^comment\\.php\\?.*c=(\\d*).*/);\r\n\t\tct_comment_id = result[1];\r\n\t\tundo_comment_id = ct_comment_id;\r\n\t\tct_send_feedback_request(ct_comment_id, 'approve', 0);\t\t\r\n\t});\r\n\t\r\n\t// For unapprove\r\n\tjQuery('span.unapprove').on('click', function(){\r\n\t\tvar result = jQuery(this).children('a').attr('href');\r\n\t\tresult = result.match(/^comment\\.php\\?.*c=(\\d*).*/);\r\n\t\tct_comment_id = result[1];\r\n\t\tundo_comment_id = ct_comment_id;\r\n\t\tct_send_feedback_request(ct_comment_id, 'spam', 0);\t\t\r\n\t});\r\n\t\r\n\t// For spammed\r\n\tjQuery('span.spam').on('click', function(){\r\n\t\tvar result = jQuery(this).children('a').attr('href');\r\n\t\tresult = result.match(/^comment\\.php\\?.*c=(\\d*).*/);\r\n\t\tct_comment_id = result[1];\r\n\t\tundo_comment_id = ct_comment_id;\r\n\t\tct_send_feedback_request(ct_comment_id, 'spam', 0);\r\n\t\t\r\n\t\tsetTimeout(function(){\r\n\t\t\tjQuery('tr#undo-'+ct_comment_id+' span.unspam a').click(function(){\r\n\t\t\t\tvar result = jQuery(this).attr('href');\r\n\t\t\t\tresult = result.match(/^comment\\.php\\?.*&c=(\\d*).*/);\r\n\t\t\t\tct_comment_id = result[1];\r\n\t\t\t\tct_send_feedback_request(ct_comment_id, 'approve', 1);\r\n\t\t\t});\r\n\t\t}, 202);\r\n\t\t\r\n\t});\r\n\t\r\n\t// For unspammed\r\n\tjQuery('span.unspam').on('click', function(){\r\n\t\tvar result = jQuery(this).children('a').attr('href');\r\n\t\tresult = result.match(/^comment\\.php\\?.*c=(\\d*).*/);\r\n\t\tct_comment_id = result[1];\r\n\t\tct_send_feedback_request(ct_comment_id, 'approve', 0);\r\n\t});\r\n\t\r\n\t// For untrashed\r\n\tjQuery('span.untrash a').on('click', function(){\r\n\t\tvar result = jQuery(this).attr('href');\r\n\t\tresult = result.match(/^comment\\.php\\?.*c=(\\d*).*/);\r\n\t\tct_comment_id = result[1];\r\n\t\tfeedback_result = ct_send_feedback_request(ct_comment_id, 'approve', 0);\t\t\r\n\t});\t\r\n});\r\n\r\n// Send feedback to backend\r\nfunction ct_send_feedback_request(ct_comment_id, ct_comment_status, ct_undo){\r\n\t\r\n\tvar data = {\r\n\t\t'action': 'ct_feedback_comment',\r\n\t\t'security': ctCommentsScreen.ct_ajax_nonce,\r\n\t\t'comment_id': ct_comment_id,\r\n\t\t'comment_status': ct_comment_status\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\tct_feedback_message_output(ct_comment_id, ct_comment_status, msg, ct_undo);\r\n\t\t},\r\n error: function(jqXHR, textStatus, errorThrown) {\r\n\t\t\tconsole.log(jqXHR);\r\n\t\t\tconsole.log(textStatus);\r\n\t\t\tconsole.log(errorThrown);\r\n\t\t},\r\n timeout: 5000\r\n\t});\r\n}\r\n\r\n// Outputs CT message about feedback\r\nfunction ct_feedback_message_output(ct_comment_id, ct_comment_status, ct_result, ct_undo){\r\n\tif(ct_result == 1){\r\n\t\tif(ct_comment_status == 'approve' && !ct_undo){\r\n\t\t\tjQuery('tr#comment-'+ct_comment_id)\r\n\t\t\t\t.html('')\r\n\t\t\t\t.show()\r\n\t\t\t\t.append(\"<td colspan='5'></td>\").children('td')\r\n\t\t\t\t\t.css('background', 'rgba(110,240,110,0.7)')\r\n\t\t\t\t\t.append(\"<div class='spam-undo-inside'>\"+ctCommentsScreen.ct_feedback_msg_whitelisted+\" \"+ctCommentsScreen.ct_feedback_msg+\"</div>\");\t\t\t\t\t\t\r\n\t\t}\r\n\t\tif(ct_comment_status == 'spam'){\r\n\t\t\tif(jQuery('tr').is('#undo-'+ct_comment_id)){\r\n\t\t\t\tjQuery('tr#undo-'+ct_comment_id)\r\n\t\t\t\t\t.css('background', 'rgba(240,110,110,0.7)');\r\n\t\t\t\tjQuery('tr#undo-'+ct_comment_id+' div.spam-undo-inside')\r\n\t\t\t\t\t.append(\" \"+ctCommentsScreen.ct_feedback_msg_blacklisted+\" \"+ctCommentsScreen.ct_feedback_msg);\r\n\t\t\t}else{\r\n\t\t\t\tjQuery('tr#comment-'+ct_comment_id)\r\n\t\t\t\t.html('')\r\n\t\t\t\t.show()\r\n\t\t\t\t.css('background', 'rgba(240,110,110,0.7)')\r\n\t\t\t\t.append(\"<td colspan='5'></td>\").children('td')\r\n\t\t\t\t\t.append(\"<div class='spam-undo-inside'>\"+ctCommentsScreen.ct_feedback_msg_blacklisted+\" \"+ctCommentsScreen.ct_feedback_msg+\"</div>\");\t\t\t\t\t\t\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tif(ct_result == 0){\r\n\t\t// Error occurred\r\n\t}if(ct_result == 'no_hash'){\r\n\t\t// No hash for this comment\r\n\t}\r\n}\r\n"]}
1
+ {"version":3,"sources":["cleantalk-comments-editscreen.js"],"names":["ct_is_email","str","search","ct_is_ip","ct_send_feedback_request","ct_comment_id","ct_comment_status","ct_undo","data","action","security","ctCommentsScreen","ct_ajax_nonce","comment_id","comment_status","jQuery","ajax","type","url","ajaxurl","success","msg","ct_feedback_message_output","error","jqXHR","textStatus","errorThrown","console","log","timeout","ct_result","html","show","append","children","css","ct_feedback_msg_whitelisted","ct_feedback_msg","is","ct_feedback_msg_blacklisted","document","ready","parseInt","ct_show_check_links","each","ct_curr_str","this","after","ct_img_src_new_tab","on","result","attr","match","undo_comment_id","setTimeout","click","feedback_result"],"mappings":"AAAA,SAASA,YAAYC,GACpB,OAAOA,EAAIC,OAAO,aAEnB,SAASC,SAASF,GACjB,OAAOA,EAAIC,OAAO,wCAwEnB,SAASE,yBAAyBC,EAAeC,EAAmBC,GAEnE,IAAIC,EAAO,CACVC,OAAU,sBACVC,SAAYC,iBAAiBC,cAC7BC,WAAcR,EACdS,eAAkBR,GAGnBS,OAAOC,KAAK,CACXC,KAAM,OACNC,IAAKC,QACLX,KAAMA,EACNY,QAAS,SAASC,GACjBC,2BAA2BjB,EAAeC,EAAmBe,EAAKd,IAE7DgB,MAAO,SAASC,EAAOC,EAAYC,GACxCC,QAAQC,IAAIJ,GACZG,QAAQC,IAAIH,GACZE,QAAQC,IAAIF,IAEPG,QAAS,MAKjB,SAASP,2BAA2BjB,EAAeC,EAAmBwB,EAAWvB,GAChE,GAAbuB,IACsB,WAArBxB,GAAmCC,GACrCQ,OAAO,cAAcV,GACnB0B,KAAK,IACLC,OACAC,OAAO,yBAAyBC,SAAS,MACxCC,IAAI,aAAc,yBAClBF,OAAO,iCAAiCtB,iBAAiByB,4BAA4B,IAAIzB,iBAAiB0B,gBAAgB,UAEtG,QAArB/B,IACCS,OAAO,MAAMuB,GAAG,SAASjC,IAC3BU,OAAO,WAAWV,GAChB8B,IAAI,aAAc,yBACpBpB,OAAO,WAAWV,EAAc,yBAC9B4B,OAAO,IAAItB,iBAAiB4B,4BAA4B,IAAI5B,iBAAiB0B,kBAE/EtB,OAAO,cAAcV,GACpB0B,KAAK,IACLC,OACAG,IAAI,aAAc,yBAClBF,OAAO,yBAAyBC,SAAS,MACxCD,OAAO,iCAAiCtB,iBAAiB4B,4BAA4B,IAAI5B,iBAAiB0B,gBAAgB,YArHhItB,OAAOyB,UAAUC,MAAM,WAYtB,IAAIpC,EATDqC,SAAS/B,iBAAiBgC,sBAC5B5B,OAAO,uCAAuC6B,KAAK,WAClD,IAAIC,EAAc9B,OAAO+B,MAAMf,QACC,GAA7B/B,YAAY6C,KAAgD,GAA1B1C,SAAS0C,IAC7C9B,OAAO+B,MAAMC,MAAM,mDAAmDF,EAAY,6DAA6DA,EAAY,uCAAuClC,iBAAiBqC,mBAAmB,YAQzOjC,OAAO,gBAAgBkC,GAAG,QAAS,WAClC,IAAIC,EAASnC,OAAO+B,MAAMZ,SAAS,KAAKiB,KAAK,QAC7CD,EAASA,EAAOE,MAAM,8BACtB/C,EAAgB6C,EAAO,GAEvB9C,yBADAiD,gBAAkBhD,EACsB,UAAW,KAIpDU,OAAO,kBAAkBkC,GAAG,QAAS,WACpC,IAAIC,EAASnC,OAAO+B,MAAMZ,SAAS,KAAKiB,KAAK,QAC7CD,EAASA,EAAOE,MAAM,8BACtB/C,EAAgB6C,EAAO,GAEvB9C,yBADAiD,gBAAkBhD,EACsB,OAAQ,KAIjDU,OAAO,aAAakC,GAAG,QAAS,WAC/B,IAAIC,EAASnC,OAAO+B,MAAMZ,SAAS,KAAKiB,KAAK,QAC7CD,EAASA,EAAOE,MAAM,8BACtB/C,EAAgB6C,EAAO,GAEvB9C,yBADAiD,gBAAkBhD,EACsB,OAAQ,GAEhDiD,WAAW,WACVvC,OAAO,WAAWV,EAAc,kBAAkBkD,MAAM,WACvD,IAAIL,EAASnC,OAAO+B,MAAMK,KAAK,QAC/BD,EAASA,EAAOE,MAAM,+BAEtBhD,yBADAC,EAAgB6C,EAAO,GACiB,UAAW,MAElD,OAKJnC,OAAO,eAAekC,GAAG,QAAS,WACjC,IAAIC,EAASnC,OAAO+B,MAAMZ,SAAS,KAAKiB,KAAK,QAC7CD,EAASA,EAAOE,MAAM,8BAEtBhD,yBADAC,EAAgB6C,EAAO,GACiB,UAAW,KAIpDnC,OAAO,kBAAkBkC,GAAG,QAAS,WACpC,IAAIC,EAASnC,OAAO+B,MAAMK,KAAK,QAC/BD,EAASA,EAAOE,MAAM,8BACtB/C,EAAgB6C,EAAO,GACvBM,gBAAkBpD,yBAAyBC,EAAe,UAAW","file":"cleantalk-comments-editscreen.min.js","sourcesContent":["function ct_is_email(str){\r\n\treturn str.search(/.*@.*\\..*/);\r\n}\r\nfunction ct_is_ip(str){\r\n\treturn str.search(/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/);\r\n}\r\n\r\njQuery(document).ready(function(){\r\n\r\n\t/* Shows link to blacklists near every email and IP address */\r\n\tif(parseInt(ctCommentsScreen.ct_show_check_links))\r\n\t\tjQuery('.column-author a, .comment-author a').each(function(){\r\n\t\t\tvar ct_curr_str = jQuery(this).html();\r\n\t\t\tif(ct_is_email(ct_curr_str) != -1 || ct_is_ip(ct_curr_str) != -1){\r\n\t\t\t\tjQuery(this).after('&nbsp;<a href=\"https://cleantalk.org/blacklists/'+ct_curr_str+'\" target=\"_blank\" title=\"https://cleantalk.org/blacklists/'+ct_curr_str+'\" class=\"ct_link_new_tab\"><img src=\"'+ctCommentsScreen.ct_img_src_new_tab+'\"></a>');\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\t/* Feedback for comments */\r\n\tvar ct_comment_id;\r\n\t\r\n\t// For approved\r\n\tjQuery('span.approve').on('click', function(){\r\n\t\tvar result = jQuery(this).children('a').attr('href');\r\n\t\tresult = result.match(/^comment\\.php\\?.*c=(\\d*).*/);\r\n\t\tct_comment_id = result[1];\r\n\t\tundo_comment_id = ct_comment_id;\r\n\t\tct_send_feedback_request(ct_comment_id, 'approve', 0);\t\t\r\n\t});\r\n\t\r\n\t// For unapprove\r\n\tjQuery('span.unapprove').on('click', function(){\r\n\t\tvar result = jQuery(this).children('a').attr('href');\r\n\t\tresult = result.match(/^comment\\.php\\?.*c=(\\d*).*/);\r\n\t\tct_comment_id = result[1];\r\n\t\tundo_comment_id = ct_comment_id;\r\n\t\tct_send_feedback_request(ct_comment_id, 'spam', 0);\t\t\r\n\t});\r\n\t\r\n\t// For spammed\r\n\tjQuery('span.spam').on('click', function(){\r\n\t\tvar result = jQuery(this).children('a').attr('href');\r\n\t\tresult = result.match(/^comment\\.php\\?.*c=(\\d*).*/);\r\n\t\tct_comment_id = result[1];\r\n\t\tundo_comment_id = ct_comment_id;\r\n\t\tct_send_feedback_request(ct_comment_id, 'spam', 0);\r\n\t\t\r\n\t\tsetTimeout(function(){\r\n\t\t\tjQuery('tr#undo-'+ct_comment_id+' span.unspam a').click(function(){\r\n\t\t\t\tvar result = jQuery(this).attr('href');\r\n\t\t\t\tresult = result.match(/^comment\\.php\\?.*&c=(\\d*).*/);\r\n\t\t\t\tct_comment_id = result[1];\r\n\t\t\t\tct_send_feedback_request(ct_comment_id, 'approve', 1);\r\n\t\t\t});\r\n\t\t}, 202);\r\n\t\t\r\n\t});\r\n\t\r\n\t// For unspammed\r\n\tjQuery('span.unspam').on('click', function(){\r\n\t\tvar result = jQuery(this).children('a').attr('href');\r\n\t\tresult = result.match(/^comment\\.php\\?.*c=(\\d*).*/);\r\n\t\tct_comment_id = result[1];\r\n\t\tct_send_feedback_request(ct_comment_id, 'approve', 0);\r\n\t});\r\n\t\r\n\t// For untrashed\r\n\tjQuery('span.untrash a').on('click', function(){\r\n\t\tvar result = jQuery(this).attr('href');\r\n\t\tresult = result.match(/^comment\\.php\\?.*c=(\\d*).*/);\r\n\t\tct_comment_id = result[1];\r\n\t\tfeedback_result = ct_send_feedback_request(ct_comment_id, 'approve', 0);\t\t\r\n\t});\t\r\n});\r\n\r\n// Send feedback to backend\r\nfunction ct_send_feedback_request(ct_comment_id, ct_comment_status, ct_undo){\r\n\t\r\n\tvar data = {\r\n\t\t'action': 'ct_feedback_comment',\r\n\t\t'security': ctCommentsScreen.ct_ajax_nonce,\r\n\t\t'comment_id': ct_comment_id,\r\n\t\t'comment_status': ct_comment_status\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\tct_feedback_message_output(ct_comment_id, ct_comment_status, msg, ct_undo);\r\n\t\t},\r\n error: function(jqXHR, textStatus, errorThrown) {\r\n\t\t\tconsole.log(jqXHR);\r\n\t\t\tconsole.log(textStatus);\r\n\t\t\tconsole.log(errorThrown);\r\n\t\t},\r\n timeout: 5000\r\n\t});\r\n}\r\n\r\n// Outputs CT message about feedback\r\nfunction ct_feedback_message_output(ct_comment_id, ct_comment_status, ct_result, ct_undo){\r\n\tif(ct_result == 1){\r\n\t\tif(ct_comment_status == 'approve' && !ct_undo){\r\n\t\t\tjQuery('tr#comment-'+ct_comment_id)\r\n\t\t\t\t.html('')\r\n\t\t\t\t.show()\r\n\t\t\t\t.append(\"<td colspan='5'></td>\").children('td')\r\n\t\t\t\t\t.css('background', 'rgba(110,240,110,0.7)')\r\n\t\t\t\t\t.append(\"<div class='spam-undo-inside'>\"+ctCommentsScreen.ct_feedback_msg_whitelisted+\" \"+ctCommentsScreen.ct_feedback_msg+\"</div>\");\t\t\t\t\t\t\r\n\t\t}\r\n\t\tif(ct_comment_status == 'spam'){\r\n\t\t\tif(jQuery('tr').is('#undo-'+ct_comment_id)){\r\n\t\t\t\tjQuery('tr#undo-'+ct_comment_id)\r\n\t\t\t\t\t.css('background', 'rgba(240,110,110,0.7)');\r\n\t\t\t\tjQuery('tr#undo-'+ct_comment_id+' div.spam-undo-inside')\r\n\t\t\t\t\t.append(\" \"+ctCommentsScreen.ct_feedback_msg_blacklisted+\" \"+ctCommentsScreen.ct_feedback_msg);\r\n\t\t\t}else{\r\n\t\t\t\tjQuery('tr#comment-'+ct_comment_id)\r\n\t\t\t\t.html('')\r\n\t\t\t\t.show()\r\n\t\t\t\t.css('background', 'rgba(240,110,110,0.7)')\r\n\t\t\t\t.append(\"<td colspan='5'></td>\").children('td')\r\n\t\t\t\t\t.append(\"<div class='spam-undo-inside'>\"+ctCommentsScreen.ct_feedback_msg_blacklisted+\" \"+ctCommentsScreen.ct_feedback_msg+\"</div>\");\t\t\t\t\t\t\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tif(ct_result == 0){\r\n\t\t// Error occurred\r\n\t}if(ct_result == 'no_hash'){\r\n\t\t// No hash for this comment\r\n\t}\r\n}\r\n"]}
js/cleantalk-users-editscreen.min.js CHANGED
@@ -1,2 +1,2 @@
1
- function ct_is_email(t){return t.search(/.*@.*\..*/)}function ct_is_ip(t){return t.search(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/)}jQuery(document).ready(function(){jQuery("#changeit").after(' <a href="users.php?page=ct_check_users" class="button" style="margin:1px 0 0 0; display: inline-block;">'+ctAdminCommon.logo_small_colored+"&nbsp;"+ctUsersScreen.spambutton_text+"</a>&nbsp;"),parseInt(ctUsersScreen.ct_show_check_links)&&jQuery(".column-email a").each(function(){var t=jQuery(this).html();-1!=ct_is_email(t)&&jQuery(this).after('&nbsp;<a href="https://cleantalk.org/blacklists/'+t+'" target="_blank" title="https://cleantalk.org/blacklists/'+t+'" class="ct_link_new_tab"><img src="'+ctUsersScreen.ct_img_src_new_tab+'"></a>')})});
2
  //# sourceMappingURL=cleantalk-users-editscreen.min.js.map
1
+ function ct_is_email(t){return t.search(/.*@.*\..*/)}function ct_is_ip(t){return t.search(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/)}jQuery(document).ready(function(){parseInt(ctUsersScreen.ct_show_check_links)&&jQuery(".column-email a").each(function(){var t=jQuery(this).html();-1!=ct_is_email(t)&&jQuery(this).after('&nbsp;<a href="https://cleantalk.org/blacklists/'+t+'" target="_blank" title="https://cleantalk.org/blacklists/'+t+'" class="ct_link_new_tab"><img src="'+ctUsersScreen.ct_img_src_new_tab+'"></a>')})});
2
  //# sourceMappingURL=cleantalk-users-editscreen.min.js.map
js/cleantalk-users-editscreen.min.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["cleantalk-users-editscreen.js"],"names":["ct_is_email","str","search","ct_is_ip","jQuery","document","ready","after","ctAdminCommon","logo_small_colored","ctUsersScreen","spambutton_text","parseInt","ct_show_check_links","each","ct_curr_str","this","html","ct_img_src_new_tab"],"mappings":"AAAA,SAASA,YAAYC,GACpB,OAAOA,EAAIC,OAAO,aAEnB,SAASC,SAASF,GACjB,OAAOA,EAAIC,OAAO,wCAGnBE,OAAOC,UAAUC,MAAM,WAGtBF,OAAO,aAAaG,MAAM,4GAA4GC,cAAcC,mBAAmB,SAASC,cAAcC,gBAAgB,cAG3MC,SAASF,cAAcG,sBACzBT,OAAO,mBAAmBU,KAAK,WAC9B,IAAIC,EAAcX,OAAOY,MAAMC,QACC,GAA7BjB,YAAYe,IACdX,OAAOY,MAAMT,MAAM,mDAAmDQ,EAAY,6DAA6DA,EAAY,uCAAuCL,cAAcQ,mBAAmB","file":"cleantalk-users-editscreen.min.js","sourcesContent":["function ct_is_email(str){\r\n\treturn str.search(/.*@.*\\..*/);\r\n}\r\nfunction ct_is_ip(str){\r\n\treturn str.search(/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/);\r\n}\r\n\r\njQuery(document).ready(function(){\r\n\t\r\n\t/* Shows \"Find spam users\" Buttons */\r\n\tjQuery('#changeit').after(' <a href=\"users.php?page=ct_check_users\" class=\"button\" style=\"margin:1px 0 0 0; display: inline-block;\">'+ctAdminCommon.logo_small_colored+'&nbsp;'+ctUsersScreen.spambutton_text+'</a>&nbsp;');\r\n\t\r\n\t/* Shows link to blacklists near every email and IP address */\r\n\tif(parseInt(ctUsersScreen.ct_show_check_links))\r\n\t\tjQuery('.column-email a').each(function(){\r\n\t\t\tvar ct_curr_str = jQuery(this).html();\r\n\t\t\tif(ct_is_email(ct_curr_str) != -1){\r\n\t\t\t\tjQuery(this).after('&nbsp;<a href=\"https://cleantalk.org/blacklists/'+ct_curr_str+'\" target=\"_blank\" title=\"https://cleantalk.org/blacklists/'+ct_curr_str+'\" class=\"ct_link_new_tab\"><img src=\"'+ctUsersScreen.ct_img_src_new_tab+'\"></a>');\r\n\t\t\t}\r\n\t\t});\r\n});"]}
1
+ {"version":3,"sources":["cleantalk-users-editscreen.js"],"names":["ct_is_email","str","search","ct_is_ip","jQuery","document","ready","parseInt","ctUsersScreen","ct_show_check_links","each","ct_curr_str","this","html","after","ct_img_src_new_tab"],"mappings":"AAAA,SAASA,YAAYC,GACpB,OAAOA,EAAIC,OAAO,aAEnB,SAASC,SAASF,GACjB,OAAOA,EAAIC,OAAO,wCAGnBE,OAAOC,UAAUC,MAAM,WAGnBC,SAASC,cAAcC,sBACzBL,OAAO,mBAAmBM,KAAK,WAC9B,IAAIC,EAAcP,OAAOQ,MAAMC,QACC,GAA7Bb,YAAYW,IACdP,OAAOQ,MAAME,MAAM,mDAAmDH,EAAY,6DAA6DA,EAAY,uCAAuCH,cAAcO,mBAAmB","file":"cleantalk-users-editscreen.min.js","sourcesContent":["function ct_is_email(str){\r\n\treturn str.search(/.*@.*\\..*/);\r\n}\r\nfunction ct_is_ip(str){\r\n\treturn str.search(/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/);\r\n}\r\n\r\njQuery(document).ready(function(){\r\n\r\n\t/* Shows link to blacklists near every email and IP address */\r\n\tif(parseInt(ctUsersScreen.ct_show_check_links))\r\n\t\tjQuery('.column-email a').each(function(){\r\n\t\t\tvar ct_curr_str = jQuery(this).html();\r\n\t\t\tif(ct_is_email(ct_curr_str) != -1){\r\n\t\t\t\tjQuery(this).after('&nbsp;<a href=\"https://cleantalk.org/blacklists/'+ct_curr_str+'\" target=\"_blank\" title=\"https://cleantalk.org/blacklists/'+ct_curr_str+'\" class=\"ct_link_new_tab\"><img src=\"'+ctUsersScreen.ct_img_src_new_tab+'\"></a>');\r\n\t\t\t}\r\n\t\t});\r\n});"]}
lib/Cleantalk/Arr.php CHANGED
@@ -173,7 +173,7 @@ class Arr
173
  foreach ( $searched as $searched_key => $searched_val ){
174
  switch ($type){
175
  case 'key':
176
- if( $key == $searched_val || ($regexp && preg_match( '/' . $searched_val . '/', $key) === 1) )
177
  $found[$key] = true;
178
  break;
179
  case 'value':
173
  foreach ( $searched as $searched_key => $searched_val ){
174
  switch ($type){
175
  case 'key':
176
+ if( $key === $searched_val || ($regexp && preg_match( '/' . $searched_val . '/', $key) === 1) )
177
  $found[$key] = true;
178
  break;
179
  case 'value':
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: safronik
3
  Tags: spam, antispam, protection, comments, firewall
4
  Requires at least: 3.0
5
  Tested up to: 5.3
6
- Stable tag: 5.128
7
  License: GPLv2
8
 
9
  Spam protection, antispam, all-in-one, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
@@ -214,14 +214,12 @@ CleanTalk has an advanced option "Spam FireWall". This option allows you to bloc
214
 
215
  = White Label Mode =
216
 
217
- To switch the plugin work in the white-label mode you must insert this code to your wp-config.php:
218
 
219
- define('APBCT_WHITELABEL', true);
220
- define('APBCT_WHITELABEL_NAME', 'YOUR_PLUGIN_NAME');
221
- define('APBCT_HOSTER_API_KEY', 'YOUR_HOSTER_API_KEY');
222
-
223
- Where APBCT_WHITELABEL_NAME is any name you want for the plugin.
224
- Where YOUR_HOSTER_API_KEY is a key from CleanTalk's hoster panel.
225
 
226
  The plugin will do everything rest.
227
 
@@ -568,6 +566,14 @@ If your website has forms that send data to external sources, you can enable opt
568
  10. Website's options.
569
 
570
  == Changelog ==
 
 
 
 
 
 
 
 
571
  = 5.128 October 17 2019 =
572
  * Mod: Users check - functionality updated.
573
  * Fix: Users check - dates format updated.
3
  Tags: spam, antispam, protection, comments, firewall
4
  Requires at least: 3.0
5
  Tested up to: 5.3
6
+ Stable tag: 5.128.1
7
  License: GPLv2
8
 
9
  Spam protection, antispam, all-in-one, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
214
 
215
  = White Label Mode =
216
 
217
+ To switch the plugin work in the white-label mode you should set up a few settings on your main site in Wordpress Multisite Network:
218
 
219
+ 1. Check setting "Enable White Label Mode".
220
+ 2. Fill "Hoster API Key" field with key from CleanTalk's hoster panel.
221
+ 3. Fill "Plugin name" field. It could be any name you want for the plugin.
222
+ 4. Save settings.
 
 
223
 
224
  The plugin will do everything rest.
225
 
566
  10. Website's options.
567
 
568
  == Changelog ==
569
+ = 5.128.1 October 23 2019 =
570
+ * Fix: Fatal error when using buffer output.
571
+ * Fix: Translate domain for errors.
572
+ * Code: Fix spelling in function name.
573
+ * Fix: JS disabled error.
574
+ * Upd: Comment edit screen updated.
575
+ * Fix: Cleantalk\Arr::search() fixed.
576
+
577
  = 5.128 October 17 2019 =
578
  * Mod: Users check - functionality updated.
579
  * Fix: Users check - dates format updated.