PluginProbe
Loginizer / 2.0.3
Loginizer v2.0.3
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 / main / settings / brute-force.php

brute-force.php in Loginizer 2.0.3, at main/settings/brute-force.php

1,303 lines 47.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if(!defined('ABSPATH')){
4 die('Hacking Attempt!');
5 }
6
7 // The Loginizer Admin Options Page
8 function loginizer_page_brute_force(){
9
10 global $wpdb, $wp_roles, $loginizer;
11
12 if(!current_user_can('manage_options')){
13 wp_die('Sorry, but you do not have permissions to change settings.');
14 }
15
16 /* Make sure post was from this page */
17 if(count($_POST) > 0){
18 check_admin_referer('loginizer-options');
19 }
20
21 // BEGIN THEME
22 loginizer_page_header('Brute Force Settings');
23
24 // Load the blacklist and whitelist
25 $loginizer['blacklist'] = get_option('loginizer_blacklist');
26 $loginizer['whitelist'] = get_option('loginizer_whitelist');
27
28 // Disable Brute Force
29 if(isset($_POST['disable_brute_lz'])){
30
31 // Save the options
32 update_option('loginizer_disable_brute', 1);
33
34 $loginizer['disable_brute'] = 1;
35
36 echo '<div id="message" class="updated"><p>'
37 . __('The Brute Force Protection feature is now disabled', 'loginizer')
38 . '</p></div><br />';
39
40 }
41
42 // Enable brute force
43 if(isset($_POST['enable_brute_lz'])){
44
45 // Save the options
46 update_option('loginizer_disable_brute', 0);
47
48 $loginizer['disable_brute'] = 0;
49
50 echo '<div id="message" class="updated"><p>'
51 . __('The Brute Force Protection feature is now enabled', 'loginizer')
52 . '</p></div><br />';
53
54 }
55
56 if(isset($_POST['save_lz_login_email'])){
57 $login_email['enable'] = (int) lz_optpost('loginizer_login_mail_enable');
58 $login_email['disable_whitelist'] = (int) lz_optpost('loginizer_login_mail_disable_whitelist');
59 $login_email['html_mail'] = (!empty(lz_optpost('loginizer_notify_html_mail')) ? true : false);
60 $login_email['subject'] = sanitize_textarea_field(wp_unslash($_POST['loginizer_login_mail_subject']));
61 $login_email['body'] = wp_kses_post(wp_unslash($_POST['loginizer_login_mail_body']));
62 $login_email['roles'] = !empty($_POST['loginizer_login_mail_roles']) ? map_deep($_POST['loginizer_login_mail_roles'], 'sanitize_text_field') : [];
63
64 // Save the options
65 update_option('loginizer_login_mail', $login_email);
66 $loginizer['login_mail'] = $login_email;
67
68 // Mark as saved
69 $GLOBALS['lz_saved'] = true;
70 }
71
72 // The Brute Force Settings
73 if(isset($_POST['save_lz'])){
74
75 $max_retries = (int) lz_optpost('max_retries');
76 $lockout_time = (int) lz_optpost('lockout_time');
77 $max_lockouts = (int) lz_optpost('max_lockouts');
78 $lockouts_extend = (int) lz_optpost('lockouts_extend');
79 $reset_retries = (int) lz_optpost('reset_retries');
80 $notify_email = (int) lz_optpost('notify_email');
81 $notify_email_address = lz_optpost('notify_email_address');
82 $trusted_ips = lz_optpost('trusted_ips');
83 $blocked_screen = lz_optpost('blocked_screen');
84
85 if(!empty($notify_email_address) && !lz_valid_email($notify_email_address)){
86 $error[] = __('Email address is invalid', 'loginizer');
87 }
88
89 if(empty(loginizer_is_whitelisted()) && isset($_POST['trusted_ips'])){
90 $error[] = __('Add your IP to whitelist to enable Trusted IP\'s', 'loginizer');
91 }
92
93 if(!empty($max_retries) && $max_retries < 0){
94 $error[] = __('Max Retries value is invalid', 'loginizer');
95 }
96
97 if(!empty($lockout_time) && $lockout_time < 0){
98 $error[] = __('Lockout Time value is invalid', 'loginizer');
99 }
100
101 if(!empty($max_lockouts) && $max_lockouts < 0){
102 $error[] = __('Max Lockouts value is invalid', 'loginizer');
103 }
104
105 if(!empty($lockouts_extend) && $lockouts_extend < 0){
106 $error[] = __('Extended Lockout value is invalid', 'loginizer');
107 }
108
109 if(!empty($reset_retries) && $reset_retries < 0){
110 $error[] = __('Reset Retries value is invalid', 'loginizer');
111 }
112
113 if(!empty($notify_email) && $notify_email < 0){
114 $error[] = __('Email Notification value is invalid', 'loginizer');
115 }
116
117 $lockout_time = $lockout_time * 60;
118 $lockouts_extend = $lockouts_extend * 60 * 60;
119 $reset_retries = $reset_retries * 60 * 60;
120
121 if(empty($error)){
122
123 $option['max_retries'] = $max_retries;
124 $option['lockout_time'] = $lockout_time;
125 $option['max_lockouts'] = $max_lockouts;
126 $option['lockouts_extend'] = $lockouts_extend;
127 $option['reset_retries'] = $reset_retries;
128 $option['notify_email'] = $notify_email;
129 $option['notify_email_address'] = $notify_email_address;
130 $option['trusted_ips'] = $trusted_ips;
131 $option['blocked_screen'] = $blocked_screen;
132
133 // Save the options
134 update_option('loginizer_options', $option);
135
136 $saved = true;
137
138 }else{
139 lz_report_error($error);
140 }
141
142 if(!empty($notice)){
143 lz_report_notice($notice);
144 }
145
146 if(!empty($saved)){
147 echo '<div id="message" class="updated"><p>'
148 . __('The settings were saved successfully', 'loginizer')
149 . '</p></div><br />';
150 }
151
152 }
153
154 // Delete a Blackist IP range
155 if(isset($_POST['bdelid'])){
156
157 $delid = (int) lz_optreq('bdelid');
158
159 // Unset and save
160 $blacklist = $loginizer['blacklist'];
161 unset($blacklist[$delid]);
162 update_option('loginizer_blacklist', $blacklist);
163
164 echo '<div id="message" class="updated fade"><p>'
165 . __('The Blacklist IP range has been deleted successfully', 'loginizer')
166 . '</p></div><br />';
167
168 }
169
170 // Delete all Blackist IP ranges
171 if(isset($_POST['del_all_blacklist'])){
172
173 // Unset and save
174 update_option('loginizer_blacklist', array());
175
176 echo '<div id="message" class="updated fade"><p>'
177 . __('The Blacklist IP range(s) have been cleared successfully', 'loginizer')
178 . '</p></div><br />';
179
180 }
181
182 // Delete a Whitelist IP range
183 if(isset($_POST['delid'])){
184
185 $delid = (int) lz_optreq('delid');
186
187 // Unset and save
188 $whitelist = $loginizer['whitelist'];
189 unset($whitelist[$delid]);
190 update_option('loginizer_whitelist', $whitelist);
191
192 echo '<div id="message" class="updated fade"><p>'
193 . __('The Whitelist IP range has been deleted successfully', 'loginizer')
194 . '</p></div><br />';
195
196 }
197
198 // Delete all Blackist IP ranges
199 if(isset($_POST['del_all_whitelist'])){
200
201 // Unset and save
202 update_option('loginizer_whitelist', array());
203
204 echo '<div id="message" class="updated fade"><p>'
205 . __('The Whitelist IP range(s) have been cleared successfully', 'loginizer')
206 . '</p></div><br />';
207
208 }
209
210 // Reset All Logs
211 if(isset($_POST['lz_reset_all_ip'])){
212
213 $result = $wpdb->query("DELETE FROM `".$wpdb->prefix."loginizer_logs` WHERE `time` > 0");
214
215 echo '<div id="message" class="updated fade"><p>'
216 . __('All the IP Logs have been cleared', 'loginizer')
217 . '</p></div><br />';
218 }
219
220 // Reset Logs
221 if(isset($_POST['lz_reset_ip']) && isset($_POST['lz_reset_ips']) && is_array($_POST['lz_reset_ips'])){
222
223 $ips = $_POST['lz_reset_ips'];
224
225 foreach($ips as $ip){
226 if(!lz_valid_ip($ip)){
227 $error[] = 'The IP - '.esc_html($ip).' is invalid !';
228 }
229 }
230
231 if(count($ips) < 1){
232 $error[] = __('There are no IPs submitted', 'loginizer');
233 }
234
235 // Should we start deleting logs
236 if(empty($error)){
237
238 foreach($ips as $ip){
239 $result = $wpdb->query($wpdb->prepare("DELETE FROM `".$wpdb->prefix."loginizer_logs` WHERE `ip` = %s", $ip));
240 }
241
242 if(empty($error)){
243
244 echo '<div id="message" class="updated fade"><p>'
245 . __('The selected IP Logs have been reset', 'loginizer')
246 . '</p></div><br />';
247
248 }
249
250 }
251
252 if(!empty($error)){
253 lz_report_error($error);echo '<br />';
254 }
255
256 }
257
258 if(isset($_POST['blacklist_iprange'])){
259
260 $start_ip = lz_optpost('start_ip');
261 $end_ip = lz_optpost('end_ip');
262
263 // If no end IP we consider only 1 IP
264 if(empty($end_ip)){
265 $end_ip = $start_ip;
266 }
267
268 // Validate the IP against all checks
269 loginizer_iprange_validate($start_ip, $end_ip, $loginizer['blacklist'], $error);
270
271 if(empty($error)){
272
273 $blacklist = $loginizer['blacklist'];
274
275 $newid = ( empty($blacklist) ? 0 : max(array_keys($blacklist)) ) + 1;
276
277 $blacklist[$newid] = array();
278 $blacklist[$newid]['start'] = $start_ip;
279 $blacklist[$newid]['end'] = $end_ip;
280 $blacklist[$newid]['time'] = time();
281
282 update_option('loginizer_blacklist', $blacklist);
283
284 echo '<div id="message" class="updated fade"><p>'
285 . __('Blacklist IP range added successfully', 'loginizer')
286 . '</p></div><br />';
287
288 }
289
290 if(!empty($error)){
291 lz_report_error($error);echo '<br />';
292 }
293
294 }
295
296 if(isset($_POST['whitelist_iprange'])){
297
298 $start_ip = lz_optpost('start_ip_w');
299 $end_ip = lz_optpost('end_ip_w');
300
301 // If no end IP we consider only 1 IP
302 if(empty($end_ip)){
303 $end_ip = $start_ip;
304 }
305
306 // Validate the IP against all checks
307 loginizer_iprange_validate($start_ip, $end_ip, $loginizer['whitelist'], $error);
308
309 if(empty($error)){
310
311 $whitelist = $loginizer['whitelist'];
312
313 $newid = ( empty($whitelist) ? 0 : max(array_keys($whitelist)) ) + 1;
314
315 $whitelist[$newid] = array();
316 $whitelist[$newid]['start'] = $start_ip;
317 $whitelist[$newid]['end'] = $end_ip;
318 $whitelist[$newid]['time'] = time();
319
320 update_option('loginizer_whitelist', $whitelist);
321
322 echo '<div id="message" class="updated fade"><p>'
323 . __('Whitelist IP range added successfully', 'loginizer')
324 . '</p></div><br />';
325
326 }
327
328 if(!empty($error)){
329 lz_report_error($error);echo '<br />';
330 }
331 }
332
333 if(isset($_POST['lz_import_csv'])){
334
335 if(!empty($_FILES['lz_import_file_csv']['name'])){
336
337 $lz_csv_type = lz_optpost('lz_csv_type');
338
339 // Is the submitted type in the allowed list ?
340 if(!in_array($lz_csv_type, array('blacklist', 'whitelist'))){
341 $error[] = __('Invalid import type', 'loginizer');
342 }
343
344 if(empty($error)){
345
346 //Get the extension of the file
347 $csv_file_name = basename($_FILES['lz_import_file_csv']['name']);
348 $csv_ext_name = strtolower(pathinfo($csv_file_name, PATHINFO_EXTENSION));
349
350 //Check if it's a csv file
351 if($csv_ext_name == 'csv'){
352
353 $file = fopen($_FILES['lz_import_file_csv']['tmp_name'], "r");
354
355 $line_count = 0;
356 $update_record = 0;
357
358 while($content = fgetcsv($file)){
359
360 //Increment the $line_count
361 $line_count++;
362
363 //Skip the first line
364 if($line_count <= 1){
365 continue;
366 }
367
368 if(loginizer_iprange_validate($content[0], $content[1], $loginizer[$lz_csv_type], $error, $line_count)){
369
370 $newid = ( empty($loginizer[$lz_csv_type]) ? 0 : max(array_keys($loginizer[$lz_csv_type])) ) + 1;
371
372 $loginizer[$lz_csv_type][$newid] = array();
373 $loginizer[$lz_csv_type][$newid]['start'] = $content[0];
374 $loginizer[$lz_csv_type][$newid]['end'] = $content[1];
375 $loginizer[$lz_csv_type][$newid]['time'] = time();
376
377 $update_record = 1;
378
379 }
380 }
381
382 fclose($file);
383
384 if(!empty($update_record)){
385
386 update_option('loginizer_'.$lz_csv_type, $loginizer[$lz_csv_type]);
387
388 echo '<div id="message" class="updated fade"><p>'
389 . __('Imported '.ucfirst($lz_csv_type).' IP range(s) successfully', 'loginizer')
390 . '</p></div><br />';
391
392 }
393
394 if(!empty($error)){
395 lz_report_error($error);echo '<br />';
396 }
397 }
398
399 }
400 }
401 }
402
403 //Brute Force Bulk Blacklist/ Whitelist Ip
404 if(isset($_POST['lz_blacklist_selected_ip'])){
405 if(isset($_POST['lz_reset_ips']) && is_array($_POST['lz_reset_ips'])){
406
407 $ips = $_POST['lz_reset_ips'];
408
409 foreach($ips as $ip){
410 if(!lz_valid_ip($ip)){
411 $error[] = sprintf(__('The IP - %s is invalid !', 'loginizer'), esc_html($ip));
412 }
413 }
414
415 if(count($ips) < 1){
416 $error[] = __('There are no IPs submitted', 'loginizer');
417 }
418
419 // Should we start deleting logs
420 if(empty($error)){
421
422 $update_record = 0;
423
424 foreach($ips as $ip){
425
426 if(loginizer_iprange_validate($ip, '', $loginizer['blacklist'], $error)){
427
428 $newid = ( empty($loginizer['blacklist']) ? 0 : max(array_keys($loginizer['blacklist'])) ) + 1;
429
430 $loginizer['blacklist'][$newid] = array();
431 $loginizer['blacklist'][$newid]['start'] = $ip;
432 $loginizer['blacklist'][$newid]['end'] = $ip;
433 $loginizer['blacklist'][$newid]['time'] = time();
434
435 $update_record = 1;
436 }
437 }
438
439 if(!empty($update_record)){
440
441 update_option('loginizer_blacklist', $loginizer['blacklist']);
442
443 echo '<div id="message" class="updated fade"><p>'
444 . __('The selected IP(s) have been blacklisted', 'loginizer')
445 . '</p></div><br />';
446
447 }
448
449 }
450 }else{
451 $error[] = __('No IP(s) selected', 'loginizer');
452 }
453
454 if(!empty($error)){
455 lz_report_error($error);echo '<br />';
456 }
457 }
458
459 // Save the messages
460 if(isset($_POST['save_err_msgs_lz'])){
461
462 $msgs['inv_userpass'] = lz_optpost('msg_inv_userpass');
463 $msgs['ip_blacklisted'] = lz_optpost('msg_ip_blacklisted');
464 $msgs['attempts_left'] = lz_optpost('msg_attempts_left');
465 $msgs['lockout_err'] = lz_optpost('msg_lockout_err');
466 $msgs['minutes_err'] = lz_optpost('msg_minutes_err');
467 $msgs['hours_err'] = lz_optpost('msg_hours_err');
468
469 // Update them
470 update_option('loginizer_msg', $msgs);
471
472 echo '<div id="message" class="updated fade"><p>'
473 . __('Error messages were saved successfully', 'loginizer')
474 . '</p></div><br />';
475
476 }
477
478 // Count the Results
479 $tmp = lz_selectquery("SELECT COUNT(*) AS num FROM `".$wpdb->prefix."loginizer_logs`");
480 //print_r($tmp);
481
482 // Which Page is it
483 $lz_env['res_len'] = 10;
484 $lz_env['cur_page'] = lz_get_page('lzpage', $lz_env['res_len']);
485 $lz_env['num_res'] = $tmp['num'];
486 $lz_env['max_page'] = ceil($lz_env['num_res'] / $lz_env['res_len']);
487
488 // Get the logs
489 $result = lz_selectquery("SELECT * FROM `".$wpdb->prefix."loginizer_logs`
490 ORDER BY `time` DESC
491 LIMIT ".$lz_env['cur_page'].", ".$lz_env['res_len']."", 1);
492 //print_r($result);
493
494 $lz_env['cur_page'] = ($lz_env['cur_page'] / $lz_env['res_len']) + 1;
495 $lz_env['cur_page'] = $lz_env['cur_page'] < 1 ? 1 : $lz_env['cur_page'];
496 $lz_env['next_page'] = ($lz_env['cur_page'] + 1) > $lz_env['max_page'] ? $lz_env['max_page'] : ($lz_env['cur_page'] + 1);
497 $lz_env['prev_page'] = ($lz_env['cur_page'] - 1) < 1 ? 1 : ($lz_env['cur_page'] - 1);
498
499 // Reload the settings
500 $loginizer['blacklist'] = get_option('loginizer_blacklist');
501 $loginizer['whitelist'] = get_option('loginizer_whitelist');
502
503 $saved_msgs = get_option('loginizer_msg');
504
505 ?>
506
507 <div id="" class="postbox">
508
509 <div class="postbox-header">
510 <h2 class="hndle ui-sortable-handle">
511 <?php echo '<span>'.__('Failed Login Attempts Logs', 'loginizer').'</span> &nbsp; ('.__('Past', 'loginizer').' '.($loginizer['reset_retries']/60/60).' '.__('hours', 'loginizer').')'; ?>
512 </h2>
513 </div>
514
515 <script>
516 function yesdsd(){
517 window.location = '<?php echo menu_page_url('loginizer_brute_force', false);?>&lzpage='+jQuery("#current-page-selector").val();
518 return false;
519 }
520
521 function lz_export_ajax(lz_csv_type){
522
523 var data = new Object();
524 data["action"] = lz_csv_type != "failed_login" ? "loginizer_export" : "loginizer_failed_login_export";
525 data["lz_csv_type"] = lz_csv_type;
526 data["nonce"] = "<?php echo wp_create_nonce('loginizer_admin_ajax'); ?>";
527
528 var admin_url = "<?php admin_url(); ?>"+"admin-ajax.php";
529
530 jQuery.post(admin_url, data, function(response){
531
532 // Was the ajax call successful ?
533 if(response.substring(0,2) == "-1"){
534
535 var err_message = response.substring(2);
536
537 if(err_message){
538 alert(err_message);
539 }else{
540 alert("Failed to export data");
541 }
542
543 return false;
544 }
545
546 /*
547 * Make CSV downloadable
548 */
549 var downloadLink = document.createElement("a");
550 var fileData = ['\ufeff'+response];
551
552 var blobObject = new Blob(fileData,{
553 type: "text/csv;charset=utf-8;"
554 });
555
556 var url = URL.createObjectURL(blobObject);
557 downloadLink.href = url;
558 downloadLink.download = "loginizer-"+lz_csv_type+".csv";
559
560 /*
561 * Actually download CSV
562 */
563 document.body.appendChild(downloadLink);
564 downloadLink.click();
565 document.body.removeChild(downloadLink);
566
567 });
568
569 }
570
571 </script>
572
573 <form method="get" onsubmit="return yesdsd();">
574 <div class="tablenav">
575 <p class="tablenav-pages" style="margin: 5px 10px" align="right">
576 <span class="displaying-num"><?php echo $lz_env['num_res'];?> items</span>
577 <span class="pagination-links">
578 <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>
579 <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>
580 <span class="paging-input">
581 <label for="current-page-selector" class="screen-reader-text">Current Page</label>
582 <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>
583 </span>
584 <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>
585 <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>
586 </span>
587 </p>
588 </div>
589 </form>
590
591 <form action="" method="post" enctype="multipart/form-data">
592 <?php wp_nonce_field('loginizer-options'); ?>
593 <div class="inside">
594 <table class="wp-list-table widefat fixed users" border="0">
595 <tr>
596 <th scope="row" valign="top" style="background:#EFEFEF;" width="20"><input type="checkbox" id="lz_check_all_logs" onchange="lz_multiple_check()" style="margin-left:-1px;"/></th>
597 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('IP','loginizer'); ?></th>
598 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Attempted Username','loginizer'); ?></th>
599 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Last Failed Attempt (DD/MM/YYYY)','loginizer'); ?></th>
600 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Failed Attempts Count','loginizer'); ?></th>
601 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Lockouts Count','loginizer'); ?></th>
602 <th scope="row" valign="top" style="background:#EFEFEF;" width="150"><?php echo __('URL Attacked','loginizer'); ?></th>
603 </tr>
604 <?php
605
606 if(empty($result)){
607 echo '
608 <tr>
609 <td colspan="4">
610 '.__('No Logs. You will see logs about failed login attempts here.', 'loginizer').'
611 </td>
612 </tr>';
613 }else{
614 foreach($result as $ik => $iv){
615 $status_button = (!empty($iv['status']) ? 'disable' : 'enable');
616 echo '
617 <tr>
618 <td>
619 <input type="checkbox" value="'.esc_attr($iv['ip']).'" name="lz_reset_ips[]" class="lz_shift_select_logs lz_check_all_logs" />
620 </td>
621 <td>
622 <a href="https://ipinfo.io/'.esc_html($iv['ip']).'" target="_blank">'.esc_html($iv['ip']).'&nbsp;<span class="dashicons dashicons-external"></span></a>
623 </td>
624 <td>
625 '.esc_html($iv['username']).'
626 </td>
627 <td>
628 '.date('d/M/Y H:i:s P', $iv['time']).'
629 </td>
630 <td>
631 '.esc_html($iv['count']).'
632 </td>
633 <td>
634 '.esc_html($iv['lockout']).'
635 </td>
636 <td>
637 '.esc_html($iv['url']).'
638 </td>
639 </tr>';
640 }
641 }
642
643 ?>
644 </table>
645
646 <br>
647 <input name="lz_reset_ip" class="button button-primary action" value="<?php echo __('Remove From Logs', 'loginizer'); ?>" type="submit" />
648 &nbsp; &nbsp;
649 <input name="lz_reset_all_ip" class="button button-primary action" value="<?php echo __('Clear All Logs', 'loginizer'); ?>" type="submit" />
650 &nbsp; &nbsp;
651 <input name="lz_blacklist_selected_ip" class="button button-primary action" value="<?php echo __('Blacklist Selected IPs', 'loginizer'); ?>" type="submit" />
652 &nbsp; &nbsp;
653 <input name="lz_export_csv" onclick="lz_export_ajax('failed_login'); return false;" class="button button-primary action" value="<?php echo __('Export CSV', 'loginizer'); ?>" type="submit" />
654 </div>
655 </div>
656 </form>
657 <br />
658
659 <div id="" class="postbox">
660
661 <div class="postbox-header">
662 <h2 class="hndle ui-sortable-handle">
663 <span><?php echo __('Brute Force Settings', 'loginizer'); ?></span>
664 </h2>
665 </div>
666
667 <div class="inside">
668
669 <form action="" method="post" enctype="multipart/form-data">
670 <?php wp_nonce_field('loginizer-options'); ?>
671 <table class="form-table">
672 <tr>
673 <th scope="row" valign="top"><label for="max_retries"><?php echo __('Max Retries','loginizer'); ?></label></th>
674 <td>
675 <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 />
676 </td>
677 </tr>
678 <tr>
679 <th scope="row" valign="top"><label for="lockout_time"><?php echo __('Lockout Time','loginizer'); ?></label></th>
680 <td>
681 <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 />
682 </td>
683 </tr>
684 <tr>
685 <th scope="row" valign="top"><label for="max_lockouts"><?php echo __('Max Lockouts','loginizer'); ?></label></th>
686 <td>
687 <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 />
688 </td>
689 </tr>
690 <tr>
691 <th scope="row" valign="top"><label for="lockouts_extend"><?php echo __('Extend Lockout','loginizer'); ?></label></th>
692 <td>
693 <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 />
694 </td>
695 </tr>
696 <tr>
697 <th scope="row" valign="top"><label for="reset_retries"><?php echo __('Reset Retries','loginizer'); ?></label></th>
698 <td>
699 <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 />
700 </td>
701 </tr>
702 <tr>
703 <th scope="row" valign="top"><label for="notify_email"><?php echo __('Email Notification','loginizer'); ?></label></th>
704 <td>
705 <?php echo __('after ','loginizer'); ?>
706 <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'); ?>
707 </td>
708 </tr>
709 <tr>
710 <th scope="row" valign="top"><label for="notify_email_address"><?php echo __('Email Address','loginizer'); ?></label></th>
711 <td>
712 <input type="text" value="<?php echo (!empty($notify_email_address) ? $notify_email_address : (!empty($loginizer['custom_notify_email']) ? $loginizer['notify_email_address'] : '')); ?>" name="notify_email_address" id="notify_email_address" size="30" /> <br /><?php echo __('failed login attempts notifications will be sent to this email','loginizer'); ?>
713 </td>
714 </tr>
715 <tr>
716 <th scope="row" valign="top"><label for="trusted_ips"><?php echo __('Trusted IP\'s','loginizer'); ?></label></th>
717 <td>
718 <input type="checkbox" <?php echo lz_POSTchecked('trusted_ips', (empty($loginizer['trusted_ips']) ? false : true)); ?> name="trusted_ips" id="trusted_ips"/>
719 <?php _e('If enabled Loginizer will only allow whitlisted IP\'s to Login.', 'loginizer'); ?>
720 </td>
721 </tr>
722 <tr>
723 <th scope="row" valign="top"><label for="blocked_screen"><?php echo __('Blocked Screen','loginizer'); ?></label></th>
724 <td>
725 <input type="checkbox" <?php echo lz_POSTchecked('blocked_screen', (empty($loginizer['blocked_screen']) ? false : true)); ?> name="blocked_screen" id="blocked_screen"/>
726 <?php _e('Shows an error page in place of the login page if the user is locked out or blacklisted, to prevent attackers from attempting to log in when locked out, which saves resources', 'loginizer'); ?>
727 </td>
728 </tr>
729 </table><br />
730 <input name="save_lz" class="button button-primary action" value="<?php echo __('Save Settings','loginizer'); ?>" type="submit" />
731 <?php
732
733 if(empty($loginizer['disable_brute'])){
734
735 echo '<input name="disable_brute_lz" class="button action" value="'.__('Disable Brute Force Protection','loginizer').'" type="submit" style="float:right" />';
736
737 }else{
738
739 echo '<input name="enable_brute_lz" class="button button-primary action" value="'.__('Enable Brute Force Protection','loginizer').'" type="submit" style="float:right" />';
740
741 }
742
743 ?>
744 </form>
745
746 </div>
747 </div>
748 <br />
749
750 <?php
751
752 wp_enqueue_script('jquery-paginate', LOGINIZER_URL.'/assets/js/jquery-paginate.js', array('jquery'), '1.10.15');
753
754 ?>
755
756 <style>
757 .page-navigation a {
758 margin: 5px 2px;
759 display: inline-block;
760 padding: 5px 8px;
761 color: #0073aa;
762 background: #e5e5e5 none repeat scroll 0 0;
763 border: 1px solid #ccc;
764 text-decoration: none;
765 transition-duration: 0.05s;
766 transition-property: border, background, color;
767 transition-timing-function: ease-in-out;
768 }
769
770 .page-navigation a[data-selected] {
771 background-color: #00a0d2;
772 color: #fff;
773 }
774 </style>
775
776 <script>
777
778 jQuery(document).ready(function(){
779 jQuery('#lz_bl_table').paginate({ limit: 11, navigationWrapper: jQuery('#lz_bl_nav')});
780 jQuery('#lz_wl_table').paginate({ limit: 11, navigationWrapper: jQuery('#lz_wl_nav')});
781 lz_multiple_check();
782 lz_shift_check_all('lz_shift_select_logs');
783 });
784
785 // Delete a Blacklist / Whitelist IP Range
786 function del_confirm(field, todo_id, msg){
787 var ret = confirm(msg);
788
789 if(ret){
790 jQuery('#lz_bl_wl_todo').attr('name', field);
791 jQuery('#lz_bl_wl_todo').val(todo_id);
792 jQuery('#lz_bl_wl_form').submit();
793 }
794
795 return false;
796
797 }
798
799 // Delete all Blacklist / Whitelist IP Ranges
800 function del_confirm_all(msg){
801 var ret = confirm(msg);
802
803 if(ret){
804 return true;
805 }
806
807 return false;
808
809 }
810
811 //Check all the failed log attempts
812 function lz_multiple_check(){
813 jQuery("#lz_check_all_logs").on("click", function(event){
814 if(this.checked == true){
815 jQuery(".lz_check_all_logs").prop("checked", true);
816 }else{
817 jQuery(".lz_check_all_logs").prop("checked", false);
818 }
819 });
820 }
821
822 //To select the installations/backups using shift key
823 function lz_shift_check_all(check_class){
824
825 var checkboxes = jQuery("."+check_class);
826 var lastChecked = null;
827
828 checkboxes.click(function(event){
829 if(!lastChecked){
830 lastChecked = this;
831 return;
832 }
833
834 if(event.shiftKey){
835 var start = checkboxes.index(this);
836 var end = checkboxes.index(lastChecked);
837
838 checkboxes.slice(Math.min(start,end), Math.max(start,end)+ 1).prop("checked", this.checked);
839 }
840
841 lastChecked = this;
842 });
843 };
844
845 </script>
846
847 <div id="" class="postbox">
848
849 <div class="postbox-header">
850 <h2 class="hndle ui-sortable-handle">
851 <span><?php echo __('Blacklist IP','loginizer'); ?></span>
852 </h2>
853 </div>
854
855 <div class="inside">
856
857 <?php echo __('Enter the IP you want to blacklist from login','loginizer'); ?>
858
859 <form action="" method="post">
860 <?php wp_nonce_field('loginizer-options'); ?>
861 <table class="form-table">
862 <tr>
863 <th scope="row" valign="top"><label for="start_ip"><?php echo __('Start IP','loginizer'); ?></label></th>
864 <td>
865 <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 />
866 </td>
867 </tr>
868 <tr>
869 <th scope="row" valign="top"><label for="end_ip"><?php echo __('End IP (Optional)','loginizer'); ?></label></th>
870 <td>
871 <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 />
872 </td>
873 </tr>
874 </table><br />
875 <input name="blacklist_iprange" class="button button-primary action" value="<?php echo __('Add Blacklist IP Range','loginizer'); ?>" type="submit" />
876 <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" />
877 </form>
878 </div>
879
880 <div id="lz_bl_nav" style="margin: 5px 10px; text-align:right"></div>
881
882 <!--Brute Force Blacklist Import CSV Form-->
883 <div class="inside" id="blacklist_csv" style="display:none;">
884 <form action="" method="post" enctype="multipart/form-data">
885 <?php wp_nonce_field('loginizer-options'); ?>
886 <input type="hidden" value="blacklist" name="lz_csv_type" />
887 <h3><?php echo __('Import Blacklist IPs (CSV)', 'loginizer'); ?>:</h3>
888 <input type="file" name="lz_import_file_csv" value="Import CSV" />
889 <br><br>
890 <input name="lz_import_csv" class="button button-primary action" value="<?php echo __('Submit', 'loginizer'); ?>" type="submit" />
891 </form>
892 </div>
893 <!---->
894
895 <!--Brute Force Blacklist Export CSV Form-->
896 <div class="inside" style="float:right;">
897 <form action="" method="post">
898 <?php wp_nonce_field('loginizer-options'); ?>
899 <input type="hidden" value="blacklist" name="lz_csv_type" />
900 <input class="button button-primary action" value="<?php echo __('Import CSV', 'loginizer'); ?>" type="button" onclick="jQuery('#blacklist_csv').toggle();"/>
901 <input name="lz_export_csv" onclick="lz_export_ajax('blacklist'); return false;" class="button button-primary action" value="<?php echo __('Export CSV', 'loginizer'); ?>" type="submit" />
902 </form>
903
904 </div>
905 <!---->
906
907 <table id="lz_bl_table" class="wp-list-table fixed striped users" border="0" width="95%" cellpadding="10" align="center">
908 <tr>
909 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Start IP','loginizer'); ?></th>
910 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('End IP','loginizer'); ?></th>
911 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Date (DD/MM/YYYY)','loginizer'); ?></th>
912 <th scope="row" valign="top" style="background:#EFEFEF;" width="100"><?php echo __('Options','loginizer'); ?></th>
913 </tr>
914 <?php
915 if(empty($loginizer['blacklist'])){
916 echo '
917 <tr>
918 <td colspan="4">
919 '.__('No Blacklist IPs. You will see blacklisted IP ranges here.', 'loginizer').'
920 </td>
921 </tr>';
922 }else{
923 foreach($loginizer['blacklist'] as $ik => $iv){
924 echo '
925 <tr>
926 <td>
927 '.$iv['start'].'
928 </td>
929 <td>
930 '.$iv['end'].'
931 </td>
932 <td>
933 '.date('d/m/Y', $iv['time']).'
934 </td>
935 <td>
936 <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>
937 </td>
938 </tr>';
939 }
940 }
941 ?>
942 </table>
943 <br />
944 <form action="" method="post" id="lz_bl_wl_form">
945 <?php wp_nonce_field('loginizer-options'); ?>
946 <input type="hidden" value="" name="" id="lz_bl_wl_todo"/>
947 </form>
948 </div>
949
950 <br />
951
952 <div id="" class="postbox">
953
954 <div class="postbox-header">
955 <h2 class="hndle ui-sortable-handle">
956 <span><?php echo __('Whitelist IP', 'loginizer'); ?></span>
957 </h2>
958 </div>
959
960 <div class="inside">
961
962 <?php echo __('Enter the IP you want to whitelist for login','loginizer'); ?>
963 <form action="" method="post">
964 <?php wp_nonce_field('loginizer-options'); ?>
965 <table class="form-table">
966 <tr>
967 <th scope="row" valign="top"><label for="start_ip_w"><?php echo __('Start IP','loginizer'); ?></label></th>
968 <td>
969 <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 />
970 </td>
971 </tr>
972 <tr>
973 <th scope="row" valign="top"><label for="end_ip_w"><?php echo __('End IP (Optional)','loginizer'); ?></label></th>
974 <td>
975 <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 />
976 </td>
977 </tr>
978 </table><br />
979 <input name="whitelist_iprange" class="button button-primary action" value="<?php echo __('Add Whitelist IP Range','loginizer'); ?>" type="submit" />
980 <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" />
981 </form>
982 </div>
983
984 <div id="lz_wl_nav" style="margin: 5px 10px; text-align:right"></div>
985
986 <!--Brute Force Whitelist Import CSV Form-->
987 <div class="inside" id="lz_whitelist_csv_div" style="display:none;">
988 <form action="" method="post" enctype="multipart/form-data">
989 <?php wp_nonce_field('loginizer-options'); ?>
990 <input type="hidden" value="whitelist" name="lz_csv_type" />
991 <h3><?php echo __('Import Whitelist IPs (CSV)', 'loginizer'); ?>:</h3>
992 <input type="file" name="lz_import_file_csv" value="Import CSV" />
993 <br><br>
994 <input name="lz_import_csv" class="button button-primary action" value="<?php echo __('Submit', 'loginizer'); ?>" type="submit" />
995 </form>
996 </div>
997 <!---->
998
999 <!--Brute Force Whitelist Export CSV Form-->
1000 <div class="inside" style="float:right;">
1001 <form action="" method="post">
1002 <?php wp_nonce_field('loginizer-options'); ?>
1003 <input type="hidden" value="whitelist" name="lz_csv_type" />
1004 <input class="button button-primary action" value="<?php echo __('Import CSV', 'loginizer'); ?>" type="button" onclick="jQuery('#lz_whitelist_csv_div').toggle();"/>
1005 <input name="lz_export_csv" onclick="lz_export_ajax('whitelist'); return false;" class="button button-primary action" value="<?php echo __('Export CSV', 'loginizer'); ?>" type="submit" />
1006 </form>
1007 </div>
1008 <!---->
1009
1010 <table id="lz_wl_table" class="wp-list-table fixed striped users" border="0" width="95%" cellpadding="10" align="center">
1011 <tr>
1012 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Start IP','loginizer'); ?></th>
1013 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('End IP','loginizer'); ?></th>
1014 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Date (DD/MM/YYYY)','loginizer'); ?></th>
1015 <th scope="row" valign="top" style="background:#EFEFEF;" width="100"><?php echo __('Options','loginizer'); ?></th>
1016 </tr>
1017 <?php
1018 if(empty($loginizer['whitelist'])){
1019 echo '
1020 <tr>
1021 <td colspan="4">
1022 '.__('No Whitelist IPs. You will see whitelisted IP ranges here.', 'loginizer').'
1023 </td>
1024 </tr>';
1025 }else{
1026 foreach($loginizer['whitelist'] as $ik => $iv){
1027 echo '
1028 <tr>
1029 <td>
1030 '.$iv['start'].'
1031 </td>
1032 <td>
1033 '.$iv['end'].'
1034 </td>
1035 <td>
1036 '.date('d/m/Y', $iv['time']).'
1037 </td>
1038 <td>
1039 <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>
1040 </td>
1041 </tr>';
1042 }
1043 }
1044 ?>
1045 </table>
1046 <br />
1047
1048 </div>
1049
1050 <div id="" class="postbox">
1051
1052 <div class="postbox-header">
1053 <h2 class="hndle ui-sortable-handle">
1054 <span><?php echo __('Error Messages', 'loginizer'); ?></span>
1055 </h2>
1056 </div>
1057
1058 <div class="inside">
1059
1060 <form action="" method="post" enctype="multipart/form-data">
1061 <?php wp_nonce_field('loginizer-options'); ?>
1062 <table class="form-table">
1063 <tr>
1064 <th scope="row" valign="top"><label for="msg_inv_userpass"><?php echo __('Failed Login Attempt','loginizer'); ?></label></th>
1065 <td>
1066 <input type="text" size="25" value="<?php echo (empty($saved_msgs['inv_userpass']) ? '' : esc_attr($saved_msgs['inv_userpass'])); ?>" name="msg_inv_userpass" id="msg_inv_userpass" />
1067 <?php echo __('Default: <em>&quot;' . $loginizer['d_msg']['inv_userpass']. '&quot;</em>', 'loginizer'); ?><br />
1068 </td>
1069 </tr>
1070 <tr>
1071 <th scope="row" valign="top"><label for="msg_ip_blacklisted"><?php echo __('Blacklisted IP','loginizer'); ?></label></th>
1072 <td>
1073 <input type="text" size="25" value="<?php echo (empty($saved_msgs['ip_blacklisted']) ? '' : esc_attr($saved_msgs['ip_blacklisted'])); ?>" name="msg_ip_blacklisted" id="msg_ip_blacklisted" />
1074 <?php echo __('Default: <em>&quot;' . $loginizer['d_msg']['ip_blacklisted']. '&quot;</em>', 'loginizer'); ?><br />
1075 </td>
1076 </tr>
1077 <tr>
1078 <th scope="row" valign="top"><label for="msg_attempts_left"><?php echo __('Attempts Left','loginizer'); ?></label></th>
1079 <td>
1080 <input type="text" size="25" value="<?php echo (empty($saved_msgs['attempts_left']) ? '' : esc_attr($saved_msgs['attempts_left'])); ?>" name="msg_attempts_left" id="msg_attempts_left" />
1081 <?php echo __('Default: <em>&quot;' . $loginizer['d_msg']['attempts_left']. '&quot;</em>', 'loginizer'); ?><br />
1082 </td>
1083 </tr>
1084 <tr>
1085 <th scope="row" valign="top"><label for="msg_lockout_err"><?php echo __('Lockout Error','loginizer'); ?></label></th>
1086 <td>
1087 <input type="text" size="25" value="<?php echo (empty($saved_msgs['lockout_err']) ? '' : esc_attr($saved_msgs['lockout_err'])); ?>" name="msg_lockout_err" id="msg_lockout_err" />
1088 <?php echo __('Default: <em>&quot;' . strip_tags($loginizer['d_msg']['lockout_err']). '&quot;</em>', 'loginizer'); ?><br />
1089 </td>
1090 </tr>
1091 <tr>
1092 <th scope="row" valign="top"><label for="msg_minutes_err"><?php echo __('Minutes','loginizer'); ?></label></th>
1093 <td>
1094 <input type="text" size="25" value="<?php echo (empty($saved_msgs['minutes_err']) ? '' : esc_attr($saved_msgs['minutes_err'])); ?>" name="msg_minutes_err" id="msg_minutes_err" />
1095 <?php echo __('Default: <em>&quot;' . strip_tags($loginizer['d_msg']['minutes_err']). '&quot;</em>', 'loginizer'); ?><br />
1096 </td>
1097 </tr>
1098 <tr>
1099 <th scope="row" valign="top"><label for="msg_hours_err"><?php echo __('Hours','loginizer'); ?></label></th>
1100 <td>
1101 <input type="text" size="25" value="<?php echo (empty($saved_msgs['hours_err']) ? '' : esc_attr($saved_msgs['hours_err'])); ?>" name="msg_hours_err" id="msg_hours_err" />
1102 <?php echo __('Default: <em>&quot;' . strip_tags($loginizer['d_msg']['hours_err']). '&quot;</em>', 'loginizer'); ?><br />
1103 </td>
1104 </tr>
1105 </table><br />
1106 <input name="save_err_msgs_lz" class="button button-primary action" value="<?php echo __('Save Error Messages','loginizer'); ?>" type="submit" />
1107 </form>
1108 </div>
1109 </div>
1110
1111 <div id="" class="postbox">
1112 <div class="postbox-header">
1113 <h2 class="hndle ui-sortable-handle">
1114 <span><?php echo __('Login Notification', 'loginizer');?></span>
1115 </h2>
1116 </div>
1117 <div class="inside">
1118 <form action="" method="post" enctype="multipart/form-data">
1119 <?php wp_nonce_field('loginizer-options'); ?>
1120 <table class="form-table">
1121 <tr>
1122 <td scope="row" valign="top" style="width:350px !important">
1123 <label for="loginizer_login_mail_enable"><?php echo __('Enable Notification', 'loginizer'); ?></label>
1124 <p class="description"><?php echo __('If enabled, user will get notified about successful login attempt.', 'loginizer'); ?></p>
1125 </td>
1126 <td>
1127 <input type="checkbox" value="1" name="loginizer_login_mail_enable" id="loginizer_login_mail_enable" <?php echo lz_POSTchecked('loginizer_login_mail_enable', (empty($loginizer['login_mail']['enable']) ? false : true)); ?> />
1128
1129 </td>
1130 </tr>
1131
1132 <tr>
1133 <td scope="row" valign="top" style="width:350px !important">
1134 <label for="loginizer_notify_disable_whitelist"><?php echo __('Disable for whitelisted IPs', 'loginizer'); ?></label>
1135 <p class="description"><?php echo __("If checked, don't notify whitelisted IPs.", 'loginizer'); ?></p>
1136 </td>
1137 <td>
1138 <input type="checkbox" value="1" name="loginizer_login_mail_disable_whitelist" id="loginizer_login_mail_disable_whitelist" <?php echo lz_POSTchecked('loginizer_login_mail_disable_whitelist', (empty($loginizer['login_mail']['disable_whitelist']) ? false : true)); ?> />
1139 </td>
1140 </tr>
1141
1142 <tr>
1143 <td scope="row" valign="top" style="width:350px !important">
1144 <label for="loginizer_notify_html_mail"><?php echo __('Send email as HTML', 'loginizer'); ?></label>
1145 </td>
1146 <td>
1147 <input type="checkbox" value="1" name="loginizer_notify_html_mail" id="loginizer_notify_html_mail" <?php echo lz_POSTchecked('loginizer_notify_html_mail', (empty($loginizer['login_mail']['html_mail']) ? false : true)); ?> />
1148 </td>
1149 </tr>
1150
1151 <tr>
1152 <td scope="row" valign="top">
1153 <label for="loginizer_login_mail_subject"><?php echo __('Email Subject', 'loginizer'); ?></label><br>
1154 <span class="exp"><?php echo __('Set blank to reset to the default subject', 'loginizer'); ?></span>
1155 <br />Default : <pre style="font-size:10px"><?php echo esc_html($loginizer['login_mail_default_sub']); ?></pre>
1156 </td>
1157 <td valign="top">
1158 <input type="text" size="40" value="<?php echo !empty($_POST['loginizer_login_mail_subject']) ? esc_html(wp_unslash($_POST['loginizer_login_mail_subject'])) : (empty($loginizer['login_mail']['subject']) ? '' : esc_html($loginizer['login_mail']['subject'])); ?>" name="loginizer_login_mail_subject" id="loginizer_login_mail_subject" />
1159 <br />Variables :
1160 <br />$sitename - The Site Name
1161 <br />$user_login - User Name
1162 </td>
1163 </tr>
1164
1165 <tr>
1166 <td scope="row" valign="top">
1167 <label for="loginizer_login_mail_body"><?php echo __('Email Body', 'loginizer'); ?></label><br>
1168 <span class="exp"><?php echo __('Set blank to reset to the default message', 'loginizer'); ?></span>
1169 <br />Default : <pre style="font-size:10px"><?php echo esc_html($loginizer['login_mail_default_msg']); ?></pre>
1170 </td>
1171 <td valign="top">
1172 <textarea rows="10" style="width:70%" name="loginizer_login_mail_body" id="loginizer_login_mail_body"><?php echo !empty($_POST['loginizer_login_mail_body']) ? esc_html(wp_unslash($_POST['loginizer_login_mail_body'])) : (empty($loginizer['login_mail']['body']) ? '' : esc_html($loginizer['login_mail']['body'])); ?></textarea>
1173 <br />Variables :
1174 <br />$sitename - The Site Name
1175 <br />$user_login - User Name
1176 <br />$date - Time and Date ( current date and time of Login )
1177 <br />$ip - Device IP Address from which login happned
1178 </td>
1179
1180 </td>
1181 </tr>
1182 <tr><br>
1183 <td scope="row" valign="top" style="width:350px !important">
1184 <label for="loginizer_login_mail_roles"><?php echo __('Select Roles', 'loginizer'); ?></label><br/>
1185 <span class="exp"><?php echo __('Select the user roles for whom you want to send successful login notification.', 'loginizer'); ?></span>
1186 </td>
1187 <td align="top">
1188 <?php
1189 $editable_roles = get_editable_roles();
1190 echo '<div style="max-height:150px; overflow:auto;">';
1191
1192 foreach($editable_roles as $role => $details) {
1193 $name = translate_user_role($details['name']);
1194 // Preselect specified role.
1195 if((!empty($loginizer['login_mail']['roles']) && in_array($role, $loginizer['login_mail']['roles'])) || (!empty($_POST['loginizer_login_mail_roles']) && in_array($role, $_POST['loginizer_login_mail_roles']))){
1196 echo '<input type="checkbox" checked name="loginizer_login_mail_roles[]" value="' . esc_attr($role) . '" style="margin-top:5px">'.esc_html($name).'</option>';
1197 } else {
1198 echo '<input type="checkbox" value="' . esc_attr($role) . '" name="loginizer_login_mail_roles[]">'.esc_html($name).'</option>';
1199 }
1200
1201 echo '<br/>';
1202 }
1203 echo '</div>';
1204 ?>
1205 </td>
1206 </tr>
1207 </table><br />
1208 <center><input name="save_lz_login_email" class="button button-primary action" value="<?php echo __('Save Settings', 'loginizer'); ?>" type="submit" /></center>
1209 </form>
1210
1211 </div>
1212 </div>
1213
1214 <?php
1215
1216 loginizer_page_footer();
1217
1218 }
1219
1220 // IP range validations
1221 function loginizer_iprange_validate($start_ip, $end_ip, $cur_list, &$error = array(), $line_count = ''){
1222
1223 $line_error = '';
1224 if(!empty($line_count)){
1225 $line_error = ' '.__('Line no.', 'loginizer').' '.$line_count;
1226 }
1227
1228 if(empty($start_ip)){
1229 $cur_error[] = __('Please enter the Start IP', 'loginizer').$line_error;
1230 }
1231
1232 // If no end IP we consider only 1 IP
1233 if(empty($end_ip)){
1234 $end_ip = $start_ip;
1235 }
1236
1237 if(!lz_valid_ip($start_ip)){
1238 $cur_error[] = __('Please provide a valid start IP', 'loginizer').$line_error;
1239 }
1240
1241 if(!lz_valid_ip($end_ip)){
1242 $cur_error[] = __('Please provide a valid end IP', 'loginizer').$line_error;
1243 }
1244
1245 if(inet_ptoi($start_ip) > inet_ptoi($end_ip)){
1246
1247 // BUT, if 0.0.0.1 - 255.255.255.255 is given, it will not work
1248 if(inet_ptoi($start_ip) >= 0 && inet_ptoi($end_ip) < 0){
1249 // This is right
1250 }else{
1251 $cur_error[] = __('The End IP cannot be smaller than the Start IP', 'loginizer').$line_error;
1252 }
1253
1254 }
1255
1256 if(!empty($cur_error)){
1257
1258 foreach($cur_error as $rk => $rv){
1259 $error[] = $rv;
1260 }
1261
1262 return false;
1263 }
1264
1265 if(!empty($cur_list)){
1266
1267 foreach($cur_list as $k => $v){
1268
1269 // This is to check if there is any other range exists with the same Start or End IP
1270 if(( inet_ptoi($start_ip) <= inet_ptoi($v['start']) && inet_ptoi($v['start']) <= inet_ptoi($end_ip) )
1271 || ( inet_ptoi($start_ip) <= inet_ptoi($v['end']) && inet_ptoi($v['end']) <= inet_ptoi($end_ip) )
1272 ){
1273 $cur_error[] = __('The Start IP or End IP submitted conflicts with an existing IP range !', 'loginizer').$line_error;
1274 break;
1275 }
1276
1277 // This is to check if there is any other range exists with the same Start IP
1278 if(inet_ptoi($v['start']) <= inet_ptoi($start_ip) && inet_ptoi($start_ip) <= inet_ptoi($v['end'])){
1279 $cur_error[] = __('The Start IP is present in an existing range !', 'loginizer').$line_error;
1280 break;
1281 }
1282
1283 // This is to check if there is any other range exists with the same End IP
1284 if(inet_ptoi($v['start']) <= inet_ptoi($end_ip) && inet_ptoi($end_ip) <= inet_ptoi($v['end'])){
1285 $cur_error[] = __('The End IP is present in an existing range!', 'loginizer').$line_error;
1286 break;
1287 }
1288
1289 }
1290
1291 }
1292
1293 if(!empty($cur_error)){
1294
1295 foreach($cur_error as $rk => $rv){
1296 $error[] = $rv;
1297 }
1298
1299 return false;
1300 }
1301
1302 return true;
1303 }