PluginProbe
Loginizer / 1.4.4
Loginizer v1.4.4
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.4, at init.php

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