PluginProbe
Loginizer / 2.0.3
Loginizer v2.0.3
2.1.0 2.0.9 2.0.8 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 All 74 releases
loginizer / main / ajax.php

ajax.php in Loginizer 2.0.3, at main/ajax.php

245 lines 6.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if(!defined('ABSPATH')){
4 die('Hacking Attempt!');
5 }
6
7
8 // ------- ACTIONS -------/
9 add_action('wp_ajax_loginizer_dismiss_csrf', 'loginizer_dismiss_csrf');
10 add_action('wp_ajax_loginizer_dismiss_backuply', 'loginizer_dismiss_backuply');
11 add_action('wp_ajax_loginizer_dismiss_social_alert', 'loginizer_dismiss_social_alert');
12 add_action('wp_ajax_loginizer_dismiss_newsletter', 'loginizer_dismiss_newsletter');
13 add_action('wp_ajax_loginizer_failed_login_export', 'loginizer_failed_login_export');
14 add_action('wp_ajax_loginizer_export', 'loginizer_export');
15 add_action('wp_ajax_loginizer_social_order', 'loginizer_social_order');
16 add_action('wp_ajax_loginizer_dismiss_license_alert', 'loginizer_dismiss_license_alert');
17 add_action('wp_ajax_loginizer_dismiss_softwp_alert', 'loginizer_dismiss_softwp_alert');
18 add_action('wp_ajax_loginizer_close_update_notice', 'loginizer_close_update_notice');
19
20 // ----- FUNCTIONS ------//
21
22 function loginizer_dismiss_csrf(){
23
24 // Some AJAX security
25 check_ajax_referer('loginizer_admin_ajax', 'nonce');
26
27 if(!current_user_can('manage_options')){
28 wp_die('Sorry, but you do not have permissions to change settings.');
29 }
30
31 update_option('loginizer_csrf_promo_time', (0 - time()));
32 echo 1;
33 wp_die();
34 }
35
36 function loginizer_dismiss_social_alert(){
37
38 // Some AJAX security
39 check_ajax_referer('loginizer_admin_ajax', 'nonce');
40
41 if(!current_user_can('manage_options')){
42 wp_send_json_error('Sorry, but you do not have permissions to change settings.');
43 }
44
45 update_option('loginizer_social_login_url', wp_login_url());
46
47 wp_send_json_success();
48 }
49
50 function loginizer_dismiss_backuply(){
51
52 // Some AJAX security
53 check_ajax_referer('loginizer_admin_ajax', 'nonce');
54
55 if(!current_user_can('manage_options')){
56 wp_die('Sorry, but you do not have permissions to change settings.');
57 }
58
59 update_option('loginizer_backuply_promo_time', (0 - time()));
60 echo 1;
61 wp_die();
62 }
63
64 function loginizer_dismiss_newsletter(){
65
66 // Some AJAX security
67 check_ajax_referer('loginizer_admin_ajax', 'nonce');
68
69 if(!current_user_can('manage_options')){
70 wp_die('Sorry, but you do not have permissions to change settings.');
71 }
72
73 update_option('loginizer_dismiss_newsletter', time());
74 echo 1;
75 wp_die();
76 }
77
78 //Export Failed Login Attempts
79 function loginizer_failed_login_export(){
80
81 global $wpdb;
82 // Some AJAX security
83 check_ajax_referer('loginizer_admin_ajax', 'nonce');
84
85 if(!current_user_can('manage_options')){
86 wp_die('Sorry, but you do not have permissions to change settings.');
87 }
88
89 $csv_array = lz_selectquery("SELECT * FROM `".$wpdb->prefix."loginizer_logs` ORDER BY `time` DESC", 1);
90 $filename = 'loginizer-failed-login-attempts';
91
92 if(empty($csv_array)){
93 echo -1;
94 echo __('No data to export', 'loginizer');
95 wp_die();
96 }
97
98 header('Content-Type: text/csv; charset=utf-8');
99 header('Content-Disposition: attachment; filename='.$filename.'.csv');
100
101 $allowed_fields = array('ip' => 'IP', 'attempted_username' => 'Attempted Username', 'last_f_attemp' => 'Last Failed Attempt', 'f_attempts_count' => 'Failed Attempts Count', 'lockouts_count' => 'Lockouts Count', 'url_attacked' => 'URL Attacked');
102
103 $file = fopen("php://output","w");
104
105 fputcsv($file, array_values($allowed_fields));
106
107 foreach($csv_array as $failed_attempts){
108
109 $row = array($failed_attempts['ip'], sanitize_user($failed_attempts['username'], true), date('d/M/Y H:i:s P', $failed_attempts['time']), $failed_attempts['count'], $failed_attempts['lockout'], $failed_attempts['url']);
110 fputcsv($file, $row);
111 }
112
113
114 fclose($file);
115
116 wp_die();
117
118 }
119
120 // Export CSV
121 function loginizer_export(){
122
123 // Some AJAX security
124 check_ajax_referer('loginizer_admin_ajax', 'nonce');
125
126 if(!current_user_can('manage_options')){
127 wp_die('Sorry, but you do not have permissions to change settings.');
128 }
129
130 $lz_csv_type = lz_optpost('lz_csv_type');
131
132 switch($lz_csv_type){
133
134 case 'blacklist':
135 $csv_array = get_option('loginizer_blacklist');
136 $filename = 'loginizer-blacklist';
137 break;
138
139 case 'whitelist':
140 $csv_array = get_option('loginizer_whitelist');
141 $filename = 'loginizer-whitelist';
142 break;
143 }
144
145 if(empty($csv_array)){
146 echo -1;
147 echo __('No data to export', 'loginizer');
148 wp_die();
149 }
150
151 header('Content-Type: text/csv; charset=utf-8');
152 header('Content-Disposition: attachment; filename='.$filename.'.csv');
153
154 $allowed_fields = array('start' => 'Start IP', 'end' => 'End IP', 'time' => 'Time');
155
156 $file = fopen("php://output","w");
157
158 fputcsv($file, array_values($allowed_fields));
159
160 foreach($csv_array as $ik => $iv){
161
162 $iv['start'] = $iv['start'];
163 $iv['end'] = $iv['end'];
164 $iv['time'] = date('d/m/Y', $iv['time']);
165
166 $row = array();
167 foreach($allowed_fields as $ak => $av){
168 $row[$ak] = $iv[$ak];
169 }
170
171 fputcsv($file, $row);
172 }
173
174 fclose($file);
175
176 wp_die();
177 }
178
179 function loginizer_social_order(){
180
181 // Some AJAX security
182 check_ajax_referer('loginizer_social_nonce', 'security');
183
184 if(!current_user_can('manage_options')){
185 wp_die(__('Sorry, but you do not have permissions to change settings.', 'loginizer'));
186 }
187
188 $order = map_deep(map_deep($_POST['order'], 'wp_unslash'), 'sanitize_text_field');
189
190 update_option('loginizer_social_order', array_flip($order));
191
192 wp_send_json_success();
193
194 }
195
196 function loginizer_dismiss_license_alert(){
197 // Some AJAX security
198 check_ajax_referer('loginizer_license_notice', 'security');
199
200 if(!current_user_can('manage_options')){
201 wp_die(__('Sorry, but you do not have permissions to change settings.', 'loginizer'));
202 }
203
204 update_option('loginizer_license_notice', (0 - time()), false);
205 die('DONE');
206 }
207
208 function loginizer_dismiss_softwp_alert(){
209 // Some AJAX security
210 check_ajax_referer('loginizer_softwp_notice', 'security');
211
212 if(!current_user_can('activate_plugins')){
213 wp_die(__('Sorry, but you do not have permissions to change settings.', 'loginizer'));
214 }
215
216 update_option('loginizer_softwp_upgrade', (0 - time()), false);
217 die('DONE');
218 }
219
220 function loginizer_close_update_notice(){
221
222 if(!wp_verify_nonce($_GET['security'], 'loginizer_promo_nonce')){
223 wp_send_json_error('Security Check failed!');
224 }
225
226 if(!current_user_can('manage_options')){
227 wp_send_json_error('You don\'t have privilege to close this notice!');
228 }
229
230 $plugin_update_notice = get_option('softaculous_plugin_update_notice', []);
231 $available_update_list = get_site_transient('update_plugins');
232 $to_update_plugins = apply_filters('softaculous_plugin_update_notice', []);
233
234 if(empty($available_update_list) || empty($available_update_list->response)){
235 return;
236 }
237
238 foreach($to_update_plugins as $plugin_path => $plugin_name){
239 if(isset($available_update_list->response[$plugin_path])){
240 $plugin_update_notice[$plugin_path] = $available_update_list->response[$plugin_path]->new_version;
241 }
242 }
243
244 update_option('softaculous_plugin_update_notice', $plugin_update_notice);
245 }