PluginProbe
Loginizer / 1.3.8
Loginizer v1.3.8
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 / init.php

init.php in Loginizer 1.3.8, at init.php

2,001 lines 61.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if(!function_exists('add_action')){
4 echo 'You are not allowed to access this page directly.';
5 exit;
6 }
7
8 define('LOGINIZER_VERSION', '1.3.8');
9 define('LOGINIZER_DIR', WP_PLUGIN_DIR.'/'.basename(dirname(LOGINIZER_FILE)));
10 define('LOGINIZER_URL', plugins_url('', LOGINIZER_FILE));
11 define('LOGINIZER_PRO_URL', 'https://loginizer.com/features#compare');
12 define('LOGINIZER_DOCS', 'https://loginizer.com/docs/');
13
14 include_once(LOGINIZER_DIR.'/functions.php');
15
16 // Ok so we are now ready to go
17 register_activation_hook(LOGINIZER_FILE, 'loginizer_activation');
18
19 // Is called when the ADMIN enables the plugin
20 function loginizer_activation(){
21
22 global $wpdb;
23
24 $sql = array();
25
26 $sql[] = "DROP TABLE IF EXISTS `".$wpdb->prefix."loginizer_logs`";
27
28 $sql[] = "CREATE TABLE `".$wpdb->prefix."loginizer_logs` (
29 `username` varchar(255) NOT NULL DEFAULT '',
30 `time` int(10) NOT NULL DEFAULT '0',
31 `count` int(10) NOT NULL DEFAULT '0',
32 `lockout` int(10) NOT NULL DEFAULT '0',
33 `ip` varchar(255) NOT NULL DEFAULT '',
34 UNIQUE KEY `ip` (`ip`)
35 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
36
37 foreach($sql as $sk => $sv){
38 $wpdb->query($sv);
39 }
40
41 add_option('loginizer_version', LOGINIZER_VERSION);
42 add_option('loginizer_options', array());
43 add_option('loginizer_last_reset', 0);
44 add_option('loginizer_whitelist', array());
45 add_option('loginizer_blacklist', array());
46
47 }
48
49 // Checks if we are to update ?
50 function loginizer_update_check(){
51
52 global $wpdb;
53
54 $sql = array();
55 $current_version = get_option('loginizer_version');
56
57 // It must be the 1.0 pre stuff
58 if(empty($current_version)){
59 $current_version = get_option('lz_version');
60 }
61
62 $version = (int) str_replace('.', '', $current_version);
63
64 // No update required
65 if($current_version == LOGINIZER_VERSION){
66 return true;
67 }
68
69 // Is it first run ?
70 if(empty($current_version)){
71
72 // Reinstall
73 loginizer_activation();
74
75 // Trick the following if conditions to not run
76 $version = (int) str_replace('.', '', LOGINIZER_VERSION);
77
78 }
79
80 // Is it less than 1.0.1 ?
81 if($version < 101){
82
83 // TODO : GET the existing settings
84
85 // Get the existing settings
86 $lz_failed_logs = lz_selectquery("SELECT * FROM `".$wpdb->prefix."lz_failed_logs`;", 1);
87 $lz_options = lz_selectquery("SELECT * FROM `".$wpdb->prefix."lz_options`;", 1);
88 $lz_iprange = lz_selectquery("SELECT * FROM `".$wpdb->prefix."lz_iprange`;", 1);
89
90 // Delete the three tables
91 $sql = array();
92 $sql[] = "DROP TABLE IF EXISTS ".$wpdb->prefix."lz_failed_logs;";
93 $sql[] = "DROP TABLE IF EXISTS ".$wpdb->prefix."lz_options;";
94 $sql[] = "DROP TABLE IF EXISTS ".$wpdb->prefix."lz_iprange;";
95
96 foreach($sql as $sk => $sv){
97 $wpdb->query($sv);
98 }
99
100 // Delete option
101 delete_option('lz_version');
102
103 // Reinstall
104 loginizer_activation();
105
106 // TODO : Save the existing settings
107
108 // Update the existing failed logs to new table
109 if(is_array($lz_failed_logs)){
110 foreach($lz_failed_logs as $fk => $fv){
111 $wpdb->query("INSERT INTO ".$wpdb->prefix."loginizer_logs SET `username` = '".$fv['username']."', `time` = '".$fv['time']."', `count` = '".$fv['count']."', `lockout` = '".$fv['lockout']."', `ip` = '".$fv['ip']."';");
112 }
113 }
114
115 // Update the existing options to new structure
116 if(is_array($lz_options)){
117 foreach($lz_options as $ok => $ov){
118
119 if($ov['option_name'] == 'lz_last_reset'){
120 update_option('loginizer_last_reset', $ov['option_value']);
121 continue;
122 }
123
124 $old_option[str_replace('lz_', '', $ov['option_name'])] = $ov['option_value'];
125 }
126 // Save the options
127 update_option('loginizer_options', $old_option);
128 }
129
130 // Update the existing iprange to new structure
131 if(is_array($lz_iprange)){
132
133 $old_blacklist = array();
134 $old_whitelist = array();
135 $bid = 1;
136 $wid = 1;
137 foreach($lz_iprange as $ik => $iv){
138
139 if(!empty($iv['blacklist'])){
140 $old_blacklist[$bid] = array();
141 $old_blacklist[$bid]['start'] = long2ip($iv['start']);
142 $old_blacklist[$bid]['end'] = long2ip($iv['end']);
143 $old_blacklist[$bid]['time'] = strtotime($iv['date']);
144 $bid = $bid + 1;
145 }
146
147 if(!empty($iv['whitelist'])){
148 $old_whitelist[$wid] = array();
149 $old_whitelist[$wid]['start'] = long2ip($iv['start']);
150 $old_whitelist[$wid]['end'] = long2ip($iv['end']);
151 $old_whitelist[$wid]['time'] = strtotime($iv['date']);
152 $wid = $wid + 1;
153 }
154 }
155
156 if(!empty($old_blacklist)) update_option('loginizer_blacklist', $old_blacklist);
157 if(!empty($old_whitelist)) update_option('loginizer_whitelist', $old_whitelist);
158 }
159
160 }
161
162 // Save the new Version
163 update_option('loginizer_version', LOGINIZER_VERSION);
164
165 }
166
167 // Add the action to load the plugin
168 add_action('plugins_loaded', 'loginizer_load_plugin');
169
170 // The function that will be called when the plugin is loaded
171 function loginizer_load_plugin(){
172
173 global $loginizer;
174
175 // Check if the installed version is outdated
176 loginizer_update_check();
177
178 // Set the array
179 $loginizer = array();
180
181 // The IP Method to use
182 $loginizer['ip_method'] = get_option('loginizer_ip_method');
183 if($loginizer['ip_method'] == 3){
184 $loginizer['custom_ip_method'] = get_option('loginizer_custom_ip_method');
185 }
186
187 // Load settings
188 $options = get_option('loginizer_options');
189 $loginizer['max_retries'] = empty($options['max_retries']) ? 3 : $options['max_retries'];
190 $loginizer['lockout_time'] = empty($options['lockout_time']) ? 900 : $options['lockout_time']; // 15 minutes
191 $loginizer['max_lockouts'] = empty($options['max_lockouts']) ? 5 : $options['max_lockouts'];
192 $loginizer['lockouts_extend'] = empty($options['lockouts_extend']) ? 86400 : $options['lockouts_extend']; // 24 hours
193 $loginizer['reset_retries'] = empty($options['reset_retries']) ? 86400 : $options['reset_retries']; // 24 hours
194 $loginizer['notify_email'] = empty($options['notify_email']) ? 0 : $options['notify_email'];
195
196 // Default messages
197 $loginizer['d_msg']['inv_userpass'] = 'Incorrect Username or Password';
198 $loginizer['d_msg']['ip_blacklisted'] = 'Your IP has been blacklisted';
199
200 // Message Strings
201 $loginizer['msg'] = get_option('loginizer_msg');
202
203 foreach($loginizer['d_msg'] as $lk => $lv){
204 if(empty($loginizer['msg'][$lk])){
205 $loginizer['msg'][$lk] = $loginizer['d_msg'][$lk];
206 }
207 }
208
209 // Load the blacklist and whitelist
210 $loginizer['blacklist'] = get_option('loginizer_blacklist');
211 $loginizer['whitelist'] = get_option('loginizer_whitelist');
212
213 // When was the database cleared last time
214 $loginizer['last_reset'] = get_option('loginizer_last_reset');
215
216 //print_r($loginizer);
217
218 // Clear retries
219 if((time() - $loginizer['last_reset']) >= $loginizer['reset_retries']){
220 loginizer_reset_retries();
221 }
222
223 $ins_time = get_option('loginizer_ins_time');
224 if(empty($ins_time)){
225 $ins_time = time();
226 update_option('loginizer_ins_time', $ins_time);
227 }
228 $loginizer['ins_time'] = $ins_time;
229
230 // Set the current IP
231 $loginizer['current_ip'] = lz_getip();
232
233 /* Filters and actions */
234
235 // Use this to verify before WP tries to login
236 // Is always called and is the first function to be called
237 //add_action('wp_authenticate', 'loginizer_wp_authenticate', 10, 2);// Not called by XML-RPC
238 add_filter('authenticate', 'loginizer_wp_authenticate', 10001, 3);// This one is called by xmlrpc as well as GUI
239
240 // Is called when a login attempt fails
241 // Hence Update our records that the login failed
242 add_action('wp_login_failed', 'loginizer_login_failed');
243
244 // Is called before displaying the error message so that we dont show that the username is wrong or the password
245 // Update Error message
246 add_action('wp_login_errors', 'loginizer_error_handler', 10001, 2);
247 add_action('woocommerce_login_failed', 'loginizer_woocommerce_error_handler', 10001);
248
249 // Is the premium features there ?
250 if(file_exists(LOGINIZER_DIR.'/premium.php')){
251
252 // Include the file
253 include_once(LOGINIZER_DIR.'/premium.php');
254
255 loginizer_security_init();
256
257 // Its the free version
258 }else{
259
260 // The promo time
261 $loginizer['promo_time'] = get_option('loginizer_promo_time');
262 if(empty($loginizer['promo_time'])){
263 $loginizer['promo_time'] = time();
264 update_option('loginizer_promo_time', $loginizer['promo_time']);
265 }
266
267 // Are we to show the loginizer promo
268 if(!empty($loginizer['promo_time']) && $loginizer['promo_time'] > 0 && $loginizer['promo_time'] < (time() - (30*24*3600))){
269
270 add_action('admin_notices', 'loginizer_promo');
271
272 }
273
274 // Are we to disable the promo
275 if(isset($_GET['loginizer_promo']) && (int)$_GET['loginizer_promo'] == 0){
276 update_option('loginizer_promo_time', (0 - time()) );
277 die('DONE');
278 }
279
280 }
281
282 }
283
284 // Show the promo
285 function loginizer_promo(){
286
287 echo '
288 <style>
289 .lz_button {
290 background-color: #4CAF50; /* Green */
291 border: none;
292 color: white;
293 padding: 8px 16px;
294 text-align: center;
295 text-decoration: none;
296 display: inline-block;
297 font-size: 16px;
298 margin: 4px 2px;
299 -webkit-transition-duration: 0.4s; /* Safari */
300 transition-duration: 0.4s;
301 cursor: pointer;
302 }
303
304 .lz_button:focus{
305 border: none;
306 color: white;
307 }
308
309 .lz_button1 {
310 color: white;
311 background-color: #4CAF50;
312 border:3px solid #4CAF50;
313 }
314
315 .lz_button1:hover {
316 box-shadow: 0 6px 8px 0 rgba(0,0,0,0.24), 0 9px 25px 0 rgba(0,0,0,0.19);
317 color: white;
318 border:3px solid #4CAF50;
319 }
320
321 .lz_button2 {
322 color: white;
323 background-color: #0085ba;
324 }
325
326 .lz_button2:hover {
327 box-shadow: 0 6px 8px 0 rgba(0,0,0,0.24), 0 9px 25px 0 rgba(0,0,0,0.19);
328 color: white;
329 }
330
331 .lz_button3 {
332 color: white;
333 background-color: #365899;
334 }
335
336 .lz_button3:hover {
337 box-shadow: 0 6px 8px 0 rgba(0,0,0,0.24), 0 9px 25px 0 rgba(0,0,0,0.19);
338 color: white;
339 }
340
341 .lz_button4 {
342 color: white;
343 background-color: rgb(66, 184, 221);
344 }
345
346 .lz_button4:hover {
347 box-shadow: 0 6px 8px 0 rgba(0,0,0,0.24), 0 9px 25px 0 rgba(0,0,0,0.19);
348 color: white;
349 }
350
351 .loginizer_promo-close{
352 float:right;
353 text-decoration:none;
354 margin: 5px 10px 0px 0px;
355 }
356
357 .loginizer_promo-close:hover{
358 color: red;
359 }
360 </style>
361
362 <script>
363 jQuery(document).ready( function() {
364 (function($) {
365 $("#loginizer_promo .loginizer_promo-close").click(function(){
366 var data;
367
368 // Hide it
369 $("#loginizer_promo").hide();
370
371 // Save this preference
372 $.post("'.admin_url('?loginizer_promo=0').'", data, function(response) {
373 //alert(response);
374 });
375 });
376 })(jQuery);
377 });
378 </script>
379
380 <div class="notice notice-success" id="loginizer_promo" style="min-height:120px">
381 <a class="loginizer_promo-close" href="javascript:" aria-label="Dismiss this Notice">
382 <span class="dashicons dashicons-dismiss"></span> Dismiss
383 </a>
384 <img src="'.LOGINIZER_URL.'/loginizer-200.png" style="float:left; margin:10px 20px 10px 10px" width="100" />
385 <p style="font-size:16px">We are glad you like Loginizer and have been using it since the past few days. It is time to take the next step </p>
386 <p>
387 <a class="lz_button lz_button1" target="_blank" href="https://loginizer.com/features">Upgrade to Pro</a>
388 <a class="lz_button lz_button2" target="_blank" href="https://wordpress.org/support/view/plugin-reviews/loginizer">Rate it 5�
389 \'s</a>
390 <a class="lz_button lz_button3" target="_blank" href="https://www.facebook.com/Loginizer-815504798591884/">Like Us on Facebook</a>
391 <a class="lz_button lz_button4" target="_blank" href="https://twitter.com/home?status='.rawurlencode('I use @loginizer to secure my #WordPress site - https://loginizer.com').'">Tweet about Loginizer</a>
392 </p>
393 </div>';
394
395 }
396
397 // Should return NULL if everything is fine
398 function loginizer_wp_authenticate($user, $username, $password){
399
400 global $loginizer, $lz_error, $lz_cannot_login, $lz_user_pass;
401
402 if(!empty($username) && !empty($password)){
403 $lz_user_pass = 1;
404 }
405
406 // Are you whitelisted ?
407 if(loginizer_is_whitelisted()){
408 $loginizer['ip_is_whitelisted'] = 1;
409 return $user;
410 }
411
412 // Are you blacklisted ?
413 if(loginizer_is_blacklisted()){
414 $lz_cannot_login = 1;
415 return new WP_Error('ip_blacklisted', implode('', $lz_error), 'loginizer');
416 }
417
418 // Is the username blacklisted ?
419 if(function_exists('loginizer_user_blacklisted')){
420 if(loginizer_user_blacklisted($username)){
421 $lz_cannot_login = 1;
422 return new WP_Error('user_blacklisted', implode('', $lz_error), 'loginizer');
423 }
424 }
425
426 if(loginizer_can_login()){
427 return $user;
428 }
429
430 $lz_cannot_login = 1;
431
432 return new WP_Error('ip_blocked', implode('', $lz_error), 'loginizer');
433
434 }
435
436 function loginizer_can_login(){
437
438 global $wpdb, $loginizer, $lz_error;
439
440 // Get the logs
441 $result = lz_selectquery("SELECT * FROM `".$wpdb->prefix."loginizer_logs` WHERE `ip` = '".$loginizer['current_ip']."';");
442
443 if(!empty($result['count']) && ($result['count'] % $loginizer['max_retries']) == 0){
444
445 // Has he reached max lockouts ?
446 if($result['lockout'] >= $loginizer['max_lockouts']){
447 $loginizer['lockout_time'] = $loginizer['lockouts_extend'];
448 }
449
450 // Is he in the lockout time ?
451 if($result['time'] >= (time() - $loginizer['lockout_time'])){
452 $banlift = ceil((($result['time'] + $loginizer['lockout_time']) - time()) / 60);
453
454 //echo 'Current Time '.date('m/d/Y H:i:s', time()).'<br />';
455 //echo 'Last attempt '.date('m/d/Y H:i:s', $result['time']).'<br />';
456 //echo 'Unlock Time '.date('m/d/Y H:i:s', $result['time'] + $loginizer['lockout_time']).'<br />';
457
458 $_time = $banlift.' minute(s)';
459
460 if($banlift > 60){
461 $banlift = ceil($banlift / 60);
462 $_time = $banlift.' hour(s)';
463 }
464
465 $lz_error['ip_blocked'] = 'You have exceeded maximum login retries<br /> Please try after '.$_time;
466
467 return false;
468 }
469 }
470
471 return true;
472 }
473
474 function loginizer_is_blacklisted(){
475
476 global $wpdb, $loginizer, $lz_error;
477
478 $blacklist = $loginizer['blacklist'];
479
480 foreach($blacklist as $k => $v){
481
482 // Is the IP in the blacklist ?
483 if(inet_ptoi($v['start']) <= inet_ptoi($loginizer['current_ip']) && inet_ptoi($loginizer['current_ip']) <= inet_ptoi($v['end'])){
484 $result = 1;
485 break;
486 }
487
488 // Is it in a wider range ?
489 if(inet_ptoi($v['start']) >= 0 && inet_ptoi($v['end']) < 0){
490
491 // Since the end of the RANGE (i.e. current IP range) is beyond the +ve value of inet_ptoi,
492 // if the current IP is <= than the start of the range, it is within the range
493 // OR
494 // if the current IP is <= than the end of the range, it is within the range
495 if(inet_ptoi($v['start']) <= inet_ptoi($loginizer['current_ip'])
496 || inet_ptoi($loginizer['current_ip']) <= inet_ptoi($v['end'])){
497 $result = 1;
498 break;
499 }
500
501 }
502
503 }
504
505 // You are blacklisted
506 if(!empty($result)){
507 $lz_error['ip_blacklisted'] = $loginizer['msg']['ip_blacklisted'];
508 return true;
509 }
510
511 return false;
512
513 }
514
515 function loginizer_is_whitelisted(){
516
517 global $wpdb, $loginizer, $lz_error;
518
519 $whitelist = $loginizer['whitelist'];
520
521 foreach($whitelist as $k => $v){
522
523 // Is the IP in the blacklist ?
524 if(inet_ptoi($v['start']) <= inet_ptoi($loginizer['current_ip']) && inet_ptoi($loginizer['current_ip']) <= inet_ptoi($v['end'])){
525 $result = 1;
526 break;
527 }
528
529 // Is it in a wider range ?
530 if(inet_ptoi($v['start']) >= 0 && inet_ptoi($v['end']) < 0){
531
532 // Since the end of the RANGE (i.e. current IP range) is beyond the +ve value of inet_ptoi,
533 // if the current IP is <= than the start of the range, it is within the range
534 // OR
535 // if the current IP is <= than the end of the range, it is within the range
536 if(inet_ptoi($v['start']) <= inet_ptoi($loginizer['current_ip'])
537 || inet_ptoi($loginizer['current_ip']) <= inet_ptoi($v['end'])){
538 $result = 1;
539 break;
540 }
541
542 }
543
544 }
545
546 // You are whitelisted
547 if(!empty($result)){
548 return true;
549 }
550
551 return false;
552
553 }
554
555
556 // When the login fails, then this is called
557 // We need to update the database
558 function loginizer_login_failed($username){
559
560 global $wpdb, $loginizer, $lz_cannot_login;
561
562 if(empty($lz_cannot_login) && empty($loginizer['ip_is_whitelisted']) && empty($loginizer['no_loginizer_logs'])){
563
564 $result = lz_selectquery("SELECT * FROM `".$wpdb->prefix."loginizer_logs` WHERE `ip` = '".$loginizer['current_ip']."';");
565
566 if(!empty($result)){
567 $lockout = floor((($result['count']+1) / $loginizer['max_retries']));
568 $sresult = $wpdb->query("UPDATE `".$wpdb->prefix."loginizer_logs` SET `username` = '".$username."', `time` = '".time()."', `count` = `count`+1, `lockout` = '".$lockout."' WHERE `ip` = '".$loginizer['current_ip']."';");
569
570 // Do we need to email admin ?
571 if(!empty($loginizer['notify_email']) && $lockout >= $loginizer['notify_email']){
572
573 $sitename = lz_is_multisite() ? get_site_option('site_name') : get_option('blogname');
574 $mail = array();
575 $mail['to'] = lz_is_multisite() ? get_site_option('admin_email') : get_option('admin_email');
576 $mail['subject'] = 'Failed Login Attempts from IP '.$loginizer['current_ip'].' ('.$sitename.')';
577 $mail['message'] = 'Hi,
578
579 '.($result['count']+1).' failed login attempts and '.$lockout.' lockout(s) from IP '.$loginizer['current_ip'].'
580
581 Last Login Attempt : '.date('d/m/Y H:i:s', time()).'
582 Last User Attempt : '.$username.'
583 IP has been blocked until : '.date('d/m/Y H:i:s', time() + $loginizer['lockout_time']).'
584
585 Regards,
586 Loginizer';
587
588 @wp_mail($mail['to'], $mail['subject'], $mail['message']);
589 }
590 }else{
591 $insert = $wpdb->query("INSERT INTO `".$wpdb->prefix."loginizer_logs` SET `username` = '".$username."', `time` = '".time()."', `count` = '1', `ip` = '".$loginizer['current_ip']."', `lockout` = '0';");
592 }
593
594 // We need to add one as this is a failed attempt as well
595 $result['count'] = $result['count'] + 1;
596 $loginizer['retries_left'] = ($loginizer['max_retries'] - ($result['count'] % $loginizer['max_retries']));
597 $loginizer['retries_left'] = $loginizer['retries_left'] == $loginizer['max_retries'] ? 0 : $loginizer['retries_left'];
598
599 }
600 }
601
602 // Handles the error of the password not being there
603 function loginizer_error_handler($errors, $redirect_to){
604
605 global $wpdb, $loginizer, $lz_user_pass, $lz_cannot_login;
606
607 //echo 'loginizer_error_handler :';print_r($errors->errors);echo '<br>';
608
609 // Remove the empty password error
610 if(is_wp_error($errors)){
611
612 $codes = $errors->get_error_codes();
613
614 foreach($codes as $k => $v){
615 if($v == 'invalid_username' || $v == 'incorrect_password'){
616 $show_error = 1;
617 }
618 }
619
620 $errors->remove('invalid_username');
621 $errors->remove('incorrect_password');
622
623 }
624
625 // Add the error
626 if(!empty($lz_user_pass) && !empty($show_error) && empty($lz_cannot_login)){
627 $errors->add('invalid_userpass', '<b>ERROR:</b> ' . $loginizer['msg']['inv_userpass']);
628 }
629
630 // Add the number of retires left as well
631 if(count($errors->get_error_codes()) > 0 && isset($loginizer['retries_left'])){
632 $errors->add('retries_left', loginizer_retries_left());
633 }
634
635 return $errors;
636
637 }
638
639
640
641 // Handles the error of the password not being there
642 function loginizer_woocommerce_error_handler(){
643
644 global $wpdb, $loginizer, $lz_user_pass, $lz_cannot_login;
645
646 if(function_exists('wc_add_notice')){
647 wc_add_notice( loginizer_retries_left(), 'error' );
648 }
649
650 }
651
652 // Returns a string with the number of retries left
653 function loginizer_retries_left(){
654
655 global $wpdb, $loginizer, $lz_user_pass, $lz_cannot_login;
656
657 // If we are to show the number of retries left
658 if(isset($loginizer['retries_left'])){
659 return '<b>'.$loginizer['retries_left'].'</b> attempt(s) left';
660 }
661
662 }
663
664 function loginizer_reset_retries(){
665
666 global $wpdb, $loginizer;
667
668 $deltime = time() - $loginizer['reset_retries'];
669 $result = $wpdb->query("DELETE FROM `".$wpdb->prefix."loginizer_logs` WHERE `time` <= '".$deltime."';");
670
671 update_option('loginizer_last_reset', time());
672
673 }
674
675 add_filter("plugin_action_links_$plugin_loginizer", 'loginizer_plugin_action_links');
676
677 // Add settings link on plugin page
678 function loginizer_plugin_action_links($links) {
679
680 if(!defined('LOGINIZER_PREMIUM')){
681 $links[] = '<a href="'.LOGINIZER_PRO_URL.'" style="color:#3db634;" target="_blank">'._x('Upgrade', 'Plugin action link label.', 'loginizer').'</a>';
682 }
683
684 $settings_link = '<a href="admin.php?page=loginizer">Settings</a>';
685 array_unshift($links, $settings_link);
686
687 return $links;
688 }
689
690 add_action('admin_menu', 'loginizer_admin_menu');
691
692 // Shows the admin menu of Loginizer
693 function loginizer_admin_menu() {
694
695 global $wp_version, $loginizer;
696
697 // Add the menu page
698 add_menu_page(__('Loginizer Dashboard'), __('Loginizer Security'), 'activate_plugins', 'loginizer', 'loginizer_page_dashboard');
699
700 // Dashboard
701 add_submenu_page('loginizer', __('Loginizer Dashboard'), __('Dashboard'), 'activate_plugins', 'loginizer', 'loginizer_page_dashboard');
702
703 // Brute Force
704 add_submenu_page('loginizer', __('Loginizer Brute Force Settings'), __('Brute Force'), 'activate_plugins', 'loginizer_brute_force', 'loginizer_page_brute_force');
705
706 if(defined('LOGINIZER_PREMIUM')){
707
708 // PasswordLess
709 add_submenu_page('loginizer', __('Loginizer PasswordLess Settings'), __('PasswordLess'), 'activate_plugins', 'loginizer_passwordless', 'loginizer_page_passwordless');
710
711 // Two Factor Auth
712 add_submenu_page('loginizer', __('Loginizer Two Factor Authentication'), __('Two Factor Auth'), 'activate_plugins', 'loginizer_2fa', 'loginizer_page_2fa');
713
714 // reCaptcha
715 add_submenu_page('loginizer', __('Loginizer reCAPTCHA Settings'), __('reCAPTCHA'), 'activate_plugins', 'loginizer_recaptcha', 'loginizer_page_recaptcha');
716
717 // Security Settings
718 add_submenu_page('loginizer', __('Loginizer Security Settings'), __('Security Settings'), 'activate_plugins', 'loginizer_security', 'loginizer_page_security');
719
720 // Security Settings
721 add_submenu_page('loginizer', __('Loginizer File Checksums'), __('File Checksums'), 'activate_plugins', 'loginizer_checksums', 'loginizer_page_checksums');
722
723 }elseif(!defined('LOGINIZER_PREMIUM') && !empty($loginizer['ins_time']) && $loginizer['ins_time'] < (time() - (30*24*3600))){
724
725 // Go Pro link
726 add_submenu_page('loginizer', __('Loginizer Go Pro'), __('Go Pro'), 'activate_plugins', LOGINIZER_PRO_URL);
727
728 }
729
730 }
731
732 // The Loginizer Admin Options Page
733 function loginizer_page_header($title = 'Loginizer'){
734 /*wp_enqueue_script('common');
735 wp_enqueue_script('wp-lists');
736 wp_enqueue_script('postbox');
737 wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
738
739 echo '
740 <script>
741 jQuery(document).ready( function() {
742 //add_postbox_toggles("loginizer");
743 });
744 </script>';*/
745
746 ?>
747 <style>
748 .lz-right-ul{
749 padding-left: 10px !important;
750 }
751
752 .lz-right-ul li{
753 list-style: circle !important;
754 }
755 </style>
756 <?php
757
758 echo '<div style="margin: 10px 20px 0 2px;">
759 <div class="metabox-holder columns-2">
760 <div class="postbox-container">
761 <div id="top-sortables" class="meta-box-sortables ui-sortable">
762
763 <table cellpadding="2" cellspacing="1" width="100%" class="fixed" border="0">
764 <tr>
765 <td valign="top"><h3>'.$title.'</h3></td>
766 <td align="right"><a target="_blank" class="button button-primary" href="https://wordpress.org/support/view/plugin-reviews/loginizer">Review Loginizer</a></td>
767 <td align="right" width="40"><a target="_blank" href="https://twitter.com/loginizer"><img src="'.LOGINIZER_URL.'/twitter.png" /></a></td>
768 <td align="right" width="40"><a target="_blank" href="https://www.facebook.com/Loginizer-815504798591884"><img src="'.LOGINIZER_URL.'/facebook.png" /></a></td>
769 </tr>
770 </table>
771 <hr />
772
773 <!--Main Table-->
774 <table cellpadding="8" cellspacing="1" width="100%" class="fixed">
775 <tr>
776 <td valign="top">';
777
778 }
779
780 // The Loginizer Theme footer
781 function loginizer_page_footer(){
782
783 echo '</td>
784 <td width="200" valign="top" id="loginizer-right-bar">';
785
786 if(!defined('LOGINIZER_PREMIUM')){
787
788 echo '
789 <div class="postbox" style="min-width:0px !important;">
790 <h2 class="hndle ui-sortable-handle">
791 <span>Premium Version</span>
792 </h2>
793 <div class="inside">
794 <i>Upgrade to the premium version and get the following features </i>:<br>
795 <ul class="lz-right-ul">
796 <li>PasswordLess Login</li>
797 <li>Two Factor Auth - Email</li>
798 <li>Two Factor Auth - App</li>
799 <li>Login Challenge Question</li>
800 <li>reCAPTCHA</li>
801 <li>Rename Login Page</li>
802 <li>Disable XML-RPC</li>
803 <li>And many more ...</li>
804 </ul>
805 <center><a class="button button-primary" href="https://loginizer.com/members/cart.php">Upgrade</a></center>
806 </div>
807 </div>';
808
809 }else{
810
811 echo '
812 <div class="postbox" style="min-width:0px !important;">
813 <h2 class="hndle ui-sortable-handle">
814 <span>Recommendations</span>
815 </h2>
816 <div class="inside">
817 <i>We recommed that you enable atleast one of the following security features</i>:<br>
818 <ul class="lz-right-ul">
819 <li>Rename Login Page</li>
820 <li>Login Challenge Question</li>
821 <li>reCAPTCHA</li>
822 <li>Two Factor Auth - Email</li>
823 <li>Two Factor Auth - App</li>
824 <li>Change \'admin\' Username</li>
825 </ul>
826 </div>
827 </div>';
828 }
829
830 echo '</td>
831 </tr>
832 </table>
833 <br />
834 <div style="width:45%;background:#FFF;padding:15px; margin:auto">
835 <b>Let your friends know that you have secured your website :</b>
836 <form method="get" action="https://twitter.com/intent/tweet" id="tweet" onsubmit="return dotweet(this);">
837 <textarea name="text" cols="45" row="3" style="resize:none;">I just secured my @WordPress site against #bruteforce using @loginizer</textarea>
838 &nbsp; &nbsp; <input type="submit" value="Tweet!" class="button button-primary" onsubmit="return false;" id="twitter-btn" style="margin-top:20px;"/>
839 </form>
840
841 </div>
842 <br />
843
844 <script>
845 function dotweet(ele){
846 window.open(jQuery("#"+ele.id).attr("action")+"?"+jQuery("#"+ele.id).serialize(), "_blank", "scrollbars=no, menubar=no, height=400, width=500, resizable=yes, toolbar=no, status=no");
847 return false;
848 }
849 </script>
850
851 <hr />
852 <a href="http://loginizer.com" target="_blank">Loginizer</a> v'.LOGINIZER_VERSION.'. You can report any bugs <a href="http://wordpress.org/support/plugin/loginizer" target="_blank">here</a>.
853
854 </div>
855 </div>
856 </div>
857 </div>';
858
859 }
860
861 // The Loginizer Admin Options Page
862 function loginizer_page_dashboard(){
863
864 global $loginizer, $lz_error, $lz_env;
865
866 // Is there a license key ?
867 if(isset($_POST['save_lz'])){
868
869 $license = lz_optpost('lz_license');
870
871 // Check if its a valid license
872 if(empty($license)){
873 $lz_error['lic_invalid'] = __('The license key was not submitted', 'loginizer');
874 return loginizer_page_dashboard_T();
875 }
876
877 $resp = wp_remote_get(LOGINIZER_API.'license.php?license='.$license);
878
879 if(is_array($resp)){
880 $json = json_decode($resp['body'], true);
881 //print_r($json);
882 }
883
884 // Save the License
885 if(empty($json['license'])){
886
887 $lz_error['lic_invalid'] = __('The license key is invalid', 'loginizer');
888 return loginizer_page_dashboard_T();
889
890 }else{
891
892 update_option('loginizer_license', $json);
893
894 // Mark as saved
895 $GLOBALS['lz_saved'] = true;
896 }
897
898 }
899
900
901 // Is there a IP Method ?
902 if(isset($_POST['save_lz_ip_method'])){
903
904 $ip_method = (int) lz_optpost('lz_ip_method');
905 $custom_ip_method = lz_optpost('lz_custom_ip_method');
906
907 if($ip_method >= 0 && $ip_method <= 3){
908 update_option('loginizer_ip_method', $ip_method);
909 }
910
911 // Custom Method name ?
912 if($ip_method == 3){
913 update_option('loginizer_custom_ip_method', $custom_ip_method);
914 }
915
916 }
917
918 loginizer_page_dashboard_T();
919
920 }
921
922 // The Loginizer Admin Options Page - THEME
923 function loginizer_page_dashboard_T(){
924
925 global $loginizer, $lz_error, $lz_env;
926
927 loginizer_page_header('Loginizer Dashboard');
928 ?>
929 <style>
930 .welcome-panel{
931 margin: 0px;
932 padding: 10px;
933 }
934
935 input[type="text"], textarea, select {
936 width: 70%;
937 }
938
939 .form-table label{
940 font-weight:bold;
941 }
942
943 .exp{
944 font-size:12px;
945 }
946 </style>
947
948 <?php
949 echo '<script src="https://api.loginizer.com/'.(defined('LOGINIZER_PREMIUM') ? 'news_security.js' : 'news.js').'"></script><br>';
950
951 // Saved ?
952 if(!empty($GLOBALS['lz_saved'])){
953 echo '<div id="message" class="updated"><p>'. __('The settings were saved successfully', 'loginizer'). '</p></div><br />';
954 }
955
956 // Any errors ?
957 if(!empty($lz_error)){
958 lz_report_error($lz_error);echo '<br />';
959 }
960
961 ?>
962
963 <div class="postbox">
964
965 <button class="handlediv button-link" aria-expanded="true" type="button">
966 <span class="screen-reader-text">Toggle panel: Getting Started</span>
967 <span class="toggle-indicator" aria-hidden="true"></span>
968 </button>
969
970 <h2 class="hndle ui-sortable-handle">
971 <span><?php echo __('Getting Started', 'loginizer'); ?></span>
972 </h2>
973
974 <div class="inside">
975
976 <form action="" method="post" enctype="multipart/form-data">
977 <?php wp_nonce_field('loginizer-options'); ?>
978 <table class="form-table">
979 <tr>
980 <td scope="row" valign="top" colspan="2" style="line-height:150%">
981 <i>Welcome to Loginizer Security. By default the <b>Brute Force Protection</b> is immediately enabled. You should start by going over the default settings and tweaking them as per your needs.</i>
982 <?php
983 if(defined('LOGINIZER_PREMIUM')){
984 echo '<br><i>In the Premium version of Loginizer you have many more features. We recommend you enable features like <b>reCAPTCHA, Two Factor Auth or Email based PasswordLess</b> login. These features will improve your websites security.</i>';
985 }
986 ?>
987 </td>
988 </tr>
989 </table>
990 </form>
991
992 </div>
993 </div>
994
995 <div class="postbox">
996
997 <button class="handlediv button-link" aria-expanded="true" type="button">
998 <span class="screen-reader-text">Toggle panel: System Information</span>
999 <span class="toggle-indicator" aria-hidden="true"></span>
1000 </button>
1001
1002 <h2 class="hndle ui-sortable-handle">
1003 <span><?php echo __('System Information', 'loginizer'); ?></span>
1004 </h2>
1005
1006 <div class="inside">
1007
1008 <form action="" method="post" enctype="multipart/form-data">
1009 <?php wp_nonce_field('loginizer-options'); ?>
1010 <table class="wp-list-table fixed striped users" cellspacing="1" border="0" width="95%" cellpadding="10" align="center">
1011 <?php
1012 echo '
1013 <tr>
1014 <th align="left" width="25%">'.__('Loginizer Version', 'loginizer').'</th>
1015 <td>'.LOGINIZER_VERSION.(defined('LOGINIZER_PREMIUM') ? ' (Security PRO Version)' : '').'</td>
1016 </tr>';
1017
1018 if(defined('LOGINIZER_PREMIUM')){
1019 echo '
1020 <tr>
1021 <th align="left" valign="top">'.__('Loginizer License', 'loginizer').'</th>
1022 <td align="left">
1023 '.(empty($loginizer['license']) ? '<span style="color:red">Unlicensed</span> &nbsp; &nbsp;' : '').'
1024 <input type="text" name="lz_license" value="'.(empty($loginizer['license']) ? '' : $loginizer['license']['license']).'" size="30" placeholder="e.g. WXCSE-SFJJX-XXXXX-AAAAA-BBBBB" style="width:300px;" /> &nbsp;
1025 <input name="save_lz" class="button button-primary" value="Update License" type="submit" />';
1026
1027 if(!empty($loginizer['license'])){
1028
1029 $expires = $loginizer['license']['expires'];
1030 $expires = substr($expires, 0, 4).'/'.substr($expires, 4, 2).'/'.substr($expires, 6);
1031
1032 echo '<div style="margin-top:10px;">License Active : '.(empty($loginizer['license']['active']) ? '<span style="color:red">No</span>' : 'Yes').' &nbsp; &nbsp; &nbsp;
1033 License Expires : '.($loginizer['license']['expires'] <= date('Ymd') ? '<span style="color:red">'.$expires.'</span>' : $expires).'
1034 </div>';
1035 }
1036
1037
1038 echo
1039 '</td>
1040 </tr>';
1041 }
1042
1043 echo '<tr>
1044 <th align="left">'.__('URL', 'loginizer').'</th>
1045 <td>'.get_site_url().'</td>
1046 </tr>
1047 <tr>
1048 <th align="left">'.__('Path', 'loginizer').'</th>
1049 <td>'.ABSPATH.'</td>
1050 </tr>
1051 <tr>
1052 <th align="left">'.__('Server\'s IP Address', 'loginizer').'</th>
1053 <td>'.$_SERVER['SERVER_ADDR'].'</td>
1054 </tr>
1055 <tr>
1056 <th align="left">'.__('Your IP Address', 'loginizer').'</th>
1057 <td>'.lz_getip().'
1058 <div style="float:right">
1059 Method :
1060 <select name="lz_ip_method" id="lz_ip_method" style="font-size:11px; width:150px" onchange="lz_ip_method_handle()">
1061 <option value="0" '.lz_POSTselect('lz_ip_method', 0, (@$loginizer['ip_method'] == 0)).'>REMOTE_ADDR</option>
1062 <option value="1" '.lz_POSTselect('lz_ip_method', 1, (@$loginizer['ip_method'] == 1)).'>HTTP_X_FORWARDED_FOR</option>
1063 <option value="2" '.lz_POSTselect('lz_ip_method', 2, (@$loginizer['ip_method'] == 2)).'>HTTP_CLIENT_IP</option>
1064 <option value="3" '.lz_POSTselect('lz_ip_method', 3, (@$loginizer['ip_method'] == 3)).'>CUSTOM</option>
1065 </select>
1066 <input name="lz_custom_ip_method" id="lz_custom_ip_method" type="text" value="'.lz_optpost('lz_custom_ip_method', @$loginizer['custom_ip_method']).'" style="font-size:11px; width:100px; display:none" />
1067 <input name="save_lz_ip_method" class="button button-primary" value="Save" type="submit" />
1068 </div>
1069 </td>
1070 </tr>
1071 <tr>
1072 <th align="left">'.__('wp-config.php is writable', 'loginizer').'</th>
1073 <td>'.(is_writable(ABSPATH.'/wp-config.php') ? '<span style="color:red">Yes</span>' : '<span style="color:green">No</span>').'</td>
1074 </tr>';
1075
1076 if(file_exists(ABSPATH.'/.htaccess')){
1077 echo '
1078 <tr>
1079 <th align="left">'.__('.htaccess is writable', 'loginizer').'</th>
1080 <td>'.(is_writable(ABSPATH.'/.htaccess') ? '<span style="color:red">Yes</span>' : '<span style="color:green">No</span>').'</td>
1081 </tr>';
1082
1083 }
1084
1085 ?>
1086 </table>
1087 </form>
1088
1089 </div>
1090 </div>
1091
1092 <script type="text/javascript">
1093
1094 function lz_ip_method_handle(){
1095 var ele = jQuery('#lz_ip_method');
1096 if(ele.val() == 3){
1097 jQuery('#lz_custom_ip_method').show();
1098 }else{
1099 jQuery('#lz_custom_ip_method').hide();
1100 }
1101 };
1102
1103 lz_ip_method_handle();
1104
1105 </script>
1106
1107 <div id="" class="postbox">
1108
1109 <button class="handlediv button-link" aria-expanded="true" type="button">
1110 <span class="screen-reader-text">Toggle panel: File Permissions</span>
1111 <span class="toggle-indicator" aria-hidden="true"></span>
1112 </button>
1113
1114 <h2 class="hndle ui-sortable-handle">
1115 <span><?php echo __('File Permissions', 'loginizer'); ?></span>
1116 </h2>
1117
1118 <div class="inside">
1119
1120 <form action="" method="post" enctype="multipart/form-data">
1121 <?php wp_nonce_field('loginizer-options'); ?>
1122 <table class="wp-list-table fixed striped users" border="0" width="95%" cellpadding="10" align="center">
1123 <?php
1124
1125 echo '
1126 <tr>
1127 <th style="background:#EFEFEF;">'.__('Relative Path', 'loginizer').'</th>
1128 <th style="width:10%; background:#EFEFEF;">'.__('Suggested', 'loginizer').'</th>
1129 <th style="width:10%; background:#EFEFEF;">'.__('Actual', 'loginizer').'</th>
1130 </tr>';
1131
1132 $wp_content = basename(dirname(dirname(dirname(__FILE__))));
1133
1134 $files_to_check = array('/' => '0755',
1135 '/wp-admin' => '0755',
1136 '/wp-includes' => '0755',
1137 '/wp-config.php' => '0444',
1138 '/'.$wp_content => '0755',
1139 '/'.$wp_content.'/themes' => '0755',
1140 '/'.$wp_content.'/plugins' => '0755',
1141 '.htaccess' => '0444');
1142
1143 $root = ABSPATH;
1144
1145 foreach($files_to_check as $k => $v){
1146
1147 $path = $root.'/'.$k;
1148 $stat = @stat($path);
1149 $suggested = $v;
1150 $actual = substr(sprintf('%o', $stat['mode']), -4);
1151
1152 echo '
1153 <tr>
1154 <td>'.$k.'</td>
1155 <td>'.$suggested.'</td>
1156 <td><span '.($suggested != $actual ? 'style="color: red;"' : '').'>'.$actual.'</span></td>
1157 </tr>';
1158
1159 }
1160
1161 ?>
1162 </table>
1163 </form>
1164
1165 </div>
1166 </div>
1167
1168 <?php
1169
1170 loginizer_page_footer();
1171
1172 }
1173
1174 // The Loginizer Admin Options Page
1175 function loginizer_page_brute_force(){
1176
1177 global $wpdb, $wp_roles, $loginizer;
1178
1179 if(!current_user_can('manage_options')){
1180 wp_die('Sorry, but you do not have permissions to change settings.');
1181 }
1182
1183 /* Make sure post was from this page */
1184 if(count($_POST) > 0){
1185 check_admin_referer('loginizer-options');
1186 }
1187
1188 // BEGIN THEME
1189 loginizer_page_header('Loginizer - Brute Force Settings');
1190
1191 // Load the blacklist and whitelist
1192 $loginizer['blacklist'] = get_option('loginizer_blacklist');
1193 $loginizer['whitelist'] = get_option('loginizer_whitelist');
1194
1195 if(isset($_POST['save_lz'])){
1196
1197 $max_retries = (int) lz_optpost('max_retries');
1198 $lockout_time = (int) lz_optpost('lockout_time');
1199 $max_lockouts = (int) lz_optpost('max_lockouts');
1200 $lockouts_extend = (int) lz_optpost('lockouts_extend');
1201 $reset_retries = (int) lz_optpost('reset_retries');
1202 $notify_email = (int) lz_optpost('notify_email');
1203
1204 $lockout_time = $lockout_time * 60;
1205 $lockouts_extend = $lockouts_extend * 60 * 60;
1206 $reset_retries = $reset_retries * 60 * 60;
1207
1208 if(empty($error)){
1209
1210 $option['max_retries'] = $max_retries;
1211 $option['lockout_time'] = $lockout_time;
1212 $option['max_lockouts'] = $max_lockouts;
1213 $option['lockouts_extend'] = $lockouts_extend;
1214 $option['reset_retries'] = $reset_retries;
1215 $option['notify_email'] = $notify_email;
1216
1217 // Save the options
1218 update_option('loginizer_options', $option);
1219
1220 $saved = true;
1221
1222 }else{
1223 lz_report_error($error);
1224 }
1225
1226 if(!empty($notice)){
1227 lz_report_notice($notice);
1228 }
1229
1230 if(!empty($saved)){
1231 echo '<div id="message" class="updated"><p>'
1232 . __('The settings were saved successfully', 'loginizer')
1233 . '</p></div><br />';
1234 }
1235
1236 }
1237
1238 // Delete a Blackist IP range
1239 if(isset($_POST['bdelid'])){
1240
1241 $delid = (int) lz_optreq('bdelid');
1242
1243 // Unset and save
1244 $blacklist = $loginizer['blacklist'];
1245 unset($blacklist[$delid]);
1246 update_option('loginizer_blacklist', $blacklist);
1247
1248 echo '<div id="message" class="updated fade"><p>'
1249 . __('The Blacklist IP range has been deleted successfully', 'loginizer')
1250 . '</p></div><br />';
1251
1252 }
1253
1254 // Delete all Blackist IP ranges
1255 if(isset($_POST['del_all_blacklist'])){
1256
1257 // Unset and save
1258 update_option('loginizer_blacklist', array());
1259
1260 echo '<div id="message" class="updated fade"><p>'
1261 . __('The Blacklist IP range(s) have been cleared successfully', 'loginizer')
1262 . '</p></div><br />';
1263
1264 }
1265
1266 // Delete a Whitelist IP range
1267 if(isset($_POST['delid'])){
1268
1269 $delid = (int) lz_optreq('delid');
1270
1271 // Unset and save
1272 $whitelist = $loginizer['whitelist'];
1273 unset($whitelist[$delid]);
1274 update_option('loginizer_whitelist', $whitelist);
1275
1276 echo '<div id="message" class="updated fade"><p>'
1277 . __('The Whitelist IP range has been deleted successfully', 'loginizer')
1278 . '</p></div><br />';
1279
1280 }
1281
1282 // Delete all Blackist IP ranges
1283 if(isset($_POST['del_all_whitelist'])){
1284
1285 // Unset and save
1286 update_option('loginizer_whitelist', array());
1287
1288 echo '<div id="message" class="updated fade"><p>'
1289 . __('The Whitelist IP range(s) have been cleared successfully', 'loginizer')
1290 . '</p></div><br />';
1291
1292 }
1293
1294 // Reset All Logs
1295 if(isset($_POST['lz_reset_all_ip'])){
1296
1297 $result = $wpdb->query("DELETE FROM `".$wpdb->prefix."loginizer_logs`
1298 WHERE `time` > 0");
1299
1300 echo '<div id="message" class="updated fade"><p>'
1301 . __('All the IP Logs have been cleared', 'loginizer')
1302 . '</p></div><br />';
1303 }
1304
1305 // Reset Logs
1306 if(isset($_POST['lz_reset_ips']) && is_array($_POST['lz_reset_ips'])){
1307
1308 $ips = $_POST['lz_reset_ips'];
1309
1310 foreach($ips as $ip){
1311 if(!lz_valid_ip($ip)){
1312 $error[] = 'The IP - '.$ip.' is invalid !';
1313 }
1314 }
1315
1316 if(count($ips) < 1){
1317 $error[] = 'There are no IPs submitted';
1318 }
1319
1320 // Should we start deleting logs
1321 if(empty($error)){
1322
1323 $result = $wpdb->query("DELETE FROM `".$wpdb->prefix."loginizer_logs`
1324 WHERE `ip` IN ('".implode("', '", $ips)."')");
1325
1326 if(empty($error)){
1327
1328 echo '<div id="message" class="updated fade"><p>'
1329 . __('The selected IP Logs have been reset', 'loginizer')
1330 . '</p></div><br />';
1331
1332 }
1333
1334 }
1335
1336 if(!empty($error)){
1337 lz_report_error($error);echo '<br />';
1338 }
1339
1340 }
1341
1342 if(isset($_POST['blacklist_iprange'])){
1343
1344 $start_ip = lz_optpost('start_ip');
1345 $end_ip = lz_optpost('end_ip');
1346
1347 if(empty($start_ip)){
1348 $error[] = 'Please enter the Start IP';
1349 }
1350
1351 // If no end IP we consider only 1 IP
1352 if(empty($end_ip)){
1353 $end_ip = $start_ip;
1354 }
1355
1356 if(!lz_valid_ip($start_ip)){
1357 $error[] = 'Please provide a valid start IP';
1358 }
1359
1360 if(!lz_valid_ip($end_ip)){
1361 $error[] = 'Please provide a valid end IP';
1362 }
1363
1364 // Regular ranges will work
1365 if(inet_ptoi($start_ip) > inet_ptoi($end_ip)){
1366
1367 // BUT, if 0.0.0.1 - 255.255.255.255 is given, it will not work
1368 if(inet_ptoi($start_ip) >= 0 && inet_ptoi($end_ip) < 0){
1369 // This is right
1370 }else{
1371 $error[] = 'The End IP cannot be smaller than the Start IP';
1372 }
1373
1374 }
1375
1376 if(empty($error)){
1377
1378 $blacklist = $loginizer['blacklist'];
1379
1380 foreach($blacklist as $k => $v){
1381
1382 // This is to check if there is any other range exists with the same Start or End IP
1383 if(( inet_ptoi($start_ip) <= inet_ptoi($v['start']) && inet_ptoi($v['start']) <= inet_ptoi($end_ip) )
1384 || ( inet_ptoi($start_ip) <= inet_ptoi($v['end']) && inet_ptoi($v['end']) <= inet_ptoi($end_ip) )
1385 ){
1386 $error[] = 'The Start IP or End IP submitted conflicts with an existing IP range !';
1387 break;
1388 }
1389
1390 // This is to check if there is any other range exists with the same Start IP
1391 if(inet_ptoi($v['start']) <= inet_ptoi($start_ip) && inet_ptoi($start_ip) <= inet_ptoi($v['end'])){
1392 $error[] = 'The Start IP is present in an existing range !';
1393 break;
1394 }
1395
1396 // This is to check if there is any other range exists with the same End IP
1397 if(inet_ptoi($v['start']) <= inet_ptoi($end_ip) && inet_ptoi($end_ip) <= inet_ptoi($v['end'])){
1398 $error[] = 'The End IP is present in an existing range!';
1399 break;
1400 }
1401
1402 }
1403
1404 $newid = ( empty($blacklist) ? 0 : max(array_keys($blacklist)) ) + 1;
1405
1406 if(empty($error)){
1407
1408 $blacklist[$newid] = array();
1409 $blacklist[$newid]['start'] = $start_ip;
1410 $blacklist[$newid]['end'] = $end_ip;
1411 $blacklist[$newid]['time'] = time();
1412
1413 update_option('loginizer_blacklist', $blacklist);
1414
1415 echo '<div id="message" class="updated fade"><p>'
1416 . __('Blacklist IP range added successfully', 'loginizer')
1417 . '</p></div><br />';
1418
1419 }
1420
1421 }
1422
1423 if(!empty($error)){
1424 lz_report_error($error);echo '<br />';
1425 }
1426
1427 }
1428
1429 if(isset($_POST['whitelist_iprange'])){
1430
1431 $start_ip = lz_optpost('start_ip_w');
1432 $end_ip = lz_optpost('end_ip_w');
1433
1434 if(empty($start_ip)){
1435 $error[] = 'Please enter the Start IP';
1436 }
1437
1438 // If no end IP we consider only 1 IP
1439 if(empty($end_ip)){
1440 $end_ip = $start_ip;
1441 }
1442
1443 if(!lz_valid_ip($start_ip)){
1444 $error[] = 'Please provide a valid start IP';
1445 }
1446
1447 if(!lz_valid_ip($end_ip)){
1448 $error[] = 'Please provide a valid end IP';
1449 }
1450
1451 if(inet_ptoi($start_ip) > inet_ptoi($end_ip)){
1452
1453 // BUT, if 0.0.0.1 - 255.255.255.255 is given, it will not work
1454 if(inet_ptoi($start_ip) >= 0 && inet_ptoi($end_ip) < 0){
1455 // This is right
1456 }else{
1457 $error[] = 'The End IP cannot be smaller than the Start IP';
1458 }
1459
1460 }
1461
1462 if(empty($error)){
1463
1464 $whitelist = $loginizer['whitelist'];
1465
1466 foreach($whitelist as $k => $v){
1467
1468 // This is to check if there is any other range exists with the same Start or End IP
1469 if(( inet_ptoi($start_ip) <= inet_ptoi($v['start']) && inet_ptoi($v['start']) <= inet_ptoi($end_ip) )
1470 || ( inet_ptoi($start_ip) <= inet_ptoi($v['end']) && inet_ptoi($v['end']) <= inet_ptoi($end_ip) )
1471 ){
1472 $error[] = 'The Start IP or End IP submitted conflicts with an existing IP range !';
1473 break;
1474 }
1475
1476 // This is to check if there is any other range exists with the same Start IP
1477 if(inet_ptoi($v['start']) <= inet_ptoi($start_ip) && inet_ptoi($start_ip) <= inet_ptoi($v['end'])){
1478 $error[] = 'The Start IP is present in an existing range !';
1479 break;
1480 }
1481
1482 // This is to check if there is any other range exists with the same End IP
1483 if(inet_ptoi($v['start']) <= inet_ptoi($end_ip) && inet_ptoi($end_ip) <= inet_ptoi($v['end'])){
1484 $error[] = 'The End IP is present in an existing range!';
1485 break;
1486 }
1487
1488 }
1489
1490 $newid = ( empty($whitelist) ? 0 : max(array_keys($whitelist)) ) + 1;
1491
1492 if(empty($error)){
1493
1494 $whitelist[$newid] = array();
1495 $whitelist[$newid]['start'] = $start_ip;
1496 $whitelist[$newid]['end'] = $end_ip;
1497 $whitelist[$newid]['time'] = time();
1498
1499 update_option('loginizer_whitelist', $whitelist);
1500
1501 echo '<div id="message" class="updated fade"><p>'
1502 . __('Whitelist IP range added successfully', 'loginizer')
1503 . '</p></div><br />';
1504
1505 }
1506
1507 }
1508
1509 if(!empty($error)){
1510 lz_report_error($error);echo '<br />';
1511 }
1512 }
1513
1514 // Save the messages
1515 if(isset($_POST['save_err_msgs_lz'])){
1516
1517 $msgs['inv_userpass'] = lz_optpost('msg_inv_userpass');
1518 $msgs['ip_blacklisted'] = lz_optpost('msg_ip_blacklisted');
1519
1520 // Update them
1521 update_option('loginizer_msg', $msgs);
1522
1523 echo '<div id="message" class="updated fade"><p>'
1524 . __('Error messages were saved successfully', 'loginizer')
1525 . '</p></div><br />';
1526
1527 }
1528
1529 // Count the Results
1530 $tmp = lz_selectquery("SELECT COUNT(*) AS num FROM `".$wpdb->prefix."loginizer_logs`");
1531 //print_r($tmp);
1532
1533 // Which Page is it
1534 $lz_env['res_len'] = 10;
1535 $lz_env['cur_page'] = lz_get_page('lzpage', $lz_env['res_len']);
1536 $lz_env['num_res'] = $tmp['num'];
1537 $lz_env['max_page'] = ceil($lz_env['num_res'] / $lz_env['res_len']);
1538
1539 // Get the logs
1540 $result = lz_selectquery("SELECT * FROM `".$wpdb->prefix."loginizer_logs`
1541 ORDER BY `time` DESC
1542 LIMIT ".$lz_env['cur_page'].", ".$lz_env['res_len']."", 1);
1543 //print_r($result);
1544
1545 $lz_env['cur_page'] = ($lz_env['cur_page'] / $lz_env['res_len']) + 1;
1546 $lz_env['cur_page'] = $lz_env['cur_page'] < 1 ? 1 : $lz_env['cur_page'];
1547 $lz_env['next_page'] = ($lz_env['cur_page'] + 1) > $lz_env['max_page'] ? $lz_env['max_page'] : ($lz_env['cur_page'] + 1);
1548 $lz_env['prev_page'] = ($lz_env['cur_page'] - 1) < 1 ? 1 : ($lz_env['cur_page'] - 1);
1549
1550 // Reload the settings
1551 $loginizer['blacklist'] = get_option('loginizer_blacklist');
1552 $loginizer['whitelist'] = get_option('loginizer_whitelist');
1553
1554 $saved_msgs = get_option('loginizer_msg');
1555
1556 ?>
1557
1558 <div id="" class="postbox">
1559
1560 <button class="handlediv button-link" aria-expanded="true" type="button">
1561 <span class="screen-reader-text">Toggle panel: Failed Login Attempts Logs</span>
1562 <span class="toggle-indicator" aria-hidden="true"></span>
1563 </button>
1564
1565 <h2 class="hndle ui-sortable-handle">
1566 <?php echo __('<span>Failed Login Attempts Logs</span> &nbsp; (Past '.($loginizer['reset_retries']/60/60).' hours)','loginizer'); ?>
1567 </h2>
1568
1569 <script>
1570 function yesdsd(){
1571 window.location = '<?php echo menu_page_url('loginizer_brute_force', false);?>&lzpage='+jQuery("#current-page-selector").val();
1572 return false;
1573 }
1574 </script>
1575
1576 <form method="get" onsubmit="return yesdsd();">
1577 <div class="tablenav">
1578 <p class="tablenav-pages" style="margin: 5px 10px" align="right">
1579 <span class="displaying-num"><?php echo $lz_env['num_res'];?> items</span>
1580 <span class="pagination-links">
1581 <a class="first-page" href="<?php echo menu_page_url('loginizer_brute_force', false).'&lzpage=1';?>"><span class="screen-reader-text">First page</span><span aria-hidden="true">«</span></a>
1582 <a class="prev-page" href="<?php echo menu_page_url('loginizer_brute_force', false).'&lzpage='.$lz_env['prev_page'];?>"><span class="screen-reader-text">Previous page</span><span aria-hidden="true">‹</span></a>
1583 <span class="paging-input">
1584 <label for="current-page-selector" class="screen-reader-text">Current Page</label>
1585 <input class="current-page" id="current-page-selector" name="lzpage" value="<?php echo $lz_env['cur_page'];?>" size="3" aria-describedby="table-paging" type="text"><span class="tablenav-paging-text"> of <span class="total-pages"><?php echo $lz_env['max_page'];?></span></span>
1586 </span>
1587 <a class="next-page" href="<?php echo menu_page_url('loginizer_brute_force', false).'&lzpage='.$lz_env['next_page'];?>"><span class="screen-reader-text">Next page</span><span aria-hidden="true">›</span></a>
1588 <a class="last-page" href="<?php echo menu_page_url('loginizer_brute_force', false).'&lzpage='.$lz_env['max_page'];?>"><span class="screen-reader-text">Last page</span><span aria-hidden="true">»</span></a>
1589 </span>
1590 </p>
1591 </div>
1592 </form>
1593
1594 <form action="" method="post" enctype="multipart/form-data">
1595 <?php wp_nonce_field('loginizer-options'); ?>
1596 <div class="inside">
1597 <table class="wp-list-table widefat fixed users" border="0">
1598 <tr>
1599 <th scope="row" valign="top" style="background:#EFEFEF;" width="20">#</th>
1600 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('IP','loginizer'); ?></th>
1601 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Attempted Username','loginizer'); ?></th>
1602 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Last Failed Attempt (DD/MM/YYYY)','loginizer'); ?></th>
1603 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Failed Attempts Count','loginizer'); ?></th>
1604 <th scope="row" valign="top" style="background:#EFEFEF;" width="150"><?php echo __('Lockouts Count','loginizer'); ?></th>
1605 </tr>
1606 <?php
1607
1608 if(empty($result)){
1609 echo '
1610 <tr>
1611 <td colspan="4">
1612 No Logs. You will see logs about failed login attempts here.
1613 </td>
1614 </tr>';
1615 }else{
1616 foreach($result as $ik => $iv){
1617 $status_button = (!empty($iv['status']) ? 'disable' : 'enable');
1618 echo '
1619 <tr>
1620 <td>
1621 <input type="checkbox" value="'.$iv['ip'].'" name="lz_reset_ips[]" />
1622 </td>
1623 <td>
1624 '.$iv['ip'].'
1625 </td>
1626 <td>
1627 '.$iv['username'].'
1628 </td>
1629 <td>
1630 '.date('d/m/Y H:i:s', $iv['time']).'
1631 </td>
1632 <td>
1633 '.$iv['count'].'
1634 </td>
1635 <td>
1636 '.$iv['lockout'].'
1637 </td>
1638 </tr>';
1639 }
1640 }
1641
1642 ?>
1643 </table>
1644
1645 <br>
1646 <input name="lz_reset_ip" class="button button-primary action" value="<?php echo __('Remove From Logs', 'loginizer'); ?>" type="submit" />
1647 &nbsp; &nbsp;
1648 <input name="lz_reset_all_ip" class="button button-primary action" value="<?php echo __('Clear All Logs', 'loginizer'); ?>" type="submit" />
1649 </div>
1650 </div>
1651 </form>
1652 <br />
1653
1654 <div id="" class="postbox">
1655
1656 <button class="handlediv button-link" aria-expanded="true" type="button">
1657 <span class="screen-reader-text">Toggle panel: Brute Force Settings</span>
1658 <span class="toggle-indicator" aria-hidden="true"></span>
1659 </button>
1660
1661 <h2 class="hndle ui-sortable-handle">
1662 <span><?php echo __('Brute Force Settings', 'loginizer'); ?></span>
1663 </h2>
1664
1665 <div class="inside">
1666
1667 <form action="" method="post" enctype="multipart/form-data">
1668 <?php wp_nonce_field('loginizer-options'); ?>
1669 <table class="form-table">
1670 <tr>
1671 <th scope="row" valign="top"><label for="max_retries"><?php echo __('Max Retries','loginizer'); ?></label></th>
1672 <td>
1673 <input type="text" size="3" value="<?php echo lz_optpost('max_retries', $loginizer['max_retries']); ?>" name="max_retries" id="max_retries" /> <?php echo __('Maximum failed attempts allowed before lockout','loginizer'); ?> <br />
1674 </td>
1675 </tr>
1676 <tr>
1677 <th scope="row" valign="top"><label for="lockout_time"><?php echo __('Lockout Time','loginizer'); ?></label></th>
1678 <td>
1679 <input type="text" size="3" value="<?php echo (!empty($lockout_time) ? $lockout_time : $loginizer['lockout_time']) / 60; ?>" name="lockout_time" id="lockout_time" /> <?php echo __('minutes','loginizer'); ?> <br />
1680 </td>
1681 </tr>
1682 <tr>
1683 <th scope="row" valign="top"><label for="max_lockouts"><?php echo __('Max Lockouts','loginizer'); ?></label></th>
1684 <td>
1685 <input type="text" size="3" value="<?php echo lz_optpost('max_lockouts', $loginizer['max_lockouts']); ?>" name="max_lockouts" id="max_lockouts" /> <?php echo __('','loginizer'); ?> <br />
1686 </td>
1687 </tr>
1688 <tr>
1689 <th scope="row" valign="top"><label for="lockouts_extend"><?php echo __('Extend Lockout','loginizer'); ?></label></th>
1690 <td>
1691 <input type="text" size="3" value="<?php echo (!empty($lockouts_extend) ? $lockouts_extend : $loginizer['lockouts_extend']) / 60 / 60; ?>" name="lockouts_extend" id="lockouts_extend" /> <?php echo __('hours. Extend Lockout time after Max Lockouts','loginizer'); ?> <br />
1692 </td>
1693 </tr>
1694 <tr>
1695 <th scope="row" valign="top"><label for="reset_retries"><?php echo __('Reset Retries','loginizer'); ?></label></th>
1696 <td>
1697 <input type="text" size="3" value="<?php echo (!empty($reset_retries) ? $reset_retries : $loginizer['reset_retries']) / 60 / 60; ?>" name="reset_retries" id="reset_retries" /> <?php echo __('hours','loginizer'); ?> <br />
1698 </td>
1699 </tr>
1700 <tr>
1701 <th scope="row" valign="top"><label for="notify_email"><?php echo __('Email Notification','loginizer'); ?></label></th>
1702 <td>
1703 <?php echo __('after ','loginizer'); ?>
1704 <input type="text" size="3" value="<?php echo (!empty($notify_email) ? $notify_email : $loginizer['notify_email']); ?>" name="notify_email" id="notify_email" /> <?php echo __('lockouts <br />0 to disable email notifications','loginizer'); ?>
1705 </td>
1706 </tr>
1707 </table><br />
1708 <input name="save_lz" class="button button-primary action" value="<?php echo __('Save Settings','loginizer'); ?>" type="submit" />
1709 </form>
1710
1711 </div>
1712 </div>
1713 <br />
1714
1715 <?php
1716
1717 wp_enqueue_script('jquery-paginate', LOGINIZER_URL.'/jquery-paginate.js', array('jquery'), '1.10.15');
1718
1719 ?>
1720
1721 <style>
1722 .page-navigation a {
1723 margin: 5px 2px;
1724 display: inline-block;
1725 padding: 5px 8px;
1726 color: #0073aa;
1727 background: #e5e5e5 none repeat scroll 0 0;
1728 border: 1px solid #ccc;
1729 text-decoration: none;
1730 transition-duration: 0.05s;
1731 transition-property: border, background, color;
1732 transition-timing-function: ease-in-out;
1733 }
1734
1735 .page-navigation a[data-selected] {
1736 background-color: #00a0d2;
1737 color: #fff;
1738 }
1739 </style>
1740
1741 <script>
1742
1743 jQuery(document).ready(function(){
1744 jQuery('#lz_bl_table').paginate({ limit: 11, navigationWrapper: jQuery('#lz_bl_nav')});
1745 jQuery('#lz_wl_table').paginate({ limit: 11, navigationWrapper: jQuery('#lz_wl_nav')});
1746 });
1747
1748 // Delete a Blacklist / Whitelist IP Range
1749 function del_confirm(field, todo_id, msg){
1750 var ret = confirm(msg);
1751
1752 if(ret){
1753 jQuery('#lz_bl_wl_todo').attr('name', field);
1754 jQuery('#lz_bl_wl_todo').val(todo_id);
1755 jQuery('#lz_bl_wl_form').submit();
1756 }
1757
1758 return false;
1759
1760 }
1761
1762 // Delete all Blacklist / Whitelist IP Ranges
1763 function del_confirm_all(msg){
1764 var ret = confirm(msg);
1765
1766 if(ret){
1767 return true;
1768 }
1769
1770 return false;
1771
1772 }
1773
1774 </script>
1775
1776 <div id="" class="postbox">
1777
1778 <button class="handlediv button-link" aria-expanded="true" type="button">
1779 <span class="screen-reader-text">Toggle panel: Blacklist IP</span>
1780 <span class="toggle-indicator" aria-hidden="true"></span>
1781 </button>
1782
1783 <h2 class="hndle ui-sortable-handle">
1784 <span><?php echo __('Blacklist IP','loginizer'); ?></span>
1785 </h2>
1786
1787 <div class="inside">
1788
1789 <?php echo __('Enter the IP you want to blacklist from login','loginizer'); ?>
1790
1791 <form action="" method="post">
1792 <?php wp_nonce_field('loginizer-options'); ?>
1793 <table class="form-table">
1794 <tr>
1795 <th scope="row" valign="top"><label for="start_ip"><?php echo __('Start IP','loginizer'); ?></label></th>
1796 <td>
1797 <input type="text" size="25" value="<?php echo(lz_optpost('start_ip')); ?>" name="start_ip" id="start_ip"/> <?php echo __('Start IP of the range','loginizer'); ?> <br />
1798 </td>
1799 </tr>
1800 <tr>
1801 <th scope="row" valign="top"><label for="end_ip"><?php echo __('End IP (Optional)','loginizer'); ?></label></th>
1802 <td>
1803 <input type="text" size="25" value="<?php echo(lz_optpost('end_ip')); ?>" name="end_ip" id="end_ip"/> <?php echo __('End IP of the range. <br />If you want to blacklist single IP leave this field blank.','loginizer'); ?> <br />
1804 </td>
1805 </tr>
1806 </table><br />
1807 <input name="blacklist_iprange" class="button button-primary action" value="<?php echo __('Add Blacklist IP Range','loginizer'); ?>" type="submit" />
1808 <input style="float:right" name="del_all_blacklist" onclick="return del_confirm_all('<?php echo __('Are you sure you want to delete all Blacklist IP Range(s) ?','loginizer'); ?>')" class="button action" value="<?php echo __('Delete All Blacklist IP Range(s)','loginizer'); ?>" type="submit" />
1809 </form>
1810 </div>
1811
1812 <div id="lz_bl_nav" style="margin: 5px 10px; text-align:right"></div>
1813 <table id="lz_bl_table" class="wp-list-table fixed striped users" border="0" width="95%" cellpadding="10" align="center">
1814 <tr>
1815 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Start IP','loginizer'); ?></th>
1816 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('End IP','loginizer'); ?></th>
1817 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Date (DD/MM/YYYY)','loginizer'); ?></th>
1818 <th scope="row" valign="top" style="background:#EFEFEF;" width="100"><?php echo __('Options','loginizer'); ?></th>
1819 </tr>
1820 <?php
1821 if(empty($loginizer['blacklist'])){
1822 echo '
1823 <tr>
1824 <td colspan="4">
1825 No Blacklist IPs. You will see blacklisted IP ranges here.
1826 </td>
1827 </tr>';
1828 }else{
1829 foreach($loginizer['blacklist'] as $ik => $iv){
1830 echo '
1831 <tr>
1832 <td>
1833 '.$iv['start'].'
1834 </td>
1835 <td>
1836 '.$iv['end'].'
1837 </td>
1838 <td>
1839 '.date('d/m/Y', $iv['time']).'
1840 </td>
1841 <td>
1842 <a class="submitdelete" href="javascript:void(0)" onclick="return del_confirm(\'bdelid\', '.$ik.', \'Are you sure you want to delete this IP range ?\')">Delete</a>
1843 </td>
1844 </tr>';
1845 }
1846 }
1847 ?>
1848 </table>
1849 <br />
1850 <form action="" method="post" id="lz_bl_wl_form">
1851 <?php wp_nonce_field('loginizer-options'); ?>
1852 <input type="hidden" value="" name="" id="lz_bl_wl_todo"/>
1853 </form>
1854 </div>
1855
1856 <br />
1857
1858 <div id="" class="postbox">
1859
1860 <button class="handlediv button-link" aria-expanded="true" type="button">
1861 <span class="screen-reader-text">Toggle panel: Whitelist IP</span>
1862 <span class="toggle-indicator" aria-hidden="true"></span>
1863 </button>
1864
1865 <h2 class="hndle ui-sortable-handle">
1866 <span><?php echo __('Whitelist IP', 'loginizer'); ?></span>
1867 </h2>
1868
1869 <div class="inside">
1870
1871 <?php echo __('Enter the IP you want to whitelist for login','loginizer'); ?>
1872 <form action="" method="post">
1873 <?php wp_nonce_field('loginizer-options'); ?>
1874 <table class="form-table">
1875 <tr>
1876 <th scope="row" valign="top"><label for="start_ip_w"><?php echo __('Start IP','loginizer'); ?></label></th>
1877 <td>
1878 <input type="text" size="25" value="<?php echo(lz_optpost('start_ip_w')); ?>" name="start_ip_w" id="start_ip_w"/> <?php echo __('Start IP of the range','loginizer'); ?> <br />
1879 </td>
1880 </tr>
1881 <tr>
1882 <th scope="row" valign="top"><label for="end_ip_w"><?php echo __('End IP (Optional)','loginizer'); ?></label></th>
1883 <td>
1884 <input type="text" size="25" value="<?php echo(lz_optpost('end_ip_w')); ?>" name="end_ip_w" id="end_ip_w"/> <?php echo __('End IP of the range. <br />If you want to whitelist single IP leave this field blank.','loginizer'); ?> <br />
1885 </td>
1886 </tr>
1887 </table><br />
1888 <input name="whitelist_iprange" class="button button-primary action" value="<?php echo __('Add Whitelist IP Range','loginizer'); ?>" type="submit" />
1889 <input style="float:right" name="del_all_whitelist" onclick="return del_confirm_all('<?php echo __('Are you sure you want to delete all Whitelist IP Range(s) ?','loginizer'); ?>')" class="button action" value="<?php echo __('Delete All Whitelist IP Range(s)','loginizer'); ?>" type="submit" />
1890 </form>
1891 </div>
1892
1893 <div id="lz_wl_nav" style="margin: 5px 10px; text-align:right"></div>
1894 <table id="lz_wl_table" class="wp-list-table fixed striped users" border="0" width="95%" cellpadding="10" align="center">
1895 <tr>
1896 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Start IP','loginizer'); ?></th>
1897 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('End IP','loginizer'); ?></th>
1898 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Date (DD/MM/YYYY)','loginizer'); ?></th>
1899 <th scope="row" valign="top" style="background:#EFEFEF;" width="100"><?php echo __('Options','loginizer'); ?></th>
1900 </tr>
1901 <?php
1902 if(empty($loginizer['whitelist'])){
1903 echo '
1904 <tr>
1905 <td colspan="4">
1906 No Whitelist IPs. You will see whitelisted IP ranges here.
1907 </td>
1908 </tr>';
1909 }else{
1910 foreach($loginizer['whitelist'] as $ik => $iv){
1911 echo '
1912 <tr>
1913 <td>
1914 '.$iv['start'].'
1915 </td>
1916 <td>
1917 '.$iv['end'].'
1918 </td>
1919 <td>
1920 '.date('d/m/Y', $iv['time']).'
1921 </td>
1922 <td>
1923 <a class="submitdelete" href="javascript:void(0)" onclick="return del_confirm(\'delid\', '.$ik.', \'Are you sure you want to delete this IP range ?\')">Delete</a>
1924 </td>
1925 </tr>';
1926 }
1927 }
1928 ?>
1929 </table>
1930 <br />
1931
1932 </div>
1933
1934 <div id="" class="postbox">
1935
1936 <button class="handlediv button-link" aria-expanded="true" type="button">
1937 <span class="screen-reader-text">Toggle panel: Error Messages</span>
1938 <span class="toggle-indicator" aria-hidden="true"></span>
1939 </button>
1940
1941 <h2 class="hndle ui-sortable-handle">
1942 <span><?php echo __('Error Messages', 'loginizer'); ?></span>
1943 </h2>
1944
1945 <div class="inside">
1946
1947 <form action="" method="post" enctype="multipart/form-data">
1948 <?php wp_nonce_field('loginizer-options'); ?>
1949 <table class="form-table">
1950 <tr>
1951 <th scope="row" valign="top"><label for="msg_inv_userpass"><?php echo __('Failed Login Attempt','loginizer'); ?></label></th>
1952 <td>
1953 <input type="text" size="25" value="<?php echo esc_attr($saved_msgs['inv_userpass']); ?>" name="msg_inv_userpass" id="msg_inv_userpass" />
1954 <?php echo __('Default: <em>&quot;' . $loginizer['d_msg']['inv_userpass']. '&quot;</em>', 'loginizer'); ?><br />
1955 </td>
1956 </tr>
1957 <tr>
1958 <th scope="row" valign="top"><label for="msg_ip_blacklisted"><?php echo __('Blacklisted IP','loginizer'); ?></label></th>
1959 <td>
1960 <input type="text" size="25" value="<?php echo esc_attr($saved_msgs['ip_blacklisted']); ?>" name="msg_ip_blacklisted" id="msg_ip_blacklisted" />
1961 <?php echo __('Default: <em>&quot;' . $loginizer['d_msg']['ip_blacklisted']. '&quot;</em>', 'loginizer'); ?><br />
1962 </td>
1963 </tr>
1964 </table><br />
1965 <input name="save_err_msgs_lz" class="button button-primary action" value="<?php echo __('Save Error Messages','loginizer'); ?>" type="submit" />
1966 </form>
1967 </div>
1968 </div>
1969 <?php
1970
1971 loginizer_page_footer();
1972
1973 }
1974
1975
1976 // Sorry to see you going
1977 register_uninstall_hook(LOGINIZER_FILE, 'loginizer_deactivation');
1978
1979 function loginizer_deactivation(){
1980
1981 global $wpdb;
1982
1983 $sql = array();
1984 $sql[] = "DROP TABLE ".$wpdb->prefix."loginizer_logs;";
1985
1986 foreach($sql as $sk => $sv){
1987 $wpdb->query($sv);
1988 }
1989
1990 delete_option('loginizer_version');
1991 delete_option('loginizer_options');
1992 delete_option('loginizer_last_reset');
1993 delete_option('loginizer_whitelist');
1994 delete_option('loginizer_blacklist');
1995 delete_option('loginizer_msg');
1996 delete_option('loginizer_security');
1997 delete_option('loginizer_wp_admin');
1998
1999 }
2000
2001