PluginProbe
Loginizer / 1.4.0
Loginizer v1.4.0
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.4.0, at init.php

2,064 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.4.0');
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 $url = esc_url($url);
580
581 $result = lz_selectquery("SELECT * FROM `".$wpdb->prefix."loginizer_logs` WHERE `ip` = '".$loginizer['current_ip']."';");
582
583 if(!empty($result)){
584 $lockout = floor((($result['count']+1) / $loginizer['max_retries']));
585 $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']."';");
586
587 // Do we need to email admin ?
588 if(!empty($loginizer['notify_email']) && $lockout >= $loginizer['notify_email']){
589
590 $sitename = lz_is_multisite() ? get_site_option('site_name') : get_option('blogname');
591 $mail = array();
592 $mail['to'] = lz_is_multisite() ? get_site_option('admin_email') : get_option('admin_email');
593 $mail['subject'] = 'Failed Login Attempts from IP '.$loginizer['current_ip'].' ('.$sitename.')';
594 $mail['message'] = 'Hi,
595
596 '.($result['count']+1).' failed login attempts and '.$lockout.' lockout(s) from IP '.$loginizer['current_ip'].'
597
598 Last Login Attempt : '.date('d/m/Y H:i:s', time()).'
599 Last User Attempt : '.$username.'
600 IP has been blocked until : '.date('d/m/Y H:i:s', time() + $loginizer['lockout_time']).'
601
602 Regards,
603 Loginizer';
604
605 @wp_mail($mail['to'], $mail['subject'], $mail['message']);
606 }
607 }else{
608 $insert = $wpdb->query("INSERT INTO `".$wpdb->prefix."loginizer_logs` SET `username` = '".$username."', `time` = '".time()."', `count` = '1', `ip` = '".$loginizer['current_ip']."', `lockout` = '0', `url` = '".$url."';");
609 }
610
611 // We need to add one as this is a failed attempt as well
612 $result['count'] = $result['count'] + 1;
613 $loginizer['retries_left'] = ($loginizer['max_retries'] - ($result['count'] % $loginizer['max_retries']));
614 $loginizer['retries_left'] = $loginizer['retries_left'] == $loginizer['max_retries'] ? 0 : $loginizer['retries_left'];
615
616 }
617 }
618
619 // Handles the error of the password not being there
620 function loginizer_error_handler($errors, $redirect_to){
621
622 global $wpdb, $loginizer, $lz_user_pass, $lz_cannot_login;
623
624 //echo 'loginizer_error_handler :';print_r($errors->errors);echo '<br>';
625
626 // Remove the empty password error
627 if(is_wp_error($errors)){
628
629 $codes = $errors->get_error_codes();
630
631 foreach($codes as $k => $v){
632 if($v == 'invalid_username' || $v == 'incorrect_password'){
633 $show_error = 1;
634 }
635 }
636
637 $errors->remove('invalid_username');
638 $errors->remove('incorrect_password');
639
640 }
641
642 // Add the error
643 if(!empty($lz_user_pass) && !empty($show_error) && empty($lz_cannot_login)){
644 $errors->add('invalid_userpass', '<b>ERROR:</b> ' . $loginizer['msg']['inv_userpass']);
645 }
646
647 // Add the number of retires left as well
648 if(count($errors->get_error_codes()) > 0 && isset($loginizer['retries_left'])){
649 $errors->add('retries_left', loginizer_retries_left());
650 }
651
652 return $errors;
653
654 }
655
656
657
658 // Handles the error of the password not being there
659 function loginizer_woocommerce_error_handler(){
660
661 global $wpdb, $loginizer, $lz_user_pass, $lz_cannot_login;
662
663 if(function_exists('wc_add_notice')){
664 wc_add_notice( loginizer_retries_left(), 'error' );
665 }
666
667 }
668
669 // Returns a string with the number of retries left
670 function loginizer_retries_left(){
671
672 global $wpdb, $loginizer, $lz_user_pass, $lz_cannot_login;
673
674 // If we are to show the number of retries left
675 if(isset($loginizer['retries_left'])){
676 return '<b>'.$loginizer['retries_left'].'</b> attempt(s) left';
677 }
678
679 }
680
681 function loginizer_reset_retries(){
682
683 global $wpdb, $loginizer;
684
685 $deltime = time() - $loginizer['reset_retries'];
686 $result = $wpdb->query("DELETE FROM `".$wpdb->prefix."loginizer_logs` WHERE `time` <= '".$deltime."';");
687
688 update_option('loginizer_last_reset', time());
689
690 }
691
692 add_filter("plugin_action_links_$plugin_loginizer", 'loginizer_plugin_action_links');
693
694 // Add settings link on plugin page
695 function loginizer_plugin_action_links($links) {
696
697 if(!defined('LOGINIZER_PREMIUM')){
698 $links[] = '<a href="'.LOGINIZER_PRO_URL.'" style="color:#3db634;" target="_blank">'._x('Upgrade', 'Plugin action link label.', 'loginizer').'</a>';
699 }
700
701 $settings_link = '<a href="admin.php?page=loginizer">Settings</a>';
702 array_unshift($links, $settings_link);
703
704 return $links;
705 }
706
707 add_action('admin_menu', 'loginizer_admin_menu');
708
709 // Shows the admin menu of Loginizer
710 function loginizer_admin_menu() {
711
712 global $wp_version, $loginizer;
713
714 // Add the menu page
715 add_menu_page(__('Loginizer Dashboard'), __('Loginizer Security'), 'activate_plugins', 'loginizer', 'loginizer_page_dashboard');
716
717 // Dashboard
718 add_submenu_page('loginizer', __('Loginizer Dashboard'), __('Dashboard'), 'activate_plugins', 'loginizer', 'loginizer_page_dashboard');
719
720 // Brute Force
721 add_submenu_page('loginizer', __('Loginizer Brute Force Settings'), __('Brute Force'), 'activate_plugins', 'loginizer_brute_force', 'loginizer_page_brute_force');
722
723 if(defined('LOGINIZER_PREMIUM')){
724
725 // PasswordLess
726 add_submenu_page('loginizer', __('Loginizer PasswordLess Settings'), __('PasswordLess'), 'activate_plugins', 'loginizer_passwordless', 'loginizer_page_passwordless');
727
728 // Two Factor Auth
729 add_submenu_page('loginizer', __('Loginizer Two Factor Authentication'), __('Two Factor Auth'), 'activate_plugins', 'loginizer_2fa', 'loginizer_page_2fa');
730
731 // reCaptcha
732 add_submenu_page('loginizer', __('Loginizer reCAPTCHA Settings'), __('reCAPTCHA'), 'activate_plugins', 'loginizer_recaptcha', 'loginizer_page_recaptcha');
733
734 // Security Settings
735 add_submenu_page('loginizer', __('Loginizer Security Settings'), __('Security Settings'), 'activate_plugins', 'loginizer_security', 'loginizer_page_security');
736
737 // Security Settings
738 add_submenu_page('loginizer', __('Loginizer File Checksums'), __('File Checksums'), 'activate_plugins', 'loginizer_checksums', 'loginizer_page_checksums');
739
740 }elseif(!defined('LOGINIZER_PREMIUM') && !empty($loginizer['ins_time']) && $loginizer['ins_time'] < (time() - (30*24*3600))){
741
742 // Go Pro link
743 add_submenu_page('loginizer', __('Loginizer Go Pro'), __('Go Pro'), 'activate_plugins', LOGINIZER_PRO_URL);
744
745 }
746
747 }
748
749 // The Loginizer Admin Options Page
750 function loginizer_page_header($title = 'Loginizer'){
751 /*wp_enqueue_script('common');
752 wp_enqueue_script('wp-lists');
753 wp_enqueue_script('postbox');
754 wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
755
756 echo '
757 <script>
758 jQuery(document).ready( function() {
759 //add_postbox_toggles("loginizer");
760 });
761 </script>';*/
762
763 ?>
764 <style>
765 .lz-right-ul{
766 padding-left: 10px !important;
767 }
768
769 .lz-right-ul li{
770 list-style: circle !important;
771 }
772 </style>
773 <?php
774
775 echo '<div style="margin: 10px 20px 0 2px;">
776 <div class="metabox-holder columns-2">
777 <div class="postbox-container">
778 <div id="top-sortables" class="meta-box-sortables ui-sortable">
779
780 <table cellpadding="2" cellspacing="1" width="100%" class="fixed" border="0">
781 <tr>
782 <td valign="top"><h3>'.$title.'</h3></td>
783 <td align="right"><a target="_blank" class="button button-primary" href="https://wordpress.org/support/view/plugin-reviews/loginizer">Review Loginizer</a></td>
784 <td align="right" width="40"><a target="_blank" href="https://twitter.com/loginizer"><img src="'.LOGINIZER_URL.'/twitter.png" /></a></td>
785 <td align="right" width="40"><a target="_blank" href="https://www.facebook.com/Loginizer-815504798591884"><img src="'.LOGINIZER_URL.'/facebook.png" /></a></td>
786 </tr>
787 </table>
788 <hr />
789
790 <!--Main Table-->
791 <table cellpadding="8" cellspacing="1" width="100%" class="fixed">
792 <tr>
793 <td valign="top">';
794
795 }
796
797 // The Loginizer Theme footer
798 function loginizer_page_footer(){
799
800 echo '</td>
801 <td width="200" valign="top" id="loginizer-right-bar">';
802
803 if(!defined('LOGINIZER_PREMIUM')){
804
805 echo '
806 <div class="postbox" style="min-width:0px !important;">
807 <h2 class="hndle ui-sortable-handle">
808 <span>Premium Version</span>
809 </h2>
810 <div class="inside">
811 <i>Upgrade to the premium version and get the following features </i>:<br>
812 <ul class="lz-right-ul">
813 <li>PasswordLess Login</li>
814 <li>Two Factor Auth - Email</li>
815 <li>Two Factor Auth - App</li>
816 <li>Login Challenge Question</li>
817 <li>reCAPTCHA</li>
818 <li>Rename Login Page</li>
819 <li>Disable XML-RPC</li>
820 <li>And many more ...</li>
821 </ul>
822 <center><a class="button button-primary" href="https://loginizer.com/members/cart.php">Upgrade</a></center>
823 </div>
824 </div>';
825
826 }else{
827
828 echo '
829 <div class="postbox" style="min-width:0px !important;">
830 <h2 class="hndle ui-sortable-handle">
831 <span>Recommendations</span>
832 </h2>
833 <div class="inside">
834 <i>We recommed that you enable atleast one of the following security features</i>:<br>
835 <ul class="lz-right-ul">
836 <li>Rename Login Page</li>
837 <li>Login Challenge Question</li>
838 <li>reCAPTCHA</li>
839 <li>Two Factor Auth - Email</li>
840 <li>Two Factor Auth - App</li>
841 <li>Change \'admin\' Username</li>
842 </ul>
843 </div>
844 </div>';
845 }
846
847 echo '</td>
848 </tr>
849 </table>
850 <br />
851 <div style="width:45%;background:#FFF;padding:15px; margin:auto">
852 <b>Let your friends know that you have secured your website :</b>
853 <form method="get" action="https://twitter.com/intent/tweet" id="tweet" onsubmit="return dotweet(this);">
854 <textarea name="text" cols="45" row="3" style="resize:none;">I just secured my @WordPress site against #bruteforce using @loginizer</textarea>
855 &nbsp; &nbsp; <input type="submit" value="Tweet!" class="button button-primary" onsubmit="return false;" id="twitter-btn" style="margin-top:20px;"/>
856 </form>
857
858 </div>
859 <br />
860
861 <script>
862 function dotweet(ele){
863 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");
864 return false;
865 }
866 </script>
867
868 <hr />
869 <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>.
870
871 </div>
872 </div>
873 </div>
874 </div>';
875
876 }
877
878 // The Loginizer Admin Options Page
879 function loginizer_page_dashboard(){
880
881 global $loginizer, $lz_error, $lz_env;
882
883 // Is there a license key ?
884 if(isset($_POST['save_lz'])){
885
886 $license = lz_optpost('lz_license');
887
888 // Check if its a valid license
889 if(empty($license)){
890 $lz_error['lic_invalid'] = __('The license key was not submitted', 'loginizer');
891 return loginizer_page_dashboard_T();
892 }
893
894 $resp = wp_remote_get(LOGINIZER_API.'license.php?license='.$license);
895
896 if(is_array($resp)){
897 $json = json_decode($resp['body'], true);
898 //print_r($json);
899 }
900
901 // Save the License
902 if(empty($json['license'])){
903
904 $lz_error['lic_invalid'] = __('The license key is invalid', 'loginizer');
905 return loginizer_page_dashboard_T();
906
907 }else{
908
909 update_option('loginizer_license', $json);
910
911 // Mark as saved
912 $GLOBALS['lz_saved'] = true;
913 }
914
915 }
916
917
918 // Is there a IP Method ?
919 if(isset($_POST['save_lz_ip_method'])){
920
921 $ip_method = (int) lz_optpost('lz_ip_method');
922 $custom_ip_method = lz_optpost('lz_custom_ip_method');
923
924 if($ip_method >= 0 && $ip_method <= 3){
925 update_option('loginizer_ip_method', $ip_method);
926 }
927
928 // Custom Method name ?
929 if($ip_method == 3){
930 update_option('loginizer_custom_ip_method', $custom_ip_method);
931 }
932
933 }
934
935 loginizer_page_dashboard_T();
936
937 }
938
939 // The Loginizer Admin Options Page - THEME
940 function loginizer_page_dashboard_T(){
941
942 global $loginizer, $lz_error, $lz_env;
943
944 loginizer_page_header('Loginizer Dashboard');
945 ?>
946 <style>
947 .welcome-panel{
948 margin: 0px;
949 padding: 10px;
950 }
951
952 input[type="text"], textarea, select {
953 width: 70%;
954 }
955
956 .form-table label{
957 font-weight:bold;
958 }
959
960 .exp{
961 font-size:12px;
962 }
963 </style>
964
965 <?php
966 echo '<script src="https://api.loginizer.com/'.(defined('LOGINIZER_PREMIUM') ? 'news_security.js' : 'news.js').'"></script><br>';
967
968 // Saved ?
969 if(!empty($GLOBALS['lz_saved'])){
970 echo '<div id="message" class="updated"><p>'. __('The settings were saved successfully', 'loginizer'). '</p></div><br />';
971 }
972
973 // Any errors ?
974 if(!empty($lz_error)){
975 lz_report_error($lz_error);echo '<br />';
976 }
977
978 ?>
979
980 <div class="postbox">
981
982 <button class="handlediv button-link" aria-expanded="true" type="button">
983 <span class="screen-reader-text">Toggle panel: Getting Started</span>
984 <span class="toggle-indicator" aria-hidden="true"></span>
985 </button>
986
987 <h2 class="hndle ui-sortable-handle">
988 <span><?php echo __('Getting Started', 'loginizer'); ?></span>
989 </h2>
990
991 <div class="inside">
992
993 <form action="" method="post" enctype="multipart/form-data">
994 <?php wp_nonce_field('loginizer-options'); ?>
995 <table class="form-table">
996 <tr>
997 <td scope="row" valign="top" colspan="2" style="line-height:150%">
998 <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>
999 <?php
1000 if(defined('LOGINIZER_PREMIUM')){
1001 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>';
1002 }
1003 ?>
1004 </td>
1005 </tr>
1006 </table>
1007 </form>
1008
1009 </div>
1010 </div>
1011
1012 <div class="postbox">
1013
1014 <button class="handlediv button-link" aria-expanded="true" type="button">
1015 <span class="screen-reader-text">Toggle panel: System Information</span>
1016 <span class="toggle-indicator" aria-hidden="true"></span>
1017 </button>
1018
1019 <h2 class="hndle ui-sortable-handle">
1020 <span><?php echo __('System Information', 'loginizer'); ?></span>
1021 </h2>
1022
1023 <div class="inside">
1024
1025 <form action="" method="post" enctype="multipart/form-data">
1026 <?php wp_nonce_field('loginizer-options'); ?>
1027 <table class="wp-list-table fixed striped users" cellspacing="1" border="0" width="95%" cellpadding="10" align="center">
1028 <?php
1029 echo '
1030 <tr>
1031 <th align="left" width="25%">'.__('Loginizer Version', 'loginizer').'</th>
1032 <td>'.LOGINIZER_VERSION.(defined('LOGINIZER_PREMIUM') ? ' (Security PRO Version)' : '').'</td>
1033 </tr>';
1034
1035 if(defined('LOGINIZER_PREMIUM')){
1036 echo '
1037 <tr>
1038 <th align="left" valign="top">'.__('Loginizer License', 'loginizer').'</th>
1039 <td align="left">
1040 '.(empty($loginizer['license']) ? '<span style="color:red">Unlicensed</span> &nbsp; &nbsp;' : '').'
1041 <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;
1042 <input name="save_lz" class="button button-primary" value="Update License" type="submit" />';
1043
1044 if(!empty($loginizer['license'])){
1045
1046 $expires = $loginizer['license']['expires'];
1047 $expires = substr($expires, 0, 4).'/'.substr($expires, 4, 2).'/'.substr($expires, 6);
1048
1049 echo '<div style="margin-top:10px;">License Active : '.(empty($loginizer['license']['active']) ? '<span style="color:red">No</span>' : 'Yes').' &nbsp; &nbsp; &nbsp;
1050 License Expires : '.($loginizer['license']['expires'] <= date('Ymd') ? '<span style="color:red">'.$expires.'</span>' : $expires).'
1051 </div>';
1052 }
1053
1054
1055 echo
1056 '</td>
1057 </tr>';
1058 }
1059
1060 echo '<tr>
1061 <th align="left">'.__('URL', 'loginizer').'</th>
1062 <td>'.get_site_url().'</td>
1063 </tr>
1064 <tr>
1065 <th align="left">'.__('Path', 'loginizer').'</th>
1066 <td>'.ABSPATH.'</td>
1067 </tr>
1068 <tr>
1069 <th align="left">'.__('Server\'s IP Address', 'loginizer').'</th>
1070 <td>'.$_SERVER['SERVER_ADDR'].'</td>
1071 </tr>
1072 <tr>
1073 <th align="left">'.__('Your IP Address', 'loginizer').'</th>
1074 <td>'.lz_getip().'
1075 <div style="float:right">
1076 Method :
1077 <select name="lz_ip_method" id="lz_ip_method" style="font-size:11px; width:150px" onchange="lz_ip_method_handle()">
1078 <option value="0" '.lz_POSTselect('lz_ip_method', 0, (@$loginizer['ip_method'] == 0)).'>REMOTE_ADDR</option>
1079 <option value="1" '.lz_POSTselect('lz_ip_method', 1, (@$loginizer['ip_method'] == 1)).'>HTTP_X_FORWARDED_FOR</option>
1080 <option value="2" '.lz_POSTselect('lz_ip_method', 2, (@$loginizer['ip_method'] == 2)).'>HTTP_CLIENT_IP</option>
1081 <option value="3" '.lz_POSTselect('lz_ip_method', 3, (@$loginizer['ip_method'] == 3)).'>CUSTOM</option>
1082 </select>
1083 <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" />
1084 <input name="save_lz_ip_method" class="button button-primary" value="Save" type="submit" />
1085 </div>
1086 </td>
1087 </tr>
1088 <tr>
1089 <th align="left">'.__('wp-config.php is writable', 'loginizer').'</th>
1090 <td>'.(is_writable(ABSPATH.'/wp-config.php') ? '<span style="color:red">Yes</span>' : '<span style="color:green">No</span>').'</td>
1091 </tr>';
1092
1093 if(file_exists(ABSPATH.'/.htaccess')){
1094 echo '
1095 <tr>
1096 <th align="left">'.__('.htaccess is writable', 'loginizer').'</th>
1097 <td>'.(is_writable(ABSPATH.'/.htaccess') ? '<span style="color:red">Yes</span>' : '<span style="color:green">No</span>').'</td>
1098 </tr>';
1099
1100 }
1101
1102 ?>
1103 </table>
1104 </form>
1105
1106 </div>
1107 </div>
1108
1109 <script type="text/javascript">
1110
1111 function lz_ip_method_handle(){
1112 var ele = jQuery('#lz_ip_method');
1113 if(ele.val() == 3){
1114 jQuery('#lz_custom_ip_method').show();
1115 }else{
1116 jQuery('#lz_custom_ip_method').hide();
1117 }
1118 };
1119
1120 lz_ip_method_handle();
1121
1122 </script>
1123
1124 <div id="" class="postbox">
1125
1126 <button class="handlediv button-link" aria-expanded="true" type="button">
1127 <span class="screen-reader-text">Toggle panel: File Permissions</span>
1128 <span class="toggle-indicator" aria-hidden="true"></span>
1129 </button>
1130
1131 <h2 class="hndle ui-sortable-handle">
1132 <span><?php echo __('File Permissions', 'loginizer'); ?></span>
1133 </h2>
1134
1135 <div class="inside">
1136
1137 <form action="" method="post" enctype="multipart/form-data">
1138 <?php wp_nonce_field('loginizer-options'); ?>
1139 <table class="wp-list-table fixed striped users" border="0" width="95%" cellpadding="10" align="center">
1140 <?php
1141
1142 echo '
1143 <tr>
1144 <th style="background:#EFEFEF;">'.__('Relative Path', 'loginizer').'</th>
1145 <th style="width:10%; background:#EFEFEF;">'.__('Suggested', 'loginizer').'</th>
1146 <th style="width:10%; background:#EFEFEF;">'.__('Actual', 'loginizer').'</th>
1147 </tr>';
1148
1149 $wp_content = basename(dirname(dirname(dirname(__FILE__))));
1150
1151 $files_to_check = array('/' => '0755',
1152 '/wp-admin' => '0755',
1153 '/wp-includes' => '0755',
1154 '/wp-config.php' => '0444',
1155 '/'.$wp_content => '0755',
1156 '/'.$wp_content.'/themes' => '0755',
1157 '/'.$wp_content.'/plugins' => '0755',
1158 '.htaccess' => '0444');
1159
1160 $root = ABSPATH;
1161
1162 foreach($files_to_check as $k => $v){
1163
1164 $path = $root.'/'.$k;
1165 $stat = @stat($path);
1166 $suggested = $v;
1167 $actual = substr(sprintf('%o', $stat['mode']), -4);
1168
1169 echo '
1170 <tr>
1171 <td>'.$k.'</td>
1172 <td>'.$suggested.'</td>
1173 <td><span '.($suggested != $actual ? 'style="color: red;"' : '').'>'.$actual.'</span></td>
1174 </tr>';
1175
1176 }
1177
1178 ?>
1179 </table>
1180 </form>
1181
1182 </div>
1183 </div>
1184
1185 <?php
1186
1187 loginizer_page_footer();
1188
1189 }
1190
1191 // The Loginizer Admin Options Page
1192 function loginizer_page_brute_force(){
1193
1194 global $wpdb, $wp_roles, $loginizer;
1195
1196 if(!current_user_can('manage_options')){
1197 wp_die('Sorry, but you do not have permissions to change settings.');
1198 }
1199
1200 /* Make sure post was from this page */
1201 if(count($_POST) > 0){
1202 check_admin_referer('loginizer-options');
1203 }
1204
1205 // BEGIN THEME
1206 loginizer_page_header('Loginizer - Brute Force Settings');
1207
1208 // Load the blacklist and whitelist
1209 $loginizer['blacklist'] = get_option('loginizer_blacklist');
1210 $loginizer['whitelist'] = get_option('loginizer_whitelist');
1211
1212 // Disable Brute Force
1213 if(isset($_POST['disable_brute_lz'])){
1214
1215 // Save the options
1216 update_option('loginizer_disable_brute', 1);
1217
1218 $loginizer['disable_brute'] = 1;
1219
1220 echo '<div id="message" class="updated"><p>'
1221 . __('The Brute Force Protection feature is now disabled', 'loginizer')
1222 . '</p></div><br />';
1223
1224 }
1225
1226 // Enable brute force
1227 if(isset($_POST['enable_brute_lz'])){
1228
1229 // Save the options
1230 update_option('loginizer_disable_brute', 0);
1231
1232 $loginizer['disable_brute'] = 0;
1233
1234 echo '<div id="message" class="updated"><p>'
1235 . __('The Brute Force Protection feature is now enabled', 'loginizer')
1236 . '</p></div><br />';
1237
1238 }
1239
1240 // The Brute Force Settings
1241 if(isset($_POST['save_lz'])){
1242
1243 $max_retries = (int) lz_optpost('max_retries');
1244 $lockout_time = (int) lz_optpost('lockout_time');
1245 $max_lockouts = (int) lz_optpost('max_lockouts');
1246 $lockouts_extend = (int) lz_optpost('lockouts_extend');
1247 $reset_retries = (int) lz_optpost('reset_retries');
1248 $notify_email = (int) lz_optpost('notify_email');
1249
1250 $lockout_time = $lockout_time * 60;
1251 $lockouts_extend = $lockouts_extend * 60 * 60;
1252 $reset_retries = $reset_retries * 60 * 60;
1253
1254 if(empty($error)){
1255
1256 $option['max_retries'] = $max_retries;
1257 $option['lockout_time'] = $lockout_time;
1258 $option['max_lockouts'] = $max_lockouts;
1259 $option['lockouts_extend'] = $lockouts_extend;
1260 $option['reset_retries'] = $reset_retries;
1261 $option['notify_email'] = $notify_email;
1262
1263 // Save the options
1264 update_option('loginizer_options', $option);
1265
1266 $saved = true;
1267
1268 }else{
1269 lz_report_error($error);
1270 }
1271
1272 if(!empty($notice)){
1273 lz_report_notice($notice);
1274 }
1275
1276 if(!empty($saved)){
1277 echo '<div id="message" class="updated"><p>'
1278 . __('The settings were saved successfully', 'loginizer')
1279 . '</p></div><br />';
1280 }
1281
1282 }
1283
1284 // Delete a Blackist IP range
1285 if(isset($_POST['bdelid'])){
1286
1287 $delid = (int) lz_optreq('bdelid');
1288
1289 // Unset and save
1290 $blacklist = $loginizer['blacklist'];
1291 unset($blacklist[$delid]);
1292 update_option('loginizer_blacklist', $blacklist);
1293
1294 echo '<div id="message" class="updated fade"><p>'
1295 . __('The Blacklist IP range has been deleted successfully', 'loginizer')
1296 . '</p></div><br />';
1297
1298 }
1299
1300 // Delete all Blackist IP ranges
1301 if(isset($_POST['del_all_blacklist'])){
1302
1303 // Unset and save
1304 update_option('loginizer_blacklist', array());
1305
1306 echo '<div id="message" class="updated fade"><p>'
1307 . __('The Blacklist IP range(s) have been cleared successfully', 'loginizer')
1308 . '</p></div><br />';
1309
1310 }
1311
1312 // Delete a Whitelist IP range
1313 if(isset($_POST['delid'])){
1314
1315 $delid = (int) lz_optreq('delid');
1316
1317 // Unset and save
1318 $whitelist = $loginizer['whitelist'];
1319 unset($whitelist[$delid]);
1320 update_option('loginizer_whitelist', $whitelist);
1321
1322 echo '<div id="message" class="updated fade"><p>'
1323 . __('The Whitelist IP range has been deleted successfully', 'loginizer')
1324 . '</p></div><br />';
1325
1326 }
1327
1328 // Delete all Blackist IP ranges
1329 if(isset($_POST['del_all_whitelist'])){
1330
1331 // Unset and save
1332 update_option('loginizer_whitelist', array());
1333
1334 echo '<div id="message" class="updated fade"><p>'
1335 . __('The Whitelist IP range(s) have been cleared successfully', 'loginizer')
1336 . '</p></div><br />';
1337
1338 }
1339
1340 // Reset All Logs
1341 if(isset($_POST['lz_reset_all_ip'])){
1342
1343 $result = $wpdb->query("DELETE FROM `".$wpdb->prefix."loginizer_logs`
1344 WHERE `time` > 0");
1345
1346 echo '<div id="message" class="updated fade"><p>'
1347 . __('All the IP Logs have been cleared', 'loginizer')
1348 . '</p></div><br />';
1349 }
1350
1351 // Reset Logs
1352 if(isset($_POST['lz_reset_ips']) && is_array($_POST['lz_reset_ips'])){
1353
1354 $ips = $_POST['lz_reset_ips'];
1355
1356 foreach($ips as $ip){
1357 if(!lz_valid_ip($ip)){
1358 $error[] = 'The IP - '.$ip.' is invalid !';
1359 }
1360 }
1361
1362 if(count($ips) < 1){
1363 $error[] = 'There are no IPs submitted';
1364 }
1365
1366 // Should we start deleting logs
1367 if(empty($error)){
1368
1369 $result = $wpdb->query("DELETE FROM `".$wpdb->prefix."loginizer_logs`
1370 WHERE `ip` IN ('".implode("', '", $ips)."')");
1371
1372 if(empty($error)){
1373
1374 echo '<div id="message" class="updated fade"><p>'
1375 . __('The selected IP Logs have been reset', 'loginizer')
1376 . '</p></div><br />';
1377
1378 }
1379
1380 }
1381
1382 if(!empty($error)){
1383 lz_report_error($error);echo '<br />';
1384 }
1385
1386 }
1387
1388 if(isset($_POST['blacklist_iprange'])){
1389
1390 $start_ip = lz_optpost('start_ip');
1391 $end_ip = lz_optpost('end_ip');
1392
1393 if(empty($start_ip)){
1394 $error[] = 'Please enter the Start IP';
1395 }
1396
1397 // If no end IP we consider only 1 IP
1398 if(empty($end_ip)){
1399 $end_ip = $start_ip;
1400 }
1401
1402 if(!lz_valid_ip($start_ip)){
1403 $error[] = 'Please provide a valid start IP';
1404 }
1405
1406 if(!lz_valid_ip($end_ip)){
1407 $error[] = 'Please provide a valid end IP';
1408 }
1409
1410 // Regular ranges will work
1411 if(inet_ptoi($start_ip) > inet_ptoi($end_ip)){
1412
1413 // BUT, if 0.0.0.1 - 255.255.255.255 is given, it will not work
1414 if(inet_ptoi($start_ip) >= 0 && inet_ptoi($end_ip) < 0){
1415 // This is right
1416 }else{
1417 $error[] = 'The End IP cannot be smaller than the Start IP';
1418 }
1419
1420 }
1421
1422 if(empty($error)){
1423
1424 $blacklist = $loginizer['blacklist'];
1425
1426 foreach($blacklist as $k => $v){
1427
1428 // This is to check if there is any other range exists with the same Start or End IP
1429 if(( inet_ptoi($start_ip) <= inet_ptoi($v['start']) && inet_ptoi($v['start']) <= inet_ptoi($end_ip) )
1430 || ( inet_ptoi($start_ip) <= inet_ptoi($v['end']) && inet_ptoi($v['end']) <= inet_ptoi($end_ip) )
1431 ){
1432 $error[] = 'The Start IP or End IP submitted conflicts with an existing IP range !';
1433 break;
1434 }
1435
1436 // This is to check if there is any other range exists with the same Start IP
1437 if(inet_ptoi($v['start']) <= inet_ptoi($start_ip) && inet_ptoi($start_ip) <= inet_ptoi($v['end'])){
1438 $error[] = 'The Start IP is present in an existing range !';
1439 break;
1440 }
1441
1442 // This is to check if there is any other range exists with the same End IP
1443 if(inet_ptoi($v['start']) <= inet_ptoi($end_ip) && inet_ptoi($end_ip) <= inet_ptoi($v['end'])){
1444 $error[] = 'The End IP is present in an existing range!';
1445 break;
1446 }
1447
1448 }
1449
1450 $newid = ( empty($blacklist) ? 0 : max(array_keys($blacklist)) ) + 1;
1451
1452 if(empty($error)){
1453
1454 $blacklist[$newid] = array();
1455 $blacklist[$newid]['start'] = $start_ip;
1456 $blacklist[$newid]['end'] = $end_ip;
1457 $blacklist[$newid]['time'] = time();
1458
1459 update_option('loginizer_blacklist', $blacklist);
1460
1461 echo '<div id="message" class="updated fade"><p>'
1462 . __('Blacklist IP range added successfully', 'loginizer')
1463 . '</p></div><br />';
1464
1465 }
1466
1467 }
1468
1469 if(!empty($error)){
1470 lz_report_error($error);echo '<br />';
1471 }
1472
1473 }
1474
1475 if(isset($_POST['whitelist_iprange'])){
1476
1477 $start_ip = lz_optpost('start_ip_w');
1478 $end_ip = lz_optpost('end_ip_w');
1479
1480 if(empty($start_ip)){
1481 $error[] = 'Please enter the Start IP';
1482 }
1483
1484 // If no end IP we consider only 1 IP
1485 if(empty($end_ip)){
1486 $end_ip = $start_ip;
1487 }
1488
1489 if(!lz_valid_ip($start_ip)){
1490 $error[] = 'Please provide a valid start IP';
1491 }
1492
1493 if(!lz_valid_ip($end_ip)){
1494 $error[] = 'Please provide a valid end IP';
1495 }
1496
1497 if(inet_ptoi($start_ip) > inet_ptoi($end_ip)){
1498
1499 // BUT, if 0.0.0.1 - 255.255.255.255 is given, it will not work
1500 if(inet_ptoi($start_ip) >= 0 && inet_ptoi($end_ip) < 0){
1501 // This is right
1502 }else{
1503 $error[] = 'The End IP cannot be smaller than the Start IP';
1504 }
1505
1506 }
1507
1508 if(empty($error)){
1509
1510 $whitelist = $loginizer['whitelist'];
1511
1512 foreach($whitelist as $k => $v){
1513
1514 // This is to check if there is any other range exists with the same Start or End IP
1515 if(( inet_ptoi($start_ip) <= inet_ptoi($v['start']) && inet_ptoi($v['start']) <= inet_ptoi($end_ip) )
1516 || ( inet_ptoi($start_ip) <= inet_ptoi($v['end']) && inet_ptoi($v['end']) <= inet_ptoi($end_ip) )
1517 ){
1518 $error[] = 'The Start IP or End IP submitted conflicts with an existing IP range !';
1519 break;
1520 }
1521
1522 // This is to check if there is any other range exists with the same Start IP
1523 if(inet_ptoi($v['start']) <= inet_ptoi($start_ip) && inet_ptoi($start_ip) <= inet_ptoi($v['end'])){
1524 $error[] = 'The Start IP is present in an existing range !';
1525 break;
1526 }
1527
1528 // This is to check if there is any other range exists with the same End IP
1529 if(inet_ptoi($v['start']) <= inet_ptoi($end_ip) && inet_ptoi($end_ip) <= inet_ptoi($v['end'])){
1530 $error[] = 'The End IP is present in an existing range!';
1531 break;
1532 }
1533
1534 }
1535
1536 $newid = ( empty($whitelist) ? 0 : max(array_keys($whitelist)) ) + 1;
1537
1538 if(empty($error)){
1539
1540 $whitelist[$newid] = array();
1541 $whitelist[$newid]['start'] = $start_ip;
1542 $whitelist[$newid]['end'] = $end_ip;
1543 $whitelist[$newid]['time'] = time();
1544
1545 update_option('loginizer_whitelist', $whitelist);
1546
1547 echo '<div id="message" class="updated fade"><p>'
1548 . __('Whitelist IP range added successfully', 'loginizer')
1549 . '</p></div><br />';
1550
1551 }
1552
1553 }
1554
1555 if(!empty($error)){
1556 lz_report_error($error);echo '<br />';
1557 }
1558 }
1559
1560 // Save the messages
1561 if(isset($_POST['save_err_msgs_lz'])){
1562
1563 $msgs['inv_userpass'] = lz_optpost('msg_inv_userpass');
1564 $msgs['ip_blacklisted'] = lz_optpost('msg_ip_blacklisted');
1565
1566 // Update them
1567 update_option('loginizer_msg', $msgs);
1568
1569 echo '<div id="message" class="updated fade"><p>'
1570 . __('Error messages were saved successfully', 'loginizer')
1571 . '</p></div><br />';
1572
1573 }
1574
1575 // Count the Results
1576 $tmp = lz_selectquery("SELECT COUNT(*) AS num FROM `".$wpdb->prefix."loginizer_logs`");
1577 //print_r($tmp);
1578
1579 // Which Page is it
1580 $lz_env['res_len'] = 10;
1581 $lz_env['cur_page'] = lz_get_page('lzpage', $lz_env['res_len']);
1582 $lz_env['num_res'] = $tmp['num'];
1583 $lz_env['max_page'] = ceil($lz_env['num_res'] / $lz_env['res_len']);
1584
1585 // Get the logs
1586 $result = lz_selectquery("SELECT * FROM `".$wpdb->prefix."loginizer_logs`
1587 ORDER BY `time` DESC
1588 LIMIT ".$lz_env['cur_page'].", ".$lz_env['res_len']."", 1);
1589 //print_r($result);
1590
1591 $lz_env['cur_page'] = ($lz_env['cur_page'] / $lz_env['res_len']) + 1;
1592 $lz_env['cur_page'] = $lz_env['cur_page'] < 1 ? 1 : $lz_env['cur_page'];
1593 $lz_env['next_page'] = ($lz_env['cur_page'] + 1) > $lz_env['max_page'] ? $lz_env['max_page'] : ($lz_env['cur_page'] + 1);
1594 $lz_env['prev_page'] = ($lz_env['cur_page'] - 1) < 1 ? 1 : ($lz_env['cur_page'] - 1);
1595
1596 // Reload the settings
1597 $loginizer['blacklist'] = get_option('loginizer_blacklist');
1598 $loginizer['whitelist'] = get_option('loginizer_whitelist');
1599
1600 $saved_msgs = get_option('loginizer_msg');
1601
1602 ?>
1603
1604 <div id="" class="postbox">
1605
1606 <button class="handlediv button-link" aria-expanded="true" type="button">
1607 <span class="screen-reader-text">Toggle panel: Failed Login Attempts Logs</span>
1608 <span class="toggle-indicator" aria-hidden="true"></span>
1609 </button>
1610
1611 <h2 class="hndle ui-sortable-handle">
1612 <?php echo __('<span>Failed Login Attempts Logs</span> &nbsp; (Past '.($loginizer['reset_retries']/60/60).' hours)','loginizer'); ?>
1613 </h2>
1614
1615 <script>
1616 function yesdsd(){
1617 window.location = '<?php echo menu_page_url('loginizer_brute_force', false);?>&lzpage='+jQuery("#current-page-selector").val();
1618 return false;
1619 }
1620 </script>
1621
1622 <form method="get" onsubmit="return yesdsd();">
1623 <div class="tablenav">
1624 <p class="tablenav-pages" style="margin: 5px 10px" align="right">
1625 <span class="displaying-num"><?php echo $lz_env['num_res'];?> items</span>
1626 <span class="pagination-links">
1627 <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>
1628 <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>
1629 <span class="paging-input">
1630 <label for="current-page-selector" class="screen-reader-text">Current Page</label>
1631 <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>
1632 </span>
1633 <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>
1634 <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>
1635 </span>
1636 </p>
1637 </div>
1638 </form>
1639
1640 <form action="" method="post" enctype="multipart/form-data">
1641 <?php wp_nonce_field('loginizer-options'); ?>
1642 <div class="inside">
1643 <table class="wp-list-table widefat fixed users" border="0">
1644 <tr>
1645 <th scope="row" valign="top" style="background:#EFEFEF;" width="20">#</th>
1646 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('IP','loginizer'); ?></th>
1647 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Attempted Username','loginizer'); ?></th>
1648 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Last Failed Attempt (DD/MM/YYYY)','loginizer'); ?></th>
1649 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Failed Attempts Count','loginizer'); ?></th>
1650 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Lockouts Count','loginizer'); ?></th>
1651 <th scope="row" valign="top" style="background:#EFEFEF;" width="150"><?php echo __('URL Attacked','loginizer'); ?></th>
1652 </tr>
1653 <?php
1654
1655 if(empty($result)){
1656 echo '
1657 <tr>
1658 <td colspan="4">
1659 No Logs. You will see logs about failed login attempts here.
1660 </td>
1661 </tr>';
1662 }else{
1663 foreach($result as $ik => $iv){
1664 $status_button = (!empty($iv['status']) ? 'disable' : 'enable');
1665 echo '
1666 <tr>
1667 <td>
1668 <input type="checkbox" value="'.$iv['ip'].'" name="lz_reset_ips[]" />
1669 </td>
1670 <td>
1671 '.$iv['ip'].'
1672 </td>
1673 <td>
1674 '.$iv['username'].'
1675 </td>
1676 <td>
1677 '.date('d/m/Y H:i:s', $iv['time']).'
1678 </td>
1679 <td>
1680 '.$iv['count'].'
1681 </td>
1682 <td>
1683 '.$iv['lockout'].'
1684 </td>
1685 <td>
1686 '.$iv['url'].'
1687 </td>
1688 </tr>';
1689 }
1690 }
1691
1692 ?>
1693 </table>
1694
1695 <br>
1696 <input name="lz_reset_ip" class="button button-primary action" value="<?php echo __('Remove From Logs', 'loginizer'); ?>" type="submit" />
1697 &nbsp; &nbsp;
1698 <input name="lz_reset_all_ip" class="button button-primary action" value="<?php echo __('Clear All Logs', 'loginizer'); ?>" type="submit" />
1699 </div>
1700 </div>
1701 </form>
1702 <br />
1703
1704 <div id="" class="postbox">
1705
1706 <button class="handlediv button-link" aria-expanded="true" type="button">
1707 <span class="screen-reader-text">Toggle panel: Brute Force Settings</span>
1708 <span class="toggle-indicator" aria-hidden="true"></span>
1709 </button>
1710
1711 <h2 class="hndle ui-sortable-handle">
1712 <span><?php echo __('Brute Force Settings', 'loginizer'); ?></span>
1713 </h2>
1714
1715 <div class="inside">
1716
1717 <form action="" method="post" enctype="multipart/form-data">
1718 <?php wp_nonce_field('loginizer-options'); ?>
1719 <table class="form-table">
1720 <tr>
1721 <th scope="row" valign="top"><label for="max_retries"><?php echo __('Max Retries','loginizer'); ?></label></th>
1722 <td>
1723 <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 />
1724 </td>
1725 </tr>
1726 <tr>
1727 <th scope="row" valign="top"><label for="lockout_time"><?php echo __('Lockout Time','loginizer'); ?></label></th>
1728 <td>
1729 <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 />
1730 </td>
1731 </tr>
1732 <tr>
1733 <th scope="row" valign="top"><label for="max_lockouts"><?php echo __('Max Lockouts','loginizer'); ?></label></th>
1734 <td>
1735 <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 />
1736 </td>
1737 </tr>
1738 <tr>
1739 <th scope="row" valign="top"><label for="lockouts_extend"><?php echo __('Extend Lockout','loginizer'); ?></label></th>
1740 <td>
1741 <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 />
1742 </td>
1743 </tr>
1744 <tr>
1745 <th scope="row" valign="top"><label for="reset_retries"><?php echo __('Reset Retries','loginizer'); ?></label></th>
1746 <td>
1747 <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 />
1748 </td>
1749 </tr>
1750 <tr>
1751 <th scope="row" valign="top"><label for="notify_email"><?php echo __('Email Notification','loginizer'); ?></label></th>
1752 <td>
1753 <?php echo __('after ','loginizer'); ?>
1754 <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'); ?>
1755 </td>
1756 </tr>
1757 </table><br />
1758 <input name="save_lz" class="button button-primary action" value="<?php echo __('Save Settings','loginizer'); ?>" type="submit" />
1759 <?php
1760
1761 if(empty($loginizer['disable_brute'])){
1762
1763 echo '<input name="disable_brute_lz" class="button action" value="'.__('Disable Brute Force Protection','loginizer').'" type="submit" style="float:right" />';
1764
1765 }else{
1766
1767 echo '<input name="enable_brute_lz" class="button button-primary action" value="'.__('Enable Brute Force Protection','loginizer').'" type="submit" style="float:right" />';
1768
1769 }
1770
1771 ?>
1772 </form>
1773
1774 </div>
1775 </div>
1776 <br />
1777
1778 <?php
1779
1780 wp_enqueue_script('jquery-paginate', LOGINIZER_URL.'/jquery-paginate.js', array('jquery'), '1.10.15');
1781
1782 ?>
1783
1784 <style>
1785 .page-navigation a {
1786 margin: 5px 2px;
1787 display: inline-block;
1788 padding: 5px 8px;
1789 color: #0073aa;
1790 background: #e5e5e5 none repeat scroll 0 0;
1791 border: 1px solid #ccc;
1792 text-decoration: none;
1793 transition-duration: 0.05s;
1794 transition-property: border, background, color;
1795 transition-timing-function: ease-in-out;
1796 }
1797
1798 .page-navigation a[data-selected] {
1799 background-color: #00a0d2;
1800 color: #fff;
1801 }
1802 </style>
1803
1804 <script>
1805
1806 jQuery(document).ready(function(){
1807 jQuery('#lz_bl_table').paginate({ limit: 11, navigationWrapper: jQuery('#lz_bl_nav')});
1808 jQuery('#lz_wl_table').paginate({ limit: 11, navigationWrapper: jQuery('#lz_wl_nav')});
1809 });
1810
1811 // Delete a Blacklist / Whitelist IP Range
1812 function del_confirm(field, todo_id, msg){
1813 var ret = confirm(msg);
1814
1815 if(ret){
1816 jQuery('#lz_bl_wl_todo').attr('name', field);
1817 jQuery('#lz_bl_wl_todo').val(todo_id);
1818 jQuery('#lz_bl_wl_form').submit();
1819 }
1820
1821 return false;
1822
1823 }
1824
1825 // Delete all Blacklist / Whitelist IP Ranges
1826 function del_confirm_all(msg){
1827 var ret = confirm(msg);
1828
1829 if(ret){
1830 return true;
1831 }
1832
1833 return false;
1834
1835 }
1836
1837 </script>
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: Blacklist IP</span>
1843 <span class="toggle-indicator" aria-hidden="true"></span>
1844 </button>
1845
1846 <h2 class="hndle ui-sortable-handle">
1847 <span><?php echo __('Blacklist IP','loginizer'); ?></span>
1848 </h2>
1849
1850 <div class="inside">
1851
1852 <?php echo __('Enter the IP you want to blacklist from login','loginizer'); ?>
1853
1854 <form action="" method="post">
1855 <?php wp_nonce_field('loginizer-options'); ?>
1856 <table class="form-table">
1857 <tr>
1858 <th scope="row" valign="top"><label for="start_ip"><?php echo __('Start IP','loginizer'); ?></label></th>
1859 <td>
1860 <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 />
1861 </td>
1862 </tr>
1863 <tr>
1864 <th scope="row" valign="top"><label for="end_ip"><?php echo __('End IP (Optional)','loginizer'); ?></label></th>
1865 <td>
1866 <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 />
1867 </td>
1868 </tr>
1869 </table><br />
1870 <input name="blacklist_iprange" class="button button-primary action" value="<?php echo __('Add Blacklist IP Range','loginizer'); ?>" type="submit" />
1871 <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" />
1872 </form>
1873 </div>
1874
1875 <div id="lz_bl_nav" style="margin: 5px 10px; text-align:right"></div>
1876 <table id="lz_bl_table" class="wp-list-table fixed striped users" border="0" width="95%" cellpadding="10" align="center">
1877 <tr>
1878 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Start IP','loginizer'); ?></th>
1879 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('End IP','loginizer'); ?></th>
1880 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Date (DD/MM/YYYY)','loginizer'); ?></th>
1881 <th scope="row" valign="top" style="background:#EFEFEF;" width="100"><?php echo __('Options','loginizer'); ?></th>
1882 </tr>
1883 <?php
1884 if(empty($loginizer['blacklist'])){
1885 echo '
1886 <tr>
1887 <td colspan="4">
1888 No Blacklist IPs. You will see blacklisted IP ranges here.
1889 </td>
1890 </tr>';
1891 }else{
1892 foreach($loginizer['blacklist'] as $ik => $iv){
1893 echo '
1894 <tr>
1895 <td>
1896 '.$iv['start'].'
1897 </td>
1898 <td>
1899 '.$iv['end'].'
1900 </td>
1901 <td>
1902 '.date('d/m/Y', $iv['time']).'
1903 </td>
1904 <td>
1905 <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>
1906 </td>
1907 </tr>';
1908 }
1909 }
1910 ?>
1911 </table>
1912 <br />
1913 <form action="" method="post" id="lz_bl_wl_form">
1914 <?php wp_nonce_field('loginizer-options'); ?>
1915 <input type="hidden" value="" name="" id="lz_bl_wl_todo"/>
1916 </form>
1917 </div>
1918
1919 <br />
1920
1921 <div id="" class="postbox">
1922
1923 <button class="handlediv button-link" aria-expanded="true" type="button">
1924 <span class="screen-reader-text">Toggle panel: Whitelist IP</span>
1925 <span class="toggle-indicator" aria-hidden="true"></span>
1926 </button>
1927
1928 <h2 class="hndle ui-sortable-handle">
1929 <span><?php echo __('Whitelist IP', 'loginizer'); ?></span>
1930 </h2>
1931
1932 <div class="inside">
1933
1934 <?php echo __('Enter the IP you want to whitelist for login','loginizer'); ?>
1935 <form action="" method="post">
1936 <?php wp_nonce_field('loginizer-options'); ?>
1937 <table class="form-table">
1938 <tr>
1939 <th scope="row" valign="top"><label for="start_ip_w"><?php echo __('Start IP','loginizer'); ?></label></th>
1940 <td>
1941 <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 />
1942 </td>
1943 </tr>
1944 <tr>
1945 <th scope="row" valign="top"><label for="end_ip_w"><?php echo __('End IP (Optional)','loginizer'); ?></label></th>
1946 <td>
1947 <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 />
1948 </td>
1949 </tr>
1950 </table><br />
1951 <input name="whitelist_iprange" class="button button-primary action" value="<?php echo __('Add Whitelist IP Range','loginizer'); ?>" type="submit" />
1952 <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" />
1953 </form>
1954 </div>
1955
1956 <div id="lz_wl_nav" style="margin: 5px 10px; text-align:right"></div>
1957 <table id="lz_wl_table" class="wp-list-table fixed striped users" border="0" width="95%" cellpadding="10" align="center">
1958 <tr>
1959 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Start IP','loginizer'); ?></th>
1960 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('End IP','loginizer'); ?></th>
1961 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Date (DD/MM/YYYY)','loginizer'); ?></th>
1962 <th scope="row" valign="top" style="background:#EFEFEF;" width="100"><?php echo __('Options','loginizer'); ?></th>
1963 </tr>
1964 <?php
1965 if(empty($loginizer['whitelist'])){
1966 echo '
1967 <tr>
1968 <td colspan="4">
1969 No Whitelist IPs. You will see whitelisted IP ranges here.
1970 </td>
1971 </tr>';
1972 }else{
1973 foreach($loginizer['whitelist'] as $ik => $iv){
1974 echo '
1975 <tr>
1976 <td>
1977 '.$iv['start'].'
1978 </td>
1979 <td>
1980 '.$iv['end'].'
1981 </td>
1982 <td>
1983 '.date('d/m/Y', $iv['time']).'
1984 </td>
1985 <td>
1986 <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>
1987 </td>
1988 </tr>';
1989 }
1990 }
1991 ?>
1992 </table>
1993 <br />
1994
1995 </div>
1996
1997 <div id="" class="postbox">
1998
1999 <button class="handlediv button-link" aria-expanded="true" type="button">
2000 <span class="screen-reader-text">Toggle panel: Error Messages</span>
2001 <span class="toggle-indicator" aria-hidden="true"></span>
2002 </button>
2003
2004 <h2 class="hndle ui-sortable-handle">
2005 <span><?php echo __('Error Messages', 'loginizer'); ?></span>
2006 </h2>
2007
2008 <div class="inside">
2009
2010 <form action="" method="post" enctype="multipart/form-data">
2011 <?php wp_nonce_field('loginizer-options'); ?>
2012 <table class="form-table">
2013 <tr>
2014 <th scope="row" valign="top"><label for="msg_inv_userpass"><?php echo __('Failed Login Attempt','loginizer'); ?></label></th>
2015 <td>
2016 <input type="text" size="25" value="<?php echo esc_attr($saved_msgs['inv_userpass']); ?>" name="msg_inv_userpass" id="msg_inv_userpass" />
2017 <?php echo __('Default: <em>&quot;' . $loginizer['d_msg']['inv_userpass']. '&quot;</em>', 'loginizer'); ?><br />
2018 </td>
2019 </tr>
2020 <tr>
2021 <th scope="row" valign="top"><label for="msg_ip_blacklisted"><?php echo __('Blacklisted IP','loginizer'); ?></label></th>
2022 <td>
2023 <input type="text" size="25" value="<?php echo esc_attr($saved_msgs['ip_blacklisted']); ?>" name="msg_ip_blacklisted" id="msg_ip_blacklisted" />
2024 <?php echo __('Default: <em>&quot;' . $loginizer['d_msg']['ip_blacklisted']. '&quot;</em>', 'loginizer'); ?><br />
2025 </td>
2026 </tr>
2027 </table><br />
2028 <input name="save_err_msgs_lz" class="button button-primary action" value="<?php echo __('Save Error Messages','loginizer'); ?>" type="submit" />
2029 </form>
2030 </div>
2031 </div>
2032 <?php
2033
2034 loginizer_page_footer();
2035
2036 }
2037
2038
2039 // Sorry to see you going
2040 register_uninstall_hook(LOGINIZER_FILE, 'loginizer_deactivation');
2041
2042 function loginizer_deactivation(){
2043
2044 global $wpdb;
2045
2046 $sql = array();
2047 $sql[] = "DROP TABLE ".$wpdb->prefix."loginizer_logs;";
2048
2049 foreach($sql as $sk => $sv){
2050 $wpdb->query($sv);
2051 }
2052
2053 delete_option('loginizer_version');
2054 delete_option('loginizer_options');
2055 delete_option('loginizer_last_reset');
2056 delete_option('loginizer_whitelist');
2057 delete_option('loginizer_blacklist');
2058 delete_option('loginizer_msg');
2059 delete_option('loginizer_security');
2060 delete_option('loginizer_wp_admin');
2061
2062 }
2063
2064