PluginProbe
Loginizer / 1.3.6
Loginizer v1.3.6
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.6, at init.php

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