PluginProbe
Loginizer / 1.8.3
Loginizer v1.8.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 1.8.3, at main/ajax.php

159 lines 4.1 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_newsletter', 'loginizer_dismiss_newsletter');
12 add_action('wp_ajax_loginizer_failed_login_export', 'loginizer_failed_login_export');
13 add_action('wp_ajax_loginizer_export', 'loginizer_export');
14
15
16 // ----- FUNCTIONS ------//
17
18 function loginizer_dismiss_csrf(){
19
20 // Some AJAX security
21 check_ajax_referer('loginizer_admin_ajax', 'nonce');
22
23 if(!current_user_can('manage_options')){
24 wp_die('Sorry, but you do not have permissions to change settings.');
25 }
26
27 update_option('loginizer_csrf_promo_time', (0 - time()));
28 echo 1;
29 wp_die();
30 }
31
32 function loginizer_dismiss_backuply(){
33
34 // Some AJAX security
35 check_ajax_referer('loginizer_admin_ajax', 'nonce');
36
37 if(!current_user_can('manage_options')){
38 wp_die('Sorry, but you do not have permissions to change settings.');
39 }
40
41 update_option('loginizer_backuply_promo_time', (0 - time()));
42 echo 1;
43 wp_die();
44 }
45
46 function loginizer_dismiss_newsletter(){
47
48 // Some AJAX security
49 check_ajax_referer('loginizer_admin_ajax', 'nonce');
50
51 if(!current_user_can('manage_options')){
52 wp_die('Sorry, but you do not have permissions to change settings.');
53 }
54
55 update_option('loginizer_dismiss_newsletter', time());
56 echo 1;
57 wp_die();
58 }
59
60 //Export Failed Login Attempts
61 function loginizer_failed_login_export(){
62
63 global $wpdb;
64 // Some AJAX security
65 check_ajax_referer('loginizer_admin_ajax', 'nonce');
66
67 if(!current_user_can('manage_options')){
68 wp_die('Sorry, but you do not have permissions to change settings.');
69 }
70
71 $csv_array = lz_selectquery("SELECT * FROM `".$wpdb->prefix."loginizer_logs` ORDER BY `time` DESC", 1);
72 $filename = 'loginizer-failed-login-attempts';
73
74 if(empty($csv_array)){
75 echo -1;
76 echo __('No data to export', 'loginizer');
77 wp_die();
78 }
79
80 header('Content-Type: text/csv; charset=utf-8');
81 header('Content-Disposition: attachment; filename='.$filename.'.csv');
82
83 $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');
84
85 $file = fopen("php://output","w");
86
87 fputcsv($file, array_values($allowed_fields));
88
89 foreach($csv_array as $failed_attempts){
90
91 $row = array($failed_attempts['ip'], $failed_attempts['username'], date('d/M/Y H:i:s P', $failed_attempts['time']), $failed_attempts['count'], $failed_attempts['lockout'], $failed_attempts['url']);
92 fputcsv($file, $row);
93 }
94
95
96 fclose($file);
97
98 wp_die();
99
100 }
101
102 // Export CSV
103 function loginizer_export(){
104
105 // Some AJAX security
106 check_ajax_referer('loginizer_admin_ajax', 'nonce');
107
108 if(!current_user_can('manage_options')){
109 wp_die('Sorry, but you do not have permissions to change settings.');
110 }
111
112 $lz_csv_type = lz_optpost('lz_csv_type');
113
114 switch($lz_csv_type){
115
116 case 'blacklist':
117 $csv_array = get_option('loginizer_blacklist');
118 $filename = 'loginizer-blacklist';
119 break;
120
121 case 'whitelist':
122 $csv_array = get_option('loginizer_whitelist');
123 $filename = 'loginizer-whitelist';
124 break;
125 }
126
127 if(empty($csv_array)){
128 echo -1;
129 echo __('No data to export', 'loginizer');
130 wp_die();
131 }
132
133 header('Content-Type: text/csv; charset=utf-8');
134 header('Content-Disposition: attachment; filename='.$filename.'.csv');
135
136 $allowed_fields = array('start' => 'Start IP', 'end' => 'End IP', 'time' => 'Time');
137
138 $file = fopen("php://output","w");
139
140 fputcsv($file, array_values($allowed_fields));
141
142 foreach($csv_array as $ik => $iv){
143
144 $iv['start'] = $iv['start'];
145 $iv['end'] = $iv['end'];
146 $iv['time'] = date('d/m/Y', $iv['time']);
147
148 $row = array();
149 foreach($allowed_fields as $ak => $av){
150 $row[$ak] = $iv[$ak];
151 }
152
153 fputcsv($file, $row);
154 }
155
156 fclose($file);
157
158 wp_die();
159 }