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 / 2fa.php

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

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