PluginProbe
Loginizer / 1.3.9
Loginizer v1.3.9
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.9, at init.php

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