PluginProbe
Loginizer / 2.0.7
Loginizer v2.0.7
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.7, at main/settings/2fa.php

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