Version Description
July 13 2017 = * New updater logic. * Self cron system. * Improved AMP compatibility. * Optimization. * Fixed users and comments spam check. * Fixed layout for Comment's feedback from public page. * Updated SpamFireWall. * SFW: SpamFireWall counter now work in real-time. * SFW: Improved compatibility with different Data Bases.
Download this release
Release Info
Developer | Safronik |
Plugin | Spam protection, AntiSpam, FireWall by CleanTalk |
Version | 5.70 |
Comparing to | |
See all releases |
Code changes from version 5.69 to 5.70
- assets/css/cleantalk-public.css +11 -15
- assets/js/cleantalk-comments-checkspam.js +6 -6
- assets/js/cleantalk-comments-editscreen.js +1 -4
- assets/js/cleantalk-public.js +1 -1
- assets/js/cleantalk-users-checkspam.js +4 -2
- cleantalk.php +134 -443
- inc/cleantalk-admin.php +125 -242
- inc/cleantalk-common.php +21 -32
- inc/cleantalk-public.php +66 -40
- inc/cleantalk-sfw.class.php +0 -195
- inc/cleantalk-sfw.php +0 -42
- inc/cleantalk-updater.php +73 -0
- inc/cleantalk-users.php +1 -1
- inc/cleantalk_api.php +0 -126
- inc/cleantalk_external.js +1 -1
- inc/cleantalk_internal.js +2 -2
- inc/cleantalk_nocache.js +8 -8
- inc/sfw_die_page.html +27 -27
- lib/CleantalkCron.php +143 -0
- lib/CleantalkSFW.php +500 -0
- readme.txt +23 -1
assets/css/cleantalk-public.css
CHANGED
@@ -4,39 +4,36 @@
|
|
4 |
|
5 |
.ct_comment_info{
|
6 |
position: relative;
|
7 |
-
top:
|
8 |
-
padding:
|
9 |
margin-bottom: 20px;
|
10 |
-
min-height: 20px !important;
|
11 |
border: 1px solid gray !important;
|
12 |
border-radius: 8px;
|
13 |
-
font-size:
|
|
|
14 |
}
|
15 |
.ct_comment_info_title{
|
16 |
position: absolute;
|
17 |
-
top: -
|
18 |
margin: 0; padding: 0 5px;
|
19 |
-
font-size: 15px;
|
20 |
background: inherit;
|
21 |
-
line-height:
|
22 |
}
|
23 |
p.ct_comment_logo_title{
|
24 |
position: absolute;
|
25 |
-
bottom: -
|
26 |
margin: 0; padding: 0 7px;
|
27 |
-
font-size: 15px;
|
28 |
background: inherit;
|
29 |
-
line-height:
|
30 |
}
|
31 |
.ct_comment_logo_img{
|
32 |
-
height:
|
33 |
margin-right: 0px;
|
34 |
vertical-align: text-top;
|
35 |
}
|
36 |
|
37 |
.ct_this_is{
|
38 |
-
|
39 |
-
padding: 2px 5px;
|
40 |
cursor: pointer;
|
41 |
white-space: nowrap;
|
42 |
color: black !important;
|
@@ -50,11 +47,10 @@
|
|
50 |
p.ct_feedback_wrap{
|
51 |
display: none;
|
52 |
position: absolute;
|
53 |
-
top:
|
54 |
width: 98%;
|
55 |
background: white;
|
56 |
padding: 2px 6px;
|
57 |
-
border: 1px solid gray;
|
58 |
border-radius: 3px;
|
59 |
}
|
60 |
.ct_feedback_result{display: none; text-decoration: underline;}
|
4 |
|
5 |
.ct_comment_info{
|
6 |
position: relative;
|
7 |
+
top: 10px;
|
8 |
+
padding: 2px 1% 2px 1%;
|
9 |
margin-bottom: 20px;
|
|
|
10 |
border: 1px solid gray !important;
|
11 |
border-radius: 8px;
|
12 |
+
font-size: 11px;
|
13 |
+
line-height: 17px;
|
14 |
}
|
15 |
.ct_comment_info_title{
|
16 |
position: absolute;
|
17 |
+
top: -10px; left: 15px;
|
18 |
margin: 0; padding: 0 5px;
|
|
|
19 |
background: inherit;
|
20 |
+
line-height: 12px;
|
21 |
}
|
22 |
p.ct_comment_logo_title{
|
23 |
position: absolute;
|
24 |
+
bottom: -12px; right: 10px;
|
25 |
margin: 0; padding: 0 7px;
|
|
|
26 |
background: inherit;
|
27 |
+
line-height: 12px;
|
28 |
}
|
29 |
.ct_comment_logo_img{
|
30 |
+
height: 12px;
|
31 |
margin-right: 0px;
|
32 |
vertical-align: text-top;
|
33 |
}
|
34 |
|
35 |
.ct_this_is{
|
36 |
+
padding: 0px 2px;
|
|
|
37 |
cursor: pointer;
|
38 |
white-space: nowrap;
|
39 |
color: black !important;
|
47 |
p.ct_feedback_wrap{
|
48 |
display: none;
|
49 |
position: absolute;
|
50 |
+
top: 0px; left: 1%;
|
51 |
width: 98%;
|
52 |
background: white;
|
53 |
padding: 2px 6px;
|
|
|
54 |
border-radius: 3px;
|
55 |
}
|
56 |
.ct_feedback_result{display: none; text-decoration: underline;}
|
assets/js/cleantalk-comments-checkspam.js
CHANGED
@@ -93,7 +93,7 @@ function ct_send_comments(){
|
|
93 |
data: data,
|
94 |
success: function(msg){
|
95 |
|
96 |
-
msg =
|
97 |
|
98 |
if(parseInt(msg.error)){
|
99 |
ct_working=false;
|
@@ -111,6 +111,7 @@ function ct_send_comments(){
|
|
111 |
if(parseInt(ct_comments_spam) > 0)
|
112 |
status_string += ctCommentsCheck.ct_status_string_warning;
|
113 |
jQuery('#ct_checking_status').html(status_string);
|
|
|
114 |
ct_send_comments();
|
115 |
}else if(parseInt(msg.end) == 1){
|
116 |
ct_working=false;
|
@@ -123,7 +124,7 @@ function ct_send_comments(){
|
|
123 |
jQuery('#ct_error_message').show();
|
124 |
jQuery('#cleantalk_ajax_error').html(textStatus);
|
125 |
jQuery('#cleantalk_js_func').html('Check comments');
|
126 |
-
setTimeout(
|
127 |
},
|
128 |
timeout: 25000
|
129 |
});
|
@@ -153,7 +154,6 @@ function ct_show_info(){
|
|
153 |
data: data,
|
154 |
success: function(msg){
|
155 |
msg = jQuery.parseJSON(msg);
|
156 |
-
console.log(msg);
|
157 |
jQuery('#ct_checking_status').html(msg.message);
|
158 |
ct_comments_total = msg.total;
|
159 |
},
|
@@ -161,7 +161,7 @@ function ct_show_info(){
|
|
161 |
jQuery('#ct_error_message').show();
|
162 |
jQuery('#cleantalk_ajax_error').html(textStatus);
|
163 |
jQuery('#cleantalk_js_func').html('Check comments');
|
164 |
-
setTimeout(
|
165 |
},
|
166 |
timeout: 15000
|
167 |
});
|
@@ -205,7 +205,7 @@ function ct_delete_all(){
|
|
205 |
jQuery('#ct_error_message').show();
|
206 |
jQuery('#cleantalk_ajax_error').html(textStatus);
|
207 |
jQuery('#cleantalk_js_func').html('Check comments');
|
208 |
-
setTimeout(
|
209 |
}
|
210 |
});
|
211 |
}
|
@@ -236,7 +236,7 @@ function ct_delete_checked(){
|
|
236 |
jQuery('#ct_error_message').show();
|
237 |
jQuery('#cleantalk_ajax_error').html(textStatus);
|
238 |
jQuery('#cleantalk_js_func').html('Check comments');
|
239 |
-
setTimeout(
|
240 |
}
|
241 |
});
|
242 |
}
|
93 |
data: data,
|
94 |
success: function(msg){
|
95 |
|
96 |
+
msg = jQuery.parseJSON(msg);
|
97 |
|
98 |
if(parseInt(msg.error)){
|
99 |
ct_working=false;
|
111 |
if(parseInt(ct_comments_spam) > 0)
|
112 |
status_string += ctCommentsCheck.ct_status_string_warning;
|
113 |
jQuery('#ct_checking_status').html(status_string);
|
114 |
+
jQuery('#ct_error_message').hide();
|
115 |
ct_send_comments();
|
116 |
}else if(parseInt(msg.end) == 1){
|
117 |
ct_working=false;
|
124 |
jQuery('#ct_error_message').show();
|
125 |
jQuery('#cleantalk_ajax_error').html(textStatus);
|
126 |
jQuery('#cleantalk_js_func').html('Check comments');
|
127 |
+
setTimeout(ct_send_comments(), 3000);
|
128 |
},
|
129 |
timeout: 25000
|
130 |
});
|
154 |
data: data,
|
155 |
success: function(msg){
|
156 |
msg = jQuery.parseJSON(msg);
|
|
|
157 |
jQuery('#ct_checking_status').html(msg.message);
|
158 |
ct_comments_total = msg.total;
|
159 |
},
|
161 |
jQuery('#ct_error_message').show();
|
162 |
jQuery('#cleantalk_ajax_error').html(textStatus);
|
163 |
jQuery('#cleantalk_js_func').html('Check comments');
|
164 |
+
setTimeout(ct_show_info(), 3000);
|
165 |
},
|
166 |
timeout: 15000
|
167 |
});
|
205 |
jQuery('#ct_error_message').show();
|
206 |
jQuery('#cleantalk_ajax_error').html(textStatus);
|
207 |
jQuery('#cleantalk_js_func').html('Check comments');
|
208 |
+
setTimeout(ct_delete_all(), 3000);
|
209 |
}
|
210 |
});
|
211 |
}
|
236 |
jQuery('#ct_error_message').show();
|
237 |
jQuery('#cleantalk_ajax_error').html(textStatus);
|
238 |
jQuery('#cleantalk_js_func').html('Check comments');
|
239 |
+
setTimeout(ct_delete_checked(), 3000);
|
240 |
}
|
241 |
});
|
242 |
}
|
assets/js/cleantalk-comments-editscreen.js
CHANGED
@@ -19,11 +19,8 @@ jQuery(document).ready(function(){
|
|
19 |
jQuery(this).after(' <a href="https://cleantalk.org/blacklists/'+ct_curr_str+'" target="_blank" title="https://cleantalk.org/blacklists/'+ct_curr_str+'" class="ct_link_new_tab"><img src="'+ctCommentsScreen.ct_img_src_new_tab+'"></a>');
|
20 |
}
|
21 |
});
|
22 |
-
|
23 |
-
console.log(parseInt(ctCommentsScreen.ct_show_check_links));
|
24 |
-
|
25 |
/* Feedback for comments */
|
26 |
-
|
27 |
var ct_comment_id;
|
28 |
|
29 |
// For approved
|
19 |
jQuery(this).after(' <a href="https://cleantalk.org/blacklists/'+ct_curr_str+'" target="_blank" title="https://cleantalk.org/blacklists/'+ct_curr_str+'" class="ct_link_new_tab"><img src="'+ctCommentsScreen.ct_img_src_new_tab+'"></a>');
|
20 |
}
|
21 |
});
|
22 |
+
|
|
|
|
|
23 |
/* Feedback for comments */
|
|
|
24 |
var ct_comment_id;
|
25 |
|
26 |
// For approved
|
assets/js/cleantalk-public.js
CHANGED
@@ -34,7 +34,7 @@ jQuery(document).ready(function(){
|
|
34 |
|
35 |
jQuery.ajax({
|
36 |
type: "POST",
|
37 |
-
url:
|
38 |
data: data,
|
39 |
success: function(msg){
|
40 |
ct_current_button.hide();
|
34 |
|
35 |
jQuery.ajax({
|
36 |
type: "POST",
|
37 |
+
url: ctPublic.ajaxurl,
|
38 |
data: data,
|
39 |
success: function(msg){
|
40 |
ct_current_button.hide();
|
assets/js/cleantalk-users-checkspam.js
CHANGED
@@ -91,8 +91,9 @@ function ct_send_users(){
|
|
91 |
type: "POST",
|
92 |
url: ajaxurl,
|
93 |
data: data,
|
94 |
-
success: function(msg){
|
95 |
-
|
|
|
96 |
|
97 |
if(parseInt(msg.error)){
|
98 |
ct_working=false;
|
@@ -110,6 +111,7 @@ function ct_send_users(){
|
|
110 |
if(parseInt(ct_users_spam) > 0)
|
111 |
status_string += ctUsersCheck.ct_status_string_warning;
|
112 |
jQuery('#ct_checking_users_status').html(status_string);
|
|
|
113 |
ct_send_users();
|
114 |
}else if(parseInt(msg.end) == 1){
|
115 |
ct_working=false;
|
91 |
type: "POST",
|
92 |
url: ajaxurl,
|
93 |
data: data,
|
94 |
+
success: function(msg){
|
95 |
+
|
96 |
+
msg = jQuery.parseJSON(msg);
|
97 |
|
98 |
if(parseInt(msg.error)){
|
99 |
ct_working=false;
|
111 |
if(parseInt(ct_users_spam) > 0)
|
112 |
status_string += ctUsersCheck.ct_status_string_warning;
|
113 |
jQuery('#ct_checking_users_status').html(status_string);
|
114 |
+
jQuery('#ct_error_message').hide();
|
115 |
ct_send_users();
|
116 |
}else if(parseInt(msg.end) == 1){
|
117 |
ct_working=false;
|
cleantalk.php
CHANGED
@@ -3,21 +3,16 @@
|
|
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. Formerly Anti-Spam by CleanTalk.
|
6 |
-
Version: 5.
|
7 |
Author: СleanTalk <welcome@cleantalk.org>
|
8 |
Author URI: http://cleantalk.org
|
9 |
*/
|
10 |
-
$cleantalk_plugin_version='5.
|
11 |
-
$ct_agent_version = 'wordpress-
|
12 |
$cleantalk_executed=false;
|
13 |
$ct_sfw_updated = false;
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
define('CLEANTALK_REMOTE_CALL_SLEEP', 10); //Minimum time between remote call
|
18 |
-
|
19 |
-
$cleantalk_use_buffer = (defined('CLEANTALK_AJAX_USE_BUFFER') ? CLEANTALK_AJAX_USE_BUFFER : true);
|
20 |
-
$cleantalk_use_footer_header = (defined('CLEANTALK_AJAX_USE_FOOTER_HEADER') ? CLEANTALK_AJAX_USE_FOOTER_HEADER : true);
|
21 |
|
22 |
if(!defined('CLEANTALK_PLUGIN_DIR')){
|
23 |
|
@@ -30,55 +25,27 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
|
|
30 |
|
31 |
$ct_options=ct_get_options();
|
32 |
$ct_data=ct_get_data();
|
33 |
-
|
34 |
-
//Cron jobs
|
35 |
-
add_action('cleantalk_send_daily_report_hook', 'cleantalk_send_daily_report'); //Sending daily report (daily)
|
36 |
-
add_action('cleantalk_get_brief_data_hook', 'cleantalk_get_brief_data'); //Sending daily report (daily)
|
37 |
-
add_action('ct_hourly_event_hook', 'ct_do_this_hourly'); // Sends feedback, deleting old spam (hourly)
|
38 |
-
add_action('cleantalk_update_sfw_hook', 'cleantalk_update_sfw'); //Updates SFW (daily)
|
39 |
-
|
40 |
-
//Delete cookie for admin trial notice
|
41 |
-
add_action('wp_logout', 'ct_wp_logout');
|
42 |
|
43 |
-
//
|
44 |
-
if(!
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
$
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
) ENGINE = MYISAM ;");
|
53 |
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
PRIMARY KEY (`ip`))
|
60 |
-
ENGINE = MYISAM;");
|
61 |
-
|
62 |
-
$ct_data['db_refreshed'] = 1;
|
63 |
-
update_option('cleantalk_data', $ct_data);
|
64 |
-
|
65 |
-
}
|
66 |
-
if(isset($ct_data['db_refreshed']) && $ct_data['db_refreshed'] == 1){
|
67 |
-
if (!wp_next_scheduled('cleantalk_update_sfw_hook'))
|
68 |
-
wp_schedule_event(time()+1800, 'daily', 'cleantalk_update_sfw_hook' );
|
69 |
-
$ct_data['db_refreshed'] = 2;
|
70 |
-
update_option('cleantalk_data', $ct_data);
|
71 |
-
}
|
72 |
-
/*
|
73 |
-
if(isset($ct_data['db_refreshed']) && $ct_data['db_refreshed'] == 2){
|
74 |
-
$ct_activation_timestamp = get_option('cleantalk_activation_timestamp');
|
75 |
-
if(!$ct_activation_timestamp)
|
76 |
-
add_option('cleantalk_activation_timestamp', time());
|
77 |
-
$ct_data['db_refreshed'] = 3;
|
78 |
-
update_option('cleantalk_data', $ct_data);
|
79 |
}
|
80 |
-
//*/
|
81 |
|
|
|
|
|
|
|
82 |
// Early checks
|
83 |
// Facebook
|
84 |
if (isset($ct_options['general_contact_forms_test']) && $ct_options['general_contact_forms_test'] == 1
|
@@ -94,7 +61,7 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
|
|
94 |
|
95 |
}
|
96 |
|
97 |
-
if(
|
98 |
$_POST['action']='ninja_forms_ajax_submit';
|
99 |
|
100 |
// SFW start
|
@@ -129,45 +96,45 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
|
|
129 |
}
|
130 |
}
|
131 |
|
132 |
-
|
133 |
-
{
|
134 |
-
|
135 |
-
include_once("
|
136 |
|
137 |
-
$is_sfw_check=true;
|
138 |
-
$sfw = new
|
139 |
-
$
|
140 |
|
141 |
-
foreach($
|
142 |
if(isset($_COOKIE['ct_sfw_pass_key']) && $_COOKIE['ct_sfw_pass_key'] == md5($ct_cur_ip.$ct_options['apikey'])){
|
143 |
$is_sfw_check=false;
|
144 |
if(isset($_COOKIE['ct_sfw_passed'])){
|
145 |
-
|
146 |
-
|
|
|
|
|
|
|
147 |
}
|
148 |
-
}else
|
149 |
$is_sfw_check=true;
|
150 |
-
|
|
|
151 |
if($is_sfw_check){
|
152 |
$sfw->check_ip();
|
153 |
if($sfw->result){
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
if(time() - $last_sfw_send > 3600){
|
163 |
-
ct_send_sfw_log();
|
164 |
-
$ct_data['last_sfw_send'] = time();
|
165 |
-
update_option('cleantalk_data', $ct_data);
|
166 |
}
|
167 |
-
|
168 |
}
|
169 |
|
170 |
-
|
171 |
if(isset($_GET['spbc_remote_call_token'], $_GET['spbc_remote_call_action'], $_GET['plugin_name']) && ($_GET['plugin_name'] == 'antispam' || $_GET['plugin_name'] == 'anti-spam')){
|
172 |
|
173 |
if(isset($ct_data['last_remote_call']) && time() - $ct_data['last_remote_call'] < CLEANTALK_REMOTE_CALL_SLEEP){
|
@@ -185,58 +152,41 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
|
|
185 |
if($_GET['spbc_remote_call_action'] == 'close_renew_banner'){
|
186 |
$ct_data['show_ct_notice_trial'] = 0;
|
187 |
$ct_data['show_ct_notice_renew'] = 0;
|
188 |
-
$ct_data['next_account_status_check'] = time() + $account_notice_check_timeout*3600;
|
189 |
update_option('cleantalk_data', $ct_data);
|
190 |
-
|
191 |
echo "OK";
|
192 |
die();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
}
|
194 |
}else{
|
195 |
echo "FAIL WRONG_TOKEN";
|
196 |
die();
|
197 |
}
|
198 |
-
|
199 |
}
|
200 |
-
//*/
|
201 |
|
202 |
-
if(isset($ct_options['check_external']) && @intval($ct_options['check_external']) == 1)
|
203 |
-
$test_external_forms=true;
|
204 |
-
else
|
205 |
-
$test_external_forms=false;
|
206 |
-
|
207 |
-
if(isset($ct_options['check_internal']) && @intval($ct_options['check_internal']) == 1)
|
208 |
-
$test_internal_forms = true;
|
209 |
-
else
|
210 |
-
$test_internal_forms = false;
|
211 |
-
|
212 |
// Activation/deactivation functions must be in main plugin file.
|
213 |
// http://codex.wordpress.org/Function_Reference/register_activation_hook
|
214 |
register_activation_hook( __FILE__, 'ct_activation' );
|
215 |
register_deactivation_hook( __FILE__, 'ct_deactivation' );
|
216 |
-
|
217 |
-
//
|
218 |
// Redirect admin to plugin settings.
|
219 |
-
//
|
220 |
if(!defined('WP_ALLOW_MULTISITE') || defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE == false)
|
221 |
add_action('admin_init', 'ct_plugin_redirect');
|
222 |
|
223 |
// After plugin loaded - to load locale as described in manual
|
224 |
-
add_action(
|
225 |
-
ct_plugin_loaded();
|
226 |
-
|
227 |
-
$use_ajax = (isset($ct_options['use_ajax']) ? intval($ct_options['use_ajax']) : 1);
|
228 |
|
229 |
-
if( $use_ajax
|
230 |
stripos($_SERVER['REQUEST_URI'],'.xml')===false &&
|
231 |
stripos($_SERVER['REQUEST_URI'],'.xsl')===false)
|
232 |
{
|
233 |
-
if($cleantalk_use_buffer)
|
234 |
-
add_action('wp_loaded', 'ct_add_nocache_script', 1);
|
235 |
-
|
236 |
-
if($cleantalk_use_footer_header){
|
237 |
-
add_action('wp_footer', 'ct_add_nocache_script_footer', 1);
|
238 |
-
add_action('wp_head', 'ct_add_nocache_script_header', 1);
|
239 |
-
}
|
240 |
add_action( 'wp_ajax_nopriv_ct_get_cookie', 'ct_get_cookie',1 );
|
241 |
add_action( 'wp_ajax_ct_get_cookie', 'ct_get_cookie',1 );
|
242 |
}
|
@@ -249,6 +199,7 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
|
|
249 |
require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-users.php');
|
250 |
}
|
251 |
|
|
|
252 |
if (is_admin()||is_network_admin()){
|
253 |
|
254 |
require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-admin.php');
|
@@ -329,7 +280,7 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
|
|
329 |
if($pagenow=='users.php')
|
330 |
add_action('delete_user', 'ct_delete_user', 10, 2);
|
331 |
|
332 |
-
if($pagenow=='plugins.php' ||
|
333 |
|
334 |
add_filter('plugin_action_links_'.plugin_basename(__FILE__), 'ct_plugin_action_links', 10, 2);
|
335 |
add_filter('network_admin_plugin_action_links_'.plugin_basename(__FILE__), 'ct_plugin_action_links', 10, 2);
|
@@ -337,6 +288,8 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
|
|
337 |
add_filter('plugin_row_meta', 'ct_register_plugin_links', 10, 2);
|
338 |
}
|
339 |
add_action('updated_option', 'ct_update_option'); // param - option name, i.e. 'cleantalk_settings'
|
|
|
|
|
340 |
}else{
|
341 |
|
342 |
require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-public.php');
|
@@ -376,46 +329,44 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
|
|
376 |
}
|
377 |
}
|
378 |
|
379 |
-
function ct_db_refresh(){
|
380 |
-
global $wpdb;
|
381 |
-
|
382 |
-
$wpdb->query("CREATE TABLE IF NOT EXISTS `".$wpdb->base_prefix."cleantalk_sfw` (
|
383 |
-
`network` int(11) unsigned NOT NULL,
|
384 |
-
`mask` int(11) unsigned NOT NULL,
|
385 |
-
INDEX ( `network` , `mask` )
|
386 |
-
) ENGINE = MYISAM ;");
|
387 |
-
|
388 |
-
$wpdb->query("CREATE TABLE IF NOT EXISTS `".$wpdb->base_prefix."cleantalk_sfw_logs` (
|
389 |
-
`ip` VARCHAR(15) NOT NULL ,
|
390 |
-
`all` INT NOT NULL ,
|
391 |
-
`blocked` INT NOT NULL ,
|
392 |
-
`timestamp` INT NOT NULL ,
|
393 |
-
PRIMARY KEY (`ip`))
|
394 |
-
ENGINE = MYISAM;");
|
395 |
-
|
396 |
-
}
|
397 |
-
|
398 |
/**
|
399 |
* On activation, set a time, frequency and name of an action hook to be scheduled.
|
400 |
*/
|
401 |
if (!function_exists ( 'ct_activation')) {
|
402 |
function ct_activation() {
|
403 |
|
404 |
-
|
405 |
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
415 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
416 |
add_option('ct_plugin_do_activation_redirect', true);
|
417 |
-
add_option('cleantalk_activation_timestamp', time());
|
418 |
add_option('ct_installing', true);
|
|
|
|
|
|
|
419 |
}
|
420 |
}
|
421 |
|
@@ -425,18 +376,15 @@ if (!function_exists ( 'ct_activation')) {
|
|
425 |
if (!function_exists ( 'ct_deactivation')) {
|
426 |
function ct_deactivation() {
|
427 |
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
wp_clear_scheduled_hook( 'cleantalk_send_daily_report_hook' );
|
438 |
-
wp_clear_scheduled_hook( 'cleantalk_get_brief_data_hook' );
|
439 |
-
|
440 |
}
|
441 |
}
|
442 |
|
@@ -444,16 +392,10 @@ if (!function_exists ( 'ct_deactivation')) {
|
|
444 |
* Redirects admin to plugin settings after activation.
|
445 |
*/
|
446 |
function ct_plugin_redirect()
|
447 |
-
{
|
448 |
-
|
449 |
-
if (get_option('ct_plugin_do_activation_redirect', false))
|
450 |
-
{
|
451 |
delete_option('ct_plugin_do_activation_redirect');
|
452 |
-
|
453 |
-
{
|
454 |
-
setcookie($ct_redirects_label, 1, null, '/');
|
455 |
-
wp_redirect("options-general.php?page=cleantalk");
|
456 |
-
}
|
457 |
}
|
458 |
}
|
459 |
|
@@ -461,9 +403,6 @@ function ct_add_event($event_type)
|
|
461 |
{
|
462 |
global $ct_data,$cleantalk_executed;
|
463 |
|
464 |
-
if(!get_option('cleantalk_sends_reports_till'));
|
465 |
-
add_option('cleantalk_sends_reports_till', time()+7*24*3600);
|
466 |
-
|
467 |
//
|
468 |
// To migrate on the new version of ct_add_event().
|
469 |
//
|
@@ -473,42 +412,25 @@ function ct_add_event($event_type)
|
|
473 |
}
|
474 |
|
475 |
$ct_data = ct_get_data();
|
476 |
-
$current_hour=intval(date('G'));
|
477 |
-
|
478 |
-
//Daily counter
|
479 |
-
if(!isset($ct_data['array_accepted'])){
|
480 |
-
$ct_data['array_accepted']=Array();
|
481 |
-
$ct_data['array_blocked']=Array();
|
482 |
-
$ct_data['current_hour']=$current_hour;
|
483 |
-
}
|
484 |
-
//All time counter
|
485 |
-
if(!isset($ct_data['all_time_counter'])){
|
486 |
-
$ct_data['all_time_counter']['accepted']=0;
|
487 |
-
$ct_data['all_time_counter']['blocked']=0;
|
488 |
-
}
|
489 |
-
//User counter
|
490 |
-
if(!isset($ct_data['user_counter'])){
|
491 |
-
$ct_data['user_counter']['accepted']=0;
|
492 |
-
$ct_data['user_counter']['blocked']=0;
|
493 |
-
$ct_data['user_counter']['since']=date('d M');
|
494 |
-
}
|
495 |
|
|
|
496 |
if($current_hour!=$ct_data['current_hour']){
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
}
|
501 |
|
502 |
//Add 1 to counters
|
503 |
if($event_type=='yes'){
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
}
|
508 |
if($event_type=='no'){
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
}
|
513 |
|
514 |
update_option('cleantalk_data', $ct_data);
|
@@ -526,93 +448,6 @@ function ct_get_cookie()
|
|
526 |
die();
|
527 |
}
|
528 |
|
529 |
-
/**
|
530 |
-
* adds nocache script
|
531 |
-
*/
|
532 |
-
function ct_add_nocache_script()
|
533 |
-
{
|
534 |
-
ob_start('ct_inject_nocache_script');
|
535 |
-
}
|
536 |
-
|
537 |
-
function ct_add_nocache_script_footer(){
|
538 |
-
|
539 |
-
if(strpos($_SERVER['REQUEST_URI'],'jm-ajax') === false){
|
540 |
-
|
541 |
-
global $test_external_forms, $test_internal_forms, $cleantalk_plugin_version;
|
542 |
-
|
543 |
-
print "<script async type='text/javascript' src='".plugins_url( '/inc/cleantalk_nocache.js' , __FILE__ )."?ver=".$cleantalk_plugin_version."'></script>\n";
|
544 |
-
|
545 |
-
if($test_external_forms){
|
546 |
-
print "\n<script type='text/javascript'>var ct_blog_home = '".get_home_url()."';</script>\n";
|
547 |
-
print "<script async type='text/javascript' src='".plugins_url( '/inc/cleantalk_external.js' , __FILE__ )."?ver=".$cleantalk_plugin_version."'></script>\n";
|
548 |
-
}
|
549 |
-
|
550 |
-
if($test_internal_forms){
|
551 |
-
print "\n<script type='text/javascript'>var ct_blog_home = '".get_home_url()."';</script>\n";
|
552 |
-
print "<script async type='text/javascript' src='".plugins_url( '/inc/cleantalk_internal.js' , __FILE__ )."?ver=".$cleantalk_plugin_version."'></script>\n";
|
553 |
-
}
|
554 |
-
}
|
555 |
-
}
|
556 |
-
|
557 |
-
/**
|
558 |
-
* Function prepares values to manage JavaScript code
|
559 |
-
* @return string
|
560 |
-
*/
|
561 |
-
function ct_set_info_flag () {
|
562 |
-
global $ct_options;
|
563 |
-
|
564 |
-
$ct_options=ct_get_options();
|
565 |
-
|
566 |
-
$result = 'false';
|
567 |
-
if(@intval($ct_options['collect_details'])==1
|
568 |
-
&& @intval($ct_options['set_cookies']) == 1
|
569 |
-
) {
|
570 |
-
$result = 'true';
|
571 |
-
}
|
572 |
-
|
573 |
-
$ct_info_flag = "var ct_info_flag=$result;\n";
|
574 |
-
|
575 |
-
$result = 'true';
|
576 |
-
if (@intval($ct_options['set_cookies']) == 0) {
|
577 |
-
$result = 'false';
|
578 |
-
}
|
579 |
-
|
580 |
-
$ct_set_cookies_flag = "var ct_set_cookies_flag=$result;\n";
|
581 |
-
|
582 |
-
return $ct_info_flag . $ct_set_cookies_flag;
|
583 |
-
}
|
584 |
-
|
585 |
-
function ct_add_nocache_script_header(){
|
586 |
-
|
587 |
-
if(strpos($_SERVER['REQUEST_URI'],'jm-ajax')===false){
|
588 |
-
$ct_info_flag = ct_set_info_flag();
|
589 |
-
print "\n<script type='text/javascript'>\nvar ct_ajaxurl = '".admin_url('admin-ajax.php')."';\n $ct_info_flag </script>\n";
|
590 |
-
}
|
591 |
-
|
592 |
-
}
|
593 |
-
|
594 |
-
function ct_inject_nocache_script($html){
|
595 |
-
|
596 |
-
if(strpos($_SERVER['REQUEST_URI'],'jm-ajax')===false){
|
597 |
-
|
598 |
-
global $test_external_forms, $test_internal_forms, $cleantalk_plugin_version, $ct_options;
|
599 |
-
|
600 |
-
$ct_info_flag = ct_set_info_flag();
|
601 |
-
|
602 |
-
if(!is_admin()&&stripos($html,"</body>")!==false){
|
603 |
-
|
604 |
-
$ct_replace="<script async type='text/javascript' src='".plugins_url( '/inc/cleantalk_nocache.js' , __FILE__ )."?random=".$cleantalk_plugin_version."'></script>\n";
|
605 |
-
|
606 |
-
if($test_external_forms){
|
607 |
-
$ct_replace.="\n<script type='text/javascript'>var ct_blog_home = '".get_home_url()."';</script>\n";
|
608 |
-
$ct_replace.="<script async type='text/javascript' src='".plugins_url( '/inc/cleantalk_external.js' , __FILE__ )."?random=".$cleantalk_plugin_version."'></script>\n";
|
609 |
-
}
|
610 |
-
|
611 |
-
$html = preg_replace("/<\/body>\s*<\/html>/", $ct_replace."</body></html>", $html, 1); }
|
612 |
-
}
|
613 |
-
return $html;
|
614 |
-
}
|
615 |
-
|
616 |
function ct_show_comment_link(){
|
617 |
|
618 |
print "<div style='font-size:10pt;'><a href='https://cleantalk.org/wordpress-anti-spam-plugin' target='_blank'>".__( 'WordPress spam', 'cleantalk' )."</a> ".__( 'blocked by', 'cleantalk' )." CleanTalk.</div>";
|
@@ -621,193 +456,49 @@ function ct_show_comment_link(){
|
|
621 |
|
622 |
add_action( 'right_now_content_table_end', 'my_add_counts_to_dashboard' );
|
623 |
|
624 |
-
function
|
625 |
-
|
|
|
626 |
|
627 |
if(!function_exists('sendRawRequest'))
|
628 |
require_once('inc/cleantalk.class.php');
|
629 |
|
630 |
-
if(isset($ct_options['spam_firewall']) && intval($ct_options['spam_firewall']) == 1
|
631 |
|
632 |
-
|
633 |
-
'method_name' => '2s_blacklists_db'
|
634 |
-
);
|
635 |
-
|
636 |
-
$result=sendRawRequest('https://api.cleantalk.org', $data);
|
637 |
|
638 |
-
$
|
|
|
|
|
|
|
|
|
639 |
|
640 |
-
if(isset($result['data'])){
|
641 |
-
|
642 |
-
$wpdb->query("TRUNCATE TABLE `".$wpdb->base_prefix."cleantalk_sfw`;");
|
643 |
-
$result=$result['data'];
|
644 |
-
$query="INSERT INTO `".$wpdb->base_prefix."cleantalk_sfw` VALUES ";
|
645 |
-
for($i=0;$i<sizeof($result);$i++){
|
646 |
-
|
647 |
-
if($i==sizeof($result)-1)
|
648 |
-
$query.="(".$result[$i][0].",".$result[$i][1].");";
|
649 |
-
else
|
650 |
-
$query.="(".$result[$i][0].",".$result[$i][1]."), ";
|
651 |
-
|
652 |
-
}
|
653 |
-
$wpdb->query($query);
|
654 |
-
$ct_sfw_updated = true;
|
655 |
-
}
|
656 |
-
}
|
657 |
-
}
|
658 |
-
|
659 |
-
function cleantalk_get_ip(){
|
660 |
-
|
661 |
-
$result=Array();
|
662 |
-
|
663 |
-
if ( function_exists( 'apache_request_headers' ) )
|
664 |
-
$headers = apache_request_headers();
|
665 |
-
else
|
666 |
-
$headers = $_SERVER;
|
667 |
-
|
668 |
-
if ( array_key_exists( 'X-Forwarded-For', $headers ) ){
|
669 |
-
$the_ip=explode(",", trim($headers['X-Forwarded-For']));
|
670 |
-
$result[] = trim($the_ip[0]);
|
671 |
}
|
672 |
|
673 |
-
|
674 |
-
$the_ip=explode(",", trim($headers['HTTP_X_FORWARDED_FOR']));
|
675 |
-
$result[] = trim($the_ip[0]);
|
676 |
-
}
|
677 |
|
678 |
-
$result[] = filter_var( $_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 );
|
679 |
-
|
680 |
-
if(isset($_GET['sfw_test_ip']))
|
681 |
-
$result[]=$_GET['sfw_test_ip'];
|
682 |
-
|
683 |
-
return $result;
|
684 |
}
|
685 |
|
686 |
-
function
|
687 |
{
|
688 |
global $ct_options, $ct_data;
|
689 |
|
690 |
$ct_options=ct_get_options();
|
691 |
$ct_data=ct_get_data();
|
692 |
-
|
693 |
-
include_once("inc/cleantalk-sfw.class.php");
|
694 |
-
$result = CleanTalkSFW::send_logs($ct_options['apikey']);
|
695 |
-
|
696 |
-
if($result !== false){
|
697 |
-
|
698 |
-
if(!isset($ct_data['sfw_counter']))
|
699 |
-
$ct_data['sfw_counter'] = array('all' => 0, 'blocked' => 0);
|
700 |
-
|
701 |
-
$ct_data['sfw_counter']['all'] += $result['all'];
|
702 |
-
$ct_data['sfw_counter']['blocked'] += $result['blocked'];
|
703 |
-
$ct_data['last_sfw_send']=time();
|
704 |
-
update_option('cleantalk_data', $ct_data);
|
705 |
-
|
706 |
-
return true;
|
707 |
-
|
708 |
-
}else
|
709 |
-
return false;
|
710 |
-
}
|
711 |
-
|
712 |
-
// Sends daily report from get_antispam_report method
|
713 |
-
function cleantalk_send_daily_report(){
|
714 |
-
|
715 |
|
716 |
-
$
|
717 |
|
718 |
-
|
719 |
-
if($timestamp_trial_ends === false){
|
720 |
-
return;
|
721 |
-
}elseif((int)$timestamp_trial_ends < time()){
|
722 |
-
wp_clear_scheduled_hook( 'cleantalk_send_daily_report_hook' );
|
723 |
-
return;
|
724 |
-
}
|
725 |
-
|
726 |
-
if(!function_exists('ct_get_data'))
|
727 |
-
include_once("inc/cleantalk-common.php");
|
728 |
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
$site_url = preg_replace('/http[s]?:\/\//', '', $site_url, 1);
|
733 |
-
$site_domain = preg_replace('/\/.*$/', '', $site_url, 1);
|
734 |
-
|
735 |
-
if($ct_options['apikey'] == ''){
|
736 |
|
737 |
-
|
738 |
-
include_once("inc/cleantalk.class.php");
|
739 |
-
|
740 |
-
$result = getAntispamReport($site_domain);
|
741 |
-
$result = json_decode($result, true);
|
742 |
-
|
743 |
-
//Connection failed
|
744 |
-
if(!$result){
|
745 |
-
|
746 |
-
$ct_data['errors'][__FUNCTION__] = array(
|
747 |
-
'time' => date("M d Y H:i:s", time()),
|
748 |
-
'error_no' => (-1),
|
749 |
-
'error' => 'Request method returns FALSE'
|
750 |
-
);
|
751 |
-
update_option('cleantalk_data', $ct_data);
|
752 |
-
return $ct_data['errors'][__FUNCTION__];
|
753 |
-
} //Error returned
|
754 |
-
elseif(isset($result['error_message']) && isset($result['error_no']))
|
755 |
-
{
|
756 |
-
$ct_data['errors'][__FUNCTION__] = array(
|
757 |
-
'time' => date("M d Y H:i:s", time()),
|
758 |
-
'error_no' => $result['error_no'],
|
759 |
-
'error' => $result['error_message']
|
760 |
-
);
|
761 |
-
update_option('cleantalk_data', $ct_data);
|
762 |
-
return $ct_data['errors'][__FUNCTION__];
|
763 |
-
} //OK
|
764 |
-
elseif(!empty($result['data']))
|
765 |
-
{
|
766 |
-
$result = $result['data']['stat'];
|
767 |
-
if(isset($ct_data['errors'][__FUNCTION__])){
|
768 |
-
unset($ct_data['errors'][__FUNCTION__]);
|
769 |
-
update_option('cleantalk_data', $ct_data);
|
770 |
-
}
|
771 |
-
}
|
772 |
-
|
773 |
-
//Comple mail
|
774 |
-
include_once("templates/daily_report.php");
|
775 |
-
|
776 |
-
$title = sprintf(__('%d spam attacks have been blocked', 'cleantalk'), $result['deny_comments'] + $result['deny_registrations'] + $result['deny_contacts']);
|
777 |
-
$events = sprintf($events,
|
778 |
-
$result['allow_comments'], $result['deny_comments'],
|
779 |
-
$result['allow_registrations'], $result['deny_registrations'],
|
780 |
-
$result['allow_contacts'], $result['deny_contacts']
|
781 |
-
);
|
782 |
-
|
783 |
-
$href_for_network_admin = (is_network_admin() ? "settings" : "options-general");
|
784 |
-
|
785 |
-
$message = sprintf($msg_template,
|
786 |
-
$style, //Headers and styles
|
787 |
-
$title, //Title
|
788 |
-
$events, //Result table
|
789 |
-
$site_url, $href_for_network_admin, __('Complete setup', 'cleantalk'), //Right link to cleantalk's settings
|
790 |
-
__('To see the anti-spam log and complete the setup, please get the Access key.', 'cleantalk'),
|
791 |
-
$site_url, $href_for_network_admin, 'Antispam by CleanTalk' //Right link to cleantalk's settings
|
792 |
-
);
|
793 |
-
|
794 |
-
$admin_email = get_option('admin_email');
|
795 |
-
$subject = sprintf(__("%s spam attacks report", "cleantalk"), $site_domain);
|
796 |
-
$headers[] = 'content-type: text/html';
|
797 |
-
|
798 |
-
$result = $send_mail_result = wp_mail(
|
799 |
-
$admin_email,
|
800 |
-
$subject,
|
801 |
-
$message,
|
802 |
-
$headers
|
803 |
-
);
|
804 |
-
|
805 |
-
return ($result ? true : false);
|
806 |
|
807 |
}
|
808 |
|
809 |
-
return;
|
810 |
-
|
811 |
}
|
812 |
|
813 |
function cleantalk_get_brief_data(){
|
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. Formerly Anti-Spam by CleanTalk.
|
6 |
+
Version: 5.70
|
7 |
Author: СleanTalk <welcome@cleantalk.org>
|
8 |
Author URI: http://cleantalk.org
|
9 |
*/
|
10 |
+
$cleantalk_plugin_version='5.70';
|
11 |
+
$ct_agent_version = 'wordpress-570';
|
12 |
$cleantalk_executed=false;
|
13 |
$ct_sfw_updated = false;
|
14 |
|
15 |
+
define('CLEANTALK_REMOTE_CALL_SLEEP', 10); // Minimum time between remote call
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
if(!defined('CLEANTALK_PLUGIN_DIR')){
|
18 |
|
25 |
|
26 |
$ct_options=ct_get_options();
|
27 |
$ct_data=ct_get_data();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
+
// Self cron
|
30 |
+
if(!defined('DOING_CRON') || (defined('DOING_CRON') && DOING_CRON !== true)){
|
31 |
+
|
32 |
+
require_once(CLEANTALK_PLUGIN_DIR. 'lib/CleantalkCron.php');
|
33 |
+
|
34 |
+
$ct_cron = new cleantalk\antispam\CleantalkCron();
|
35 |
+
$ct_cron->checkTasks();
|
36 |
+
|
37 |
+
if(!empty($ct_cron->tasks_to_run)){
|
|
|
38 |
|
39 |
+
define('CT_CRON', true); // Letting know functions that they are running under CT_CRON
|
40 |
+
$ct_cron->runTasks();
|
41 |
+
unset($ct_cron);
|
42 |
+
|
43 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
}
|
|
|
45 |
|
46 |
+
//Delete cookie for admin trial notice
|
47 |
+
add_action('wp_logout', 'ct_wp_logout');
|
48 |
+
|
49 |
// Early checks
|
50 |
// Facebook
|
51 |
if (isset($ct_options['general_contact_forms_test']) && $ct_options['general_contact_forms_test'] == 1
|
61 |
|
62 |
}
|
63 |
|
64 |
+
if(isset($_SERVER['REQUEST_URI']) && stripos($_SERVER['REQUEST_URI'],'admin-ajax.php')!==false && sizeof($_POST)>0 && isset($_GET['action']) && $_GET['action']=='ninja_forms_ajax_submit')
|
65 |
$_POST['action']='ninja_forms_ajax_submit';
|
66 |
|
67 |
// SFW start
|
96 |
}
|
97 |
}
|
98 |
|
99 |
+
// SpamFireWall check
|
100 |
+
if($value==1 && !is_admin() || $value==1 && defined( 'DOING_AJAX' ) && DOING_AJAX && $_SERVER["REQUEST_METHOD"] == 'GET'){
|
101 |
+
|
102 |
+
include_once(CLEANTALK_PLUGIN_DIR . "lib/CleantalkSFW.php");
|
103 |
|
104 |
+
$is_sfw_check = true;
|
105 |
+
$sfw = new cleantalk\antispam\CleantalkSFW();
|
106 |
+
$sfw_ip = $sfw->cleantalk_get_real_ip();
|
107 |
|
108 |
+
foreach($sfw_ip as $ct_cur_ip){
|
109 |
if(isset($_COOKIE['ct_sfw_pass_key']) && $_COOKIE['ct_sfw_pass_key'] == md5($ct_cur_ip.$ct_options['apikey'])){
|
110 |
$is_sfw_check=false;
|
111 |
if(isset($_COOKIE['ct_sfw_passed'])){
|
112 |
+
$sfw->sfw_update_logs($ct_cur_ip, 'passed');
|
113 |
+
$ct_data['sfw_counter']['all']++;
|
114 |
+
update_option('cleantalk_data', $ct_data);
|
115 |
+
if(!headers_sent())
|
116 |
+
setcookie ('ct_sfw_passed', '0', 1, "/");
|
117 |
}
|
118 |
+
}else{
|
119 |
$is_sfw_check=true;
|
120 |
+
}
|
121 |
+
}
|
122 |
if($is_sfw_check){
|
123 |
$sfw->check_ip();
|
124 |
if($sfw->result){
|
125 |
+
$sfw->sfw_update_logs($sfw->blocked_ip, 'blocked');
|
126 |
+
$ct_data['sfw_counter']['blocked']++;
|
127 |
+
update_option('cleantalk_data', $ct_data);
|
128 |
+
$sfw->sfw_die($ct_options['apikey']);
|
129 |
+
}else{
|
130 |
+
if(!empty($ct_options['set_cookies']))
|
131 |
+
setcookie ('ct_sfw_pass_key', md5($sfw->passed_ip.$ct_options['apikey']), 0, "/");
|
132 |
+
}
|
|
|
|
|
|
|
|
|
133 |
}
|
134 |
+
unset($is_sfw_check, $sfw, $sfw_ip, $ct_cur_ip);
|
135 |
}
|
136 |
|
137 |
+
// Remote calls
|
138 |
if(isset($_GET['spbc_remote_call_token'], $_GET['spbc_remote_call_action'], $_GET['plugin_name']) && ($_GET['plugin_name'] == 'antispam' || $_GET['plugin_name'] == 'anti-spam')){
|
139 |
|
140 |
if(isset($ct_data['last_remote_call']) && time() - $ct_data['last_remote_call'] < CLEANTALK_REMOTE_CALL_SLEEP){
|
152 |
if($_GET['spbc_remote_call_action'] == 'close_renew_banner'){
|
153 |
$ct_data['show_ct_notice_trial'] = 0;
|
154 |
$ct_data['show_ct_notice_renew'] = 0;
|
|
|
155 |
update_option('cleantalk_data', $ct_data);
|
156 |
+
cleantalk\antispam\CleantalkCron::updateTask('check_account_status', 'ct_account_status_check', 86400);
|
157 |
echo "OK";
|
158 |
die();
|
159 |
+
}elseif($_GET['spbc_remote_call_action'] == 'sfw_update'){
|
160 |
+
$rc_result = ct_sfw_update();
|
161 |
+
echo $rc_result === true ? 'OK' : 'FAIL '.$rc_result;
|
162 |
+
die();
|
163 |
+
}elseif($_GET['spbc_remote_call_action'] == 'sfw_send_logs'){
|
164 |
+
$rc_result = ct_sfw_send_logs();
|
165 |
+
echo $rc_result === true ? 'OK' : 'FAIL '.$rc_result;
|
166 |
+
die();
|
167 |
}
|
168 |
}else{
|
169 |
echo "FAIL WRONG_TOKEN";
|
170 |
die();
|
171 |
}
|
|
|
172 |
}
|
|
|
173 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
// Activation/deactivation functions must be in main plugin file.
|
175 |
// http://codex.wordpress.org/Function_Reference/register_activation_hook
|
176 |
register_activation_hook( __FILE__, 'ct_activation' );
|
177 |
register_deactivation_hook( __FILE__, 'ct_deactivation' );
|
178 |
+
|
|
|
179 |
// Redirect admin to plugin settings.
|
|
|
180 |
if(!defined('WP_ALLOW_MULTISITE') || defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE == false)
|
181 |
add_action('admin_init', 'ct_plugin_redirect');
|
182 |
|
183 |
// After plugin loaded - to load locale as described in manual
|
184 |
+
add_action('plugin_loaded', 'ct_plugin_loaded' );
|
|
|
|
|
|
|
185 |
|
186 |
+
if( !empty($ct_options['use_ajax']) &&
|
187 |
stripos($_SERVER['REQUEST_URI'],'.xml')===false &&
|
188 |
stripos($_SERVER['REQUEST_URI'],'.xsl')===false)
|
189 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
add_action( 'wp_ajax_nopriv_ct_get_cookie', 'ct_get_cookie',1 );
|
191 |
add_action( 'wp_ajax_ct_get_cookie', 'ct_get_cookie',1 );
|
192 |
}
|
199 |
require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-users.php');
|
200 |
}
|
201 |
|
202 |
+
// Admin panel actions
|
203 |
if (is_admin()||is_network_admin()){
|
204 |
|
205 |
require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-admin.php');
|
280 |
if($pagenow=='users.php')
|
281 |
add_action('delete_user', 'ct_delete_user', 10, 2);
|
282 |
|
283 |
+
if($pagenow=='plugins.php' || (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'],'plugins.php') !== false)){
|
284 |
|
285 |
add_filter('plugin_action_links_'.plugin_basename(__FILE__), 'ct_plugin_action_links', 10, 2);
|
286 |
add_filter('network_admin_plugin_action_links_'.plugin_basename(__FILE__), 'ct_plugin_action_links', 10, 2);
|
288 |
add_filter('plugin_row_meta', 'ct_register_plugin_links', 10, 2);
|
289 |
}
|
290 |
add_action('updated_option', 'ct_update_option'); // param - option name, i.e. 'cleantalk_settings'
|
291 |
+
|
292 |
+
// Public pages actions
|
293 |
}else{
|
294 |
|
295 |
require_once(CLEANTALK_PLUGIN_DIR . 'inc/cleantalk-public.php');
|
329 |
}
|
330 |
}
|
331 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
332 |
/**
|
333 |
* On activation, set a time, frequency and name of an action hook to be scheduled.
|
334 |
*/
|
335 |
if (!function_exists ( 'ct_activation')) {
|
336 |
function ct_activation() {
|
337 |
|
338 |
+
global $wpdb;
|
339 |
|
340 |
+
$wpdb->query("CREATE TABLE IF NOT EXISTS `".$wpdb->base_prefix."cleantalk_sfw` (
|
341 |
+
`network` int(11) unsigned NOT NULL,
|
342 |
+
`mask` int(11) unsigned NOT NULL,
|
343 |
+
INDEX ( `network` , `mask` )
|
344 |
+
) ENGINE = MYISAM ;"
|
345 |
+
);
|
346 |
+
|
347 |
+
$wpdb->query("CREATE TABLE IF NOT EXISTS `".$wpdb->base_prefix."cleantalk_sfw_logs` (
|
348 |
+
`ip` VARCHAR(15) NOT NULL,
|
349 |
+
`all_entries` INT NOT NULL,
|
350 |
+
`blocked_entries` INT NOT NULL,
|
351 |
+
`entries_timestamp` INT NOT NULL,
|
352 |
+
PRIMARY KEY (`ip`))
|
353 |
+
ENGINE = MYISAM;"
|
354 |
+
);
|
355 |
|
356 |
+
// Cron tasks
|
357 |
+
cleantalk\antispam\CleantalkCron::addTask('check_account_status', 'ct_account_status_check', 3600, time()+1800); // Checks account status
|
358 |
+
cleantalk\antispam\CleantalkCron::addTask('delete_spam_comments', 'ct_delete_spam_comments', 3600, time()+3500); // Formerly ct_hourly_event_hook()
|
359 |
+
cleantalk\antispam\CleantalkCron::addTask('send_feedback', 'ct_send_feedback', 3600, time()+3500); // Formerly ct_hourly_event_hook()
|
360 |
+
cleantalk\antispam\CleantalkCron::addTask('sfw_update', 'ct_sfw_update', 86400, time()+43200);// SFW update
|
361 |
+
cleantalk\antispam\CleantalkCron::addTask('send_sfw_logs', 'ct_sfw_send_logs', 3600, time()+1800); // SFW send logs
|
362 |
+
cleantalk\antispam\CleantalkCron::addTask('get_brief_data', 'cleantalk_get_brief_data', 86400, time()+3500); // Get data for dashboard widget
|
363 |
+
|
364 |
+
// Additional options
|
365 |
add_option('ct_plugin_do_activation_redirect', true);
|
|
|
366 |
add_option('ct_installing', true);
|
367 |
+
|
368 |
+
// Updating SFW
|
369 |
+
ct_sfw_update();
|
370 |
}
|
371 |
}
|
372 |
|
376 |
if (!function_exists ( 'ct_deactivation')) {
|
377 |
function ct_deactivation() {
|
378 |
|
379 |
+
global $wpdb;
|
380 |
+
|
381 |
+
// Deleting SFW tables
|
382 |
+
$wpdb->query("DROP TABLE IF EXISTS `".$wpdb->base_prefix."cleantalk_sfw`;");
|
383 |
+
$wpdb->query("DROP TABLE IF EXISTS `".$wpdb->base_prefix."cleantalk_sfw_logs`;");
|
384 |
+
|
385 |
+
// Deleting cron entries
|
386 |
+
delete_option('cleantalk_cron');
|
387 |
+
|
|
|
|
|
|
|
388 |
}
|
389 |
}
|
390 |
|
392 |
* Redirects admin to plugin settings after activation.
|
393 |
*/
|
394 |
function ct_plugin_redirect()
|
395 |
+
{
|
396 |
+
if (get_option('ct_plugin_do_activation_redirect', false) && !isset($_GET['activate-multi'])){
|
|
|
|
|
397 |
delete_option('ct_plugin_do_activation_redirect');
|
398 |
+
wp_redirect("options-general.php?page=cleantalk");
|
|
|
|
|
|
|
|
|
399 |
}
|
400 |
}
|
401 |
|
403 |
{
|
404 |
global $ct_data,$cleantalk_executed;
|
405 |
|
|
|
|
|
|
|
406 |
//
|
407 |
// To migrate on the new version of ct_add_event().
|
408 |
//
|
412 |
}
|
413 |
|
414 |
$ct_data = ct_get_data();
|
415 |
+
$current_hour = intval(date('G'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
416 |
|
417 |
+
// Updating current hour
|
418 |
if($current_hour!=$ct_data['current_hour']){
|
419 |
+
$ct_data['current_hour']=$current_hour;
|
420 |
+
$ct_data['array_accepted'][$current_hour]=0;
|
421 |
+
$ct_data['array_blocked'][$current_hour]=0;
|
422 |
}
|
423 |
|
424 |
//Add 1 to counters
|
425 |
if($event_type=='yes'){
|
426 |
+
$ct_data['array_accepted'][$current_hour]++;
|
427 |
+
$ct_data['all_time_counter']['accepted']++;
|
428 |
+
$ct_data['user_counter']['accepted']++;
|
429 |
}
|
430 |
if($event_type=='no'){
|
431 |
+
$ct_data['array_blocked'][$current_hour]++;
|
432 |
+
$ct_data['all_time_counter']['blocked']++;
|
433 |
+
$ct_data['user_counter']['blocked']++;
|
434 |
}
|
435 |
|
436 |
update_option('cleantalk_data', $ct_data);
|
448 |
die();
|
449 |
}
|
450 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
451 |
function ct_show_comment_link(){
|
452 |
|
453 |
print "<div style='font-size:10pt;'><a href='https://cleantalk.org/wordpress-anti-spam-plugin' target='_blank'>".__( 'WordPress spam', 'cleantalk' )."</a> ".__( 'blocked by', 'cleantalk' )." CleanTalk.</div>";
|
456 |
|
457 |
add_action( 'right_now_content_table_end', 'my_add_counts_to_dashboard' );
|
458 |
|
459 |
+
function ct_sfw_update(){
|
460 |
+
|
461 |
+
global $ct_options;
|
462 |
|
463 |
if(!function_exists('sendRawRequest'))
|
464 |
require_once('inc/cleantalk.class.php');
|
465 |
|
466 |
+
if(isset($ct_options['spam_firewall']) && intval($ct_options['spam_firewall']) == 1){
|
467 |
|
468 |
+
include_once(CLEANTALK_PLUGIN_DIR . "lib/CleantalkSFW.php");
|
|
|
|
|
|
|
|
|
469 |
|
470 |
+
$sfw = new cleantalk\antispam\CleantalkSFW();
|
471 |
+
$result = $sfw->sfw_update($ct_options['apikey']);
|
472 |
+
unset($sfw);
|
473 |
+
|
474 |
+
return $result === true ? true : $result;
|
475 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
476 |
}
|
477 |
|
478 |
+
return 'SFW_DISABLED';
|
|
|
|
|
|
|
479 |
|
|
|
|
|
|
|
|
|
|
|
|
|
480 |
}
|
481 |
|
482 |
+
function ct_sfw_send_logs()
|
483 |
{
|
484 |
global $ct_options, $ct_data;
|
485 |
|
486 |
$ct_options=ct_get_options();
|
487 |
$ct_data=ct_get_data();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
488 |
|
489 |
+
if(isset($ct_options['spam_firewall']) && intval($ct_options['spam_firewall']) == 1){
|
490 |
|
491 |
+
include_once(CLEANTALK_PLUGIN_DIR . "lib/CleantalkSFW.php");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
492 |
|
493 |
+
$sfw = new cleantalk\antispam\CleantalkSFW();
|
494 |
+
$result = $sfw->send_logs($ct_options['apikey']);
|
495 |
+
unset($sfw);
|
|
|
|
|
|
|
|
|
496 |
|
497 |
+
return $result === true ? true : $result;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
498 |
|
499 |
}
|
500 |
|
501 |
+
return 'SFW_DISABLED';
|
|
|
502 |
}
|
503 |
|
504 |
function cleantalk_get_brief_data(){
|
inc/cleantalk-admin.php
CHANGED
@@ -302,12 +302,80 @@ function ct_admin_add_page() {
|
|
302 |
|
303 |
}
|
304 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
305 |
/**
|
306 |
* Admin action 'admin_init' - Add the admin settings and such
|
307 |
*/
|
308 |
function ct_admin_init(){
|
309 |
|
310 |
-
global $ct_server_timeout, $show_ct_notice_autokey, $ct_notice_autokey_label, $ct_notice_autokey_value, $show_ct_notice_renew, $ct_notice_renew_label, $show_ct_notice_trial, $ct_notice_trial_label, $show_ct_notice_online, $ct_notice_online_label, $renew_notice_showtime, $trial_notice_showtime, $ct_plugin_name, $ct_options, $ct_data, $
|
311 |
|
312 |
$ct_options = ct_get_options();
|
313 |
$ct_data = ct_get_data();
|
@@ -317,10 +385,10 @@ function ct_admin_init(){
|
|
317 |
if($is_installing){
|
318 |
delete_option('ct_installing');
|
319 |
$ct_data['plugin_version'] = $cleantalk_plugin_version;
|
320 |
-
|
321 |
update_option( 'cleantalk_data' , $ct_data);
|
322 |
}else{
|
323 |
-
$current_version = (isset($ct_data['plugin_version']) ? $ct_data['plugin_version'] : '
|
324 |
if($current_version != $cleantalk_plugin_version){
|
325 |
if(is_main_site()){
|
326 |
require_once('cleantalk-updater.php');
|
@@ -334,14 +402,7 @@ function ct_admin_init(){
|
|
334 |
update_option( 'cleantalk_data' , $ct_data);
|
335 |
}
|
336 |
}
|
337 |
-
|
338 |
}
|
339 |
-
}
|
340 |
-
|
341 |
-
// Set notice if came from report
|
342 |
-
if(isset($_GET['from_report']) && $_GET['from_report']){
|
343 |
-
$ct_data['ct_show_notice_from_report'] = true;
|
344 |
-
update_option('cleantalk_data', $ct_data);
|
345 |
}
|
346 |
|
347 |
// Drop debug data
|
@@ -397,8 +458,7 @@ function ct_admin_init(){
|
|
397 |
|
398 |
if ($result)
|
399 |
{
|
400 |
-
|
401 |
-
update_option('cleantalk_data', $ct_data);
|
402 |
$result = json_decode($result, true);
|
403 |
|
404 |
if (isset($result['data']) && is_array($result['data']))
|
@@ -421,79 +481,11 @@ function ct_admin_init(){
|
|
421 |
}
|
422 |
}
|
423 |
|
424 |
-
//Account's status check
|
425 |
-
if (
|
426 |
-
|
427 |
-
$notice_check_timeout = $account_notice_check_timeout;
|
428 |
-
|
429 |
-
$api_key = isset($_POST['cleantalk_settings']['apikey']) ? $_POST['cleantalk_settings']['apikey'] : $ct_options['apikey'];
|
430 |
-
|
431 |
-
if(!function_exists('noticePaidTill'))
|
432 |
-
require_once('cleantalk.class.php');
|
433 |
-
|
434 |
-
$result = noticePaidTill($api_key);
|
435 |
-
|
436 |
-
if ($result){
|
437 |
-
|
438 |
-
$result = json_decode($result, true);
|
439 |
-
|
440 |
-
if (isset($result['data']) && is_array($result['data']))
|
441 |
-
$result = $result['data'];
|
442 |
-
|
443 |
-
if(isset($result['spam_count']))
|
444 |
-
$ct_data['admin_blocked']=$result['spam_count'];
|
445 |
-
|
446 |
-
if (isset($result['show_notice'])){
|
447 |
-
|
448 |
-
if ($result['show_notice'] == 1 && isset($result['trial']) && $result['trial'] == 1){
|
449 |
-
$notice_check_timeout = $trial_notice_check_timeout;
|
450 |
-
$show_ct_notice_trial = true;
|
451 |
-
$ct_data['show_ct_notice_trial']=1;
|
452 |
-
}
|
453 |
-
|
454 |
-
if ($result['show_notice'] == 1 && isset($result['renew']) && $result['renew'] == 1){
|
455 |
-
$notice_check_timeout = $renew_notice_check_timeout;
|
456 |
-
$show_ct_notice_renew = true;
|
457 |
-
$ct_data['show_ct_notice_renew']=1;
|
458 |
-
}
|
459 |
-
|
460 |
-
if (isset($result['show_review']) && $result['show_review'] == 1)
|
461 |
-
$ct_data['show_ct_notice_review'] = 1;
|
462 |
-
|
463 |
-
if ($result['show_notice'] == 0)
|
464 |
-
$notice_check_timeout = $account_notice_check_timeout;
|
465 |
-
|
466 |
-
$ct_data['show_ct_notice_trial']=(int) $show_ct_notice_trial;
|
467 |
-
$ct_data['show_ct_notice_renew']= (int) $show_ct_notice_renew;
|
468 |
-
}
|
469 |
-
|
470 |
-
if (isset($result['moderate_ip']) && $result['moderate_ip'] == 1){
|
471 |
-
$ct_data['moderate_ip'] = 1;
|
472 |
-
$ct_data['ip_license'] = $result['ip_license'];
|
473 |
-
}else{
|
474 |
-
$ct_data['moderate_ip'] = 0;
|
475 |
-
$ct_data['ip_license'] = 0;
|
476 |
-
}
|
477 |
-
|
478 |
-
if (isset($result['user_token']))
|
479 |
-
$ct_data['user_token'] = $result['user_token'];
|
480 |
-
}
|
481 |
-
// Save next status request time
|
482 |
-
$ct_data['next_account_status_check'] = time() + $notice_check_timeout * 3600;
|
483 |
-
update_option('cleantalk_data', $ct_data);
|
484 |
-
|
485 |
-
/*if ($result)
|
486 |
-
{
|
487 |
-
if($show_ct_notice_trial == true)
|
488 |
-
{
|
489 |
-
setcookie($ct_notice_trial_label, (string) $show_ct_notice_trial, strtotime("+$trial_notice_showtime minutes"), '/');
|
490 |
-
}
|
491 |
-
if($show_ct_notice_renew == true)
|
492 |
-
{
|
493 |
-
setcookie($ct_notice_renew_label, (string) $show_ct_notice_renew, strtotime("+$renew_notice_showtime minutes"), '/');
|
494 |
-
}
|
495 |
-
}*/
|
496 |
}
|
|
|
497 |
|
498 |
$show_ct_notice_online = '';
|
499 |
if (isset($_COOKIE[$ct_notice_online_label]))
|
@@ -685,46 +677,18 @@ function ct_add_admin_menu( $wp_admin_bar ) {
|
|
685 |
global $ct_options, $ct_data;
|
686 |
|
687 |
$ct_options = ct_get_options();
|
688 |
-
if(isset($ct_options['show_adminbar']))
|
689 |
-
{
|
690 |
-
$value = @intval($ct_options['show_adminbar']);
|
691 |
-
}
|
692 |
-
else
|
693 |
-
{
|
694 |
-
$value=1;
|
695 |
-
}
|
696 |
-
|
697 |
-
if (current_user_can('activate_plugins')&&$value==1 && ct_valid_key($ct_options['apikey']) !== false) {
|
698 |
-
$ct_data=ct_get_data();
|
699 |
-
|
700 |
-
//Create daily counter
|
701 |
-
if(!isset($ct_data['array_accepted'])){
|
702 |
-
$ct_data['array_accepted']=Array();
|
703 |
-
$ct_data['array_blocked']=Array();
|
704 |
-
$ct_data['current_hour']=0;
|
705 |
-
update_option('cleantalk_data', $ct_data);
|
706 |
-
}
|
707 |
-
|
708 |
-
//Create all time counter
|
709 |
-
if(!isset($ct_data['all_time_counter'])){
|
710 |
-
$ct_data['all_time_counter']['accepted']=0;
|
711 |
-
$ct_data['all_time_counter']['blocked']=0;
|
712 |
-
update_option('cleantalk_data', $ct_data);
|
713 |
-
}
|
714 |
|
|
|
|
|
|
|
715 |
//Reset or create user counter
|
716 |
-
if(!
|
717 |
-
$ct_data['user_counter']['accepted']=0;
|
718 |
-
$ct_data['user_counter']['blocked']=0;
|
719 |
-
$ct_data['user_counter']['since']=date('d M');
|
720 |
update_option('cleantalk_data', $ct_data);
|
721 |
}
|
722 |
|
723 |
-
if(!isset($ct_data['sfw_counter'])){
|
724 |
-
$ct_data['sfw_counter']['all'] = 0;
|
725 |
-
$ct_data['sfw_counter']['blocked'] = 0;
|
726 |
-
}
|
727 |
-
|
728 |
//Compile user's counter string
|
729 |
$user_counter=Array('accepted'=>$ct_data['user_counter']['accepted'], 'blocked'=>$ct_data['user_counter']['blocked'], 'all'=>$ct_data['user_counter']['accepted'] + $ct_data['user_counter']['blocked'], 'since'=>$ct_data['user_counter']['since']);
|
730 |
//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>';
|
@@ -1080,6 +1044,7 @@ function ct_input_show_check_links() {
|
|
1080 |
$ct_data = ct_get_data();
|
1081 |
|
1082 |
$value = $ct_options['show_check_links'];
|
|
|
1083 |
echo "<input type='radio' id='cleantalk_show_check_links1' name='cleantalk_settings[show_check_links]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_show_check_links1'> " . __('Yes') . "</label>";
|
1084 |
echo ' ';
|
1085 |
echo "<input type='radio' id='cleantalk_show_check_links1' name='cleantalk_settings[show_check_links]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_show_check_links1'> " . __('No') . "</label>";
|
@@ -1387,18 +1352,10 @@ function ct_input_set_cookies() {
|
|
1387 |
|
1388 |
$ct_options = ct_get_options();
|
1389 |
$ct_data = ct_get_data();
|
1390 |
-
|
1391 |
-
|
1392 |
-
{
|
1393 |
-
$value = @intval($ct_options['set_cookies']);
|
1394 |
-
}
|
1395 |
-
else
|
1396 |
-
{
|
1397 |
-
$value=0;
|
1398 |
-
}
|
1399 |
-
echo "<input type='radio' id='cleantalk_set_cookies1' name='cleantalk_settings[set_cookies]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_set_cookies1'> " . __('Yes') . "</label>";
|
1400 |
echo ' ';
|
1401 |
-
echo "<input type='radio' id='cleantalk_set_cookies0' name='cleantalk_settings[set_cookies]' value='0' " . ($
|
1402 |
@admin_addDescriptionsFields(sprintf(__('Turn this option off to deny plugin generates any cookies on website front-end. This option is helpful if you use Varnish. But most of contact forms will not be protected by CleanTalk if the option is turned off!', 'cleantalk')));
|
1403 |
}
|
1404 |
|
@@ -1407,18 +1364,10 @@ function ct_input_ssl_on() {
|
|
1407 |
|
1408 |
$ct_options = ct_get_options();
|
1409 |
$ct_data = ct_get_data();
|
1410 |
-
|
1411 |
-
|
1412 |
-
{
|
1413 |
-
$value = @intval($ct_options['ssl_on']);
|
1414 |
-
}
|
1415 |
-
else
|
1416 |
-
{
|
1417 |
-
$value=0;
|
1418 |
-
}
|
1419 |
-
echo "<input type='radio' id='cleantalk_ssl_on1' name='cleantalk_settings[ssl_on]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_ssl_on1'> " . __('Yes') . "</label>";
|
1420 |
echo ' ';
|
1421 |
-
echo "<input type='radio' id='cleantalk_ssl_on0' name='cleantalk_settings[ssl_on]' value='0' " . ($
|
1422 |
@admin_addDescriptionsFields(sprintf(__('Turn this option on to use encrypted (SSL) connection with CleanTalk servers.', 'cleantalk')));
|
1423 |
}
|
1424 |
|
@@ -1427,19 +1376,10 @@ function ct_input_protect_logged_in() {
|
|
1427 |
|
1428 |
$ct_options = ct_get_options();
|
1429 |
$ct_data = ct_get_data();
|
1430 |
-
|
1431 |
-
|
1432 |
-
{
|
1433 |
-
$value = @intval($ct_options['protect_logged_in']);
|
1434 |
-
$value = $value == 1 ? $value : 0;
|
1435 |
-
}
|
1436 |
-
else
|
1437 |
-
{
|
1438 |
-
$value=0;
|
1439 |
-
}
|
1440 |
-
echo "<input type='radio' id='cleantalk_protect_logged_in1' name='cleantalk_settings[protect_logged_in]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_protect_logged_in1'> " . __('Yes') . "</label>";
|
1441 |
echo ' ';
|
1442 |
-
echo "<input type='radio' id='cleantalk_protect_logged_in0' name='cleantalk_settings[protect_logged_in]' value='0' " . ($
|
1443 |
@admin_addDescriptionsFields(sprintf(__('Turn this option on to check for spam any submissions (comments, contact forms and etc.) from registered Users.', 'cleantalk')));
|
1444 |
|
1445 |
return null;
|
@@ -1450,22 +1390,13 @@ function ct_input_show_link() {
|
|
1450 |
|
1451 |
$ct_options = ct_get_options();
|
1452 |
$ct_data = ct_get_data();
|
1453 |
-
|
1454 |
-
if(isset($ct_options['show_link']))
|
1455 |
-
{
|
1456 |
-
$value = @intval($ct_options['show_link']);
|
1457 |
-
}
|
1458 |
-
else
|
1459 |
-
{
|
1460 |
-
$value=0;
|
1461 |
-
}
|
1462 |
|
1463 |
/* echo "<input type='radio' id='cleantalk_show_link1' name='cleantalk_settings[show_link]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_show_link1'> " . __('Yes') . "</label>";
|
1464 |
echo ' ';
|
1465 |
echo "<input type='radio' id='cleantalk_show_link0' name='cleantalk_settings[show_link]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_show_link0'> " . __('No') . "</label>";*/
|
1466 |
|
1467 |
echo "<div id='cleantalk_anchor' style='display:none'></div><input type=hidden name='cleantalk_settings[show_link]' value='0' />";
|
1468 |
-
echo "<input type='checkbox' id='cleantalk_show_link1' name='cleantalk_settings[show_link]' value='1' " . ($
|
1469 |
@admin_addDescriptionsFields(sprintf(__("Checking this box places a small link under the comment form that lets others know what anti-spam tool protects your site.", 'cleantalk'), $ct_options['show_link']));
|
1470 |
echo "<script>
|
1471 |
jQuery(document).ready(function(){
|
@@ -1480,18 +1411,9 @@ function ct_input_spam_firewall() {
|
|
1480 |
|
1481 |
$ct_options = ct_get_options();
|
1482 |
$ct_data = ct_get_data();
|
1483 |
-
|
1484 |
-
if(isset($ct_options['spam_firewall']))
|
1485 |
-
{
|
1486 |
-
$value = @intval($ct_options['spam_firewall']);
|
1487 |
-
}
|
1488 |
-
else
|
1489 |
-
{
|
1490 |
-
$value=0;
|
1491 |
-
}
|
1492 |
|
1493 |
echo "<div id='cleantalk_anchor1' style='display:none'></div><input type=hidden name='cleantalk_settings[spam_firewall]' value='0' />";
|
1494 |
-
echo "<input type='checkbox' id='cleantalk_spam_firewall1' name='cleantalk_settings[spam_firewall]' value='1' " . ($
|
1495 |
@admin_addDescriptionsFields(sprintf(__("This option allows to filter spam bots before they access website. Also reduces CPU usage on hosting server and accelerates pages load time.", 'cleantalk'), $ct_options['spam_firewall']) .
|
1496 |
" " .
|
1497 |
'<a href="https://cleantalk.org/cleantalk-spam-firewall" style="font-size: 10pt; color: #666 !important" target="_blank">' . __('Learn more', 'cleantalk') . '</a>.'
|
@@ -1621,48 +1543,28 @@ function ct_settings_page() {
|
|
1621 |
|
1622 |
$ct_data = get_option('cleantalk_data');
|
1623 |
|
1624 |
-
|
1625 |
-
|
1626 |
-
$page = get_current_screen();
|
1627 |
-
$trial_time = get_option('cleantalk_sends_reports_till');
|
1628 |
-
$trial_days_left = ($trial_time ? ceil(($trial_time - time()) / 86400) : false);
|
1629 |
-
|
1630 |
-
// Trial days
|
1631 |
-
/* INACTIVE
|
1632 |
-
if ((is_network_admin() || is_admin()) && $trial_days_left && $page->id == 'settings_page_cleantalk' && $ct_data['moderate_ip'] == 0){
|
1633 |
-
$trial_days_left = 7; //Magic number!
|
1634 |
-
echo ($trial_days_left == 1 ? "<span style='color:red;'>" : "");
|
1635 |
-
echo '<br>' . sprintf(__("You have <b>%d</b> days free trial to test the anti-spam protection.", 'cleantalk'), $trial_days_left) . '';
|
1636 |
-
echo ($trial_days_left == 1 ? "</span>" : "");
|
1637 |
-
}
|
1638 |
-
//*/
|
1639 |
-
|
1640 |
-
}else{
|
1641 |
-
|
1642 |
-
$user_token = (!empty($ct_data['user_token']) ? $ct_data['user_token'] : false);
|
1643 |
-
|
1644 |
-
// Translate banner for non EN locale
|
1645 |
-
if(substr(get_locale(), 0, 2) != 'en'){
|
1646 |
-
require_once(CLEANTALK_PLUGIN_DIR.'templates/translate_banner.php');
|
1647 |
-
printf($ct_translate_banner_template, substr(get_locale(), 0, 2));
|
1648 |
-
}else
|
1649 |
-
echo "<br /><br /><br />";
|
1650 |
-
|
1651 |
-
echo "<div>";
|
1652 |
-
|
1653 |
-
echo __("CleanTalk's tech support:", 'cleantalk')
|
1654 |
-
." "
|
1655 |
-
.'<a target="_blank" href="https://wordpress.org/support/plugin/cleantalk-spam-protect">Wordpress.org</a>.'
|
1656 |
-
// .' <a href="https://community.cleantalk.org/viewforum.php?f=25" target="_blank">'.__("Tech forum", 'cleantalk').'</a>'
|
1657 |
-
// .($user_token ? ", <a href='https://cleantalk.org/my/support?user_token=$user_token&cp_mode=antispam' target='_blank'>".__("Service support ", 'cleantalk').'</a>' : '').
|
1658 |
-
.'<br>';
|
1659 |
-
echo __('Plugin Homepage at', 'cleantalk').' <a href="http://cleantalk.org" target="_blank">cleantalk.org</a>.<br />';
|
1660 |
-
echo __('Use s@cleantalk.org to test plugin in any WordPress form.', 'cleantalk').'<br>';
|
1661 |
-
echo __('CleanTalk is registered Trademark. All rights reserved.', 'cleantalk');
|
1662 |
|
1663 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1664 |
|
1665 |
-
|
1666 |
}
|
1667 |
|
1668 |
/**
|
@@ -1675,8 +1577,6 @@ function cleantalk_admin_notice_message(){
|
|
1675 |
$ct_options = ct_get_options();
|
1676 |
$ct_data = ct_get_data();
|
1677 |
$page = get_current_screen();
|
1678 |
-
$activation_timestapm = get_option('cleantalk_activation_timestamp', false);
|
1679 |
-
|
1680 |
|
1681 |
//General notice control flags
|
1682 |
$moderate_ip = (empty($ct_data['moderate_ip']) ? 0 : $ct_data['moderate_ip']);
|
@@ -1690,26 +1590,14 @@ function cleantalk_admin_notice_message(){
|
|
1690 |
$show_ct_notice_renew = (isset($ct_data['show_ct_notice_renew']) ? intval($ct_data['show_ct_notice_renew']) : 0);
|
1691 |
$show_ct_notice_review = (isset($ct_data['show_ct_notice_review']) ? intval($ct_data['show_ct_notice_review']) : 0);
|
1692 |
$next_notice_show = (isset($ct_data['next_notice_show']) ? intval($ct_data['next_notice_show']) : 0); //inactive
|
1693 |
-
$
|
1694 |
-
|
1695 |
-
$three_days_since_activation = (intval($activation_timestapm)+(3*24*60*60) < time() ? true : false);
|
1696 |
-
|
1697 |
//Misc
|
1698 |
$user_token = (isset($ct_data['user_token']) && $ct_data['user_token'] != '' ? "&user_token={$ct_data['user_token']}" : "");
|
1699 |
$settings_link = (is_network_admin() ? "settings.php?page=cleantalk" : "options-general.php?page=cleantalk");
|
1700 |
|
1701 |
if($self_owned_key && $is_admin && $value == 1){
|
1702 |
|
1703 |
-
//Notice when users came from the daily report letter
|
1704 |
-
if ($show_notice && $notice_from_report && !ct_valid_key()){
|
1705 |
-
|
1706 |
-
if($page_is_ct_settings)
|
1707 |
-
echo '<div class="error">
|
1708 |
-
<h3>' .__("To see the anti-spam log and complete the setup, please get the Access key.", 'cleantalk'). '</h3>
|
1709 |
-
</div>';
|
1710 |
-
$show_notice = false;
|
1711 |
-
}
|
1712 |
-
|
1713 |
//Unable to get key automatically (if ct_admin_init().getAutoKey() returns error)
|
1714 |
if ($show_notice && $show_ct_notice_autokey){
|
1715 |
echo '<div class="error">
|
@@ -1721,13 +1609,11 @@ function cleantalk_admin_notice_message(){
|
|
1721 |
|
1722 |
//key == "" || "enter key"
|
1723 |
if ($show_notice && !ct_valid_key()){
|
1724 |
-
|
1725 |
-
|
1726 |
-
|
1727 |
-
|
1728 |
-
|
1729 |
-
."</h3>
|
1730 |
-
</div>";
|
1731 |
$show_notice = false;
|
1732 |
}
|
1733 |
|
@@ -1969,8 +1855,8 @@ function ct_update_option($option_name) {
|
|
1969 |
|
1970 |
if (isset($_POST['cleantalk_settings']['spam_firewall'])) {
|
1971 |
if ($_POST['cleantalk_settings']['spam_firewall'] == 1) {
|
1972 |
-
|
1973 |
-
|
1974 |
} else {
|
1975 |
// Reseting SFW logs to do not keep huge ammount of data.
|
1976 |
$ct_data['sfw_log']= array();
|
@@ -2015,10 +1901,7 @@ function ct_update_option($option_name) {
|
|
2015 |
setcookie($ct_notice_online_label, (string) time(), strtotime("+14 days"), '/');
|
2016 |
}
|
2017 |
setcookie($ct_notice_trial_label, '0', strtotime("+$trial_notice_showtime minutes"), '/');
|
2018 |
-
|
2019 |
-
//Deleting update flag
|
2020 |
-
unset($ct_data['ct_show_notice_from_report']);
|
2021 |
-
|
2022 |
} else {
|
2023 |
setcookie($ct_notice_online_label, 'BAD_KEY', 0, '/');
|
2024 |
}
|
302 |
|
303 |
}
|
304 |
|
305 |
+
/*
|
306 |
+
* Inner function - Account status check
|
307 |
+
* Scheduled in 1800 seconds for default!
|
308 |
+
*/
|
309 |
+
function ct_account_status_check(){
|
310 |
+
|
311 |
+
global $ct_options, $ct_data, $show_ct_notice_trial, $show_ct_notice_renew;
|
312 |
+
|
313 |
+
$ct_options = ct_get_options();
|
314 |
+
$ct_data = ct_get_data();
|
315 |
+
|
316 |
+
$api_key = isset($_POST['cleantalk_settings']['apikey']) ? $_POST['cleantalk_settings']['apikey'] : $ct_options['apikey'];
|
317 |
+
|
318 |
+
if(!function_exists('noticePaidTill'))
|
319 |
+
require_once('cleantalk.class.php');
|
320 |
+
|
321 |
+
$result = noticePaidTill($api_key);
|
322 |
+
|
323 |
+
if ($result){
|
324 |
+
|
325 |
+
$result = json_decode($result, true);
|
326 |
+
|
327 |
+
if (isset($result['data']) && is_array($result['data']))
|
328 |
+
$result = $result['data'];
|
329 |
+
|
330 |
+
if(isset($result['spam_count']))
|
331 |
+
$ct_data['admin_blocked'] = $result['spam_count'];
|
332 |
+
|
333 |
+
if (isset($result['show_notice'])){
|
334 |
+
|
335 |
+
if ($result['show_notice'] == 1 && isset($result['trial']) && $result['trial'] == 1){
|
336 |
+
cleantalk\antispam\CleantalkCron::updateTask('check_account_status', 'ct_account_status_check', 3600);
|
337 |
+
$show_ct_notice_trial = true;
|
338 |
+
$ct_data['show_ct_notice_trial']=1;
|
339 |
+
}
|
340 |
+
|
341 |
+
if ($result['show_notice'] == 1 && isset($result['renew']) && $result['renew'] == 1){
|
342 |
+
cleantalk\antispam\CleantalkCron::updateTask('check_account_status', 'ct_account_status_check', 1800);
|
343 |
+
$show_ct_notice_renew = true;
|
344 |
+
$ct_data['show_ct_notice_renew']=1;
|
345 |
+
}
|
346 |
+
|
347 |
+
if (isset($result['show_review']) && $result['show_review'] == 1)
|
348 |
+
$ct_data['show_ct_notice_review'] = 1;
|
349 |
+
|
350 |
+
if ($result['show_notice'] == 0)
|
351 |
+
cleantalk\antispam\CleantalkCron::updateTask('check_account_status', 'ct_account_status_check', 86400);
|
352 |
+
|
353 |
+
$ct_data['show_ct_notice_trial'] = (int) $show_ct_notice_trial;
|
354 |
+
$ct_data['show_ct_notice_renew'] = (int) $show_ct_notice_renew;
|
355 |
+
}
|
356 |
+
|
357 |
+
if (isset($result['moderate_ip']) && $result['moderate_ip'] == 1){
|
358 |
+
$ct_data['moderate_ip'] = 1;
|
359 |
+
$ct_data['ip_license'] = $result['ip_license'];
|
360 |
+
}else{
|
361 |
+
$ct_data['moderate_ip'] = 0;
|
362 |
+
$ct_data['ip_license'] = 0;
|
363 |
+
}
|
364 |
+
|
365 |
+
if (isset($result['user_token']))
|
366 |
+
$ct_data['user_token'] = $result['user_token'];
|
367 |
+
|
368 |
+
update_option('cleantalk_data', $ct_data);
|
369 |
+
|
370 |
+
}
|
371 |
+
}
|
372 |
+
|
373 |
/**
|
374 |
* Admin action 'admin_init' - Add the admin settings and such
|
375 |
*/
|
376 |
function ct_admin_init(){
|
377 |
|
378 |
+
global $ct_server_timeout, $show_ct_notice_autokey, $ct_notice_autokey_label, $ct_notice_autokey_value, $show_ct_notice_renew, $ct_notice_renew_label, $show_ct_notice_trial, $ct_notice_trial_label, $show_ct_notice_online, $ct_notice_online_label, $renew_notice_showtime, $trial_notice_showtime, $ct_plugin_name, $ct_options, $ct_data, $ct_user_token_label, $cleantalk_plugin_version, $notice_check_timeout, $ct_agent_version;
|
379 |
|
380 |
$ct_options = ct_get_options();
|
381 |
$ct_data = ct_get_data();
|
385 |
if($is_installing){
|
386 |
delete_option('ct_installing');
|
387 |
$ct_data['plugin_version'] = $cleantalk_plugin_version;
|
388 |
+
ct_account_status_check(); // Initilazing Notice_paid_till
|
389 |
update_option( 'cleantalk_data' , $ct_data);
|
390 |
}else{
|
391 |
+
$current_version = (isset($ct_data['plugin_version']) ? $ct_data['plugin_version'] : '1.0.0');
|
392 |
if($current_version != $cleantalk_plugin_version){
|
393 |
if(is_main_site()){
|
394 |
require_once('cleantalk-updater.php');
|
402 |
update_option( 'cleantalk_data' , $ct_data);
|
403 |
}
|
404 |
}
|
|
|
405 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
406 |
}
|
407 |
|
408 |
// Drop debug data
|
458 |
|
459 |
if ($result)
|
460 |
{
|
461 |
+
ct_account_status_check();
|
|
|
462 |
$result = json_decode($result, true);
|
463 |
|
464 |
if (isset($result['data']) && is_array($result['data']))
|
481 |
}
|
482 |
}
|
483 |
|
484 |
+
//Account's status check if settings saved
|
485 |
+
if (isset($_POST['cleantalk_settings']['apikey'])){
|
486 |
+
ct_account_status_check();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
487 |
}
|
488 |
+
|
489 |
|
490 |
$show_ct_notice_online = '';
|
491 |
if (isset($_COOKIE[$ct_notice_online_label]))
|
677 |
global $ct_options, $ct_data;
|
678 |
|
679 |
$ct_options = ct_get_options();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
680 |
|
681 |
+
if (current_user_can('activate_plugins') && $ct_options['show_adminbar'] == 1 && ct_valid_key($ct_options['apikey']) !== false) {
|
682 |
+
$ct_data=ct_get_data();
|
683 |
+
|
684 |
//Reset or create user counter
|
685 |
+
if(!empty($_GET['ct_reset_user_counter'])){
|
686 |
+
$ct_data['user_counter']['accepted'] = 0;
|
687 |
+
$ct_data['user_counter']['blocked'] = 0;
|
688 |
+
$ct_data['user_counter']['since'] = date('d M');
|
689 |
update_option('cleantalk_data', $ct_data);
|
690 |
}
|
691 |
|
|
|
|
|
|
|
|
|
|
|
692 |
//Compile user's counter string
|
693 |
$user_counter=Array('accepted'=>$ct_data['user_counter']['accepted'], 'blocked'=>$ct_data['user_counter']['blocked'], 'all'=>$ct_data['user_counter']['accepted'] + $ct_data['user_counter']['blocked'], 'since'=>$ct_data['user_counter']['since']);
|
694 |
//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>';
|
1044 |
$ct_data = ct_get_data();
|
1045 |
|
1046 |
$value = $ct_options['show_check_links'];
|
1047 |
+
|
1048 |
echo "<input type='radio' id='cleantalk_show_check_links1' name='cleantalk_settings[show_check_links]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_show_check_links1'> " . __('Yes') . "</label>";
|
1049 |
echo ' ';
|
1050 |
echo "<input type='radio' id='cleantalk_show_check_links1' name='cleantalk_settings[show_check_links]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_show_check_links1'> " . __('No') . "</label>";
|
1352 |
|
1353 |
$ct_options = ct_get_options();
|
1354 |
$ct_data = ct_get_data();
|
1355 |
+
|
1356 |
+
echo "<input type='radio' id='cleantalk_set_cookies1' name='cleantalk_settings[set_cookies]' value='1' " . (!empty($ct_options['set_cookies']) ? 'checked' : '') . " /><label for='cleantalk_set_cookies1'> " . __('Yes') . "</label>";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1357 |
echo ' ';
|
1358 |
+
echo "<input type='radio' id='cleantalk_set_cookies0' name='cleantalk_settings[set_cookies]' value='0' " . (empty($ct_options['set_cookies']) ? 'checked' : '') . " /><label for='cleantalk_set_cookies0'> " . __('No') . "</label>";
|
1359 |
@admin_addDescriptionsFields(sprintf(__('Turn this option off to deny plugin generates any cookies on website front-end. This option is helpful if you use Varnish. But most of contact forms will not be protected by CleanTalk if the option is turned off!', 'cleantalk')));
|
1360 |
}
|
1361 |
|
1364 |
|
1365 |
$ct_options = ct_get_options();
|
1366 |
$ct_data = ct_get_data();
|
1367 |
+
|
1368 |
+
echo "<input type='radio' id='cleantalk_ssl_on1' name='cleantalk_settings[ssl_on]' value='1' " . (!empty($ct_options['ssl_on']) ? 'checked' : '') . " /><label for='cleantalk_ssl_on1'> " . __('Yes') . "</label>";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1369 |
echo ' ';
|
1370 |
+
echo "<input type='radio' id='cleantalk_ssl_on0' name='cleantalk_settings[ssl_on]' value='0' " . (empty($ct_options['ssl_on']) ? 'checked' : '') . " /><label for='cleantalk_ssl_on0'> " . __('No') . "</label>";
|
1371 |
@admin_addDescriptionsFields(sprintf(__('Turn this option on to use encrypted (SSL) connection with CleanTalk servers.', 'cleantalk')));
|
1372 |
}
|
1373 |
|
1376 |
|
1377 |
$ct_options = ct_get_options();
|
1378 |
$ct_data = ct_get_data();
|
1379 |
+
|
1380 |
+
echo "<input type='radio' id='cleantalk_protect_logged_in1' name='cleantalk_settings[protect_logged_in]' value='1' " . (!empty($ct_options['protect_logged_in']) ? 'checked' : '') . " /><label for='cleantalk_protect_logged_in1'> " . __('Yes') . "</label>";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1381 |
echo ' ';
|
1382 |
+
echo "<input type='radio' id='cleantalk_protect_logged_in0' name='cleantalk_settings[protect_logged_in]' value='0' " . (empty($ct_options['protect_logged_in']) ? 'checked' : '') . " /><label for='cleantalk_protect_logged_in0'> " . __('No') . "</label>";
|
1383 |
@admin_addDescriptionsFields(sprintf(__('Turn this option on to check for spam any submissions (comments, contact forms and etc.) from registered Users.', 'cleantalk')));
|
1384 |
|
1385 |
return null;
|
1390 |
|
1391 |
$ct_options = ct_get_options();
|
1392 |
$ct_data = ct_get_data();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1393 |
|
1394 |
/* echo "<input type='radio' id='cleantalk_show_link1' name='cleantalk_settings[show_link]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_show_link1'> " . __('Yes') . "</label>";
|
1395 |
echo ' ';
|
1396 |
echo "<input type='radio' id='cleantalk_show_link0' name='cleantalk_settings[show_link]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_show_link0'> " . __('No') . "</label>";*/
|
1397 |
|
1398 |
echo "<div id='cleantalk_anchor' style='display:none'></div><input type=hidden name='cleantalk_settings[show_link]' value='0' />";
|
1399 |
+
echo "<input type='checkbox' id='cleantalk_show_link1' name='cleantalk_settings[show_link]' value='1' " . (!empty($ct_options['show_link']) ? 'checked' : '') . " /><label for='cleantalk_show_link1'> " . __('Tell others about CleanTalk', 'cleantalk') . "</label>";
|
1400 |
@admin_addDescriptionsFields(sprintf(__("Checking this box places a small link under the comment form that lets others know what anti-spam tool protects your site.", 'cleantalk'), $ct_options['show_link']));
|
1401 |
echo "<script>
|
1402 |
jQuery(document).ready(function(){
|
1411 |
|
1412 |
$ct_options = ct_get_options();
|
1413 |
$ct_data = ct_get_data();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1414 |
|
1415 |
echo "<div id='cleantalk_anchor1' style='display:none'></div><input type=hidden name='cleantalk_settings[spam_firewall]' value='0' />";
|
1416 |
+
echo "<input type='checkbox' id='cleantalk_spam_firewall1' name='cleantalk_settings[spam_firewall]' value='1' " . (!empty($ct_options['spam_firewall']) ? 'checked' : '') . " /><label for='cleantalk_spam_firewall1'> " . __('SpamFireWall') . "</label>";
|
1417 |
@admin_addDescriptionsFields(sprintf(__("This option allows to filter spam bots before they access website. Also reduces CPU usage on hosting server and accelerates pages load time.", 'cleantalk'), $ct_options['spam_firewall']) .
|
1418 |
" " .
|
1419 |
'<a href="https://cleantalk.org/cleantalk-spam-firewall" style="font-size: 10pt; color: #666 !important" target="_blank">' . __('Learn more', 'cleantalk') . '</a>.'
|
1543 |
|
1544 |
$ct_data = get_option('cleantalk_data');
|
1545 |
|
1546 |
+
$user_token = (!empty($ct_data['user_token']) ? $ct_data['user_token'] : false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1547 |
|
1548 |
+
// Translate banner for non EN locale
|
1549 |
+
if(substr(get_locale(), 0, 2) != 'en'){
|
1550 |
+
require_once(CLEANTALK_PLUGIN_DIR.'templates/translate_banner.php');
|
1551 |
+
printf($ct_translate_banner_template, substr(get_locale(), 0, 2));
|
1552 |
+
}else
|
1553 |
+
echo "<br /><br /><br />";
|
1554 |
+
|
1555 |
+
echo "<div>";
|
1556 |
+
|
1557 |
+
echo __("CleanTalk's tech support:", 'cleantalk')
|
1558 |
+
." "
|
1559 |
+
.'<a target="_blank" href="https://wordpress.org/support/plugin/cleantalk-spam-protect">Wordpress.org</a>.'
|
1560 |
+
// .' <a href="https://community.cleantalk.org/viewforum.php?f=25" target="_blank">'.__("Tech forum", 'cleantalk').'</a>'
|
1561 |
+
// .($user_token ? ", <a href='https://cleantalk.org/my/support?user_token=$user_token&cp_mode=antispam' target='_blank'>".__("Service support ", 'cleantalk').'</a>' : '').
|
1562 |
+
.'<br>';
|
1563 |
+
echo __('Plugin Homepage at', 'cleantalk').' <a href="http://cleantalk.org" target="_blank">cleantalk.org</a>.<br />';
|
1564 |
+
echo __('Use s@cleantalk.org to test plugin in any WordPress form.', 'cleantalk').'<br>';
|
1565 |
+
echo __('CleanTalk is registered Trademark. All rights reserved.', 'cleantalk');
|
1566 |
|
1567 |
+
echo "</div>";
|
1568 |
}
|
1569 |
|
1570 |
/**
|
1577 |
$ct_options = ct_get_options();
|
1578 |
$ct_data = ct_get_data();
|
1579 |
$page = get_current_screen();
|
|
|
|
|
1580 |
|
1581 |
//General notice control flags
|
1582 |
$moderate_ip = (empty($ct_data['moderate_ip']) ? 0 : $ct_data['moderate_ip']);
|
1590 |
$show_ct_notice_renew = (isset($ct_data['show_ct_notice_renew']) ? intval($ct_data['show_ct_notice_renew']) : 0);
|
1591 |
$show_ct_notice_review = (isset($ct_data['show_ct_notice_review']) ? intval($ct_data['show_ct_notice_review']) : 0);
|
1592 |
$next_notice_show = (isset($ct_data['next_notice_show']) ? intval($ct_data['next_notice_show']) : 0); //inactive
|
1593 |
+
$page_is_ct_settings = ($page->id == 'settings_page_cleantalk' || $page->id == 'settings_page_cleantalk-network' ? true : false);
|
1594 |
+
|
|
|
|
|
1595 |
//Misc
|
1596 |
$user_token = (isset($ct_data['user_token']) && $ct_data['user_token'] != '' ? "&user_token={$ct_data['user_token']}" : "");
|
1597 |
$settings_link = (is_network_admin() ? "settings.php?page=cleantalk" : "options-general.php?page=cleantalk");
|
1598 |
|
1599 |
if($self_owned_key && $is_admin && $value == 1){
|
1600 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1601 |
//Unable to get key automatically (if ct_admin_init().getAutoKey() returns error)
|
1602 |
if ($show_notice && $show_ct_notice_autokey){
|
1603 |
echo '<div class="error">
|
1609 |
|
1610 |
//key == "" || "enter key"
|
1611 |
if ($show_notice && !ct_valid_key()){
|
1612 |
+
echo "<div class='error'>"
|
1613 |
+
."<h3>"
|
1614 |
+
.sprintf(__("Please enter Access Key in %s settings to enable anti spam protection!", 'cleantalk'), "<a href='{$settings_link}'>CleanTalk plugin</a>")
|
1615 |
+
."</h3>"
|
1616 |
+
."</div>";
|
|
|
|
|
1617 |
$show_notice = false;
|
1618 |
}
|
1619 |
|
1855 |
|
1856 |
if (isset($_POST['cleantalk_settings']['spam_firewall'])) {
|
1857 |
if ($_POST['cleantalk_settings']['spam_firewall'] == 1) {
|
1858 |
+
ct_sfw_update();
|
1859 |
+
ct_sfw_send_logs();
|
1860 |
} else {
|
1861 |
// Reseting SFW logs to do not keep huge ammount of data.
|
1862 |
$ct_data['sfw_log']= array();
|
1901 |
setcookie($ct_notice_online_label, (string) time(), strtotime("+14 days"), '/');
|
1902 |
}
|
1903 |
setcookie($ct_notice_trial_label, '0', strtotime("+$trial_notice_showtime minutes"), '/');
|
1904 |
+
|
|
|
|
|
|
|
1905 |
} else {
|
1906 |
setcookie($ct_notice_online_label, 'BAD_KEY', 0, '/');
|
1907 |
}
|
inc/cleantalk-common.php
CHANGED
@@ -49,15 +49,6 @@ $ct_notice_online_label = 'ct_notice_online';
|
|
49 |
// Flag to show online notice - 'Y' or 'N'
|
50 |
$show_ct_notice_online = '';
|
51 |
|
52 |
-
// Timeout before new check for trial notice in hours
|
53 |
-
$trial_notice_check_timeout = 1;
|
54 |
-
|
55 |
-
// Timeout before new check account notice in hours
|
56 |
-
$account_notice_check_timeout = 24;
|
57 |
-
|
58 |
-
// Timeout before new check account notice in hours
|
59 |
-
$renew_notice_check_timeout = 0.5;
|
60 |
-
|
61 |
// Trial notice show time in minutes
|
62 |
$trial_notice_showtime = 10;
|
63 |
|
@@ -501,7 +492,8 @@ function ct_def_options() {
|
|
501 |
'relevance_test' => 0, // Test comment for relevance
|
502 |
'notice_api_errors' => 0, // Send API error notices to WP admin
|
503 |
'user_token'=>'', //user token for auto login into spam statistics
|
504 |
-
'collect_details' => 0 // Collect details about browser of the visitor.
|
|
|
505 |
);
|
506 |
}
|
507 |
|
@@ -531,11 +523,26 @@ function ct_get_data($force=false) {
|
|
531 |
*/
|
532 |
function ct_def_data() {
|
533 |
return array(
|
534 |
-
'next_account_status_check' => 0, // Time label when the plugin should check account status
|
535 |
'user_token' => '', // User token
|
536 |
'js_keys' => array(), // Keys to do JavaScript antispam test
|
537 |
'js_keys_store_days' => 14, // JavaScript keys store days - 8 days now
|
538 |
'js_key_lifetime' => 86400, // JavaScript key life time in seconds - 1 day now
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
539 |
);
|
540 |
}
|
541 |
|
@@ -602,6 +609,7 @@ function ct_feedback($hash, $message = null, $allow) {
|
|
602 |
|
603 |
/**
|
604 |
* Inner function - Sends the results of moderation
|
|
|
605 |
* @param string $feedback_request
|
606 |
* @return bool
|
607 |
*/
|
@@ -655,31 +663,12 @@ function ct_send_feedback($feedback_request = null) {
|
|
655 |
return false;
|
656 |
}
|
657 |
|
658 |
-
/**
|
659 |
-
* On the scheduled action hook, run the function.
|
660 |
-
*/
|
661 |
-
function ct_do_this_hourly() {
|
662 |
-
global $ct_options, $ct_data;
|
663 |
-
|
664 |
-
$ct_options = ct_get_options();
|
665 |
-
$ct_data = ct_get_data();
|
666 |
-
// do something every hour
|
667 |
-
|
668 |
-
if (!isset($ct_options))
|
669 |
-
$ct_options = ct_get_options();
|
670 |
-
|
671 |
-
if (!isset($ct_data))
|
672 |
-
$ct_data = ct_get_data();
|
673 |
-
|
674 |
-
delete_spam_comments();
|
675 |
-
ct_send_feedback();
|
676 |
-
}
|
677 |
-
|
678 |
/**
|
679 |
* Delete old spam comments
|
|
|
680 |
* @return null
|
681 |
*/
|
682 |
-
function
|
683 |
global $pagenow, $ct_options, $ct_data;
|
684 |
|
685 |
$ct_options = ct_get_options();
|
49 |
// Flag to show online notice - 'Y' or 'N'
|
50 |
$show_ct_notice_online = '';
|
51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
// Trial notice show time in minutes
|
53 |
$trial_notice_showtime = 10;
|
54 |
|
492 |
'relevance_test' => 0, // Test comment for relevance
|
493 |
'notice_api_errors' => 0, // Send API error notices to WP admin
|
494 |
'user_token'=>'', //user token for auto login into spam statistics
|
495 |
+
'collect_details' => 0, // Collect details about browser of the visitor.
|
496 |
+
'show_link' => 0
|
497 |
);
|
498 |
}
|
499 |
|
523 |
*/
|
524 |
function ct_def_data() {
|
525 |
return array(
|
|
|
526 |
'user_token' => '', // User token
|
527 |
'js_keys' => array(), // Keys to do JavaScript antispam test
|
528 |
'js_keys_store_days' => 14, // JavaScript keys store days - 8 days now
|
529 |
'js_key_lifetime' => 86400, // JavaScript key life time in seconds - 1 day now
|
530 |
+
'sfw_counter' => array(
|
531 |
+
'all' => 0,
|
532 |
+
'blocked' => 0
|
533 |
+
),
|
534 |
+
'array_accepted' => array(),
|
535 |
+
'array_blocked' => array(),
|
536 |
+
'current_hour' => '',
|
537 |
+
'all_time_counter' => array(
|
538 |
+
'accepted' => 0,
|
539 |
+
'blocked' => 0
|
540 |
+
),
|
541 |
+
'user_counter' => array(
|
542 |
+
'accepted' => 0,
|
543 |
+
'blocked' => 0,
|
544 |
+
'since' => date('d M')
|
545 |
+
)
|
546 |
);
|
547 |
}
|
548 |
|
609 |
|
610 |
/**
|
611 |
* Inner function - Sends the results of moderation
|
612 |
+
* Scheduled in 3600 seconds!
|
613 |
* @param string $feedback_request
|
614 |
* @return bool
|
615 |
*/
|
663 |
return false;
|
664 |
}
|
665 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
666 |
/**
|
667 |
* Delete old spam comments
|
668 |
+
* Scheduled in 3600 seconds!
|
669 |
* @return null
|
670 |
*/
|
671 |
+
function ct_delete_spam_comments() {
|
672 |
global $pagenow, $ct_options, $ct_data;
|
673 |
|
674 |
$ct_options = ct_get_options();
|
inc/cleantalk-public.php
CHANGED
@@ -35,7 +35,7 @@ function ct_init() {
|
|
35 |
add_shortcode( 'et_pb_contact_form', 'ct_contact_form_validate' );
|
36 |
}
|
37 |
|
38 |
-
if($
|
39 |
&& isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST'
|
40 |
&& isset($_POST['cleantalk_hidden_method'])
|
41 |
&& isset($_POST['cleantalk_hidden_action'])
|
@@ -633,7 +633,7 @@ function ct_footer_add_cookie() {
|
|
633 |
if(empty($_POST['ct_multipage_form']))
|
634 |
ct_setup_page_timer(true);
|
635 |
|
636 |
-
ct_add_hidden_fields(true, 'ct_checkjs', false, true);
|
637 |
|
638 |
return null;
|
639 |
}
|
@@ -649,45 +649,44 @@ function ct_page_count(){
|
|
649 |
* Adds hidden filed to define avaialbility of client's JavaScript
|
650 |
* @param bool $random_key switch on generation random key for every page load
|
651 |
*/
|
652 |
-
function ct_add_hidden_fields($random_key = false, $field_name = 'ct_checkjs', $return_string = false, $cookie_check = false) {
|
|
|
653 |
global $ct_checkjs_def, $ct_plugin_name, $ct_options, $ct_data;
|
|
|
654 |
$ct_options = ct_get_options();
|
655 |
|
656 |
$ct_checkjs_key = ct_get_checkjs_value($random_key);
|
657 |
$field_id_hash = md5(rand(0, 1000));
|
658 |
|
659 |
if ($cookie_check && isset($ct_options['set_cookies']) && $ct_options['set_cookies'] == 1) {
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
}
|
665 |
-
|
666 |
-
</script>
|
667 |
-
';
|
668 |
-
$html = sprintf($html, $field_name, $ct_checkjs_key, $ct_checkjs_def);
|
669 |
} else {
|
|
|
|
|
|
|
|
|
|
|
670 |
$ct_input_challenge = sprintf("'%s'", $ct_checkjs_key);
|
671 |
-
|
672 |
$field_id = $field_name . '_' . $field_id_hash;
|
673 |
-
$html = '
|
674 |
-
<
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
</script>
|
684 |
-
';
|
685 |
-
$html = sprintf($html, $field_id, $field_name, $ct_checkjs_def, $field_id, $ct_input_challenge);
|
686 |
};
|
687 |
|
688 |
-
// Simplify JS code
|
689 |
-
|
690 |
-
$html = str_replace(array("\n","\r"),'', $html);
|
691 |
|
692 |
if ($return_string === true) {
|
693 |
return $html;
|
@@ -2423,6 +2422,7 @@ function ct_contact_form_validate() {
|
|
2423 |
(isset($_POST['signup_username']) && isset($_POST['signup_email']) && isset($_POST['signup_password'])) ||
|
2424 |
(isset($pagenow) && $pagenow == 'wp-login.php') || // WordPress log in form
|
2425 |
(isset($pagenow) && $pagenow == 'wp-login.php' && isset($_GET['action']) && $_GET['action']=='lostpassword') ||
|
|
|
2426 |
(strpos($_SERVER['REQUEST_URI'],'/wp-admin/')!== false && (empty($_POST['your-phone']) && empty($_POST['your-email']) && empty($_POST['your-message']))) || //Bitrix24 Contact
|
2427 |
strpos($_SERVER['REQUEST_URI'],'wp-login.php')!==false||
|
2428 |
strpos($_SERVER['REQUEST_URI'],'wp-comments-post.php')!==false ||
|
@@ -2835,6 +2835,28 @@ function ct_enqueue_scripts_public($hook){
|
|
2835 |
|
2836 |
global $cleantalk_plugin_version, $current_user, $ct_data, $ct_options;
|
2837 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2838 |
if(in_array("administrator", $current_user->roles)){
|
2839 |
|
2840 |
if(!empty($ct_options['show_check_links'])){
|
@@ -2847,7 +2869,7 @@ function ct_enqueue_scripts_public($hook){
|
|
2847 |
|
2848 |
wp_localize_script('ct_public_js', 'ctPublic', array(
|
2849 |
'ct_ajax_nonce' => $ajax_nonce,
|
2850 |
-
'
|
2851 |
'ct_feedback_msg' => sprintf(__("Feedback has been sent to %sCleanTalk Dashboard%s.", 'cleantalk'), $user_token ? "<a target='_blank' href=https://cleantalk.org/my/show_requests?user_token={$user_token}&cp_mode=antispam>" : '', $user_token ? "</a>" : ''),
|
2852 |
'ct_feedback_error' => __('Error occured while sending feedback.', 'cleantalk'),
|
2853 |
'ct_feedback_no_hash' => __('Feedback wasn\'t sent. There is no associated request.', 'cleantalk')
|
@@ -2891,26 +2913,30 @@ function ct_comments_output($curr_comment, $param2, $wp_list_comments_args){
|
|
2891 |
echo "<p class='ct_comment_info_title'>".__('Sender info', 'cleantalk')."</p>";
|
2892 |
|
2893 |
echo "<p class='ct_comment_logo_title'>
|
2894 |
-
".__('by', 'cleantalk')
|
2895 |
-
|
|
|
|
|
2896 |
|
2897 |
// Outputs email if exists
|
2898 |
if($email)
|
2899 |
-
echo "
|
2900 |
-
."
|
2901 |
." <img src='".plugins_url()."/cleantalk-spam-protect/inc/images/new_window.gif' border='0' style='float:none'/>"
|
2902 |
-
."</a>
|
2903 |
else
|
2904 |
-
echo __('No email', 'cleantalk')
|
|
|
2905 |
|
2906 |
// Outputs IP if exists
|
2907 |
if($ip)
|
2908 |
-
echo "
|
2909 |
-
."
|
2910 |
." <img src='".plugins_url()."/cleantalk-spam-protect/inc/images/new_window.gif' border='0' style='float:none'/>"
|
2911 |
-
."</a>
|
2912 |
else
|
2913 |
-
echo __('No IP', 'cleantalk')
|
|
|
2914 |
|
2915 |
echo "<span commentid='$id' class='ct_this_is ct_this_is_spam' href='#'>".__('Mark as spam', 'cleantalk')."</span>";
|
2916 |
echo "<span commentid='$id' class='ct_this_is ct_this_is_not_spam ct_hidden' href='#'>".__('Unspam', 'cleantalk')."</span>";
|
35 |
add_shortcode( 'et_pb_contact_form', 'ct_contact_form_validate' );
|
36 |
}
|
37 |
|
38 |
+
if(!empty($ct_options['check_external'])
|
39 |
&& isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST'
|
40 |
&& isset($_POST['cleantalk_hidden_method'])
|
41 |
&& isset($_POST['cleantalk_hidden_action'])
|
633 |
if(empty($_POST['ct_multipage_form']))
|
634 |
ct_setup_page_timer(true);
|
635 |
|
636 |
+
ct_add_hidden_fields(true, 'ct_checkjs', false, true, true);
|
637 |
|
638 |
return null;
|
639 |
}
|
649 |
* Adds hidden filed to define avaialbility of client's JavaScript
|
650 |
* @param bool $random_key switch on generation random key for every page load
|
651 |
*/
|
652 |
+
function ct_add_hidden_fields($random_key = false, $field_name = 'ct_checkjs', $return_string = false, $cookie_check = false, $no_print = false) {
|
653 |
+
|
654 |
global $ct_checkjs_def, $ct_plugin_name, $ct_options, $ct_data;
|
655 |
+
|
656 |
$ct_options = ct_get_options();
|
657 |
|
658 |
$ct_checkjs_key = ct_get_checkjs_value($random_key);
|
659 |
$field_id_hash = md5(rand(0, 1000));
|
660 |
|
661 |
if ($cookie_check && isset($ct_options['set_cookies']) && $ct_options['set_cookies'] == 1) {
|
662 |
+
$html = "<script type='text/javascript'>
|
663 |
+
function ctSetCookie(c_name, value, def_value){
|
664 |
+
document.cookie = c_name + '=' + escape(value) + '; path=/';
|
665 |
+
}
|
666 |
+
ctSetCookie('{$field_name}', '{$ct_checkjs_key}', '{$ct_checkjs_def}');
|
667 |
+
</script>";
|
|
|
|
|
|
|
668 |
} else {
|
669 |
+
|
670 |
+
// Fix only for wp_footer -> ct_footer_add_cookie()
|
671 |
+
if($no_print)
|
672 |
+
return;
|
673 |
+
|
674 |
$ct_input_challenge = sprintf("'%s'", $ct_checkjs_key);
|
|
|
675 |
$field_id = $field_name . '_' . $field_id_hash;
|
676 |
+
$html = "<input type='hidden' id='{$field_id}' name='{$field_name}' value='{$ct_checkjs_def}' />
|
677 |
+
<script type='text/javascript'>
|
678 |
+
setTimeout(function(){
|
679 |
+
var ct_input_name = '{$field_id}';
|
680 |
+
if (document.getElementById(ct_input_name) !== null) {
|
681 |
+
var ct_input_value = document.getElementById(ct_input_name).value;
|
682 |
+
document.getElementById(ct_input_name).value = document.getElementById(ct_input_name).value.replace(ct_input_value, {$ct_input_challenge});
|
683 |
+
}
|
684 |
+
}, 1000);
|
685 |
+
</script>";
|
|
|
|
|
|
|
686 |
};
|
687 |
|
688 |
+
// Simplify JS code and Fixing issue with wpautop()
|
689 |
+
$html = str_replace(array("\n","\r","\t"),'', $html);
|
|
|
690 |
|
691 |
if ($return_string === true) {
|
692 |
return $html;
|
2422 |
(isset($_POST['signup_username']) && isset($_POST['signup_email']) && isset($_POST['signup_password'])) ||
|
2423 |
(isset($pagenow) && $pagenow == 'wp-login.php') || // WordPress log in form
|
2424 |
(isset($pagenow) && $pagenow == 'wp-login.php' && isset($_GET['action']) && $_GET['action']=='lostpassword') ||
|
2425 |
+
(isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'],'/lostpassword/') !== false) ||
|
2426 |
(strpos($_SERVER['REQUEST_URI'],'/wp-admin/')!== false && (empty($_POST['your-phone']) && empty($_POST['your-email']) && empty($_POST['your-message']))) || //Bitrix24 Contact
|
2427 |
strpos($_SERVER['REQUEST_URI'],'wp-login.php')!==false||
|
2428 |
strpos($_SERVER['REQUEST_URI'],'wp-comments-post.php')!==false ||
|
2835 |
|
2836 |
global $cleantalk_plugin_version, $current_user, $ct_data, $ct_options;
|
2837 |
|
2838 |
+
if(!defined('CLEANTALK_AJAX_USE_FOOTER_HEADER') || (defined('CLEANTALK_AJAX_USE_FOOTER_HEADER') && CLEANTALK_AJAX_USE_FOOTER_HEADER)){
|
2839 |
+
if(!empty($ct_options['use_ajax']) && stripos($_SERVER['REQUEST_URI'],'.xml') === false && stripos($_SERVER['REQUEST_URI'],'.xsl') === false){
|
2840 |
+
if(strpos($_SERVER['REQUEST_URI'],'jm-ajax') === false){
|
2841 |
+
|
2842 |
+
wp_enqueue_script('ct_nocache', plugins_url('/cleantalk-spam-protect/inc/cleantalk_nocache.js'), array(), $cleantalk_plugin_version, 'in_footer');
|
2843 |
+
|
2844 |
+
if(!empty($ct_options['check_external']))
|
2845 |
+
wp_enqueue_script('ct_external', plugins_url('/cleantalk-spam-protect/inc/cleantalk_external.js'), array(), $cleantalk_plugin_version, 'in_footer');
|
2846 |
+
|
2847 |
+
if(!empty($ct_options['check_internal']))
|
2848 |
+
wp_enqueue_script('ct_internal', plugins_url('/cleantalk-spam-protect/inc/cleantalk_internal.js'), array('jquery'), $cleantalk_plugin_version, 'in_footer');
|
2849 |
+
|
2850 |
+
wp_localize_script('ct_nocache', 'ctNocache', array(
|
2851 |
+
'ajaxurl' => admin_url('admin-ajax.php'),
|
2852 |
+
'info_flag' => !empty($ct_options['collect_details']) && !empty($ct_options['set_cookies']) ? true : false,
|
2853 |
+
'set_cookies_flag' => empty($ct_options['set_cookies']) ? false : true,
|
2854 |
+
'blog_home' => get_home_url(),
|
2855 |
+
));
|
2856 |
+
}
|
2857 |
+
}
|
2858 |
+
}
|
2859 |
+
|
2860 |
if(in_array("administrator", $current_user->roles)){
|
2861 |
|
2862 |
if(!empty($ct_options['show_check_links'])){
|
2869 |
|
2870 |
wp_localize_script('ct_public_js', 'ctPublic', array(
|
2871 |
'ct_ajax_nonce' => $ajax_nonce,
|
2872 |
+
'ajaxurl' => admin_url('admin-ajax.php'),
|
2873 |
'ct_feedback_msg' => sprintf(__("Feedback has been sent to %sCleanTalk Dashboard%s.", 'cleantalk'), $user_token ? "<a target='_blank' href=https://cleantalk.org/my/show_requests?user_token={$user_token}&cp_mode=antispam>" : '', $user_token ? "</a>" : ''),
|
2874 |
'ct_feedback_error' => __('Error occured while sending feedback.', 'cleantalk'),
|
2875 |
'ct_feedback_no_hash' => __('Feedback wasn\'t sent. There is no associated request.', 'cleantalk')
|
2913 |
echo "<p class='ct_comment_info_title'>".__('Sender info', 'cleantalk')."</p>";
|
2914 |
|
2915 |
echo "<p class='ct_comment_logo_title'>
|
2916 |
+
".__('by', 'cleantalk')
|
2917 |
+
." <a href='{$settings_link}' target='_blank'><img class='ct_comment_logo_img' src='".plugins_url()."/cleantalk-spam-protect/inc/images/logo_color.png'></a>"
|
2918 |
+
." <a href='{$settings_link}' target='_blank'>CleanTalk</a>"
|
2919 |
+
."</p>";
|
2920 |
|
2921 |
// Outputs email if exists
|
2922 |
if($email)
|
2923 |
+
echo "<a href='https://cleantalk.org/blacklists/$email' target='_blank' title='https://cleantalk.org/blacklists/$email'>"
|
2924 |
+
."$email"
|
2925 |
." <img src='".plugins_url()."/cleantalk-spam-protect/inc/images/new_window.gif' border='0' style='float:none'/>"
|
2926 |
+
."</a>";
|
2927 |
else
|
2928 |
+
echo __('No email', 'cleantalk');
|
2929 |
+
echo " | ";
|
2930 |
|
2931 |
// Outputs IP if exists
|
2932 |
if($ip)
|
2933 |
+
echo "<a href='https://cleantalk.org/blacklists/$ip' target='_blank' title='https://cleantalk.org/blacklists/$ip'>"
|
2934 |
+
."$ip"
|
2935 |
." <img src='".plugins_url()."/cleantalk-spam-protect/inc/images/new_window.gif' border='0' style='float:none'/>"
|
2936 |
+
."</a>";
|
2937 |
else
|
2938 |
+
echo __('No IP', 'cleantalk');
|
2939 |
+
echo ' | ';
|
2940 |
|
2941 |
echo "<span commentid='$id' class='ct_this_is ct_this_is_spam' href='#'>".__('Mark as spam', 'cleantalk')."</span>";
|
2942 |
echo "<span commentid='$id' class='ct_this_is ct_this_is_not_spam ct_hidden' href='#'>".__('Unspam', 'cleantalk')."</span>";
|
inc/cleantalk-sfw.class.php
DELETED
@@ -1,195 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class CleanTalkSFW
|
3 |
-
{
|
4 |
-
public $ip = 0;
|
5 |
-
public $ip_str = '';
|
6 |
-
public $ip_array = Array();
|
7 |
-
public $ip_str_array = Array();
|
8 |
-
public $blocked_ip = '';
|
9 |
-
public $passed_ip = '';
|
10 |
-
public $result = false;
|
11 |
-
|
12 |
-
public function cleantalk_get_real_ip()
|
13 |
-
{
|
14 |
-
$result=Array();
|
15 |
-
if ( function_exists( 'apache_request_headers' ) )
|
16 |
-
$headers = apache_request_headers();
|
17 |
-
else
|
18 |
-
$headers = $_SERVER;
|
19 |
-
|
20 |
-
if ( array_key_exists( 'X-Forwarded-For', $headers ) ){
|
21 |
-
$the_ip = explode(",", trim($headers['X-Forwarded-For']));
|
22 |
-
$the_ip = trim($the_ip[0]);
|
23 |
-
$result[] = $the_ip;
|
24 |
-
$this->ip_str_array[]=$the_ip;
|
25 |
-
$this->ip_array[]=sprintf("%u", ip2long($the_ip));
|
26 |
-
}
|
27 |
-
|
28 |
-
if ( array_key_exists( 'HTTP_X_FORWARDED_FOR', $headers )){
|
29 |
-
$the_ip = explode(",", trim($headers['HTTP_X_FORWARDED_FOR']));
|
30 |
-
$the_ip = trim($the_ip[0]);
|
31 |
-
$result[] = $the_ip;
|
32 |
-
$this->ip_str_array[]=$the_ip;
|
33 |
-
$this->ip_array[]=sprintf("%u", ip2long($the_ip));
|
34 |
-
}
|
35 |
-
|
36 |
-
$the_ip = filter_var( $_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 );
|
37 |
-
$result[] = $the_ip;
|
38 |
-
$this->ip_str_array[]=$the_ip;
|
39 |
-
$this->ip_array[]=sprintf("%u", ip2long($the_ip));
|
40 |
-
|
41 |
-
if(isset($_GET['sfw_test_ip'])){
|
42 |
-
$the_ip = $_GET['sfw_test_ip'];
|
43 |
-
$result[] = $the_ip;
|
44 |
-
$this->ip_str_array[]=$the_ip;
|
45 |
-
$this->ip_array[]=sprintf("%u", ip2long($the_ip));
|
46 |
-
}
|
47 |
-
|
48 |
-
return $result;
|
49 |
-
}
|
50 |
-
|
51 |
-
public function check_ip()
|
52 |
-
{
|
53 |
-
global $wpdb,$ct_options, $ct_data;
|
54 |
-
|
55 |
-
for($i=0;$i<sizeof($this->ip_array);$i++){
|
56 |
-
$r = $wpdb->get_results("select count(network) as cnt from `".$wpdb->base_prefix."cleantalk_sfw` where network = ".$this->ip_array[$i]." & mask;", ARRAY_A);
|
57 |
-
if($r[0]['cnt']){
|
58 |
-
$this->result=true;
|
59 |
-
$this->blocked_ip=$this->ip_str_array[$i];
|
60 |
-
}else{
|
61 |
-
$this->passed_ip = $this->ip_str_array[$i];
|
62 |
-
}
|
63 |
-
}
|
64 |
-
if($this->passed_ip!=''){
|
65 |
-
@setcookie ('ct_sfw_pass_key', md5($this->passed_ip.$ct_options['apikey']), 0, "/");
|
66 |
-
}
|
67 |
-
}
|
68 |
-
|
69 |
-
public function sfw_die()
|
70 |
-
{
|
71 |
-
global $ct_options, $ct_data;
|
72 |
-
$sfw_die_page=file_get_contents(dirname(__FILE__)."/sfw_die_page.html");
|
73 |
-
$sfw_die_page=str_replace("{REMOTE_ADDRESS}",$this->blocked_ip,$sfw_die_page);
|
74 |
-
$sfw_die_page=str_replace("{REQUEST_URI}",$_SERVER['REQUEST_URI'],$sfw_die_page);
|
75 |
-
$sfw_die_page=str_replace("{SFW_COOKIE}",md5($this->blocked_ip.$ct_options['apikey']),$sfw_die_page);
|
76 |
-
|
77 |
-
if(headers_sent() === false){
|
78 |
-
header("Cache-Control: no-store, no-cache, must-revalidate");
|
79 |
-
header("Pragma: no-cache");
|
80 |
-
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
|
81 |
-
header("Expires: 0");
|
82 |
-
header("HTTP/1.0 403 Forbidden");
|
83 |
-
$sfw_die_page = str_replace("{GENERATED}", "", $sfw_die_page);
|
84 |
-
}else{
|
85 |
-
$sfw_die_page = str_replace("{GENERATED}", "<h2 class='second'>The page was generated at ".date("D, d M Y H:i:s")."</h2>",$sfw_die_page);
|
86 |
-
}
|
87 |
-
|
88 |
-
wp_die( $sfw_die_page, "Blacklisted", Array('response'=>403) );
|
89 |
-
}
|
90 |
-
|
91 |
-
static public function sfw_update($ct_key){
|
92 |
-
|
93 |
-
global $wpdb;
|
94 |
-
|
95 |
-
if(!function_exists('sendRawRequest'))
|
96 |
-
require_once(plugin_dir_path(__FILE__) . 'cleantalk.class.php');
|
97 |
-
|
98 |
-
$data = Array('auth_key' => $ct_key, 'method_name' => '2s_blacklists_db');
|
99 |
-
$result=sendRawRequest('https://api.cleantalk.org/2.1',$data,false);
|
100 |
-
|
101 |
-
$result=json_decode($result, true);
|
102 |
-
|
103 |
-
if(isset($result['data'])){
|
104 |
-
|
105 |
-
$wpdb->query("TRUNCATE TABLE `".$wpdb->base_prefix."cleantalk_sfw`;");
|
106 |
-
|
107 |
-
$result=$result['data'];
|
108 |
-
$query="INSERT INTO `".$wpdb->base_prefix."cleantalk_sfw` VALUES ";
|
109 |
-
for($i=0;$i<sizeof($result);$i++){
|
110 |
-
if($i==sizeof($result)-1){
|
111 |
-
$query.="(".$result[$i][0].",".$result[$i][1].");";
|
112 |
-
}else{
|
113 |
-
$query.="(".$result[$i][0].",".$result[$i][1]."), ";
|
114 |
-
}
|
115 |
-
}
|
116 |
-
$wpdb->query($query);
|
117 |
-
}
|
118 |
-
}
|
119 |
-
|
120 |
-
//Add entries to SFW log
|
121 |
-
static public function sfw_update_logs($ip, $result){
|
122 |
-
|
123 |
-
if($ip === NULL || $result === NULL){
|
124 |
-
error_log('SFW log update failed');
|
125 |
-
return;
|
126 |
-
}
|
127 |
-
|
128 |
-
global $wpdb;
|
129 |
-
|
130 |
-
$blocked = ($result == 'blocked' ? ' + 1' : '');
|
131 |
-
$time = time();
|
132 |
-
|
133 |
-
$query = "INSERT INTO `".$wpdb->base_prefix."cleantalk_sfw_logs`
|
134 |
-
SET
|
135 |
-
`ip` = '$ip',
|
136 |
-
`all` = 1,
|
137 |
-
`blocked` = 1,
|
138 |
-
`timestamp` = '".$time."'
|
139 |
-
ON DUPLICATE KEY
|
140 |
-
UPDATE
|
141 |
-
`all` = `all` + 1,
|
142 |
-
`blocked` = `blocked`".$blocked.",
|
143 |
-
`timestamp` = '".$time."'";
|
144 |
-
|
145 |
-
$result = $wpdb->query($query);
|
146 |
-
}
|
147 |
-
|
148 |
-
//*Send and wipe SFW log
|
149 |
-
public static function send_logs($ct_key){
|
150 |
-
|
151 |
-
global $wpdb;
|
152 |
-
|
153 |
-
//Getting logs
|
154 |
-
$result = $wpdb->get_results("SELECT * FROM `".$wpdb->base_prefix."cleantalk_sfw_logs`", ARRAY_A);
|
155 |
-
|
156 |
-
if(count($result)){
|
157 |
-
//Compile logs
|
158 |
-
$data = array();
|
159 |
-
|
160 |
-
$for_return['all'] = 0;
|
161 |
-
$for_return['blocked'] = 0;
|
162 |
-
|
163 |
-
foreach($result as $key => $value){
|
164 |
-
//Compile log
|
165 |
-
$data[] = array(trim($value['ip']), $value['all'], $value['all']-$value['blocked'], $value['timestamp']);
|
166 |
-
//Compile to return;
|
167 |
-
$for_return['all'] = $for_return['all'] + $value['all'];
|
168 |
-
$for_return['blocked'] = $for_return['blocked'] + $value['blocked'];
|
169 |
-
} unset($key, $value, $result);
|
170 |
-
|
171 |
-
//Final compile
|
172 |
-
$qdata = array (
|
173 |
-
'data' => json_encode($data),
|
174 |
-
'rows' => count($data),
|
175 |
-
'timestamp' => time()
|
176 |
-
);
|
177 |
-
|
178 |
-
if(!function_exists('sendRawRequest'))
|
179 |
-
require_once(plugin_dir_path(__FILE__) . 'cleantalk.class.php');
|
180 |
-
|
181 |
-
//Sendings request
|
182 |
-
$result=sendRawRequest('https://api.cleantalk.org/?method_name=sfw_logs&auth_key='.$ct_key, $qdata, false);
|
183 |
-
|
184 |
-
$result = json_decode($result);
|
185 |
-
//Checking answer and truncate table
|
186 |
-
if(isset($result->data) && isset($result->data->rows))
|
187 |
-
if($result->data->rows == count($data)){
|
188 |
-
$wpdb->query("TRUNCATE TABLE `".$wpdb->base_prefix."cleantalk_sfw_logs`");
|
189 |
-
return $for_return;
|
190 |
-
}
|
191 |
-
|
192 |
-
}else
|
193 |
-
return false;
|
194 |
-
}
|
195 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inc/cleantalk-sfw.php
DELETED
@@ -1,42 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$ip=(int)sprintf("%u", ip2long(cleantalk_get_ip()));
|
4 |
-
$ip_str=cleantalk_get_ip();
|
5 |
-
//$ip=(int)sprintf("%u", ip2long("2.11.242.8"));
|
6 |
-
if(isset($_GET['sfw_test_ip']))
|
7 |
-
{
|
8 |
-
$ip=(int)sprintf("%u", ip2long($_GET['sfw_test_ip']));
|
9 |
-
$ip_str=$_GET['sfw_test_ip'];
|
10 |
-
}
|
11 |
-
|
12 |
-
global $wpdb;
|
13 |
-
$r = $wpdb->get_results("select * from `".$wpdb->base_prefix."cleantalk_sfw` where $ip & mask = network & mask;", ARRAY_A);
|
14 |
-
if(sizeof($r)>0)
|
15 |
-
{
|
16 |
-
global $ct_options, $ct_data;
|
17 |
-
$sfw_die_page=file_get_contents(dirname(__FILE__)."/sfw_die_page.html");
|
18 |
-
$sfw_die_page=str_replace("{REMOTE_ADDRESS}",$ip_str,$sfw_die_page);
|
19 |
-
$sfw_die_page=str_replace("{REQUEST_URI}",$_SERVER['REQUEST_URI'],$sfw_die_page);
|
20 |
-
$sfw_die_page=str_replace("{SFW_COOKIE}",md5(cleantalk_get_ip().$ct_options['apikey']),$sfw_die_page);
|
21 |
-
if(isset($ct_data['sfw_log']))
|
22 |
-
{
|
23 |
-
$sfw_log=$ct_data['sfw_log'];
|
24 |
-
}
|
25 |
-
else
|
26 |
-
{
|
27 |
-
$sfw_log=array();
|
28 |
-
}
|
29 |
-
if(isset($sfw_log[$r[0]['network']]))
|
30 |
-
{
|
31 |
-
$sfw_log[$r[0]['network']]['block']++;
|
32 |
-
}
|
33 |
-
else
|
34 |
-
{
|
35 |
-
$sfw_log[$r[0]['network']] = Array('block' => 1, 'allow' => 0);
|
36 |
-
}
|
37 |
-
$ct_data['sfw_log'] = $sfw_log;
|
38 |
-
update_option('cleantalk_data', $ct_data);
|
39 |
-
wp_die( $sfw_die_page, "Blacklisted", Array('response'=>403) );
|
40 |
-
}
|
41 |
-
|
42 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inc/cleantalk-updater.php
CHANGED
@@ -2,8 +2,81 @@
|
|
2 |
|
3 |
function ct_run_update_actions($current_version, $new_version){
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
return true;
|
6 |
|
7 |
}
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
?>
|
2 |
|
3 |
function ct_run_update_actions($current_version, $new_version){
|
4 |
|
5 |
+
global $ct_data, $wpdb;
|
6 |
+
|
7 |
+
$current_version = ct_version_standartization($current_version);
|
8 |
+
$new_version = ct_version_standartization($new_version);
|
9 |
+
|
10 |
+
//Update actions
|
11 |
+
if($current_version[0] <= 5){
|
12 |
+
if($current_version[1] <= 49){
|
13 |
+
if($current_version[2] <= 1){
|
14 |
+
$wpdb->query("CREATE TABLE IF NOT EXISTS `".$wpdb->base_prefix."cleantalk_sfw` (
|
15 |
+
`network` int(11) unsigned NOT NULL,
|
16 |
+
`mask` int(11) unsigned NOT NULL,
|
17 |
+
INDEX ( `network` , `mask` )
|
18 |
+
) ENGINE = MYISAM ;");
|
19 |
+
|
20 |
+
$wpdb->query("CREATE TABLE IF NOT EXISTS `".$wpdb->base_prefix."cleantalk_sfw_logs` (
|
21 |
+
`ip` VARCHAR(15) NOT NULL ,
|
22 |
+
`all` INT NOT NULL ,
|
23 |
+
`blocked` INT NOT NULL ,
|
24 |
+
`timestamp` INT NOT NULL ,
|
25 |
+
PRIMARY KEY (`ip`))
|
26 |
+
ENGINE = MYISAM;");
|
27 |
+
}
|
28 |
+
}
|
29 |
+
if($current_version[1] <= 55){
|
30 |
+
if (!wp_next_scheduled('cleantalk_update_sfw_hook'))
|
31 |
+
wp_schedule_event(time()+1800, 'daily', 'cleantalk_update_sfw_hook' );
|
32 |
+
}
|
33 |
+
if($current_version[1] <= 69){
|
34 |
+
|
35 |
+
if(!in_array('all_entries', $wpdb->get_col("DESC " . $wpdb->base_prefix."cleantalk_sfw_logs", 0))){
|
36 |
+
$wpdb->query("ALTER TABLE `".$wpdb->base_prefix."cleantalk_sfw_logs`
|
37 |
+
CHANGE `all` `all_entries` INT(11) NOT NULL,
|
38 |
+
CHANGE `blocked` `blocked_entries` INT(11) NOT NULL,
|
39 |
+
CHANGE `timestamp` `entries_timestamp` INT(11) NOT NULL;"
|
40 |
+
);
|
41 |
+
}
|
42 |
+
|
43 |
+
// Deleting usless data
|
44 |
+
unset($ct_data['db_refreshed'], $ct_data['last_sfw_send'], $ct_data['next_account_status_check']);
|
45 |
+
update_option('cleantalk_data', $ct_data);
|
46 |
+
delete_option('cleantalk_sends_reports_till');
|
47 |
+
delete_option('cleantalk_activation_timestamp');
|
48 |
+
|
49 |
+
// Disabling WP_Cron tasks
|
50 |
+
wp_clear_scheduled_hook('cleantalk_send_daily_report_hook');
|
51 |
+
wp_clear_scheduled_hook('ct_hourly_event_hook');
|
52 |
+
wp_clear_scheduled_hook('ct_send_sfw_log');
|
53 |
+
wp_clear_scheduled_hook('cleantalk_update_sfw_hook');
|
54 |
+
wp_clear_scheduled_hook('cleantalk_get_brief_data_hook');
|
55 |
+
|
56 |
+
// Adding Self cron system tasks
|
57 |
+
cleantalk\antispam\CleantalkCron::addTask('check_account_status', 'ct_account_status_check', 3600, time()+1800); // New
|
58 |
+
cleantalk\antispam\CleantalkCron::addTask('delete_spam_comments', 'ct_delete_spam_comments', 3600, time()+3500);
|
59 |
+
cleantalk\antispam\CleantalkCron::addTask('send_feedback', 'ct_send_feedback', 3600, time()+3500);
|
60 |
+
cleantalk\antispam\CleantalkCron::addTask('sfw_update', 'ct_sfw_update', 86400, time()+43200);
|
61 |
+
cleantalk\antispam\CleantalkCron::addTask('send_sfw_logs', 'ct_sfw_send_logs', 3600, time()+1800); // New
|
62 |
+
cleantalk\antispam\CleantalkCron::addTask('get_brief_data', 'cleantalk_get_brief_data', 86400, time()+3500);
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
return true;
|
67 |
|
68 |
}
|
69 |
|
70 |
+
function ct_version_standartization($version){
|
71 |
+
|
72 |
+
$version = explode('.', $version);
|
73 |
+
$version = !empty($version) ? $version : array();
|
74 |
+
|
75 |
+
$version[0] = !empty($version[0]) ? (int)$version[0] : 0;
|
76 |
+
$version[1] = !empty($version[1]) ? (int)$version[1] : 0;
|
77 |
+
$version[2] = !empty($version[2]) ? (int)$version[2] : 0;
|
78 |
+
|
79 |
+
return $version;
|
80 |
+
}
|
81 |
+
|
82 |
?>
|
inc/cleantalk-users.php
CHANGED
@@ -459,7 +459,7 @@ function ct_ajax_info_users($direct_call = false)
|
|
459 |
$return['message'] .= "<p>$backup_notice</p>";
|
460 |
|
461 |
if($direct_call){
|
462 |
-
return
|
463 |
}else{
|
464 |
echo json_encode($return);
|
465 |
die();
|
459 |
$return['message'] .= "<p>$backup_notice</p>";
|
460 |
|
461 |
if($direct_call){
|
462 |
+
return $return['message'];
|
463 |
}else{
|
464 |
echo json_encode($return);
|
465 |
die();
|
inc/cleantalk_api.php
DELETED
@@ -1,126 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
require_once("cleantalk.class.php");
|
3 |
-
|
4 |
-
|
5 |
-
/**
|
6 |
-
* Get ct_get_checkjs_value
|
7 |
-
* @return string
|
8 |
-
*/
|
9 |
-
function ct_get_checkjs_value_plugin($random_key = false) {
|
10 |
-
|
11 |
-
$ct_data=get_option("cleantalk_data");
|
12 |
-
|
13 |
-
if ($random_key) {
|
14 |
-
$keys = $ct_data['js_keys'];
|
15 |
-
$keys_checksum = md5(json_encode($keys));
|
16 |
-
|
17 |
-
$key = null;
|
18 |
-
$latest_key_time = 0;
|
19 |
-
foreach ($keys as $k => $t) {
|
20 |
-
|
21 |
-
// Removing key if it's to old
|
22 |
-
if (time() - $t > $ct_data['js_keys_store_days'] * 86400) {
|
23 |
-
unset($keys[$k]);
|
24 |
-
continue;
|
25 |
-
}
|
26 |
-
|
27 |
-
if ($t > $latest_key_time) {
|
28 |
-
$latest_key_time = $t;
|
29 |
-
$key = $k;
|
30 |
-
}
|
31 |
-
}
|
32 |
-
|
33 |
-
// Get new key if the latest key is too old
|
34 |
-
if (time() - $latest_key_time > $ct_data['js_key_lifetime']) {
|
35 |
-
$key = rand();
|
36 |
-
$keys[$key] = time();
|
37 |
-
}
|
38 |
-
|
39 |
-
if (md5(json_encode($keys)) != $keys_checksum) {
|
40 |
-
$ct_data['js_keys'] = $keys;
|
41 |
-
update_option('cleantalk_data', $ct_data);
|
42 |
-
}
|
43 |
-
} else {
|
44 |
-
$key = md5($ct_options['apikey'] . '+' . get_option('admin_email'));
|
45 |
-
}
|
46 |
-
|
47 |
-
return $key;
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Validates JavaScript anti-spam test
|
52 |
-
*
|
53 |
-
*/
|
54 |
-
function js_test_plugin($field_name = 'ct_checkjs', $data = null, $random_key = false) {
|
55 |
-
|
56 |
-
$ct_data=get_option("cleantalk_data");
|
57 |
-
|
58 |
-
$checkjs = null;
|
59 |
-
$js_post_value = null;
|
60 |
-
|
61 |
-
if (!$data)
|
62 |
-
return $checkjs;
|
63 |
-
|
64 |
-
if (isset($data[$field_name])) {
|
65 |
-
$js_post_value = $data[$field_name];
|
66 |
-
if (isset($keys[$js_post_value])) {
|
67 |
-
|
68 |
-
//
|
69 |
-
// Random key check
|
70 |
-
//
|
71 |
-
if ($random_key) {
|
72 |
-
|
73 |
-
$keys = $ct_data['js_keys'];
|
74 |
-
$checkjs = 1;
|
75 |
-
} else {
|
76 |
-
$checkjs = 0;
|
77 |
-
}
|
78 |
-
} else {
|
79 |
-
$ct_challenge = ct_get_checkjs_value();
|
80 |
-
|
81 |
-
if(preg_match("/$ct_challenge/", $js_post_value)) {
|
82 |
-
$checkjs = 1;
|
83 |
-
} else {
|
84 |
-
$checkjs = 0;
|
85 |
-
}
|
86 |
-
}
|
87 |
-
|
88 |
-
|
89 |
-
}
|
90 |
-
|
91 |
-
return $checkjs;
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Check messages for external plugins
|
96 |
-
* @return array with checking result;
|
97 |
-
*/
|
98 |
-
|
99 |
-
function ct_test_message($nickname, $email, $ip, $text){
|
100 |
-
$checkjs = js_test_plugin('ct_checkjs', $_COOKIE, true);
|
101 |
-
|
102 |
-
$post_info['comment_type'] = 'feedback_plugin_check';
|
103 |
-
$post_info = json_encode($post_info);
|
104 |
-
|
105 |
-
$ct_base_call_result = ct_base_call(array(
|
106 |
-
'message' => $text,
|
107 |
-
'example' => null,
|
108 |
-
'sender_email' => $email,
|
109 |
-
'sender_nickname' => $nickname,
|
110 |
-
'post_info' => $post_info,
|
111 |
-
'sender_info' => get_sender_info(),
|
112 |
-
'checkjs' => $checkjs
|
113 |
-
));
|
114 |
-
|
115 |
-
$ct_result = $ct_base_call_result['ct_result'];
|
116 |
-
|
117 |
-
$result=Array(
|
118 |
-
'allow' => $ct_result->allow,
|
119 |
-
'comment' => $ct_result->comment,
|
120 |
-
);
|
121 |
-
return $result;
|
122 |
-
}
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inc/cleantalk_external.js
CHANGED
@@ -26,7 +26,7 @@ if(ct_external_executed==undefined)
|
|
26 |
document.forms[i].method='POST';
|
27 |
document.forms[i].appendChild(ct_method);
|
28 |
|
29 |
-
document.forms[i].action=
|
30 |
}
|
31 |
}
|
32 |
}
|
26 |
document.forms[i].method='POST';
|
27 |
document.forms[i].appendChild(ct_method);
|
28 |
|
29 |
+
document.forms[i].action=ctNocache.blog_home;
|
30 |
}
|
31 |
}
|
32 |
}
|
inc/cleantalk_internal.js
CHANGED
@@ -14,7 +14,7 @@ function ct_check_internal(currForm){
|
|
14 |
//AJAX Request
|
15 |
jQuery.ajax({
|
16 |
type: 'POST',
|
17 |
-
url:
|
18 |
datatype : 'text',
|
19 |
data: ct_data,
|
20 |
success: function(data){
|
@@ -39,7 +39,7 @@ jQuery(document).ready( function(){
|
|
39 |
ct_currForm = document.forms[i];
|
40 |
ct_currAction = ct_currForm.action;
|
41 |
if(ct_currAction.indexOf('http://')!=-1||ct_currAction.indexOf('https://')!=-1){
|
42 |
-
if(ct_currAction.search(/\/wp-content\/themes.*\.php$/) != (-1) && ct_currAction.indexOf(
|
43 |
ctPrevHandler = ct_currForm.click;
|
44 |
jQuery(ct_currForm).off('**');
|
45 |
jQuery(ct_currForm).off();
|
14 |
//AJAX Request
|
15 |
jQuery.ajax({
|
16 |
type: 'POST',
|
17 |
+
url: ctNocache.blog_home,
|
18 |
datatype : 'text',
|
19 |
data: ct_data,
|
20 |
success: function(data){
|
39 |
ct_currForm = document.forms[i];
|
40 |
ct_currAction = ct_currForm.action;
|
41 |
if(ct_currAction.indexOf('http://')!=-1||ct_currAction.indexOf('https://')!=-1){
|
42 |
+
if(ct_currAction.search(/\/wp-content\/themes.*\.php$/) != (-1) && ct_currAction.indexOf(ctNocache.blog_home) != (-1)){
|
43 |
ctPrevHandler = ct_currForm.click;
|
44 |
jQuery(ct_currForm).off('**');
|
45 |
jQuery(ct_currForm).off();
|
inc/cleantalk_nocache.js
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
/*
|
2 |
Assign default values for backend variables.
|
3 |
*/
|
4 |
-
if (typeof
|
5 |
-
|
6 |
}
|
7 |
|
8 |
-
if (typeof
|
9 |
-
|
10 |
}
|
11 |
|
12 |
function sendRequest(url,callback,postData) {
|
@@ -66,7 +66,7 @@ function ct_getCookie(name) {
|
|
66 |
|
67 |
function ct_setCookie(name, value)
|
68 |
{
|
69 |
-
if (
|
70 |
document.cookie = name+" =; expires=Thu, 01 Jan 1970 00:00:01 GMT; path = /";
|
71 |
document.cookie = name+" =; expires=Thu, 01 Jan 1970 00:00:01 GMT";
|
72 |
|
@@ -135,10 +135,10 @@ if(ct_nocache_executed==undefined)
|
|
135 |
if((old_timestamp==undefined||new_timestamp-old_timestamp>86400||checkjs_cookie==undefined)) //86400 is 24 hours
|
136 |
{
|
137 |
ct_setCookie('ct_timestamp', new_timestamp);
|
138 |
-
sendRequest(
|
139 |
}
|
140 |
|
141 |
-
if(typeof
|
142 |
{
|
143 |
|
144 |
var cleantalk_user_info={};
|
@@ -213,4 +213,4 @@ if(ct_nocache_executed==undefined)
|
|
213 |
|
214 |
setTimeout(function() { document.cookie = "ct_user_info = "+escape(JSON.stringify(cleantalk_user_info))+"; path = /;"}, 500);
|
215 |
}
|
216 |
-
}
|
1 |
/*
|
2 |
Assign default values for backend variables.
|
3 |
*/
|
4 |
+
if (typeof ctNocache.set_cookies_flag === 'undefined') {
|
5 |
+
ctNocache.set_cookies_flag = true;
|
6 |
}
|
7 |
|
8 |
+
if (typeof ctNocache.ajaxurl === 'undefined') {
|
9 |
+
ctNocache.ajaxurl = '/wp-admin/admin-ajax.php';
|
10 |
}
|
11 |
|
12 |
function sendRequest(url,callback,postData) {
|
66 |
|
67 |
function ct_setCookie(name, value)
|
68 |
{
|
69 |
+
if (ctNocache.set_cookies_flag) {
|
70 |
document.cookie = name+" =; expires=Thu, 01 Jan 1970 00:00:01 GMT; path = /";
|
71 |
document.cookie = name+" =; expires=Thu, 01 Jan 1970 00:00:01 GMT";
|
72 |
|
135 |
if((old_timestamp==undefined||new_timestamp-old_timestamp>86400||checkjs_cookie==undefined)) //86400 is 24 hours
|
136 |
{
|
137 |
ct_setCookie('ct_timestamp', new_timestamp);
|
138 |
+
sendRequest(ctNocache.ajaxurl+'?'+Math.random(),ct_callback,'action=ct_get_cookie');
|
139 |
}
|
140 |
|
141 |
+
if(typeof ctNocache.info_flag !== 'undefined' && ctNocache.info_flag)
|
142 |
{
|
143 |
|
144 |
var cleantalk_user_info={};
|
213 |
|
214 |
setTimeout(function() { document.cookie = "ct_user_info = "+escape(JSON.stringify(cleantalk_user_info))+"; path = /;"}, 500);
|
215 |
}
|
216 |
+
}
|
inc/sfw_die_page.html
CHANGED
@@ -1,21 +1,19 @@
|
|
1 |
<!doctype html>
|
2 |
|
3 |
-
<html lang=
|
4 |
<head>
|
5 |
-
<meta charset=
|
6 |
-
<meta name=
|
7 |
-
<meta http-equiv=
|
8 |
-
<meta http-equiv=
|
9 |
-
<meta http-equiv=
|
10 |
-
<meta http-equiv=
|
11 |
-
<meta http-equiv=
|
12 |
-
<meta http-equiv=
|
13 |
-
<meta http-equiv=
|
14 |
-
|
15 |
-
<!-- <title></title> -->
|
16 |
|
17 |
<!--[if lt IE 9]>
|
18 |
-
<script src=
|
19 |
<![endif]-->
|
20 |
<style>
|
21 |
html{font-size: 14pt;}
|
@@ -33,7 +31,7 @@
|
|
33 |
<script>
|
34 |
var reload_timeout = 3000;
|
35 |
function set_spamFireWallCookie(cookie_name, cookie_value) {
|
36 |
-
document.cookie = cookie_name +
|
37 |
return null;
|
38 |
}
|
39 |
function get_current_url() {
|
@@ -44,30 +42,32 @@ function get_current_url() {
|
|
44 |
</head>
|
45 |
|
46 |
<body>
|
47 |
-
<div class=
|
48 |
-
<h1 class=
|
49 |
|
50 |
-
<div id=
|
51 |
|
52 |
-
<div id=
|
53 |
-
<h3>
|
54 |
-
<a href=
|
55 |
{GENERATED}
|
56 |
<br /><br /><br />
|
57 |
-
<p class=
|
58 |
</div>
|
59 |
</div>
|
60 |
-
<div class=
|
61 |
-
<a href=
|
62 |
</div>
|
63 |
-
<script type=
|
64 |
document.getElementById('js_info').style.display = 'none';
|
65 |
document.getElementById('js_passed').style.display = 'block';
|
66 |
-
|
67 |
-
|
|
|
|
|
68 |
setTimeout(function(){
|
69 |
window.location.reload(1);
|
70 |
}, reload_timeout);
|
71 |
</script>
|
72 |
</body>
|
73 |
-
</html>
|
1 |
<!doctype html>
|
2 |
|
3 |
+
<html lang='en'>
|
4 |
<head>
|
5 |
+
<meta charset='utf-8' />
|
6 |
+
<meta name='viewport' content='width=device-width, initial-scale=1' />
|
7 |
+
<meta http-equiv='сache-сontrol' content='no-cache'>
|
8 |
+
<meta http-equiv='сache-сontrol' content='private'>
|
9 |
+
<meta http-equiv='сache-сontrol' content='max-age=0, must-revalidate'>
|
10 |
+
<meta http-equiv='сache-сontrol' content='max-age=0, proxy-revalidate'>
|
11 |
+
<meta http-equiv='expires' content='0' />
|
12 |
+
<meta http-equiv='expires' content='Tue, 01 Jan 1980 1:00:00 GMT' />
|
13 |
+
<meta http-equiv='pragma' content='no-cache' />
|
|
|
|
|
14 |
|
15 |
<!--[if lt IE 9]>
|
16 |
+
<script src='http://html5shiv.googlecode.com/svn/trunk/html5.js'></script>
|
17 |
<![endif]-->
|
18 |
<style>
|
19 |
html{font-size: 14pt;}
|
31 |
<script>
|
32 |
var reload_timeout = 3000;
|
33 |
function set_spamFireWallCookie(cookie_name, cookie_value) {
|
34 |
+
document.cookie = cookie_name + '=' + escape(cookie_value) + '; path=/;{COOKIE_DOMAIN}';
|
35 |
return null;
|
36 |
}
|
37 |
function get_current_url() {
|
42 |
</head>
|
43 |
|
44 |
<body>
|
45 |
+
<div class='container'>
|
46 |
+
<h1 class='main'>{SFW_DIE_NOTICE_IP}<a href='https://cleantalk.org/blacklists/{REMOTE_ADDRESS}' target='_blank'>{REMOTE_ADDRESS}</a></h1>
|
47 |
|
48 |
+
<div id='js_info'><br />{SFW_DIE_MAKE_SURE_JS_ENABLED}</div>
|
49 |
|
50 |
+
<div id='js_passed'>
|
51 |
+
<h3>{SFW_DIE_CLICK_TO_PASS}</h3>
|
52 |
+
<a href='{REQUEST_URI}'><script>get_current_url();</script></a>
|
53 |
{GENERATED}
|
54 |
<br /><br /><br />
|
55 |
+
<p class='js_notice'>{SFW_DIE_YOU_WILL_BE_REDIRECTED}</p>
|
56 |
</div>
|
57 |
</div>
|
58 |
+
<div class='footer'>
|
59 |
+
<a href='https://cleantalk.org' target='_blank'>{CLEANTALK_TITLE}</a>
|
60 |
</div>
|
61 |
+
<script type='text/javascript'>
|
62 |
document.getElementById('js_info').style.display = 'none';
|
63 |
document.getElementById('js_passed').style.display = 'block';
|
64 |
+
setTimeout(function(){
|
65 |
+
set_spamFireWallCookie('{COOKIE_PREFIX}ct_sfw_pass_key','{SFW_COOKIE}');
|
66 |
+
set_spamFireWallCookie('{COOKIE_PREFIX}ct_sfw_passed','1');
|
67 |
+
}, 2000);
|
68 |
setTimeout(function(){
|
69 |
window.location.reload(1);
|
70 |
}, reload_timeout);
|
71 |
</script>
|
72 |
</body>
|
73 |
+
</html>
|
lib/CleantalkCron.php
ADDED
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* CleanTalk cron class
|
5 |
+
* Version 1.0
|
6 |
+
*/
|
7 |
+
|
8 |
+
namespace cleantalk\antispam;
|
9 |
+
|
10 |
+
class CleantalkCron
|
11 |
+
{
|
12 |
+
public $tasks = array(); // Array with tasks
|
13 |
+
public $tasks_to_run = array(); // Array with tasks which should be run now
|
14 |
+
public $tasks_completed = array(); // Result of executed tasks
|
15 |
+
|
16 |
+
// Currently selected task
|
17 |
+
private $task;
|
18 |
+
private $handler;
|
19 |
+
private $period;
|
20 |
+
private $next_call;
|
21 |
+
|
22 |
+
// Option name with cron data
|
23 |
+
const CRON_OPTION_NAME = 'cleantalk_cron';
|
24 |
+
|
25 |
+
// Getting tasks option
|
26 |
+
public function __construct()
|
27 |
+
{
|
28 |
+
$tasks = get_option(self::CRON_OPTION_NAME);
|
29 |
+
$this->tasks = empty($tasks) ? array() : $tasks;
|
30 |
+
}
|
31 |
+
|
32 |
+
// Adding new cron task
|
33 |
+
static public function addTask($task, $handler, $period, $first_call = null)
|
34 |
+
{
|
35 |
+
// First call time() + preiod
|
36 |
+
$first_call = !$first_call ? time()+$period : $first_call;
|
37 |
+
|
38 |
+
$tasks = get_option(self::CRON_OPTION_NAME);
|
39 |
+
$tasks = empty($tasks) ? array() : $tasks;
|
40 |
+
|
41 |
+
if(isset($tasks[$task]))
|
42 |
+
return false;
|
43 |
+
|
44 |
+
// Task entry
|
45 |
+
$tasks[$task] = array(
|
46 |
+
'handler' => $handler,
|
47 |
+
'next_call' => $first_call,
|
48 |
+
'period' => $period,
|
49 |
+
);
|
50 |
+
|
51 |
+
update_option(self::CRON_OPTION_NAME, $tasks);
|
52 |
+
|
53 |
+
return true;
|
54 |
+
}
|
55 |
+
|
56 |
+
// Removing cron task
|
57 |
+
static public function removeTask($task)
|
58 |
+
{
|
59 |
+
$tasks = get_option(self::CRON_OPTION_NAME);
|
60 |
+
$tasks = empty($tasks) ? array() : $tasks;
|
61 |
+
|
62 |
+
if(!isset($tasks[$task]))
|
63 |
+
return false;
|
64 |
+
|
65 |
+
unset($tasks[$task]);
|
66 |
+
|
67 |
+
update_option(self::CRON_OPTION_NAME, $tasks);
|
68 |
+
|
69 |
+
return true;
|
70 |
+
}
|
71 |
+
|
72 |
+
// Updates cron task, creates task if not exists
|
73 |
+
static public function updateTask($task, $handler, $period, $first_call = null){
|
74 |
+
self::removeTask($task);
|
75 |
+
self::addTask($task, $handler, $period, $first_call = null);
|
76 |
+
}
|
77 |
+
|
78 |
+
// Getting tasks which should be run. Putting tasks that should be run to $this->tasks_to_run
|
79 |
+
public function checkTasks()
|
80 |
+
{
|
81 |
+
if(empty($this->tasks))
|
82 |
+
return true;
|
83 |
+
|
84 |
+
foreach($this->tasks as $task => $task_data){
|
85 |
+
|
86 |
+
if($task_data['next_call'] <= time())
|
87 |
+
$this->tasks_to_run[] = $task;
|
88 |
+
|
89 |
+
}unset($task, $task_data);
|
90 |
+
|
91 |
+
return $this->tasks_to_run;
|
92 |
+
}
|
93 |
+
|
94 |
+
// Run all tasks from $this->tasks_to_run. Saving all results to (array) $this->tasks_completed
|
95 |
+
public function runTasks()
|
96 |
+
{
|
97 |
+
if(empty($this->tasks_to_run))
|
98 |
+
return true;
|
99 |
+
|
100 |
+
foreach($this->tasks_to_run as $task){
|
101 |
+
|
102 |
+
$this->selectTask($task);
|
103 |
+
|
104 |
+
if(function_exists($this->handler)){
|
105 |
+
$this->tasks_completed[$task] = call_user_func($this->handler);
|
106 |
+
$this->next_call = time() + $this->period;
|
107 |
+
}else{
|
108 |
+
$this->tasks_completed[$task] = false;
|
109 |
+
}
|
110 |
+
|
111 |
+
$this->saveTask($task);
|
112 |
+
|
113 |
+
}unset($task, $task_data);
|
114 |
+
|
115 |
+
$this->saveTasks();
|
116 |
+
|
117 |
+
return $this->tasks_completed;
|
118 |
+
}
|
119 |
+
|
120 |
+
// Select task in private properties for comfortable use.
|
121 |
+
private function selectTask($task)
|
122 |
+
{
|
123 |
+
$this->task = $task;
|
124 |
+
$this->handler = $this->tasks[$task]['handler'];
|
125 |
+
$this->period = $this->tasks[$task]['period'];
|
126 |
+
$this->next_call = $this->tasks[$task]['next_call'];
|
127 |
+
}
|
128 |
+
|
129 |
+
// Save task in private properties for comfortable use
|
130 |
+
private function saveTask($task)
|
131 |
+
{
|
132 |
+
$task = $this->task;
|
133 |
+
$this->tasks[$task]['handler'] = $this->handler;
|
134 |
+
$this->tasks[$task]['period'] = $this->period;
|
135 |
+
$this->tasks[$task]['next_call'] = $this->next_call;
|
136 |
+
}
|
137 |
+
|
138 |
+
// Save option with tasks
|
139 |
+
private function saveTasks()
|
140 |
+
{
|
141 |
+
update_option(self::CRON_OPTION_NAME, $this->tasks);
|
142 |
+
}
|
143 |
+
}
|
lib/CleantalkSFW.php
ADDED
@@ -0,0 +1,500 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* CleanTalk SpamFireWall base class
|
5 |
+
* Version 1.2
|
6 |
+
* Compatible with phpBB 3.1, SMF 2.0+, Wordpress.
|
7 |
+
*/
|
8 |
+
|
9 |
+
namespace cleantalk\antispam;
|
10 |
+
|
11 |
+
class CleantalkSFW
|
12 |
+
{
|
13 |
+
public $ip = 0;
|
14 |
+
public $ip_str = '';
|
15 |
+
public $ip_array = Array();
|
16 |
+
public $ip_str_array = Array();
|
17 |
+
public $blocked_ip = '';
|
18 |
+
public $passed_ip = '';
|
19 |
+
public $result = false;
|
20 |
+
|
21 |
+
//Database variables
|
22 |
+
private $table_prefix;
|
23 |
+
private $db;
|
24 |
+
private $query;
|
25 |
+
private $db_result;
|
26 |
+
private $db_result_data = array();
|
27 |
+
|
28 |
+
public function __construct()
|
29 |
+
{
|
30 |
+
if(defined("IN_PHPBB")){
|
31 |
+
global $db, $table_prefix;
|
32 |
+
$this->table_prefix = $table_prefix;
|
33 |
+
$this->db = $db;
|
34 |
+
}
|
35 |
+
if(defined('SMF')){
|
36 |
+
global $db_connection, $db_prefix;
|
37 |
+
if (!isset($db_connection) || $db_connection === false){
|
38 |
+
loadDatabase();
|
39 |
+
}
|
40 |
+
$this->table_prefix = $db_prefix;
|
41 |
+
}
|
42 |
+
if(defined("WPINC")){
|
43 |
+
global $wpdb;
|
44 |
+
$this->table_prefix = $wpdb->prefix;
|
45 |
+
$this->db = $wpdb;
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
public function unversal_query($query, $straight_query = false)
|
50 |
+
{
|
51 |
+
if(defined("IN_PHPBB")){
|
52 |
+
$this->db_result = $this->db->sql_query($query);
|
53 |
+
}
|
54 |
+
if(defined("WPINC")){
|
55 |
+
if($straight_query)
|
56 |
+
$this->db_result = $this->db->query($query);
|
57 |
+
else
|
58 |
+
$this->query = $query;
|
59 |
+
}
|
60 |
+
if(defined('SMF')){
|
61 |
+
global $smcFunc;
|
62 |
+
$query = preg_replace("/\;$/", '', $query);
|
63 |
+
$this->db_result = $smcFunc['db_query']('', $query, array('db_error_skip' => true));
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
public function unversal_fetch()
|
68 |
+
{
|
69 |
+
if(defined("IN_PHPBB")){
|
70 |
+
$this->db_result_data = $this->db->sql_fetchrow($this->db_result);
|
71 |
+
$this->db->sql_freeresult($this->db_result);
|
72 |
+
}
|
73 |
+
if(defined("WPINC")){
|
74 |
+
$this->db_result_data = $this->db->get_row($this->query, ARRAY_A);
|
75 |
+
}
|
76 |
+
if(defined('SMF')){
|
77 |
+
global $smcFunc;
|
78 |
+
$this->db_result_data = $smcFunc['db_fetch_assoc']($this->db_result);
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
public function unversal_fetch_all()
|
83 |
+
{
|
84 |
+
if(defined("IN_PHPBB")){
|
85 |
+
$this->db_result_data = $this->db->sql_fetchrowset($this->db_result);
|
86 |
+
$this->db->sql_freeresult($this->db_result);
|
87 |
+
}
|
88 |
+
if(defined("WPINC")){
|
89 |
+
$this->db_result_data = $this->db->get_results($this->query, ARRAY_A);
|
90 |
+
}
|
91 |
+
if(defined('SMF')){
|
92 |
+
global $smcFunc;
|
93 |
+
while ($row = $smcFunc['db_fetch_assoc']($this->db_result)){
|
94 |
+
$this->db_result_data[] = $row;
|
95 |
+
}
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
|
100 |
+
/*
|
101 |
+
* Getting IP function
|
102 |
+
* Version 1.1
|
103 |
+
* Compatible with any CMS
|
104 |
+
*/
|
105 |
+
public function cleantalk_get_real_ip(){
|
106 |
+
|
107 |
+
$result=Array();
|
108 |
+
if(function_exists('apache_request_headers')){
|
109 |
+
$headers = apache_request_headers();
|
110 |
+
$headers['X-Forwarded-For'] = isset($headers['X-Forwarded-For']) ? $headers['X-Forwarded-For'] : null;
|
111 |
+
$headers['HTTP_X_FORWARDED_FOR'] = isset($headers['HTTP_X_FORWARDED_FOR']) ? $headers['HTTP_X_FORWARDED_FOR'] : null;
|
112 |
+
if(defined("IN_PHPBB")){
|
113 |
+
global $request;
|
114 |
+
$headers['REMOTE_ADDR'] = $request->server('REMOTE_ADDR');
|
115 |
+
$sfw_test_ip = $request->variable('sfw_test_ip', '');
|
116 |
+
}else{
|
117 |
+
$headers['REMOTE_ADDR'] = $_SERVER['REMOTE_ADDR'];
|
118 |
+
$sfw_test_ip = isset($_GET['sfw_test_ip']) ? $_GET['sfw_test_ip'] : null;
|
119 |
+
}
|
120 |
+
}else{
|
121 |
+
if(defined("IN_PHPBB")){
|
122 |
+
global $request;
|
123 |
+
$headers['REMOTE_ADDR'] = $request->server('REMOTE_ADDR');
|
124 |
+
$headers['X-Forwarded-For'] = $request->server('X-Forwarded-For');
|
125 |
+
$headers['HTTP_X_FORWARDED_FOR'] = $request->server('HTTP_X_FORWARDED_FOR');
|
126 |
+
$sfw_test_ip = $request->variable('sfw_test_ip', '');
|
127 |
+
}else{
|
128 |
+
$headers = $_SERVER;
|
129 |
+
$headers['REMOTE_ADDR'] = $_SERVER['REMOTE_ADDR'];
|
130 |
+
$headers['X-Forwarded-For'] = isset($headers['X-Forwarded-For']) ? $headers['X-Forwarded-For'] : null;
|
131 |
+
$headers['HTTP_X_FORWARDED_FOR'] = isset($headers['HTTP_X_FORWARDED_FOR']) ? $headers['HTTP_X_FORWARDED_FOR'] : null;
|
132 |
+
$sfw_test_ip = isset($_GET['sfw_test_ip']) ? $_GET['sfw_test_ip'] : null;
|
133 |
+
}
|
134 |
+
}
|
135 |
+
|
136 |
+
if( $headers['X-Forwarded-For'] ){
|
137 |
+
$the_ip = explode(",", trim($headers['X-Forwarded-For']));
|
138 |
+
$the_ip = trim($the_ip[0]);
|
139 |
+
$result[] = $the_ip;
|
140 |
+
$this->ip_str_array[]=$the_ip;
|
141 |
+
$this->ip_array[]=sprintf("%u", ip2long($the_ip));
|
142 |
+
}
|
143 |
+
|
144 |
+
if( $headers['HTTP_X_FORWARDED_FOR'] ){
|
145 |
+
$the_ip = explode(",", trim($headers['HTTP_X_FORWARDED_FOR']));
|
146 |
+
$the_ip = trim($the_ip[0]);
|
147 |
+
$result[] = $the_ip;
|
148 |
+
$this->ip_str_array[]=$the_ip;
|
149 |
+
$this->ip_array[]=sprintf("%u", ip2long($the_ip));
|
150 |
+
}
|
151 |
+
|
152 |
+
$the_ip = filter_var( $headers['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 );
|
153 |
+
$result[] = $the_ip;
|
154 |
+
$this->ip_str_array[]=$the_ip;
|
155 |
+
$this->ip_array[]=sprintf("%u", ip2long($the_ip));
|
156 |
+
|
157 |
+
if($sfw_test_ip){
|
158 |
+
$result[] = $sfw_test_ip;
|
159 |
+
$this->ip_str_array[]=$sfw_test_ip;
|
160 |
+
$this->ip_array[]=sprintf("%u", ip2long($sfw_test_ip));
|
161 |
+
}
|
162 |
+
|
163 |
+
return $result;
|
164 |
+
}
|
165 |
+
|
166 |
+
/*
|
167 |
+
* Getting IP function
|
168 |
+
* Version 1.1
|
169 |
+
* Compatible with any CMS
|
170 |
+
*/
|
171 |
+
public function check_ip(){
|
172 |
+
|
173 |
+
for($i=0, $arr_count = sizeof($this->ip_array); $i < $arr_count; $i++){
|
174 |
+
|
175 |
+
$query = "SELECT
|
176 |
+
COUNT(network) AS cnt
|
177 |
+
FROM ".$this->table_prefix."cleantalk_sfw
|
178 |
+
WHERE network = ".intval($this->ip_array[$i])." & mask;";
|
179 |
+
$this->unversal_query($query);
|
180 |
+
$this->unversal_fetch();
|
181 |
+
|
182 |
+
$curr_ip = long2ip($this->ip_array[$i]);
|
183 |
+
|
184 |
+
if($this->db_result_data['cnt']){
|
185 |
+
$this->result = true;
|
186 |
+
$this->blocked_ip=$this->ip_str_array[$i];
|
187 |
+
}else{
|
188 |
+
$this->passed_ip = $this->ip_str_array[$i];
|
189 |
+
}
|
190 |
+
}
|
191 |
+
}
|
192 |
+
|
193 |
+
/*
|
194 |
+
* Add entries to SFW log
|
195 |
+
* Version 1.1
|
196 |
+
* Compatible with any CMS
|
197 |
+
*/
|
198 |
+
public function sfw_update_logs($ip, $result){
|
199 |
+
|
200 |
+
if($ip === NULL || $result === NULL){
|
201 |
+
return;
|
202 |
+
}
|
203 |
+
|
204 |
+
$blocked = ($result == 'blocked' ? ' + 1' : '');
|
205 |
+
$time = time();
|
206 |
+
|
207 |
+
$query = "INSERT INTO ".$this->table_prefix."cleantalk_sfw_logs
|
208 |
+
SET
|
209 |
+
ip = '$ip',
|
210 |
+
all_entries = 1,
|
211 |
+
blocked_entries = 1,
|
212 |
+
entries_timestamp = '".intval($time)."'
|
213 |
+
ON DUPLICATE KEY
|
214 |
+
UPDATE
|
215 |
+
all_entries = all_entries + 1,
|
216 |
+
blocked_entries = blocked_entries".strval($blocked).",
|
217 |
+
entries_timestamp = '".intval($time)."'";
|
218 |
+
|
219 |
+
$this->unversal_query($query, true);
|
220 |
+
}
|
221 |
+
|
222 |
+
/*
|
223 |
+
* Updates SFW local base
|
224 |
+
* Version 1.1
|
225 |
+
* Compatible only with phpBB 3.1
|
226 |
+
*/
|
227 |
+
public function sfw_update($ct_key){
|
228 |
+
|
229 |
+
$result = self::get_2sBlacklistsDb($ct_key);
|
230 |
+
$result = self::checkRequestResult($result);
|
231 |
+
|
232 |
+
if(empty($result['error'])){
|
233 |
+
|
234 |
+
$this->unversal_query("DELETE FROM ".$this->table_prefix."cleantalk_sfw;", true);
|
235 |
+
|
236 |
+
// Cast result to int
|
237 |
+
foreach($result as $value){
|
238 |
+
$value[0] = intval($value[0]);
|
239 |
+
$value[1] = intval($value[1]);
|
240 |
+
} unset($value);
|
241 |
+
|
242 |
+
$query="INSERT INTO ".$this->table_prefix."cleantalk_sfw VALUES ";
|
243 |
+
for($i=0, $arr_count = count($result); $i < $arr_count; $i++){
|
244 |
+
if($i == count($result)-1){
|
245 |
+
$query.="(".$result[$i][0].",".$result[$i][1].");";
|
246 |
+
}else{
|
247 |
+
$query.="(".$result[$i][0].",".$result[$i][1]."), ";
|
248 |
+
}
|
249 |
+
}
|
250 |
+
$this->unversal_query($query, true);
|
251 |
+
|
252 |
+
return true;
|
253 |
+
|
254 |
+
}else{
|
255 |
+
return $result['error_string'];
|
256 |
+
}
|
257 |
+
}
|
258 |
+
|
259 |
+
/*
|
260 |
+
* Sends and wipe SFW log
|
261 |
+
* Version 1.1
|
262 |
+
* Compatible only with phpBB 3.1
|
263 |
+
*/
|
264 |
+
public function send_logs($ct_key){
|
265 |
+
|
266 |
+
//Getting logs
|
267 |
+
$query = "SELECT * FROM ".$this->table_prefix."cleantalk_sfw_logs";
|
268 |
+
$this->unversal_query($query);
|
269 |
+
$this->unversal_fetch_all();
|
270 |
+
|
271 |
+
if(count($this->db_result_data)){
|
272 |
+
|
273 |
+
//Compile logs
|
274 |
+
$data = array();
|
275 |
+
foreach($this->db_result_data as $key => $value){
|
276 |
+
$data[] = array(trim($value['ip']), $value['all_entries'], $value['all_entries']-$value['blocked_entries'], $value['entries_timestamp']);
|
277 |
+
}
|
278 |
+
unset($key, $value);
|
279 |
+
|
280 |
+
//Sending the request
|
281 |
+
$result = self::sfwLogs($ct_key, $data);
|
282 |
+
$result = self::checkRequestResult($result);
|
283 |
+
//Checking answer and deleting all lines from the table
|
284 |
+
if(empty($result['error'])){
|
285 |
+
if($result['rows'] == count($data)){
|
286 |
+
$this->unversal_query("DELETE FROM ".$this->table_prefix."cleantalk_sfw_logs", true);
|
287 |
+
return true;
|
288 |
+
}
|
289 |
+
}else{
|
290 |
+
return $result['error_string'];
|
291 |
+
}
|
292 |
+
|
293 |
+
}else{
|
294 |
+
return 'NO_LOGS_TO_SEND';
|
295 |
+
}
|
296 |
+
}
|
297 |
+
|
298 |
+
/*
|
299 |
+
* Shows DIE page
|
300 |
+
* Version 1.1
|
301 |
+
* Compatible with any CMS
|
302 |
+
*/
|
303 |
+
public function sfw_die($api_key, $cookie_prefix = '', $cookie_domain = ''){
|
304 |
+
|
305 |
+
if(defined("IN_PHPBB")){
|
306 |
+
global $request, $user;
|
307 |
+
$user->add_lang_ext('cleantalk/antispam', 'common');
|
308 |
+
}
|
309 |
+
|
310 |
+
// File exists?
|
311 |
+
if(file_exists(CLEANTALK_PLUGIN_DIR . "inc/sfw_die_page.html")){
|
312 |
+
$sfw_die_page = file_get_contents(CLEANTALK_PLUGIN_DIR . "inc/sfw_die_page.html");
|
313 |
+
}else{
|
314 |
+
die($user->lang('SFW_DIE_NO_FILE'));
|
315 |
+
}
|
316 |
+
|
317 |
+
// Translation
|
318 |
+
if(defined("IN_PHPBB")){
|
319 |
+
$request_uri = $request->server('REQUEST_URI');
|
320 |
+
$sfw_die_page = str_replace('{SFW_DIE_NOTICE_IP}', $user->lang('SFW_DIE_NOTICE_IP'), $sfw_die_page);
|
321 |
+
$sfw_die_page = str_replace('{SFW_DIE_MAKE_SURE_JS_ENABLED}', $user->lang('SFW_DIE_MAKE_SURE_JS_ENABLED'), $sfw_die_page);
|
322 |
+
$sfw_die_page = str_replace('{SFW_DIE_CLICK_TO_PASS}', $user->lang('SFW_DIE_CLICK_TO_PASS'), $sfw_die_page);
|
323 |
+
$sfw_die_page = str_replace('{SFW_DIE_YOU_WILL_BE_REDIRECTED}', $user->lang('SFW_DIE_YOU_WILL_BE_REDIRECTED'), $sfw_die_page);
|
324 |
+
$sfw_die_page = str_replace('{CLEANTALK_TITLE}', $user->lang('ACP_CLEANTALK_TITLE'), $sfw_die_page);
|
325 |
+
}elseif(defined("WPINC")){
|
326 |
+
$request_uri = $_SERVER['REQUEST_URI'];
|
327 |
+
$sfw_die_page = str_replace('{SFW_DIE_NOTICE_IP}', __('SpamFireWall is activated for your IP ', 'cleantalk'), $sfw_die_page);
|
328 |
+
$sfw_die_page = str_replace('{SFW_DIE_MAKE_SURE_JS_ENABLED}', __('To continue working with web site, please make sure that you have enabled JavaScript.', 'cleantalk'), $sfw_die_page);
|
329 |
+
$sfw_die_page = str_replace('{SFW_DIE_CLICK_TO_PASS}', __('Please click bellow to pass protection,', 'cleantalk'), $sfw_die_page);
|
330 |
+
$sfw_die_page = str_replace('{SFW_DIE_YOU_WILL_BE_REDIRECTED}', __('Or you will be automatically redirected to the requested page after 3 seconds.', 'cleantalk'), $sfw_die_page);
|
331 |
+
$sfw_die_page = str_replace('{CLEANTALK_TITLE}', __('Antispam by CleanTalk', 'cleantalk'), $sfw_die_page);
|
332 |
+
}else{
|
333 |
+
$request_uri = $_SERVER['REQUEST_URI'];
|
334 |
+
$sfw_die_page = str_replace('{SFW_DIE_NOTICE_IP}', 'SpamFireWall is activated for your IP ', $sfw_die_page);
|
335 |
+
$sfw_die_page = str_replace('{SFW_DIE_MAKE_SURE_JS_ENABLED}', 'To continue working with web site, please make sure that you have enabled JavaScript.', $sfw_die_page);
|
336 |
+
$sfw_die_page = str_replace('{SFW_DIE_CLICK_TO_PASS}', 'Please click bellow to pass protection,', $sfw_die_page);
|
337 |
+
$sfw_die_page = str_replace('{SFW_DIE_YOU_WILL_BE_REDIRECTED}', 'Or you will be automatically redirected to the requested page after 3 seconds.', $sfw_die_page);
|
338 |
+
$sfw_die_page = str_replace('{CLEANTALK_TITLE}', 'Antispam by CleanTalk', $sfw_die_page);
|
339 |
+
}
|
340 |
+
|
341 |
+
// Service info
|
342 |
+
$sfw_die_page = str_replace('{REMOTE_ADDRESS}', $this->blocked_ip, $sfw_die_page);
|
343 |
+
$sfw_die_page = str_replace('{REQUEST_URI}', $request_uri, $sfw_die_page);
|
344 |
+
$sfw_die_page = str_replace('{COOKIE_PREFIX}', $cookie_prefix, $sfw_die_page);
|
345 |
+
$sfw_die_page = str_replace('{COOKIE_DOMAIN}', $cookie_domain, $sfw_die_page);
|
346 |
+
$sfw_die_page = str_replace('{SFW_COOKIE}', md5($this->blocked_ip.$api_key), $sfw_die_page);
|
347 |
+
|
348 |
+
// Headers
|
349 |
+
if(headers_sent() === false){
|
350 |
+
header("Cache-Control: no-store, no-cache, must-revalidate");
|
351 |
+
header("Pragma: no-cache");
|
352 |
+
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
|
353 |
+
header("Expires: 0");
|
354 |
+
header("HTTP/1.0 403 Forbidden");
|
355 |
+
$sfw_die_page = str_replace('{GENERATED}', "", $sfw_die_page);
|
356 |
+
}else{
|
357 |
+
$sfw_die_page = str_replace('{GENERATED}', "<h2 class='second'>The page was generated at ".date("D, d M Y H:i:s")."</h2>",$sfw_die_page);
|
358 |
+
}
|
359 |
+
|
360 |
+
if(defined('WPINC')){
|
361 |
+
wp_die($sfw_die_page, "Blacklisted", Array('response'=>403));
|
362 |
+
}else{
|
363 |
+
die($sfw_die_page);
|
364 |
+
}
|
365 |
+
}
|
366 |
+
|
367 |
+
|
368 |
+
static public function sfwLogs($api_key, $data){
|
369 |
+
$url='https://api.cleantalk.org';
|
370 |
+
$request = array(
|
371 |
+
'auth_key' => $api_key,
|
372 |
+
'method_name' => 'sfw_logs',
|
373 |
+
'data' => json_encode($data),
|
374 |
+
'rows' => count($data),
|
375 |
+
'timestamp' => time()
|
376 |
+
);
|
377 |
+
$result = self::sendRawRequest($url, $request);
|
378 |
+
return $result;
|
379 |
+
}
|
380 |
+
|
381 |
+
static public function get_2sBlacklistsDb($api_key){
|
382 |
+
$url='https://api.cleantalk.org';
|
383 |
+
$request = array(
|
384 |
+
'auth_key' => $api_key,
|
385 |
+
'method_name' => '2s_blacklists_db'
|
386 |
+
);
|
387 |
+
$result = self::sendRawRequest($url, $request);
|
388 |
+
return $result;
|
389 |
+
}
|
390 |
+
|
391 |
+
/**
|
392 |
+
* Function sends raw request to API server
|
393 |
+
*
|
394 |
+
* @param string url of API server
|
395 |
+
* @param array data to send
|
396 |
+
* @param boolean is data have to be JSON encoded or not
|
397 |
+
* @param integer connect timeout
|
398 |
+
* @return type
|
399 |
+
*/
|
400 |
+
static public function sendRawRequest($url,$data,$isJSON=false,$timeout=3){
|
401 |
+
|
402 |
+
$result=null;
|
403 |
+
if(!$isJSON){
|
404 |
+
$data=http_build_query($data);
|
405 |
+
$data=str_replace("&", "&", $data);
|
406 |
+
}else{
|
407 |
+
$data= json_encode($data);
|
408 |
+
}
|
409 |
+
|
410 |
+
$curl_exec=false;
|
411 |
+
if (function_exists('curl_init') && function_exists('json_decode')){
|
412 |
+
|
413 |
+
$ch = curl_init();
|
414 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
415 |
+
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
|
416 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
417 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
418 |
+
|
419 |
+
// receive server response ...
|
420 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
421 |
+
// resolve 'Expect: 100-continue' issue
|
422 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
|
423 |
+
|
424 |
+
$result = curl_exec($ch);
|
425 |
+
|
426 |
+
if($result!==false){
|
427 |
+
$curl_exec=true;
|
428 |
+
}
|
429 |
+
|
430 |
+
curl_close($ch);
|
431 |
+
}
|
432 |
+
if(!$curl_exec){
|
433 |
+
|
434 |
+
$opts = array(
|
435 |
+
'http'=>array(
|
436 |
+
'method' => "POST",
|
437 |
+
'timeout'=> $timeout,
|
438 |
+
'content' => $data
|
439 |
+
)
|
440 |
+
);
|
441 |
+
$context = stream_context_create($opts);
|
442 |
+
$result = @file_get_contents($url, 0, $context);
|
443 |
+
}
|
444 |
+
return $result;
|
445 |
+
}
|
446 |
+
|
447 |
+
/**
|
448 |
+
* Function checks server response
|
449 |
+
*
|
450 |
+
* @param string request_method
|
451 |
+
* @param string result
|
452 |
+
* @return mixed (array || false)
|
453 |
+
*/
|
454 |
+
static public function checkRequestResult($result, $method_name = false){
|
455 |
+
|
456 |
+
// Errors handling
|
457 |
+
// Bad connection
|
458 |
+
if(empty($result)){
|
459 |
+
$result = array(
|
460 |
+
'error' => true,
|
461 |
+
'error_string' => 'CONNECTION_ERROR'
|
462 |
+
);
|
463 |
+
return $result;
|
464 |
+
}
|
465 |
+
|
466 |
+
// JSON decode errors
|
467 |
+
$result = json_decode($result, true);
|
468 |
+
if(empty($result)){
|
469 |
+
$result = array(
|
470 |
+
'error' => true,
|
471 |
+
'error_string' => 'JSON_DECODE_ERROR'
|
472 |
+
);
|
473 |
+
return $result;
|
474 |
+
}
|
475 |
+
|
476 |
+
// Server errors
|
477 |
+
if($result && (isset($result['error_no']) || isset($result['error_message']))){
|
478 |
+
$result = array(
|
479 |
+
'error' => true,
|
480 |
+
'error_string' => "SERVER_ERROR NO:{$result['error_no']} MSG:{$result['error_message']}",
|
481 |
+
'error_no' => $result['error_no'],
|
482 |
+
'error_message' => $result['error_message']
|
483 |
+
);
|
484 |
+
return $result;
|
485 |
+
}
|
486 |
+
|
487 |
+
/* mehod_name = notice_validate_key */
|
488 |
+
if($method_name == 'notice_validate_key' && isset($result['valid'])){
|
489 |
+
$result['error'] = false;
|
490 |
+
return $result;
|
491 |
+
}
|
492 |
+
|
493 |
+
/* Other methods */
|
494 |
+
if(isset($result['data']) && is_array($result['data'])){
|
495 |
+
$result = $result['data'];
|
496 |
+
}
|
497 |
+
|
498 |
+
return $result;
|
499 |
+
}
|
500 |
+
}
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: znaeff, shagimuratov, serge00, sartemd174, amagsumov
|
|
3 |
Tags: antispam, protection, contact form, comments, spam
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 4.8
|
6 |
-
Stable tag: 5.
|
7 |
License: GPLv2
|
8 |
|
9 |
Spam protection, antispam, all-in-one, premium plugin. No spam comments & users, no spam contact form & WooCommerce spam. Forget spam.
|
@@ -504,6 +504,17 @@ We develop plugin to do it as optimized as possible, CleanTalk doesn't downgrade
|
|
504 |
1. The Dashboard with a map of most spam active countries per your account.
|
505 |
|
506 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
507 |
= 5.69 July 3 2017 =
|
508 |
* Reviewer - integration.
|
509 |
* Optimization for Users and Comments check for big databases.
|
@@ -1381,6 +1392,17 @@ We develop plugin to do it as optimized as possible, CleanTalk doesn't downgrade
|
|
1381 |
* First version
|
1382 |
|
1383 |
== Upgrade Notice ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1384 |
= 5.69 July 3 2017 =
|
1385 |
* Reviewer - integration.
|
1386 |
* Optimization for Users and Comments check for big databases.
|
3 |
Tags: antispam, protection, contact form, comments, spam
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 4.8
|
6 |
+
Stable tag: 5.70
|
7 |
License: GPLv2
|
8 |
|
9 |
Spam protection, antispam, all-in-one, premium plugin. No spam comments & users, no spam contact form & WooCommerce spam. Forget spam.
|
504 |
1. The Dashboard with a map of most spam active countries per your account.
|
505 |
|
506 |
== Changelog ==
|
507 |
+
= 5.70 July 13 2017 =
|
508 |
+
* New updater logic.
|
509 |
+
* Self cron system.
|
510 |
+
* Improved AMP compatibility.
|
511 |
+
* Optimization.
|
512 |
+
* Fixed users and comments spam check.
|
513 |
+
* Fixed layout for Comment's feedback from public page.
|
514 |
+
* Updated SpamFireWall.
|
515 |
+
* SFW: SpamFireWall counter now work in real-time.
|
516 |
+
* SFW: Improved compatibility with different Data Bases.
|
517 |
+
|
518 |
= 5.69 July 3 2017 =
|
519 |
* Reviewer - integration.
|
520 |
* Optimization for Users and Comments check for big databases.
|
1392 |
* First version
|
1393 |
|
1394 |
== Upgrade Notice ==
|
1395 |
+
= 5.70 July 13 2017 =
|
1396 |
+
* New updater logic.
|
1397 |
+
* Self cron system.
|
1398 |
+
* Improved AMP compatibility.
|
1399 |
+
* Optimization.
|
1400 |
+
* Fixed users and comments spam check.
|
1401 |
+
* Fixed layout for Comment's feedback from public page.
|
1402 |
+
* Updated SpamFireWall.
|
1403 |
+
* SFW: SpamFireWall counter now work in real-time.
|
1404 |
+
* SFW: Improved compatibility with different Data Bases.
|
1405 |
+
|
1406 |
= 5.69 July 3 2017 =
|
1407 |
* Reviewer - integration.
|
1408 |
* Optimization for Users and Comments check for big databases.
|