PluginProbe
Loginizer / 1.4.2
Loginizer v1.4.2
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.2, at init.php

2,069 lines 63.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if(!function_exists('add_action')){
4 echo 'You are not allowed to access this page directly.';
5 exit;
6 }
7
8 define('LOGINIZER_VERSION', '1.4.2');
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, array('timeout' => 30));
895
896 if(is_array($resp)){
897 $json = json_decode($resp['body'], true);
898 //print_r($json);
899 }else{
900
901 $lz_error['resp_invalid'] = __('The response was malformed<br>'.var_export($resp, true), 'loginizer');
902 return loginizer_page_dashboard_T();
903
904 }
905
906 // Save the License
907 if(empty($json['license'])){
908
909 $lz_error['lic_invalid'] = __('The license key is invalid', 'loginizer');
910 return loginizer_page_dashboard_T();
911
912 }else{
913
914 update_option('loginizer_license', $json);
915
916 // Mark as saved
917 $GLOBALS['lz_saved'] = true;
918 }
919
920 }
921
922
923 // Is there a IP Method ?
924 if(isset($_POST['save_lz_ip_method'])){
925
926 $ip_method = (int) lz_optpost('lz_ip_method');
927 $custom_ip_method = lz_optpost('lz_custom_ip_method');
928
929 if($ip_method >= 0 && $ip_method <= 3){
930 update_option('loginizer_ip_method', $ip_method);
931 }
932
933 // Custom Method name ?
934 if($ip_method == 3){
935 update_option('loginizer_custom_ip_method', $custom_ip_method);
936 }
937
938 }
939
940 loginizer_page_dashboard_T();
941
942 }
943
944 // The Loginizer Admin Options Page - THEME
945 function loginizer_page_dashboard_T(){
946
947 global $loginizer, $lz_error, $lz_env;
948
949 loginizer_page_header('Loginizer Dashboard');
950 ?>
951 <style>
952 .welcome-panel{
953 margin: 0px;
954 padding: 10px;
955 }
956
957 input[type="text"], textarea, select {
958 width: 70%;
959 }
960
961 .form-table label{
962 font-weight:bold;
963 }
964
965 .exp{
966 font-size:12px;
967 }
968 </style>
969
970 <?php
971 echo '<script src="https://api.loginizer.com/'.(defined('LOGINIZER_PREMIUM') ? 'news_security.js' : 'news.js').'"></script><br>';
972
973 // Saved ?
974 if(!empty($GLOBALS['lz_saved'])){
975 echo '<div id="message" class="updated"><p>'. __('The settings were saved successfully', 'loginizer'). '</p></div><br />';
976 }
977
978 // Any errors ?
979 if(!empty($lz_error)){
980 lz_report_error($lz_error);echo '<br />';
981 }
982
983 ?>
984
985 <div class="postbox">
986
987 <button class="handlediv button-link" aria-expanded="true" type="button">
988 <span class="screen-reader-text">Toggle panel: Getting Started</span>
989 <span class="toggle-indicator" aria-hidden="true"></span>
990 </button>
991
992 <h2 class="hndle ui-sortable-handle">
993 <span><?php echo __('Getting Started', 'loginizer'); ?></span>
994 </h2>
995
996 <div class="inside">
997
998 <form action="" method="post" enctype="multipart/form-data">
999 <?php wp_nonce_field('loginizer-options'); ?>
1000 <table class="form-table">
1001 <tr>
1002 <td scope="row" valign="top" colspan="2" style="line-height:150%">
1003 <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>
1004 <?php
1005 if(defined('LOGINIZER_PREMIUM')){
1006 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>';
1007 }
1008 ?>
1009 </td>
1010 </tr>
1011 </table>
1012 </form>
1013
1014 </div>
1015 </div>
1016
1017 <div class="postbox">
1018
1019 <button class="handlediv button-link" aria-expanded="true" type="button">
1020 <span class="screen-reader-text">Toggle panel: System Information</span>
1021 <span class="toggle-indicator" aria-hidden="true"></span>
1022 </button>
1023
1024 <h2 class="hndle ui-sortable-handle">
1025 <span><?php echo __('System Information', 'loginizer'); ?></span>
1026 </h2>
1027
1028 <div class="inside">
1029
1030 <form action="" method="post" enctype="multipart/form-data">
1031 <?php wp_nonce_field('loginizer-options'); ?>
1032 <table class="wp-list-table fixed striped users" cellspacing="1" border="0" width="95%" cellpadding="10" align="center">
1033 <?php
1034 echo '
1035 <tr>
1036 <th align="left" width="25%">'.__('Loginizer Version', 'loginizer').'</th>
1037 <td>'.LOGINIZER_VERSION.(defined('LOGINIZER_PREMIUM') ? ' (Security PRO Version)' : '').'</td>
1038 </tr>';
1039
1040 if(defined('LOGINIZER_PREMIUM')){
1041 echo '
1042 <tr>
1043 <th align="left" valign="top">'.__('Loginizer License', 'loginizer').'</th>
1044 <td align="left">
1045 '.(empty($loginizer['license']) ? '<span style="color:red">Unlicensed</span> &nbsp; &nbsp;' : '').'
1046 <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;
1047 <input name="save_lz" class="button button-primary" value="Update License" type="submit" />';
1048
1049 if(!empty($loginizer['license'])){
1050
1051 $expires = $loginizer['license']['expires'];
1052 $expires = substr($expires, 0, 4).'/'.substr($expires, 4, 2).'/'.substr($expires, 6);
1053
1054 echo '<div style="margin-top:10px;">License Active : '.(empty($loginizer['license']['active']) ? '<span style="color:red">No</span>' : 'Yes').' &nbsp; &nbsp; &nbsp;
1055 License Expires : '.($loginizer['license']['expires'] <= date('Ymd') ? '<span style="color:red">'.$expires.'</span>' : $expires).'
1056 </div>';
1057 }
1058
1059
1060 echo
1061 '</td>
1062 </tr>';
1063 }
1064
1065 echo '<tr>
1066 <th align="left">'.__('URL', 'loginizer').'</th>
1067 <td>'.get_site_url().'</td>
1068 </tr>
1069 <tr>
1070 <th align="left">'.__('Path', 'loginizer').'</th>
1071 <td>'.ABSPATH.'</td>
1072 </tr>
1073 <tr>
1074 <th align="left">'.__('Server\'s IP Address', 'loginizer').'</th>
1075 <td>'.$_SERVER['SERVER_ADDR'].'</td>
1076 </tr>
1077 <tr>
1078 <th align="left">'.__('Your IP Address', 'loginizer').'</th>
1079 <td>'.lz_getip().'
1080 <div style="float:right">
1081 Method :
1082 <select name="lz_ip_method" id="lz_ip_method" style="font-size:11px; width:150px" onchange="lz_ip_method_handle()">
1083 <option value="0" '.lz_POSTselect('lz_ip_method', 0, (@$loginizer['ip_method'] == 0)).'>REMOTE_ADDR</option>
1084 <option value="1" '.lz_POSTselect('lz_ip_method', 1, (@$loginizer['ip_method'] == 1)).'>HTTP_X_FORWARDED_FOR</option>
1085 <option value="2" '.lz_POSTselect('lz_ip_method', 2, (@$loginizer['ip_method'] == 2)).'>HTTP_CLIENT_IP</option>
1086 <option value="3" '.lz_POSTselect('lz_ip_method', 3, (@$loginizer['ip_method'] == 3)).'>CUSTOM</option>
1087 </select>
1088 <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" />
1089 <input name="save_lz_ip_method" class="button button-primary" value="Save" type="submit" />
1090 </div>
1091 </td>
1092 </tr>
1093 <tr>
1094 <th align="left">'.__('wp-config.php is writable', 'loginizer').'</th>
1095 <td>'.(is_writable(ABSPATH.'/wp-config.php') ? '<span style="color:red">Yes</span>' : '<span style="color:green">No</span>').'</td>
1096 </tr>';
1097
1098 if(file_exists(ABSPATH.'/.htaccess')){
1099 echo '
1100 <tr>
1101 <th align="left">'.__('.htaccess is writable', 'loginizer').'</th>
1102 <td>'.(is_writable(ABSPATH.'/.htaccess') ? '<span style="color:red">Yes</span>' : '<span style="color:green">No</span>').'</td>
1103 </tr>';
1104
1105 }
1106
1107 ?>
1108 </table>
1109 </form>
1110
1111 </div>
1112 </div>
1113
1114 <script type="text/javascript">
1115
1116 function lz_ip_method_handle(){
1117 var ele = jQuery('#lz_ip_method');
1118 if(ele.val() == 3){
1119 jQuery('#lz_custom_ip_method').show();
1120 }else{
1121 jQuery('#lz_custom_ip_method').hide();
1122 }
1123 };
1124
1125 lz_ip_method_handle();
1126
1127 </script>
1128
1129 <div id="" class="postbox">
1130
1131 <button class="handlediv button-link" aria-expanded="true" type="button">
1132 <span class="screen-reader-text">Toggle panel: File Permissions</span>
1133 <span class="toggle-indicator" aria-hidden="true"></span>
1134 </button>
1135
1136 <h2 class="hndle ui-sortable-handle">
1137 <span><?php echo __('File Permissions', 'loginizer'); ?></span>
1138 </h2>
1139
1140 <div class="inside">
1141
1142 <form action="" method="post" enctype="multipart/form-data">
1143 <?php wp_nonce_field('loginizer-options'); ?>
1144 <table class="wp-list-table fixed striped users" border="0" width="95%" cellpadding="10" align="center">
1145 <?php
1146
1147 echo '
1148 <tr>
1149 <th style="background:#EFEFEF;">'.__('Relative Path', 'loginizer').'</th>
1150 <th style="width:10%; background:#EFEFEF;">'.__('Suggested', 'loginizer').'</th>
1151 <th style="width:10%; background:#EFEFEF;">'.__('Actual', 'loginizer').'</th>
1152 </tr>';
1153
1154 $wp_content = basename(dirname(dirname(dirname(__FILE__))));
1155
1156 $files_to_check = array('/' => '0755',
1157 '/wp-admin' => '0755',
1158 '/wp-includes' => '0755',
1159 '/wp-config.php' => '0444',
1160 '/'.$wp_content => '0755',
1161 '/'.$wp_content.'/themes' => '0755',
1162 '/'.$wp_content.'/plugins' => '0755',
1163 '.htaccess' => '0444');
1164
1165 $root = ABSPATH;
1166
1167 foreach($files_to_check as $k => $v){
1168
1169 $path = $root.'/'.$k;
1170 $stat = @stat($path);
1171 $suggested = $v;
1172 $actual = substr(sprintf('%o', $stat['mode']), -4);
1173
1174 echo '
1175 <tr>
1176 <td>'.$k.'</td>
1177 <td>'.$suggested.'</td>
1178 <td><span '.($suggested != $actual ? 'style="color: red;"' : '').'>'.$actual.'</span></td>
1179 </tr>';
1180
1181 }
1182
1183 ?>
1184 </table>
1185 </form>
1186
1187 </div>
1188 </div>
1189
1190 <?php
1191
1192 loginizer_page_footer();
1193
1194 }
1195
1196 // The Loginizer Admin Options Page
1197 function loginizer_page_brute_force(){
1198
1199 global $wpdb, $wp_roles, $loginizer;
1200
1201 if(!current_user_can('manage_options')){
1202 wp_die('Sorry, but you do not have permissions to change settings.');
1203 }
1204
1205 /* Make sure post was from this page */
1206 if(count($_POST) > 0){
1207 check_admin_referer('loginizer-options');
1208 }
1209
1210 // BEGIN THEME
1211 loginizer_page_header('Loginizer - Brute Force Settings');
1212
1213 // Load the blacklist and whitelist
1214 $loginizer['blacklist'] = get_option('loginizer_blacklist');
1215 $loginizer['whitelist'] = get_option('loginizer_whitelist');
1216
1217 // Disable Brute Force
1218 if(isset($_POST['disable_brute_lz'])){
1219
1220 // Save the options
1221 update_option('loginizer_disable_brute', 1);
1222
1223 $loginizer['disable_brute'] = 1;
1224
1225 echo '<div id="message" class="updated"><p>'
1226 . __('The Brute Force Protection feature is now disabled', 'loginizer')
1227 . '</p></div><br />';
1228
1229 }
1230
1231 // Enable brute force
1232 if(isset($_POST['enable_brute_lz'])){
1233
1234 // Save the options
1235 update_option('loginizer_disable_brute', 0);
1236
1237 $loginizer['disable_brute'] = 0;
1238
1239 echo '<div id="message" class="updated"><p>'
1240 . __('The Brute Force Protection feature is now enabled', 'loginizer')
1241 . '</p></div><br />';
1242
1243 }
1244
1245 // The Brute Force Settings
1246 if(isset($_POST['save_lz'])){
1247
1248 $max_retries = (int) lz_optpost('max_retries');
1249 $lockout_time = (int) lz_optpost('lockout_time');
1250 $max_lockouts = (int) lz_optpost('max_lockouts');
1251 $lockouts_extend = (int) lz_optpost('lockouts_extend');
1252 $reset_retries = (int) lz_optpost('reset_retries');
1253 $notify_email = (int) lz_optpost('notify_email');
1254
1255 $lockout_time = $lockout_time * 60;
1256 $lockouts_extend = $lockouts_extend * 60 * 60;
1257 $reset_retries = $reset_retries * 60 * 60;
1258
1259 if(empty($error)){
1260
1261 $option['max_retries'] = $max_retries;
1262 $option['lockout_time'] = $lockout_time;
1263 $option['max_lockouts'] = $max_lockouts;
1264 $option['lockouts_extend'] = $lockouts_extend;
1265 $option['reset_retries'] = $reset_retries;
1266 $option['notify_email'] = $notify_email;
1267
1268 // Save the options
1269 update_option('loginizer_options', $option);
1270
1271 $saved = true;
1272
1273 }else{
1274 lz_report_error($error);
1275 }
1276
1277 if(!empty($notice)){
1278 lz_report_notice($notice);
1279 }
1280
1281 if(!empty($saved)){
1282 echo '<div id="message" class="updated"><p>'
1283 . __('The settings were saved successfully', 'loginizer')
1284 . '</p></div><br />';
1285 }
1286
1287 }
1288
1289 // Delete a Blackist IP range
1290 if(isset($_POST['bdelid'])){
1291
1292 $delid = (int) lz_optreq('bdelid');
1293
1294 // Unset and save
1295 $blacklist = $loginizer['blacklist'];
1296 unset($blacklist[$delid]);
1297 update_option('loginizer_blacklist', $blacklist);
1298
1299 echo '<div id="message" class="updated fade"><p>'
1300 . __('The Blacklist IP range has been deleted successfully', 'loginizer')
1301 . '</p></div><br />';
1302
1303 }
1304
1305 // Delete all Blackist IP ranges
1306 if(isset($_POST['del_all_blacklist'])){
1307
1308 // Unset and save
1309 update_option('loginizer_blacklist', array());
1310
1311 echo '<div id="message" class="updated fade"><p>'
1312 . __('The Blacklist IP range(s) have been cleared successfully', 'loginizer')
1313 . '</p></div><br />';
1314
1315 }
1316
1317 // Delete a Whitelist IP range
1318 if(isset($_POST['delid'])){
1319
1320 $delid = (int) lz_optreq('delid');
1321
1322 // Unset and save
1323 $whitelist = $loginizer['whitelist'];
1324 unset($whitelist[$delid]);
1325 update_option('loginizer_whitelist', $whitelist);
1326
1327 echo '<div id="message" class="updated fade"><p>'
1328 . __('The Whitelist IP range has been deleted successfully', 'loginizer')
1329 . '</p></div><br />';
1330
1331 }
1332
1333 // Delete all Blackist IP ranges
1334 if(isset($_POST['del_all_whitelist'])){
1335
1336 // Unset and save
1337 update_option('loginizer_whitelist', array());
1338
1339 echo '<div id="message" class="updated fade"><p>'
1340 . __('The Whitelist IP range(s) have been cleared successfully', 'loginizer')
1341 . '</p></div><br />';
1342
1343 }
1344
1345 // Reset All Logs
1346 if(isset($_POST['lz_reset_all_ip'])){
1347
1348 $result = $wpdb->query("DELETE FROM `".$wpdb->prefix."loginizer_logs`
1349 WHERE `time` > 0");
1350
1351 echo '<div id="message" class="updated fade"><p>'
1352 . __('All the IP Logs have been cleared', 'loginizer')
1353 . '</p></div><br />';
1354 }
1355
1356 // Reset Logs
1357 if(isset($_POST['lz_reset_ips']) && is_array($_POST['lz_reset_ips'])){
1358
1359 $ips = $_POST['lz_reset_ips'];
1360
1361 foreach($ips as $ip){
1362 if(!lz_valid_ip($ip)){
1363 $error[] = 'The IP - '.$ip.' is invalid !';
1364 }
1365 }
1366
1367 if(count($ips) < 1){
1368 $error[] = 'There are no IPs submitted';
1369 }
1370
1371 // Should we start deleting logs
1372 if(empty($error)){
1373
1374 $result = $wpdb->query("DELETE FROM `".$wpdb->prefix."loginizer_logs`
1375 WHERE `ip` IN ('".implode("', '", $ips)."')");
1376
1377 if(empty($error)){
1378
1379 echo '<div id="message" class="updated fade"><p>'
1380 . __('The selected IP Logs have been reset', 'loginizer')
1381 . '</p></div><br />';
1382
1383 }
1384
1385 }
1386
1387 if(!empty($error)){
1388 lz_report_error($error);echo '<br />';
1389 }
1390
1391 }
1392
1393 if(isset($_POST['blacklist_iprange'])){
1394
1395 $start_ip = lz_optpost('start_ip');
1396 $end_ip = lz_optpost('end_ip');
1397
1398 if(empty($start_ip)){
1399 $error[] = 'Please enter the Start IP';
1400 }
1401
1402 // If no end IP we consider only 1 IP
1403 if(empty($end_ip)){
1404 $end_ip = $start_ip;
1405 }
1406
1407 if(!lz_valid_ip($start_ip)){
1408 $error[] = 'Please provide a valid start IP';
1409 }
1410
1411 if(!lz_valid_ip($end_ip)){
1412 $error[] = 'Please provide a valid end IP';
1413 }
1414
1415 // Regular ranges will work
1416 if(inet_ptoi($start_ip) > inet_ptoi($end_ip)){
1417
1418 // BUT, if 0.0.0.1 - 255.255.255.255 is given, it will not work
1419 if(inet_ptoi($start_ip) >= 0 && inet_ptoi($end_ip) < 0){
1420 // This is right
1421 }else{
1422 $error[] = 'The End IP cannot be smaller than the Start IP';
1423 }
1424
1425 }
1426
1427 if(empty($error)){
1428
1429 $blacklist = $loginizer['blacklist'];
1430
1431 foreach($blacklist as $k => $v){
1432
1433 // This is to check if there is any other range exists with the same Start or End IP
1434 if(( inet_ptoi($start_ip) <= inet_ptoi($v['start']) && inet_ptoi($v['start']) <= inet_ptoi($end_ip) )
1435 || ( inet_ptoi($start_ip) <= inet_ptoi($v['end']) && inet_ptoi($v['end']) <= inet_ptoi($end_ip) )
1436 ){
1437 $error[] = 'The Start IP or End IP submitted conflicts with an existing IP range !';
1438 break;
1439 }
1440
1441 // This is to check if there is any other range exists with the same Start IP
1442 if(inet_ptoi($v['start']) <= inet_ptoi($start_ip) && inet_ptoi($start_ip) <= inet_ptoi($v['end'])){
1443 $error[] = 'The Start IP is present in an existing range !';
1444 break;
1445 }
1446
1447 // This is to check if there is any other range exists with the same End IP
1448 if(inet_ptoi($v['start']) <= inet_ptoi($end_ip) && inet_ptoi($end_ip) <= inet_ptoi($v['end'])){
1449 $error[] = 'The End IP is present in an existing range!';
1450 break;
1451 }
1452
1453 }
1454
1455 $newid = ( empty($blacklist) ? 0 : max(array_keys($blacklist)) ) + 1;
1456
1457 if(empty($error)){
1458
1459 $blacklist[$newid] = array();
1460 $blacklist[$newid]['start'] = $start_ip;
1461 $blacklist[$newid]['end'] = $end_ip;
1462 $blacklist[$newid]['time'] = time();
1463
1464 update_option('loginizer_blacklist', $blacklist);
1465
1466 echo '<div id="message" class="updated fade"><p>'
1467 . __('Blacklist IP range added successfully', 'loginizer')
1468 . '</p></div><br />';
1469
1470 }
1471
1472 }
1473
1474 if(!empty($error)){
1475 lz_report_error($error);echo '<br />';
1476 }
1477
1478 }
1479
1480 if(isset($_POST['whitelist_iprange'])){
1481
1482 $start_ip = lz_optpost('start_ip_w');
1483 $end_ip = lz_optpost('end_ip_w');
1484
1485 if(empty($start_ip)){
1486 $error[] = 'Please enter the Start IP';
1487 }
1488
1489 // If no end IP we consider only 1 IP
1490 if(empty($end_ip)){
1491 $end_ip = $start_ip;
1492 }
1493
1494 if(!lz_valid_ip($start_ip)){
1495 $error[] = 'Please provide a valid start IP';
1496 }
1497
1498 if(!lz_valid_ip($end_ip)){
1499 $error[] = 'Please provide a valid end IP';
1500 }
1501
1502 if(inet_ptoi($start_ip) > inet_ptoi($end_ip)){
1503
1504 // BUT, if 0.0.0.1 - 255.255.255.255 is given, it will not work
1505 if(inet_ptoi($start_ip) >= 0 && inet_ptoi($end_ip) < 0){
1506 // This is right
1507 }else{
1508 $error[] = 'The End IP cannot be smaller than the Start IP';
1509 }
1510
1511 }
1512
1513 if(empty($error)){
1514
1515 $whitelist = $loginizer['whitelist'];
1516
1517 foreach($whitelist as $k => $v){
1518
1519 // This is to check if there is any other range exists with the same Start or End IP
1520 if(( inet_ptoi($start_ip) <= inet_ptoi($v['start']) && inet_ptoi($v['start']) <= inet_ptoi($end_ip) )
1521 || ( inet_ptoi($start_ip) <= inet_ptoi($v['end']) && inet_ptoi($v['end']) <= inet_ptoi($end_ip) )
1522 ){
1523 $error[] = 'The Start IP or End IP submitted conflicts with an existing IP range !';
1524 break;
1525 }
1526
1527 // This is to check if there is any other range exists with the same Start IP
1528 if(inet_ptoi($v['start']) <= inet_ptoi($start_ip) && inet_ptoi($start_ip) <= inet_ptoi($v['end'])){
1529 $error[] = 'The Start IP is present in an existing range !';
1530 break;
1531 }
1532
1533 // This is to check if there is any other range exists with the same End IP
1534 if(inet_ptoi($v['start']) <= inet_ptoi($end_ip) && inet_ptoi($end_ip) <= inet_ptoi($v['end'])){
1535 $error[] = 'The End IP is present in an existing range!';
1536 break;
1537 }
1538
1539 }
1540
1541 $newid = ( empty($whitelist) ? 0 : max(array_keys($whitelist)) ) + 1;
1542
1543 if(empty($error)){
1544
1545 $whitelist[$newid] = array();
1546 $whitelist[$newid]['start'] = $start_ip;
1547 $whitelist[$newid]['end'] = $end_ip;
1548 $whitelist[$newid]['time'] = time();
1549
1550 update_option('loginizer_whitelist', $whitelist);
1551
1552 echo '<div id="message" class="updated fade"><p>'
1553 . __('Whitelist IP range added successfully', 'loginizer')
1554 . '</p></div><br />';
1555
1556 }
1557
1558 }
1559
1560 if(!empty($error)){
1561 lz_report_error($error);echo '<br />';
1562 }
1563 }
1564
1565 // Save the messages
1566 if(isset($_POST['save_err_msgs_lz'])){
1567
1568 $msgs['inv_userpass'] = lz_optpost('msg_inv_userpass');
1569 $msgs['ip_blacklisted'] = lz_optpost('msg_ip_blacklisted');
1570
1571 // Update them
1572 update_option('loginizer_msg', $msgs);
1573
1574 echo '<div id="message" class="updated fade"><p>'
1575 . __('Error messages were saved successfully', 'loginizer')
1576 . '</p></div><br />';
1577
1578 }
1579
1580 // Count the Results
1581 $tmp = lz_selectquery("SELECT COUNT(*) AS num FROM `".$wpdb->prefix."loginizer_logs`");
1582 //print_r($tmp);
1583
1584 // Which Page is it
1585 $lz_env['res_len'] = 10;
1586 $lz_env['cur_page'] = lz_get_page('lzpage', $lz_env['res_len']);
1587 $lz_env['num_res'] = $tmp['num'];
1588 $lz_env['max_page'] = ceil($lz_env['num_res'] / $lz_env['res_len']);
1589
1590 // Get the logs
1591 $result = lz_selectquery("SELECT * FROM `".$wpdb->prefix."loginizer_logs`
1592 ORDER BY `time` DESC
1593 LIMIT ".$lz_env['cur_page'].", ".$lz_env['res_len']."", 1);
1594 //print_r($result);
1595
1596 $lz_env['cur_page'] = ($lz_env['cur_page'] / $lz_env['res_len']) + 1;
1597 $lz_env['cur_page'] = $lz_env['cur_page'] < 1 ? 1 : $lz_env['cur_page'];
1598 $lz_env['next_page'] = ($lz_env['cur_page'] + 1) > $lz_env['max_page'] ? $lz_env['max_page'] : ($lz_env['cur_page'] + 1);
1599 $lz_env['prev_page'] = ($lz_env['cur_page'] - 1) < 1 ? 1 : ($lz_env['cur_page'] - 1);
1600
1601 // Reload the settings
1602 $loginizer['blacklist'] = get_option('loginizer_blacklist');
1603 $loginizer['whitelist'] = get_option('loginizer_whitelist');
1604
1605 $saved_msgs = get_option('loginizer_msg');
1606
1607 ?>
1608
1609 <div id="" class="postbox">
1610
1611 <button class="handlediv button-link" aria-expanded="true" type="button">
1612 <span class="screen-reader-text">Toggle panel: Failed Login Attempts Logs</span>
1613 <span class="toggle-indicator" aria-hidden="true"></span>
1614 </button>
1615
1616 <h2 class="hndle ui-sortable-handle">
1617 <?php echo __('<span>Failed Login Attempts Logs</span> &nbsp; (Past '.($loginizer['reset_retries']/60/60).' hours)','loginizer'); ?>
1618 </h2>
1619
1620 <script>
1621 function yesdsd(){
1622 window.location = '<?php echo menu_page_url('loginizer_brute_force', false);?>&lzpage='+jQuery("#current-page-selector").val();
1623 return false;
1624 }
1625 </script>
1626
1627 <form method="get" onsubmit="return yesdsd();">
1628 <div class="tablenav">
1629 <p class="tablenav-pages" style="margin: 5px 10px" align="right">
1630 <span class="displaying-num"><?php echo $lz_env['num_res'];?> items</span>
1631 <span class="pagination-links">
1632 <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>
1633 <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>
1634 <span class="paging-input">
1635 <label for="current-page-selector" class="screen-reader-text">Current Page</label>
1636 <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>
1637 </span>
1638 <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>
1639 <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>
1640 </span>
1641 </p>
1642 </div>
1643 </form>
1644
1645 <form action="" method="post" enctype="multipart/form-data">
1646 <?php wp_nonce_field('loginizer-options'); ?>
1647 <div class="inside">
1648 <table class="wp-list-table widefat fixed users" border="0">
1649 <tr>
1650 <th scope="row" valign="top" style="background:#EFEFEF;" width="20">#</th>
1651 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('IP','loginizer'); ?></th>
1652 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Attempted Username','loginizer'); ?></th>
1653 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Last Failed Attempt (DD/MM/YYYY)','loginizer'); ?></th>
1654 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Failed Attempts Count','loginizer'); ?></th>
1655 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Lockouts Count','loginizer'); ?></th>
1656 <th scope="row" valign="top" style="background:#EFEFEF;" width="150"><?php echo __('URL Attacked','loginizer'); ?></th>
1657 </tr>
1658 <?php
1659
1660 if(empty($result)){
1661 echo '
1662 <tr>
1663 <td colspan="4">
1664 No Logs. You will see logs about failed login attempts here.
1665 </td>
1666 </tr>';
1667 }else{
1668 foreach($result as $ik => $iv){
1669 $status_button = (!empty($iv['status']) ? 'disable' : 'enable');
1670 echo '
1671 <tr>
1672 <td>
1673 <input type="checkbox" value="'.$iv['ip'].'" name="lz_reset_ips[]" />
1674 </td>
1675 <td>
1676 '.$iv['ip'].'
1677 </td>
1678 <td>
1679 '.$iv['username'].'
1680 </td>
1681 <td>
1682 '.date('d/m/Y H:i:s', $iv['time']).'
1683 </td>
1684 <td>
1685 '.$iv['count'].'
1686 </td>
1687 <td>
1688 '.$iv['lockout'].'
1689 </td>
1690 <td>
1691 '.$iv['url'].'
1692 </td>
1693 </tr>';
1694 }
1695 }
1696
1697 ?>
1698 </table>
1699
1700 <br>
1701 <input name="lz_reset_ip" class="button button-primary action" value="<?php echo __('Remove From Logs', 'loginizer'); ?>" type="submit" />
1702 &nbsp; &nbsp;
1703 <input name="lz_reset_all_ip" class="button button-primary action" value="<?php echo __('Clear All Logs', 'loginizer'); ?>" type="submit" />
1704 </div>
1705 </div>
1706 </form>
1707 <br />
1708
1709 <div id="" class="postbox">
1710
1711 <button class="handlediv button-link" aria-expanded="true" type="button">
1712 <span class="screen-reader-text">Toggle panel: Brute Force Settings</span>
1713 <span class="toggle-indicator" aria-hidden="true"></span>
1714 </button>
1715
1716 <h2 class="hndle ui-sortable-handle">
1717 <span><?php echo __('Brute Force Settings', 'loginizer'); ?></span>
1718 </h2>
1719
1720 <div class="inside">
1721
1722 <form action="" method="post" enctype="multipart/form-data">
1723 <?php wp_nonce_field('loginizer-options'); ?>
1724 <table class="form-table">
1725 <tr>
1726 <th scope="row" valign="top"><label for="max_retries"><?php echo __('Max Retries','loginizer'); ?></label></th>
1727 <td>
1728 <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 />
1729 </td>
1730 </tr>
1731 <tr>
1732 <th scope="row" valign="top"><label for="lockout_time"><?php echo __('Lockout Time','loginizer'); ?></label></th>
1733 <td>
1734 <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 />
1735 </td>
1736 </tr>
1737 <tr>
1738 <th scope="row" valign="top"><label for="max_lockouts"><?php echo __('Max Lockouts','loginizer'); ?></label></th>
1739 <td>
1740 <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 />
1741 </td>
1742 </tr>
1743 <tr>
1744 <th scope="row" valign="top"><label for="lockouts_extend"><?php echo __('Extend Lockout','loginizer'); ?></label></th>
1745 <td>
1746 <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 />
1747 </td>
1748 </tr>
1749 <tr>
1750 <th scope="row" valign="top"><label for="reset_retries"><?php echo __('Reset Retries','loginizer'); ?></label></th>
1751 <td>
1752 <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 />
1753 </td>
1754 </tr>
1755 <tr>
1756 <th scope="row" valign="top"><label for="notify_email"><?php echo __('Email Notification','loginizer'); ?></label></th>
1757 <td>
1758 <?php echo __('after ','loginizer'); ?>
1759 <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'); ?>
1760 </td>
1761 </tr>
1762 </table><br />
1763 <input name="save_lz" class="button button-primary action" value="<?php echo __('Save Settings','loginizer'); ?>" type="submit" />
1764 <?php
1765
1766 if(empty($loginizer['disable_brute'])){
1767
1768 echo '<input name="disable_brute_lz" class="button action" value="'.__('Disable Brute Force Protection','loginizer').'" type="submit" style="float:right" />';
1769
1770 }else{
1771
1772 echo '<input name="enable_brute_lz" class="button button-primary action" value="'.__('Enable Brute Force Protection','loginizer').'" type="submit" style="float:right" />';
1773
1774 }
1775
1776 ?>
1777 </form>
1778
1779 </div>
1780 </div>
1781 <br />
1782
1783 <?php
1784
1785 wp_enqueue_script('jquery-paginate', LOGINIZER_URL.'/jquery-paginate.js', array('jquery'), '1.10.15');
1786
1787 ?>
1788
1789 <style>
1790 .page-navigation a {
1791 margin: 5px 2px;
1792 display: inline-block;
1793 padding: 5px 8px;
1794 color: #0073aa;
1795 background: #e5e5e5 none repeat scroll 0 0;
1796 border: 1px solid #ccc;
1797 text-decoration: none;
1798 transition-duration: 0.05s;
1799 transition-property: border, background, color;
1800 transition-timing-function: ease-in-out;
1801 }
1802
1803 .page-navigation a[data-selected] {
1804 background-color: #00a0d2;
1805 color: #fff;
1806 }
1807 </style>
1808
1809 <script>
1810
1811 jQuery(document).ready(function(){
1812 jQuery('#lz_bl_table').paginate({ limit: 11, navigationWrapper: jQuery('#lz_bl_nav')});
1813 jQuery('#lz_wl_table').paginate({ limit: 11, navigationWrapper: jQuery('#lz_wl_nav')});
1814 });
1815
1816 // Delete a Blacklist / Whitelist IP Range
1817 function del_confirm(field, todo_id, msg){
1818 var ret = confirm(msg);
1819
1820 if(ret){
1821 jQuery('#lz_bl_wl_todo').attr('name', field);
1822 jQuery('#lz_bl_wl_todo').val(todo_id);
1823 jQuery('#lz_bl_wl_form').submit();
1824 }
1825
1826 return false;
1827
1828 }
1829
1830 // Delete all Blacklist / Whitelist IP Ranges
1831 function del_confirm_all(msg){
1832 var ret = confirm(msg);
1833
1834 if(ret){
1835 return true;
1836 }
1837
1838 return false;
1839
1840 }
1841
1842 </script>
1843
1844 <div id="" class="postbox">
1845
1846 <button class="handlediv button-link" aria-expanded="true" type="button">
1847 <span class="screen-reader-text">Toggle panel: Blacklist IP</span>
1848 <span class="toggle-indicator" aria-hidden="true"></span>
1849 </button>
1850
1851 <h2 class="hndle ui-sortable-handle">
1852 <span><?php echo __('Blacklist IP','loginizer'); ?></span>
1853 </h2>
1854
1855 <div class="inside">
1856
1857 <?php echo __('Enter the IP you want to blacklist from login','loginizer'); ?>
1858
1859 <form action="" method="post">
1860 <?php wp_nonce_field('loginizer-options'); ?>
1861 <table class="form-table">
1862 <tr>
1863 <th scope="row" valign="top"><label for="start_ip"><?php echo __('Start IP','loginizer'); ?></label></th>
1864 <td>
1865 <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 />
1866 </td>
1867 </tr>
1868 <tr>
1869 <th scope="row" valign="top"><label for="end_ip"><?php echo __('End IP (Optional)','loginizer'); ?></label></th>
1870 <td>
1871 <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 />
1872 </td>
1873 </tr>
1874 </table><br />
1875 <input name="blacklist_iprange" class="button button-primary action" value="<?php echo __('Add Blacklist IP Range','loginizer'); ?>" type="submit" />
1876 <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" />
1877 </form>
1878 </div>
1879
1880 <div id="lz_bl_nav" style="margin: 5px 10px; text-align:right"></div>
1881 <table id="lz_bl_table" class="wp-list-table fixed striped users" border="0" width="95%" cellpadding="10" align="center">
1882 <tr>
1883 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Start IP','loginizer'); ?></th>
1884 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('End IP','loginizer'); ?></th>
1885 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Date (DD/MM/YYYY)','loginizer'); ?></th>
1886 <th scope="row" valign="top" style="background:#EFEFEF;" width="100"><?php echo __('Options','loginizer'); ?></th>
1887 </tr>
1888 <?php
1889 if(empty($loginizer['blacklist'])){
1890 echo '
1891 <tr>
1892 <td colspan="4">
1893 No Blacklist IPs. You will see blacklisted IP ranges here.
1894 </td>
1895 </tr>';
1896 }else{
1897 foreach($loginizer['blacklist'] as $ik => $iv){
1898 echo '
1899 <tr>
1900 <td>
1901 '.$iv['start'].'
1902 </td>
1903 <td>
1904 '.$iv['end'].'
1905 </td>
1906 <td>
1907 '.date('d/m/Y', $iv['time']).'
1908 </td>
1909 <td>
1910 <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>
1911 </td>
1912 </tr>';
1913 }
1914 }
1915 ?>
1916 </table>
1917 <br />
1918 <form action="" method="post" id="lz_bl_wl_form">
1919 <?php wp_nonce_field('loginizer-options'); ?>
1920 <input type="hidden" value="" name="" id="lz_bl_wl_todo"/>
1921 </form>
1922 </div>
1923
1924 <br />
1925
1926 <div id="" class="postbox">
1927
1928 <button class="handlediv button-link" aria-expanded="true" type="button">
1929 <span class="screen-reader-text">Toggle panel: Whitelist IP</span>
1930 <span class="toggle-indicator" aria-hidden="true"></span>
1931 </button>
1932
1933 <h2 class="hndle ui-sortable-handle">
1934 <span><?php echo __('Whitelist IP', 'loginizer'); ?></span>
1935 </h2>
1936
1937 <div class="inside">
1938
1939 <?php echo __('Enter the IP you want to whitelist for login','loginizer'); ?>
1940 <form action="" method="post">
1941 <?php wp_nonce_field('loginizer-options'); ?>
1942 <table class="form-table">
1943 <tr>
1944 <th scope="row" valign="top"><label for="start_ip_w"><?php echo __('Start IP','loginizer'); ?></label></th>
1945 <td>
1946 <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 />
1947 </td>
1948 </tr>
1949 <tr>
1950 <th scope="row" valign="top"><label for="end_ip_w"><?php echo __('End IP (Optional)','loginizer'); ?></label></th>
1951 <td>
1952 <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 />
1953 </td>
1954 </tr>
1955 </table><br />
1956 <input name="whitelist_iprange" class="button button-primary action" value="<?php echo __('Add Whitelist IP Range','loginizer'); ?>" type="submit" />
1957 <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" />
1958 </form>
1959 </div>
1960
1961 <div id="lz_wl_nav" style="margin: 5px 10px; text-align:right"></div>
1962 <table id="lz_wl_table" class="wp-list-table fixed striped users" border="0" width="95%" cellpadding="10" align="center">
1963 <tr>
1964 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Start IP','loginizer'); ?></th>
1965 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('End IP','loginizer'); ?></th>
1966 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Date (DD/MM/YYYY)','loginizer'); ?></th>
1967 <th scope="row" valign="top" style="background:#EFEFEF;" width="100"><?php echo __('Options','loginizer'); ?></th>
1968 </tr>
1969 <?php
1970 if(empty($loginizer['whitelist'])){
1971 echo '
1972 <tr>
1973 <td colspan="4">
1974 No Whitelist IPs. You will see whitelisted IP ranges here.
1975 </td>
1976 </tr>';
1977 }else{
1978 foreach($loginizer['whitelist'] as $ik => $iv){
1979 echo '
1980 <tr>
1981 <td>
1982 '.$iv['start'].'
1983 </td>
1984 <td>
1985 '.$iv['end'].'
1986 </td>
1987 <td>
1988 '.date('d/m/Y', $iv['time']).'
1989 </td>
1990 <td>
1991 <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>
1992 </td>
1993 </tr>';
1994 }
1995 }
1996 ?>
1997 </table>
1998 <br />
1999
2000 </div>
2001
2002 <div id="" class="postbox">
2003
2004 <button class="handlediv button-link" aria-expanded="true" type="button">
2005 <span class="screen-reader-text">Toggle panel: Error Messages</span>
2006 <span class="toggle-indicator" aria-hidden="true"></span>
2007 </button>
2008
2009 <h2 class="hndle ui-sortable-handle">
2010 <span><?php echo __('Error Messages', 'loginizer'); ?></span>
2011 </h2>
2012
2013 <div class="inside">
2014
2015 <form action="" method="post" enctype="multipart/form-data">
2016 <?php wp_nonce_field('loginizer-options'); ?>
2017 <table class="form-table">
2018 <tr>
2019 <th scope="row" valign="top"><label for="msg_inv_userpass"><?php echo __('Failed Login Attempt','loginizer'); ?></label></th>
2020 <td>
2021 <input type="text" size="25" value="<?php echo esc_attr($saved_msgs['inv_userpass']); ?>" name="msg_inv_userpass" id="msg_inv_userpass" />
2022 <?php echo __('Default: <em>&quot;' . $loginizer['d_msg']['inv_userpass']. '&quot;</em>', 'loginizer'); ?><br />
2023 </td>
2024 </tr>
2025 <tr>
2026 <th scope="row" valign="top"><label for="msg_ip_blacklisted"><?php echo __('Blacklisted IP','loginizer'); ?></label></th>
2027 <td>
2028 <input type="text" size="25" value="<?php echo esc_attr($saved_msgs['ip_blacklisted']); ?>" name="msg_ip_blacklisted" id="msg_ip_blacklisted" />
2029 <?php echo __('Default: <em>&quot;' . $loginizer['d_msg']['ip_blacklisted']. '&quot;</em>', 'loginizer'); ?><br />
2030 </td>
2031 </tr>
2032 </table><br />
2033 <input name="save_err_msgs_lz" class="button button-primary action" value="<?php echo __('Save Error Messages','loginizer'); ?>" type="submit" />
2034 </form>
2035 </div>
2036 </div>
2037 <?php
2038
2039 loginizer_page_footer();
2040
2041 }
2042
2043
2044 // Sorry to see you going
2045 register_uninstall_hook(LOGINIZER_FILE, 'loginizer_deactivation');
2046
2047 function loginizer_deactivation(){
2048
2049 global $wpdb;
2050
2051 $sql = array();
2052 $sql[] = "DROP TABLE ".$wpdb->prefix."loginizer_logs;";
2053
2054 foreach($sql as $sk => $sv){
2055 $wpdb->query($sv);
2056 }
2057
2058 delete_option('loginizer_version');
2059 delete_option('loginizer_options');
2060 delete_option('loginizer_last_reset');
2061 delete_option('loginizer_whitelist');
2062 delete_option('loginizer_blacklist');
2063 delete_option('loginizer_msg');
2064 delete_option('loginizer_security');
2065 delete_option('loginizer_wp_admin');
2066
2067 }
2068
2069