PluginProbe
Loginizer / 2.0.1
Loginizer v2.0.1
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 / 2fa.php

2fa.php in Loginizer 2.0.1, at main/settings/2fa.php

758 lines 26.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 // Loginizer - Two Factor Auth Page
8 function loginizer_page_2fa(){
9
10 global $loginizer, $lz_error, $lz_env, $lz_roles, $lz_options, $saved_msgs;
11
12 if(!current_user_can('manage_options')){
13 wp_die('Sorry, but you do not have permissions to change settings.');
14 }
15
16 if(!loginizer_is_premium() && count($_POST) > 0){
17 $lz_error['not_in_free'] = __('This feature is not available in the Free version. <a href="'.LOGINIZER_PRICING_URL.'" target="_blank" style="text-decoration:none; color:green;"><b>Upgrade to Pro</b></a>', 'loginizer');
18 return loginizer_page_2fa_T();
19 }
20
21 $lz_roles = get_editable_roles();
22
23 if(empty($lz_roles)){
24 $lz_roles = array();
25 }
26
27 /* Make sure post was from this page */
28 if(count($_POST) > 0){
29 check_admin_referer('loginizer-options');
30 }
31
32 // Settings submitted
33 if(isset($_POST['save_lz'])){
34
35 // In the future there can be more settings
36 $option['2fa_app'] = (int) lz_optpost('2fa_app');
37 $option['2fa_email'] = (int) lz_optpost('2fa_email');
38 $option['question'] = (int) lz_optpost('question');
39 $option['2fa_email_force'] = (int) lz_optpost('2fa_email_force');
40
41 // Any roles to apply to ?
42 foreach($lz_roles as $k => $v){
43
44 if(lz_optpost('2fa_roles_'.$k)){
45 $option['2fa_roles'][$k] = 1;
46 }
47
48 }
49
50 // If its all, then blank it
51 if(lz_optpost('2fa_roles_all') || empty($option['2fa_roles'])){
52 $option['2fa_roles'] = '';
53 }
54
55 // Is there an error ?
56 if(!empty($lz_error)){
57 return loginizer_page_2fa_T();
58 }
59
60 // Save the options
61 update_option('loginizer_2fa', $option);
62
63 // Mark as saved
64 $GLOBALS['lz_saved'] = true;
65
66 // update the rewrite rules for WooCommerce to make security settings page accessible from woo commerce client area
67 if((!empty($option['2fa_app']) || !empty($option['2fa_email']) || !empty($option['question']) || !empty($option['2fa_email_force'])) && class_exists('WooCommerce')){
68 loginizer_woocommerce_rewrite_rule();
69 }
70
71 }
72
73 // Reset a users 2FA
74 if(isset($_POST['reset_user_lz'])){
75
76 $_username = lz_optpost('lz_user_2fa_disable');
77
78 // Try to get the user
79 $user_search = get_user_by('login', $_username);
80
81 // If not found then search by email
82 if(empty($user_search)){
83 $user_search = get_user_by('email', $_username);
84 }
85
86 // If not found then give error
87 if(empty($user_search)){
88 $lz_error['2fa_user_not'] = __('There is no such user with the email or username you submitted', 'loginizer');
89 return loginizer_page_2fa_T();
90 }
91
92 // Get the user prefences
93 $user_pref = get_user_meta($user_search->ID, 'loginizer_user_settings');
94
95 // Blank it
96 $user_pref['pref'] = 'none';
97
98 // Save it
99 update_user_meta($user_search->ID, 'loginizer_user_settings', $user_pref);
100
101 // Mark as saved
102 $GLOBALS['lz_saved'] = __('The user\'s 2FA settings have been reset', 'loginizer');
103
104 }
105
106 if(isset($_POST['save_2fa_custom_redirect'])){
107
108 if(!empty($_POST['lz_2fa_custom_login_redirect'])){
109 $loginizer['2fa_custom_login_redirect'] = map_deep($_POST['lz_2fa_custom_login_redirect'], 'sanitize_text_field');
110
111 update_option('loginizer_2fa_custom_redirect', $loginizer['2fa_custom_login_redirect']);
112
113 $GLOBALS['lz_saved'] = true;
114 }
115 }
116
117 if(isset($_POST['save_2fa_email_template_lz'])){
118
119 // In the future there can be more settings
120 $option['2fa_email_sub'] = @stripslashes($_POST['lz_2fa_email_sub']);
121 $option['2fa_email_msg'] = @stripslashes($_POST['lz_2fa_email_msg']);
122
123 // Is there an error ?
124 if(!empty($lz_error)){
125 return loginizer_page_2fa_T();
126 }
127
128 // Save the options
129 update_option('loginizer_2fa_email_template', $option);
130
131 // Mark as saved
132 $GLOBALS['lz_saved'] = true;
133
134 }
135
136 // Save the messages
137 if(isset($_POST['save_msgs_lz'])){
138
139 $msgs['otp_app'] = lz_optpost('msg_otp_app');
140 $msgs['otp_email'] = lz_optpost('msg_otp_email');
141 $msgs['otp_field'] = lz_optpost('msg_otp_field');
142 $msgs['otp_question'] = lz_optpost('msg_otp_question');
143 $msgs['otp_answer'] = lz_optpost('msg_otp_answer');
144
145 // Update them
146 update_option('loginizer_2fa_msg', $msgs);
147
148 // Mark as saved
149 $GLOBALS['lz_saved'] = __('Messages were saved successfully', 'loginizer');
150
151 }
152
153 // Delete a Whitelist IP range
154 if(isset($_POST['delid'])){
155
156 $delid = (int) lz_optreq('delid');
157
158 // Unset and save
159 $whitelist = $loginizer['2fa_whitelist'];
160 unset($whitelist[$delid]);
161 update_option('loginizer_2fa_whitelist', $whitelist);
162
163 // Mark as saved
164 $GLOBALS['lz_saved'] = __('The Whitelist IP range has been deleted successfully', 'loginizer');
165
166 }
167
168 // Delete all Blackist IP ranges
169 if(isset($_POST['del_all_whitelist'])){
170
171 // Unset and save
172 update_option('loginizer_2fa_whitelist', array());
173
174 // Mark as saved
175 $GLOBALS['lz_saved'] = __('The Whitelist IP range(s) have been cleared successfully', 'loginizer');
176
177 }
178
179 // Add IP range to 2FA whitelist
180 if(isset($_POST['2fa_whitelist_iprange'])){
181
182 $start_ip = lz_optpost('start_ip_w_2fa');
183 $end_ip = lz_optpost('end_ip_w_2fa');
184
185 if(empty($start_ip)){
186 $lz_error[] = __('Please enter the Start IP', 'loginizer');
187 return loginizer_page_2fa_T();
188 }
189
190 // If no end IP we consider only 1 IP
191 if(empty($end_ip)){
192 $end_ip = $start_ip;
193 }
194
195 if(!lz_valid_ip($start_ip)){
196 $lz_error[] = __('Please provide a valid start IP', 'loginizer');
197 }
198
199 if(!lz_valid_ip($end_ip)){
200 $lz_error[] = __('Please provide a valid end IP', 'loginizer');
201 }
202
203 if(inet_ptoi($start_ip) > inet_ptoi($end_ip)){
204
205 // BUT, if 0.0.0.1 - 255.255.255.255 is given, it will not work
206 if(inet_ptoi($start_ip) >= 0 && inet_ptoi($end_ip) < 0){
207 // This is right
208 }else{
209 $lz_error[] = __('The End IP cannot be smaller than the Start IP', 'loginizer');
210 }
211
212 }
213
214 if(empty($lz_error)){
215
216 $whitelist = $loginizer['2fa_whitelist'];
217
218 foreach($whitelist as $k => $v){
219
220 // This is to check if there is any other range exists with the same Start or End IP
221 if(( inet_ptoi($start_ip) <= inet_ptoi($v['start']) && inet_ptoi($v['start']) <= inet_ptoi($end_ip) )
222 || ( inet_ptoi($start_ip) <= inet_ptoi($v['end']) && inet_ptoi($v['end']) <= inet_ptoi($end_ip) )
223 ){
224 $lz_error[] = __('The Start IP or End IP submitted conflicts with an existing IP range !', 'loginizer');
225 break;
226 }
227
228 // This is to check if there is any other range exists with the same Start IP
229 if(inet_ptoi($v['start']) <= inet_ptoi($start_ip) && inet_ptoi($start_ip) <= inet_ptoi($v['end'])){
230 $lz_error[] = __('The Start IP is present in an existing range !', 'loginizer');
231 break;
232 }
233
234 // This is to check if there is any other range exists with the same End IP
235 if(inet_ptoi($v['start']) <= inet_ptoi($end_ip) && inet_ptoi($end_ip) <= inet_ptoi($v['end'])){
236 $lz_error[] = __('The End IP is present in an existing range!', 'loginizer');
237 break;
238 }
239
240 }
241
242 $newid = ( empty($whitelist) ? 0 : max(array_keys($whitelist)) ) + 1;
243
244 if(empty($lz_error)){
245
246 $whitelist[$newid] = array();
247 $whitelist[$newid]['start'] = $start_ip;
248 $whitelist[$newid]['end'] = $end_ip;
249 $whitelist[$newid]['time'] = time();
250
251 update_option('loginizer_2fa_whitelist', $whitelist);
252
253 // Mark as saved
254 $GLOBALS['lz_saved'] = __('Whitelist IP range for Two Factor Authentication added successfully', 'loginizer');
255
256 }
257
258 }
259 }
260
261
262 $lz_options = get_option('loginizer_2fa_email_template');
263 $saved_msgs = get_option('loginizer_2fa_msg');
264 $loginizer['2fa_whitelist'] = get_option('loginizer_2fa_whitelist');
265
266 // Call theme
267 loginizer_page_2fa_T();
268
269 }
270
271
272 // Loginizer - Two Factor Auth Page
273 function loginizer_page_2fa_T(){
274
275 global $loginizer, $lz_error, $lz_env, $lz_roles, $lz_options, $saved_msgs;
276
277 // Universal header
278 loginizer_page_header('Two Factor Authentication');
279
280 loginizer_feature_available('Two-Factor Authentication');
281
282 // Saved ?
283 if(!empty($GLOBALS['lz_saved'])){
284 echo '<div id="message" class="updated"><p>'. __(is_string($GLOBALS['lz_saved']) ? $GLOBALS['lz_saved'] : 'The settings were saved successfully', 'loginizer'). '</p></div><br />';
285 }
286
287 // Any errors ?
288 if(!empty($lz_error)){
289 lz_report_error($lz_error);echo '<br />';
290 }
291
292 ?>
293
294 <style>
295 input[type="text"], textarea, select {
296 width: 70%;
297 }
298
299 .form-table label{
300 font-weight:bold;
301 }
302
303 .exp{
304 font-size:12px;
305 }
306 </style>
307
308 <div id="" class="postbox">
309
310 <div class="postbox-header">
311 <h2 class="hndle ui-sortable-handle">
312 <span><?php echo __('Two Factor Authentication Settings', 'loginizer'); ?></span>
313 </h2>
314 </div>
315
316 <div class="inside">
317
318 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
319 <?php wp_nonce_field('loginizer-options'); ?>
320 <table class="form-table">
321 <tr>
322 <td scope="row" valign="top" colspan="2">
323 <i><?php echo __('Please choose from the following Two Factor Authentication methods. Each user can choose any one method from the ones enabled by you. You can enable all or anyone that you would like.', 'loginizer'); ?></i>
324 </td>
325 </tr>
326 <tr>
327 <td scope="row" valign="top" style="width:70% !important">
328 <label><?php echo __('OTP via App', 'loginizer'); ?></label><br>
329 <span class="exp"><?php echo __('After entering the correct login credentials, the user will be asked for the OTP. The OTP will be obtained from the users mobile app e.g. <b>Google Authenticator, Authy, etc.</b>', 'loginizer'); ?></span>
330 </td>
331 <td>
332 <input type="checkbox" value="1" name="2fa_app" <?php echo lz_POSTchecked('2fa_app', (empty($loginizer['2fa_app']) ? false : true), 'save_lz'); ?> />
333 </td>
334 </tr>
335 <tr>
336 <td scope="row" valign="top">
337 <label><?php echo __('OTP via Email', 'loginizer'); ?></label><br>
338 <span class="exp"><?php echo __('After entering the correct login credentials, the user will be asked for the OTP. The OTP will be emailed to the user.', 'loginizer'); ?></span>
339 </td>
340 <td>
341 <input type="checkbox" value="1" name="2fa_email" <?php echo lz_POSTchecked('2fa_email', (empty($loginizer['2fa_email']) ? false : true), 'save_lz'); ?> />
342 </td>
343 </tr>
344 <tr>
345 <td scope="row" valign="top">
346 <label><?php echo __('User Defined Question & Answer', 'loginizer'); ?></label><br>
347 <span class="exp"><?php echo __('In this method the user will be asked to set a secret personal question and answer. After entering the correct login credentials, the user will be asked to answer the question set by them, thus increasing the security', 'loginizer'); ?></span>
348 </td>
349 <td>
350 <input type="checkbox" value="1" name="question" <?php echo lz_POSTchecked('question', (empty($loginizer['question']) ? false : true), 'save_lz'); ?> />
351 </td>
352 </tr>
353 </table><br />
354
355 <table class="form-table">
356 <tr>
357 <td scope="row" valign="top" style="width:70% !important">
358 <label><?php echo __('Force OTP via Email', 'loginizer'); ?></label><br>
359 <span class="exp"><?php echo __('If the user does not have any 2FA method selected, this will enforce the OTP via Email for the users.', 'loginizer'); ?></span>
360 </td>
361 <td>
362 <input type="checkbox" value="1" name="2fa_email_force" <?php echo lz_POSTchecked('2fa_email_force', (empty($loginizer['2fa_email_force']) ? false : true), 'save_lz'); ?> />
363 </td>
364 </tr>
365 <tr>
366 <td scope="row" valign="top" style="width:70% !important">
367 <label><?php echo __('Apply 2FA to Roles', 'loginizer'); ?></label><br>
368 <span class="exp"><?php echo __('Select the Roles to which 2FA should be applied.', 'loginizer'); ?></span>
369 </td>
370 <td>
371 <input type="checkbox" value="1" onchange="lz_roles_handle()" name="2fa_roles_all" id="2fa_roles_all" <?php echo lz_POSTchecked('2fa_roles_all', (empty($loginizer['2fa_roles']) ? true : false), 'save_lz'); ?> /> All<br />
372 <?php
373
374 foreach($lz_roles as $k => $v){
375 echo '<span class="lz_roles"><input type="checkbox" value="1" name="2fa_roles_'.$k.'" '.lz_POSTchecked('2fa_roles_'.$k, (empty($loginizer['2fa_roles'][$k]) ? false : true), 'save_lz').' /> '.$v['name'].'<br /></span>';
376 }
377
378 ?>
379 </td>
380 </tr>
381 </table><br />
382 <center><input name="save_lz" class="button button-primary action" value="<?php echo __('Save Settings', 'loginizer'); ?>" type="submit" /></center>
383 </form>
384
385 </div>
386 </div>
387
388 <script type="text/javascript">
389
390 function lz_roles_handle(){
391
392 var obj = jQuery("#2fa_roles_all")[0];
393
394 if(obj.checked){
395 jQuery(".lz_roles").hide();
396 }else{
397 jQuery(".lz_roles").show();
398 }
399
400 }
401
402 lz_roles_handle();
403
404 </script>
405
406 <div id="" class="postbox">
407
408 <div class="postbox-header">
409 <h2 class="hndle ui-sortable-handle">
410 <span><?php echo __('OTP via Email Template', 'loginizer'); ?></span>
411 </h2>
412 </div>
413
414 <div class="inside">
415
416 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
417 <?php wp_nonce_field('loginizer-options'); ?>
418 <table class="form-table">
419 <tr>
420 <td colspan="2" valign="top">
421 <?php echo __('Customize the email template to be used when sending the OTP to login via Email for 2FA.', 'loginizer'); ?><br>
422 <?php echo __('If you do not make changes below the default email template will be used !', 'loginizer'); ?>
423 </td>
424 </tr>
425 <tr>
426 <td scope="row" valign="top" style="width:350px !important">
427 <label><?php echo __('Email Subject', 'loginizer'); ?></label><br>
428 <span class="exp"><?php echo __('Set blank to reset to the default subject', 'loginizer'); ?></span>
429 <br />Default : <?php echo (!empty($loginizer['2fa_email_d_sub']) ? $loginizer['2fa_email_d_sub'] : ''); ?>
430 </td>
431 <td valign="top">
432 <input type="text" size="40" value="<?php echo lz_htmlizer(!empty($_POST['lz_2fa_email_sub']) ? stripslashes($_POST['lz_2fa_email_sub']) : (empty($lz_options['2fa_email_sub']) ? '' : $lz_options['2fa_email_sub'])); ?>" name="lz_2fa_email_sub" />
433 </td>
434 </tr>
435 <tr>
436 <td scope="row" valign="top">
437 <label><?php echo __('Email Body', 'loginizer'); ?></label><br>
438 <span class="exp"><?php echo __('Set blank to reset to the default message', 'loginizer'); ?></span>
439 <br />Default : <pre style="font-size:10px"><?php echo (!empty($loginizer['2fa_email_d_msg']) ? $loginizer['2fa_email_d_msg'] : ''); ?></pre>
440 </td>
441 <td valign="top">
442 <textarea rows="10" name="lz_2fa_email_msg"><?php echo lz_htmlizer(!empty($_POST['lz_2fa_email_msg']) ? stripslashes($_POST['lz_2fa_email_msg']) : (empty($lz_options['2fa_email_msg']) ? '' : $lz_options['2fa_email_msg'])); ?></textarea>
443 <br />
444 Variables :
445 <br />$otp - The OTP for login
446 <br />$site_name - The Site Name
447 <br />$site_url - The Site URL
448 <br />$email - Users Email
449 <br />$display_name - Users Display Name
450 <br />$user_login - Username
451 <br />$first_name - Users First Name
452 <br />$last_name - Users Last Name
453 </td>
454 </tr>
455 </table><br />
456 <center><input name="save_2fa_email_template_lz" class="button button-primary action" value="<?php echo __('Save Settings', 'loginizer'); ?>" type="submit" /></center>
457 </form>
458
459 </div>
460 </div>
461
462 <div id="" class="postbox">
463
464 <div class="postbox-header">
465 <h2 class="hndle ui-sortable-handle">
466 <span><?php echo __('Custom Messages for OTP', 'loginizer'); ?></span>
467 </h2>
468 </div>
469
470 <div class="inside">
471
472 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
473 <?php wp_nonce_field('loginizer-options'); ?>
474 <table class="form-table">
475 <tr>
476 <td colspan="2" valign="top">
477 <?php echo __('Customize the title for OTP field displayed to the user on the login form.', 'loginizer'); ?><br>
478 <?php echo __('If you do not make changes below the default messages will be used !', 'loginizer'); ?>
479 </td>
480 </tr>
481 <tr>
482 <td scope="row" valign="top" style="width:350px !important">
483 <label for="msg_otp_app"><?php echo __('OTP via APP','loginizer'); ?></label><br />
484 <?php echo __('Default: <em>&quot;' . $loginizer['2fa_d_msg']['otp_app']. '&quot;</em>', 'loginizer'); ?>
485 </td>
486 <td>
487 <input type="text" size="50" value="<?php echo esc_attr(empty($saved_msgs['otp_app']) ? '' : $saved_msgs['otp_app']); ?>" name="msg_otp_app" id="msg_otp_app" style="width:auto !important;" />
488 <br />
489 </td>
490 </tr>
491 <tr>
492 <td scope="row" valign="top" style="width:350px !important">
493 <label for="msg_otp_email"><?php echo __('OTP via Email','loginizer'); ?></label><br />
494 <?php echo __('Default: <em>&quot;' . $loginizer['2fa_d_msg']['otp_email']. '&quot;</em>', 'loginizer'); ?>
495 </td>
496 <td>
497 <input type="text" size="50" value="<?php echo esc_attr(empty($saved_msgs['otp_email']) ? '' : $saved_msgs['otp_email']); ?>" name="msg_otp_email" id="msg_otp_email" style="width:auto !important;" />
498 <br />
499 </td>
500 </tr>
501 <tr>
502 <td scope="row" valign="top" style="width:350px !important">
503 <label for="msg_otp_field"><?php echo __('Title for OTP field','loginizer'); ?></label><br />
504 <?php echo __('Default: <em>&quot;' . $loginizer['2fa_d_msg']['otp_field']. '&quot;</em>', 'loginizer'); ?>
505 </td>
506 <td>
507 <input type="text" size="50" value="<?php echo esc_attr(empty($saved_msgs['otp_field']) ? '' : $saved_msgs['otp_field']); ?>" name="msg_otp_field" id="msg_otp_field" style="width:auto !important;" />
508 <br />
509 </td>
510 </tr>
511 <tr>
512 <td scope="row" valign="top" style="width:350px !important">
513 <label for="msg_otp_question"><?php echo __('Title for Security Question','loginizer'); ?></label><br />
514 <?php echo __('Default: <em>&quot;' . $loginizer['2fa_d_msg']['otp_question']. '&quot;</em>', 'loginizer'); ?>
515 </td>
516 <td>
517 <input type="text" size="50" value="<?php echo esc_attr(empty($saved_msgs['otp_question']) ? '' : $saved_msgs['otp_question']); ?>" name="msg_otp_question" id="msg_otp_question" style="width:auto !important;" />
518 <br />
519 </td>
520 </tr>
521 <tr>
522 <td scope="row" valign="top" style="width:350px !important">
523 <label for="msg_otp_answer"><?php echo __('Title for Security Answer','loginizer'); ?></label><br />
524 <?php echo __('Default: <em>&quot;' . $loginizer['2fa_d_msg']['otp_answer']. '&quot;</em>', 'loginizer'); ?>
525 </td>
526 <td>
527 <input type="text" size="50" value="<?php echo esc_attr(empty($saved_msgs['otp_answer']) ? '' : $saved_msgs['otp_answer']); ?>" name="msg_otp_answer" id="msg_otp_answer" style="width:auto !important;" />
528 <br />
529 </td>
530 </tr>
531 </table><br />
532 <center><input name="save_msgs_lz" class="button button-primary action" value="<?php echo __('Save Messages','loginizer'); ?>" type="submit" /></center>
533 </form>
534 </div>
535 </div>
536
537 <!--Bypass a single user-->
538 <div id="" class="postbox">
539
540 <div class="postbox-header">
541 <h2 class="hndle ui-sortable-handle">
542 <span><?php echo __('Disable Two Factor Authentication for a User', 'loginizer'); ?></span>
543 </h2>
544 </div>
545
546 <div class="inside">
547
548 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
549 <?php wp_nonce_field('loginizer-options'); ?>
550 <table class="form-table">
551 <tr>
552 <td scope="row" valign="top" colspan="2">
553 <i><?php echo __('Here you can disable the Two Factor Authentication settings of a user. In the event a user has forgotten his secret answer or lost his Device App, he will not be able to login. You can reset such a users settings from here.', 'loginizer'); ?></i>
554 </td>
555 </tr>
556 <tr>
557 <td scope="row" valign="top">
558 <label><?php echo __('Username / Email', 'loginizer'); ?></label><br>
559 <span class="exp"><?php echo __('The username or email of the user whose 2FA you would like to disable', 'loginizer'); ?></span>
560 </td>
561 <td>
562 <input type="text" size="50" value="<?php echo lz_optpost('lz_user_2fa_disable', ''); ?>" name="lz_user_2fa_disable" />
563 </td>
564 </tr>
565 </table><br />
566
567 <center><input name="reset_user_lz" class="button button-primary action" value="<?php echo __('Reset 2FA for User', 'loginizer'); ?>" type="submit" /></center>
568 </form>
569
570 </div>
571 </div>
572
573 <br />
574
575 <?php
576
577 wp_enqueue_script('jquery-paginate', LOGINIZER_URL.'/assets/js/jquery-paginate.js', array('jquery'), '1.10.15');
578
579 ?>
580
581 <style>
582 .page-navigation a {
583 margin: 5px 2px;
584 display: inline-block;
585 padding: 5px 8px;
586 color: #0073aa;
587 background: #e5e5e5 none repeat scroll 0 0;
588 border: 1px solid #ccc;
589 text-decoration: none;
590 transition-duration: 0.05s;
591 transition-property: border, background, color;
592 transition-timing-function: ease-in-out;
593 }
594
595 .page-navigation a[data-selected] {
596 background-color: #00a0d2;
597 color: #fff;
598 }
599 </style>
600
601 <script>
602
603 jQuery(document).ready(function(){
604 jQuery('#lz_wl_2fa_table').paginate({ limit: 11, navigationWrapper: jQuery('#lz_wl_2fa_nav')});
605 });
606
607 // Delete a 2FA Whitelist IP Range
608 function del_2fa_confirm(field, todo_id, msg){
609 var ret = confirm(msg);
610
611 if(ret){
612 jQuery('#lz_wl_2fa_todo').attr('name', field);
613 jQuery('#lz_wl_2fa_todo').val(todo_id);
614 jQuery('#lz_wl_2fa_form').submit();
615 }
616
617 return false;
618
619 }
620
621 // Delete all 2FA Whitelist IP Ranges
622 function del_2fa_confirm_all(msg){
623 var ret = confirm(msg);
624
625 if(ret){
626 return true;
627 }
628
629 return false;
630
631 }
632
633 </script>
634
635 <div id="" class="postbox">
636
637 <div class="postbox-header">
638 <h2 class="hndle ui-sortable-handle">
639 <span><?php echo __('Disable Two Factor Authentication for IP', 'loginizer'); ?></span>
640 </h2>
641 </div>
642
643 <div class="inside">
644
645 <?php echo __('Enter the IP you want to whitelist for two factor authentication', 'loginizer'); ?>
646 <form action="" method="post" loginizer-premium-only="1">
647 <?php wp_nonce_field('loginizer-options'); ?>
648 <table class="form-table">
649 <tr>
650 <th scope="row" valign="top"><label for="start_ip_w_2fa"><?php echo __('Start IP','loginizer'); ?></label></th>
651 <td>
652 <input type="text" size="25" style="width:auto;" value="<?php echo(lz_optpost('start_ip_w_2fa')); ?>" name="start_ip_w_2fa" id="start_ip_w_2fa"/> <?php echo __('Start IP of the range','loginizer'); ?> <br />
653 </td>
654 </tr>
655 <tr>
656 <th scope="row" valign="top"><label for="end_ip_w_2fa"><?php echo __('End IP (Optional)','loginizer'); ?></label></th>
657 <td>
658 <input type="text" size="25" style="width:auto;" value="<?php echo(lz_optpost('end_ip_w_2fa')); ?>" name="end_ip_w_2fa" id="end_ip_w_2fa"/> <?php echo __('End IP of the range. <br />If you want to whitelist single IP leave this field blank.','loginizer'); ?> <br />
659 </td>
660 </tr>
661 </table><br />
662 <input name="2fa_whitelist_iprange" class="button button-primary action" value="<?php echo __('Add Whitelist IP Range','loginizer'); ?>" type="submit" />
663 <input style="float:right" name="del_all_whitelist" onclick="return del_2fa_confirm_all('<?php echo __('Are you sure you want to delete all Whitelist IP Range(s) for 2FA ?','loginizer'); ?>')" class="button action" value="<?php echo __('Delete All Whitelist IP Range(s) for 2FA','loginizer'); ?>" type="submit" />
664 </form>
665 </div>
666
667 <div id="lz_wl_2fa_nav" style="margin: 5px 10px; text-align:right"></div>
668 <table id="lz_wl_2fa_table" class="wp-list-table fixed striped users" border="0" width="95%" cellpadding="10" align="center">
669 <tr>
670 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Start IP','loginizer'); ?></th>
671 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('End IP','loginizer'); ?></th>
672 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Date (DD/MM/YYYY)','loginizer'); ?></th>
673 <th scope="row" valign="top" style="background:#EFEFEF;" width="100"><?php echo __('Options','loginizer'); ?></th>
674 </tr>
675 <?php
676 if(empty($loginizer['2fa_whitelist'])){
677 echo '
678 <tr>
679 <td colspan="4">
680 '.__('No Whitelist IPs for Two Factor Authentication. You will see whitelisted IP ranges here.', 'loginizer').'
681 </td>
682 </tr>';
683 }else{
684 foreach($loginizer['2fa_whitelist'] as $ik => $iv){
685 echo '
686 <tr>
687 <td>
688 '.$iv['start'].'
689 </td>
690 <td>
691 '.$iv['end'].'
692 </td>
693 <td>
694 '.date('d/m/Y', $iv['time']).'
695 </td>
696 <td>
697 <a class="submitdelete" href="javascript:void(0)" onclick="return del_2fa_confirm(\'delid\', '.$ik.', \'Are you sure you want to delete this IP range for 2FA ?\')">Delete</a>
698 </td>
699 </tr>';
700 }
701 }
702 ?>
703 </table>
704 <br />
705 <form action="" method="post" id="lz_wl_2fa_form">
706 <?php wp_nonce_field('loginizer-options'); ?>
707 <input type="hidden" value="" name="" id="lz_wl_2fa_todo"/>
708 </form>
709 <br />
710
711 </div>
712
713 <!--Custom Redirects based on role-->
714 <div id="" class="postbox">
715
716 <div class="postbox-header">
717 <h2 class="hndle ui-sortable-handle">
718 <span><?php echo __('Custom Redirects based on roles', 'loginizer'); ?></span>
719 </h2>
720 </div>
721
722 <div class="inside">
723
724 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
725 <?php wp_nonce_field('loginizer-options'); ?>
726 <table class="form-table">
727 <tr>
728 <td scope="row" valign="top" colspan="2">
729 <i><?php echo __('Here you can set the URL, which you wish your user to get redirected to after login via 2FA.', 'loginizer'); ?></i>
730 </td>
731 </tr>
732 <?php
733 global $wp_roles;
734
735 foreach($wp_roles->roles as $key => $role){
736 echo'<tr>
737 <td scope="row" valign="top">
738 <label>'. esc_html($role['name']).'</label><br>
739 </td>
740 <td>
741 <input type="text" size="50" value="'.(!empty($loginizer['2fa_custom_login_redirect']) && !empty($loginizer['2fa_custom_login_redirect'][$key]) ? esc_attr($loginizer['2fa_custom_login_redirect'][$key]) : '').'" placeholder="'.site_url().'" name="lz_2fa_custom_login_redirect['.esc_html($key).']" />
742 </td>
743 </tr>';
744 }
745 ?>
746
747 </table><br />
748
749 <center><input name="save_2fa_custom_redirect" class="button button-primary action" value="<?php echo __('Save Custom URLs', 'loginizer'); ?>" type="submit" /></center>
750 </form>
751
752 </div>
753 </div>
754
755 <?php
756 loginizer_page_footer();
757
758 }