Version Description
Download this release
Release Info
Developer | Vlad Cleantalk |
Plugin | Spam protection, AntiSpam, FireWall by CleanTalk |
Version | ajax-devel |
Comparing to | |
See all releases |
Code changes from version 4.22 to ajax-devel
- cleantalk-ajax.php +175 -0
- cleantalk.php +6 -0
cleantalk-ajax.php
ADDED
@@ -0,0 +1,175 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?
|
2 |
+
|
3 |
+
/*
|
4 |
+
AJAX functions
|
5 |
+
*/
|
6 |
+
|
7 |
+
/*hooks for AJAX Login & Register email validation*/
|
8 |
+
add_action( 'wp_ajax_nopriv_validate_email', 'ct_validate_email_ajaxlogin',1 );
|
9 |
+
add_action( 'wp_ajax_validate_email', 'ct_validate_email_ajaxlogin',1 );
|
10 |
+
|
11 |
+
/*hooks for user registration*/
|
12 |
+
add_action( 'user_register', 'ct_user_register_ajaxlogin',1 );
|
13 |
+
|
14 |
+
|
15 |
+
function ct_validate_email_ajaxlogin($email=null, $is_ajax=true)
|
16 |
+
{
|
17 |
+
require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-public.php');
|
18 |
+
global $ct_agent_version, $ct_checkjs_register_form, $ct_session_request_id_label, $ct_session_register_ok_label, $bp, $ct_signup_done, $ct_formtime_label, $ct_negative_comment, $ct_options;
|
19 |
+
|
20 |
+
$ct_options=ct_get_options();
|
21 |
+
|
22 |
+
$email = is_null( $email ) ? $email : $_POST['email'];
|
23 |
+
$email=sanitize_email($email);
|
24 |
+
$is_good=true;
|
25 |
+
if ( ! filter_var( $email, FILTER_VALIDATE_EMAIL )||email_exists( $email ) )
|
26 |
+
{
|
27 |
+
$is_good=false;
|
28 |
+
}
|
29 |
+
|
30 |
+
if(class_exists('AjaxLogin')&&isset($_POST['action'])&&$_POST['action']=='validate_email')
|
31 |
+
{
|
32 |
+
|
33 |
+
$ct_options=ct_get_options();
|
34 |
+
$checkjs = js_test('ct_checkjs', $_COOKIE, true);
|
35 |
+
$submit_time = submit_time_test();
|
36 |
+
$sender_info = get_sender_info();
|
37 |
+
$sender_info['post_checkjs_passed']=$checkjs;
|
38 |
+
|
39 |
+
if ($checkjs === null)
|
40 |
+
{
|
41 |
+
$checkjs = js_test('ct_checkjs', $_COOKIE, true);
|
42 |
+
$sender_info['cookie_checkjs_passed'] = $checkjs;
|
43 |
+
}
|
44 |
+
|
45 |
+
$sender_info = json_encode($sender_info);
|
46 |
+
if ($sender_info === false)
|
47 |
+
{
|
48 |
+
$sender_info= '';
|
49 |
+
}
|
50 |
+
|
51 |
+
require_once('cleantalk.class.php');
|
52 |
+
$config = get_option('cleantalk_server');
|
53 |
+
$ct = new Cleantalk();
|
54 |
+
$ct->work_url = $config['ct_work_url'];
|
55 |
+
$ct->server_url = $ct_options['server'];
|
56 |
+
|
57 |
+
$ct->server_ttl = $config['ct_server_ttl'];
|
58 |
+
$ct->server_changed = $config['ct_server_changed'];
|
59 |
+
$ct->ssl_on = $ct_options['ssl_on'];
|
60 |
+
|
61 |
+
$ct_request = new CleantalkRequest();
|
62 |
+
$ct_request->auth_key = $ct_options['apikey'];
|
63 |
+
$ct_request->sender_email = $email;
|
64 |
+
$ct_request->sender_ip = $ct->ct_session_ip($_SERVER['REMOTE_ADDR']);
|
65 |
+
$ct_request->sender_nickname = '';
|
66 |
+
$ct_request->agent = $ct_agent_version;
|
67 |
+
$ct_request->sender_info = $sender_info;
|
68 |
+
$ct_request->js_on = $checkjs;
|
69 |
+
$ct_request->submit_time = $submit_time;
|
70 |
+
|
71 |
+
$ct_result = $ct->isAllowUser($ct_request);
|
72 |
+
|
73 |
+
if ($ct->server_change)
|
74 |
+
{
|
75 |
+
update_option(
|
76 |
+
'cleantalk_server', array(
|
77 |
+
'ct_work_url' => $ct->work_url,
|
78 |
+
'ct_server_ttl' => $ct->server_ttl,
|
79 |
+
'ct_server_changed' => time()
|
80 |
+
)
|
81 |
+
);
|
82 |
+
}
|
83 |
+
if ($ct_result->allow===0)
|
84 |
+
{
|
85 |
+
$is_good=false;
|
86 |
+
}
|
87 |
+
}
|
88 |
+
if($is_good)
|
89 |
+
{
|
90 |
+
$ajaxresult=array(
|
91 |
+
'description' => null,
|
92 |
+
'cssClass' => 'noon',
|
93 |
+
'code' => 'success'
|
94 |
+
);
|
95 |
+
}
|
96 |
+
else
|
97 |
+
{
|
98 |
+
$ajaxresult=array(
|
99 |
+
'description' => 'Invalid Email',
|
100 |
+
'cssClass' => 'error-container',
|
101 |
+
'code' => 'error'
|
102 |
+
);
|
103 |
+
}
|
104 |
+
$ajaxresult=json_encode($ajaxresult);
|
105 |
+
print $ajaxresult;
|
106 |
+
wp_die();
|
107 |
+
}
|
108 |
+
|
109 |
+
function ct_user_register_ajaxlogin($user_id)
|
110 |
+
{
|
111 |
+
require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-public.php');
|
112 |
+
global $ct_agent_version, $ct_checkjs_register_form, $ct_session_request_id_label, $ct_session_register_ok_label, $bp, $ct_signup_done, $ct_formtime_label, $ct_negative_comment, $ct_options;
|
113 |
+
|
114 |
+
$ct_options=ct_get_options();
|
115 |
+
|
116 |
+
if(class_exists('AjaxLogin')&&isset($_POST['action'])&&$_POST['action']=='register_submit')
|
117 |
+
{
|
118 |
+
$checkjs = js_test('ct_checkjs', $_COOKIE, true);
|
119 |
+
$submit_time = submit_time_test();
|
120 |
+
$sender_info = get_sender_info();
|
121 |
+
$sender_info['post_checkjs_passed']=$checkjs;
|
122 |
+
|
123 |
+
if ($checkjs === null)
|
124 |
+
{
|
125 |
+
$checkjs = js_test('ct_checkjs', $_COOKIE, true);
|
126 |
+
$sender_info['cookie_checkjs_passed'] = $checkjs;
|
127 |
+
}
|
128 |
+
|
129 |
+
$sender_info = json_encode($sender_info);
|
130 |
+
if ($sender_info === false)
|
131 |
+
{
|
132 |
+
$sender_info= '';
|
133 |
+
}
|
134 |
+
|
135 |
+
require_once('cleantalk.class.php');
|
136 |
+
$config = get_option('cleantalk_server');
|
137 |
+
$ct = new Cleantalk();
|
138 |
+
$ct->work_url = $config['ct_work_url'];
|
139 |
+
$ct->server_url = $ct_options['server'];
|
140 |
+
|
141 |
+
$ct->server_ttl = $config['ct_server_ttl'];
|
142 |
+
$ct->server_changed = $config['ct_server_changed'];
|
143 |
+
$ct->ssl_on = $ct_options['ssl_on'];
|
144 |
+
|
145 |
+
$ct_request = new CleantalkRequest();
|
146 |
+
$ct_request->auth_key = $ct_options['apikey'];
|
147 |
+
$ct_request->sender_email = sanitize_email($_POST['email']);
|
148 |
+
$ct_request->sender_ip = $ct->ct_session_ip($_SERVER['REMOTE_ADDR']);
|
149 |
+
$ct_request->sender_nickname = sanitize_email($_POST['login']); ;
|
150 |
+
$ct_request->agent = $ct_agent_version;
|
151 |
+
$ct_request->sender_info = $sender_info;
|
152 |
+
$ct_request->js_on = $checkjs;
|
153 |
+
$ct_request->submit_time = $submit_time;
|
154 |
+
|
155 |
+
$ct_result = $ct->isAllowUser($ct_request);
|
156 |
+
|
157 |
+
if ($ct->server_change)
|
158 |
+
{
|
159 |
+
update_option(
|
160 |
+
'cleantalk_server', array(
|
161 |
+
'ct_work_url' => $ct->work_url,
|
162 |
+
'ct_server_ttl' => $ct->server_ttl,
|
163 |
+
'ct_server_changed' => time()
|
164 |
+
)
|
165 |
+
);
|
166 |
+
}
|
167 |
+
if ($ct_result->allow===0)
|
168 |
+
{
|
169 |
+
wp_delete_user($user_id);
|
170 |
+
}
|
171 |
+
}
|
172 |
+
return $user_id;
|
173 |
+
}
|
174 |
+
|
175 |
+
?>
|
cleantalk.php
CHANGED
@@ -29,6 +29,12 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
|
|
29 |
add_action('admin_menu', 'ct_admin_add_page');
|
30 |
add_action('admin_notices', 'admin_notice_message');
|
31 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
add_action('admin_enqueue_scripts', 'ct_enqueue_scripts');
|
34 |
add_action('comment_unapproved_to_approvecomment', 'ct_comment_approved'); // param - comment object
|
29 |
add_action('admin_menu', 'ct_admin_add_page');
|
30 |
add_action('admin_notices', 'admin_notice_message');
|
31 |
}
|
32 |
+
|
33 |
+
if (defined( 'DOING_AJAX' ) && DOING_AJAX)
|
34 |
+
{
|
35 |
+
require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-public.php');
|
36 |
+
require_once(CLEANTALK_PLUGIN_DIR . 'cleantalk-ajax.php');
|
37 |
+
}
|
38 |
|
39 |
add_action('admin_enqueue_scripts', 'ct_enqueue_scripts');
|
40 |
add_action('comment_unapproved_to_approvecomment', 'ct_comment_approved'); // param - comment object
|