PluginProbe
Loginizer / 1.6.3
Loginizer v1.6.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 / init.php

init.php in Loginizer 1.6.3, at init.php

4,728 lines 157.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if(!function_exists('add_action')){
4 echo 'You are not allowed to access this page directly.';
5 exit;
6 }
7
8 define('LOGINIZER_VERSION', '1.6.3');
9 define('LOGINIZER_DIR', dirname(LOGINIZER_FILE));
10 define('LOGINIZER_URL', plugins_url('', LOGINIZER_FILE));
11 define('LOGINIZER_PRO_URL', 'https://loginizer.com/features#compare');
12 define('LOGINIZER_PRICING_URL', 'https://loginizer.com/pricing');
13 define('LOGINIZER_DOCS', 'https://loginizer.com/docs/');
14
15 include_once(LOGINIZER_DIR.'/functions.php');
16
17 // Ok so we are now ready to go
18 register_activation_hook(LOGINIZER_FILE, 'loginizer_activation');
19
20 // Is called when the ADMIN enables the plugin
21 function loginizer_activation(){
22
23 global $wpdb;
24
25 $sql = array();
26
27 $sql[] = "DROP TABLE IF EXISTS `".$wpdb->prefix."loginizer_logs`";
28
29 $sql[] = "CREATE TABLE `".$wpdb->prefix."loginizer_logs` (
30 `username` varchar(255) NOT NULL DEFAULT '',
31 `time` int(10) NOT NULL DEFAULT '0',
32 `count` int(10) NOT NULL DEFAULT '0',
33 `lockout` int(10) NOT NULL DEFAULT '0',
34 `ip` varchar(255) NOT NULL DEFAULT '',
35 `url` varchar(255) NOT NULL DEFAULT '',
36 UNIQUE KEY `ip` (`ip`)
37 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
38
39 foreach($sql as $sk => $sv){
40 $wpdb->query($sv);
41 }
42
43 add_option('loginizer_version', LOGINIZER_VERSION);
44 add_option('loginizer_options', array());
45 add_option('loginizer_last_reset', 0);
46 add_option('loginizer_whitelist', array());
47 add_option('loginizer_blacklist', array());
48 add_option('loginizer_2fa_whitelist', array());
49
50 }
51
52 /**
53 * Updates the database structure for Loginizer
54 *
55 * If the plugin files are updated but database structure is not updated
56 * this function will update the database structure as per the plugin version
57 * NOTE: This does not update plugin files it just updates the database structure
58 */
59 function loginizer_update_check(){
60
61 global $wpdb;
62
63 $sql = array();
64 $current_version = get_option('loginizer_version');
65
66 // It must be the 1.0 pre stuff
67 if(empty($current_version)){
68 $current_version = get_option('lz_version');
69 }
70
71 $version = (int) str_replace('.', '', $current_version);
72
73 // No update required
74 if($current_version == LOGINIZER_VERSION){
75 return true;
76 }
77
78 // Is it first run ?
79 if(empty($current_version)){
80
81 // Reinstall
82 loginizer_activation();
83
84 // Trick the following if conditions to not run
85 $version = (int) str_replace('.', '', LOGINIZER_VERSION);
86
87 }
88
89 // Is it less than 1.0.1 ?
90 if($version < 101){
91
92 // TODO : GET the existing settings
93
94 // Get the existing settings
95 $lz_failed_logs = lz_selectquery("SELECT * FROM `".$wpdb->prefix."lz_failed_logs`;", 1);
96 $lz_options = lz_selectquery("SELECT * FROM `".$wpdb->prefix."lz_options`;", 1);
97 $lz_iprange = lz_selectquery("SELECT * FROM `".$wpdb->prefix."lz_iprange`;", 1);
98
99 // Delete the three tables
100 $sql = array();
101 $sql[] = "DROP TABLE IF EXISTS ".$wpdb->prefix."lz_failed_logs;";
102 $sql[] = "DROP TABLE IF EXISTS ".$wpdb->prefix."lz_options;";
103 $sql[] = "DROP TABLE IF EXISTS ".$wpdb->prefix."lz_iprange;";
104
105 foreach($sql as $sk => $sv){
106 $wpdb->query($sv);
107 }
108
109 // Delete option
110 delete_option('lz_version');
111
112 // Reinstall
113 loginizer_activation();
114
115 // TODO : Save the existing settings
116
117 // Update the existing failed logs to new table
118 if(is_array($lz_failed_logs)){
119 foreach($lz_failed_logs as $fk => $fv){
120 $wpdb->query("INSERT INTO ".$wpdb->prefix."loginizer_logs SET `username` = '".$fv['username']."', `time` = '".$fv['time']."', `count` = '".$fv['count']."', `lockout` = '".$fv['lockout']."', `ip` = '".$fv['ip']."';");
121 }
122 }
123
124 // Update the existing options to new structure
125 if(is_array($lz_options)){
126 foreach($lz_options as $ok => $ov){
127
128 if($ov['option_name'] == 'lz_last_reset'){
129 update_option('loginizer_last_reset', $ov['option_value']);
130 continue;
131 }
132
133 $old_option[str_replace('lz_', '', $ov['option_name'])] = $ov['option_value'];
134 }
135 // Save the options
136 update_option('loginizer_options', $old_option);
137 }
138
139 // Update the existing iprange to new structure
140 if(is_array($lz_iprange)){
141
142 $old_blacklist = array();
143 $old_whitelist = array();
144 $bid = 1;
145 $wid = 1;
146 foreach($lz_iprange as $ik => $iv){
147
148 if(!empty($iv['blacklist'])){
149 $old_blacklist[$bid] = array();
150 $old_blacklist[$bid]['start'] = long2ip($iv['start']);
151 $old_blacklist[$bid]['end'] = long2ip($iv['end']);
152 $old_blacklist[$bid]['time'] = strtotime($iv['date']);
153 $bid = $bid + 1;
154 }
155
156 if(!empty($iv['whitelist'])){
157 $old_whitelist[$wid] = array();
158 $old_whitelist[$wid]['start'] = long2ip($iv['start']);
159 $old_whitelist[$wid]['end'] = long2ip($iv['end']);
160 $old_whitelist[$wid]['time'] = strtotime($iv['date']);
161 $wid = $wid + 1;
162 }
163 }
164
165 if(!empty($old_blacklist)) update_option('loginizer_blacklist', $old_blacklist);
166 if(!empty($old_whitelist)) update_option('loginizer_whitelist', $old_whitelist);
167 }
168
169 }
170
171 // Is it less than 1.3.9 ?
172 if($version < 139){
173
174 $wpdb->query("ALTER TABLE ".$wpdb->prefix."loginizer_logs ADD `url` VARCHAR(255) NOT NULL DEFAULT '' AFTER `ip`;");
175
176 }
177
178 // Save the new Version
179 update_option('loginizer_version', LOGINIZER_VERSION);
180
181 // In Sitepad Math Captcha is enabled by default
182 if(defined('SITEPAD') && get_option('loginizer_captcha') === false){
183 $option['captcha_no_google'] = 1;
184 add_option('loginizer_captcha', $option);
185 }
186
187 }
188
189 // Add the action to load the plugin
190 add_action('plugins_loaded', 'loginizer_load_plugin');
191
192 // The function that will be called when the plugin is loaded
193 function loginizer_load_plugin(){
194
195 global $loginizer;
196
197 // Check if the installed version is outdated
198 loginizer_update_check();
199
200 // Set the array
201 $loginizer = array();
202
203 $loginizer['prefix'] = !defined('SITEPAD') ? 'Loginizer ' : 'SitePad ';
204 $loginizer['app'] = !defined('SITEPAD') ? 'WordPress' : 'SitePad';
205 $loginizer['login_basename'] = !defined('SITEPAD') ? 'wp-login.php' : 'login.php';
206 $loginizer['wp-includes'] = !defined('SITEPAD') ? 'wp-includes' : 'site-inc';
207
208 // The IP Method to use
209 $loginizer['ip_method'] = get_option('loginizer_ip_method');
210 if($loginizer['ip_method'] == 3){
211 $loginizer['custom_ip_method'] = get_option('loginizer_custom_ip_method');
212 }
213
214 // Load settings
215 $options = get_option('loginizer_options');
216 $loginizer['max_retries'] = empty($options['max_retries']) ? 3 : $options['max_retries'];
217 $loginizer['lockout_time'] = empty($options['lockout_time']) ? 900 : $options['lockout_time']; // 15 minutes
218 $loginizer['max_lockouts'] = empty($options['max_lockouts']) ? 5 : $options['max_lockouts'];
219 $loginizer['lockouts_extend'] = empty($options['lockouts_extend']) ? 86400 : $options['lockouts_extend']; // 24 hours
220 $loginizer['reset_retries'] = empty($options['reset_retries']) ? 86400 : $options['reset_retries']; // 24 hours
221 $loginizer['notify_email'] = empty($options['notify_email']) ? 0 : $options['notify_email'];
222
223 // Default messages
224 $loginizer['d_msg']['inv_userpass'] = __('Incorrect Username or Password', 'loginizer');
225 $loginizer['d_msg']['ip_blacklisted'] = __('Your IP has been blacklisted', 'loginizer');
226 $loginizer['d_msg']['attempts_left'] = __('attempt(s) left', 'loginizer');
227 $loginizer['d_msg']['lockout_err'] = __('You have exceeded maximum login retries<br /> Please try after', 'loginizer');
228 $loginizer['d_msg']['minutes_err'] = __('minute(s)', 'loginizer');
229 $loginizer['d_msg']['hours_err'] = __('hour(s)', 'loginizer');
230
231 // Message Strings
232 $loginizer['msg'] = get_option('loginizer_msg');
233
234 foreach($loginizer['d_msg'] as $lk => $lv){
235 if(empty($loginizer['msg'][$lk])){
236 $loginizer['msg'][$lk] = $loginizer['d_msg'][$lk];
237 }
238 }
239
240 $loginizer['2fa_d_msg']['otp_app'] = __('Please enter the OTP as seen in your App', 'loginizer');
241 $loginizer['2fa_d_msg']['otp_email'] = __('Please enter the OTP emailed to you', 'loginizer');
242 $loginizer['2fa_d_msg']['otp_field'] = __('One Time Password', 'loginizer');
243 $loginizer['2fa_d_msg']['otp_question'] = __('Please answer your security question', 'loginizer');
244 $loginizer['2fa_d_msg']['otp_answer'] = __('Your Answer', 'loginizer');
245
246 // Message Strings
247 $loginizer['2fa_msg'] = get_option('loginizer_2fa_msg');
248
249 foreach($loginizer['2fa_d_msg'] as $lk => $lv){
250 if(empty($loginizer['2fa_msg'][$lk])){
251 $loginizer['2fa_msg'][$lk] = $loginizer['2fa_d_msg'][$lk];
252 }
253 }
254
255 // Load the blacklist and whitelist
256 $loginizer['blacklist'] = get_option('loginizer_blacklist');
257 $loginizer['whitelist'] = get_option('loginizer_whitelist');
258 $loginizer['2fa_whitelist'] = get_option('loginizer_2fa_whitelist');
259
260 // It should not be false
261 if(empty($loginizer['2fa_whitelist'])){
262 $loginizer['2fa_whitelist'] = array();
263 }
264
265 // When was the database cleared last time
266 $loginizer['last_reset'] = get_option('loginizer_last_reset');
267
268 //print_r($loginizer);
269
270 // Clear retries
271 if((time() - $loginizer['last_reset']) >= $loginizer['reset_retries']){
272 loginizer_reset_retries();
273 }
274
275 $ins_time = get_option('loginizer_ins_time');
276 if(empty($ins_time)){
277 $ins_time = time();
278 update_option('loginizer_ins_time', $ins_time);
279 }
280 $loginizer['ins_time'] = $ins_time;
281
282 // Set the current IP
283 $loginizer['current_ip'] = lz_getip();
284
285 // Is Brute Force Disabled ?
286 $loginizer['disable_brute'] = get_option('loginizer_disable_brute');
287
288 // Filters and actions
289 if(empty($loginizer['disable_brute'])){
290
291 // Use this to verify before WP tries to login
292 // Is always called and is the first function to be called
293 //add_action('wp_authenticate', 'loginizer_wp_authenticate', 10, 2);// Not called by XML-RPC
294 add_filter('authenticate', 'loginizer_wp_authenticate', 10001, 3);// This one is called by xmlrpc as well as GUI
295
296 // Is called when a login attempt fails
297 // Hence Update our records that the login failed
298 add_action('wp_login_failed', 'loginizer_login_failed');
299
300 // Is called before displaying the error message so that we dont show that the username is wrong or the password
301 // Update Error message
302 add_action('wp_login_errors', 'loginizer_error_handler', 10001, 2);
303 add_action('woocommerce_login_failed', 'loginizer_woocommerce_error_handler', 10001);
304
305 }
306
307 // ----------------
308 // PRO INIT
309 // ----------------
310
311 // Email to Login
312 $options = get_option('loginizer_epl');
313 $loginizer['pl_d_sub'] = 'Login at $site_name';
314 $loginizer['pl_d_msg'] = 'Hi,
315
316 A login request was submitted for your account $email at :
317 $site_name - $site_url
318
319 Login at $site_name by visiting this url :
320 $login_url
321
322 If you have not requested for the Login URL, please ignore this email.
323
324 Regards,
325 $site_name';
326 $loginizer['email_pass_less'] = empty($options['email_pass_less']) ? 0 : $options['email_pass_less'];
327 $loginizer['passwordless_sub'] = empty($options['passwordless_sub']) ? $loginizer['pl_d_sub'] : $options['passwordless_sub'];
328 $loginizer['passwordless_msg'] = empty($options['passwordless_msg']) ? $loginizer['pl_d_msg'] : $options['passwordless_msg'];
329 $loginizer['passwordless_msg_is_custom'] = empty($options['passwordless_msg']) ? 0 : 1;
330 $loginizer['passwordless_html'] = empty($options['passwordless_html']) ? 0 : $options['passwordless_html'];
331
332 // 2FA OTP Email to Login
333 $options = get_option('loginizer_2fa_email_template');
334 $loginizer['2fa_email_d_sub'] = 'OTP : Login at $site_name';
335 $loginizer['2fa_email_d_msg'] = 'Hi,
336
337 A login request was submitted for your account $email at :
338 $site_name - $site_url
339
340 Please use the following One Time password (OTP) to login :
341 $otp
342
343 Note : The OTP expires after 10 minutes.
344
345 If you haven\'t requested for the OTP, please ignore this email.
346
347 Regards,
348 $site_name';
349
350 $loginizer['2fa_email_sub'] = empty($options['2fa_email_sub']) ? $loginizer['2fa_email_d_sub'] : $options['2fa_email_sub'];
351 $loginizer['2fa_email_msg'] = empty($options['2fa_email_msg']) ? $loginizer['2fa_email_d_msg'] : $options['2fa_email_msg'];
352
353 // For SitePad its always on
354 if(defined('SITEPAD')){
355 $loginizer['email_pass_less'] = 1;
356 }
357
358 // Captcha
359 $options = get_option('loginizer_captcha');
360 $loginizer['captcha_type'] = empty($options['captcha_type']) ? '' : $options['captcha_type'];
361 $loginizer['captcha_key'] = empty($options['captcha_key']) ? '' : $options['captcha_key'];
362 $loginizer['captcha_secret'] = empty($options['captcha_secret']) ? '' : $options['captcha_secret'];
363 $loginizer['captcha_theme'] = empty($options['captcha_theme']) ? 'light' : $options['captcha_theme'];
364 $loginizer['captcha_size'] = empty($options['captcha_size']) ? 'normal' : $options['captcha_size'];
365 $loginizer['captcha_lang'] = empty($options['captcha_lang']) ? '' : $options['captcha_lang'];
366 $loginizer['captcha_user_hide'] = !isset($options['captcha_user_hide']) ? 0 : $options['captcha_user_hide'];
367 $loginizer['captcha_no_css_login'] = !isset($options['captcha_no_css_login']) ? 0 : $options['captcha_no_css_login'];
368 $loginizer['captcha_no_js'] = 1;
369 $loginizer['captcha_login'] = !isset($options['captcha_login']) ? 1 : $options['captcha_login'];
370 $loginizer['captcha_lostpass'] = !isset($options['captcha_lostpass']) ? 1 : $options['captcha_lostpass'];
371 $loginizer['captcha_resetpass'] = !isset($options['captcha_resetpass']) ? 1 : $options['captcha_resetpass'];
372 $loginizer['captcha_register'] = !isset($options['captcha_register']) ? 1 : $options['captcha_register'];
373 $loginizer['captcha_comment'] = !isset($options['captcha_comment']) ? 1 : $options['captcha_comment'];
374 $loginizer['captcha_wc_checkout'] = !isset($options['captcha_wc_checkout']) ? 1 : $options['captcha_wc_checkout'];
375
376 $loginizer['captcha_no_google'] = !isset($options['captcha_no_google']) ? 0 : $options['captcha_no_google'];
377 $loginizer['captcha_text'] = empty($options['captcha_text']) ? __('Math Captcha', 'loginizer') : $options['captcha_text'];
378 $loginizer['captcha_time'] = empty($options['captcha_time']) ? 300 : $options['captcha_time'];
379 $loginizer['captcha_words'] = !isset($options['captcha_words']) ? 0 : $options['captcha_words'];
380 $loginizer['captcha_add'] = !isset($options['captcha_add']) ? 1 : $options['captcha_add'];
381 $loginizer['captcha_subtract'] = !isset($options['captcha_subtract']) ? 1 : $options['captcha_subtract'];
382 $loginizer['captcha_multiply'] = !isset($options['captcha_multiply']) ? 0 : $options['captcha_multiply'];
383 $loginizer['captcha_divide'] = !isset($options['captcha_divide']) ? 0 : $options['captcha_divide'];
384
385 // 2fa/question
386 $options = get_option('loginizer_2fa');
387 $loginizer['2fa_app'] = !isset($options['2fa_app']) ? 0 : $options['2fa_app'];
388 $loginizer['2fa_email'] = !isset($options['2fa_email']) ? 0 : $options['2fa_email'];
389 $loginizer['2fa_email_force'] = !isset($options['2fa_email_force']) ? 0 : $options['2fa_email_force'];
390 $loginizer['2fa_sms'] = !isset($options['2fa_sms']) ? 0 : $options['2fa_sms'];
391 $loginizer['question'] = !isset($options['question']) ? 0 : $options['question'];
392 $loginizer['2fa_default'] = empty($options['2fa_default']) ? 'question' : $options['2fa_default'];
393 $loginizer['2fa_roles'] = empty($options['2fa_roles']) ? array() : $options['2fa_roles'];
394
395 // Security Settings
396 $options = get_option('loginizer_security');
397 $loginizer['login_slug'] = empty($options['login_slug']) ? '' : $options['login_slug'];
398 $loginizer['rename_login_secret'] = empty($options['rename_login_secret']) ? '' : $options['rename_login_secret'];
399 $loginizer['xmlrpc_slug'] = empty($options['xmlrpc_slug']) ? '' : $options['xmlrpc_slug'];
400 $loginizer['xmlrpc_disable'] = empty($options['xmlrpc_disable']) ? '' : $options['xmlrpc_disable'];// Disable XML-RPC
401 $loginizer['pingbacks_disable'] = empty($options['pingbacks_disable']) ? '' : $options['pingbacks_disable'];// Disable Pingbacks
402
403 // Admin Slug Settings
404 $options = get_option('loginizer_wp_admin');
405 $loginizer['admin_slug'] = empty($options['admin_slug']) ? '' : $options['admin_slug'];
406 $loginizer['restrict_wp_admin'] = empty($options['restrict_wp_admin']) ? '' : $options['restrict_wp_admin'];
407 $loginizer['wp_admin_msg'] = empty($options['wp_admin_msg']) ? '' : $options['wp_admin_msg'];
408
409 // Checksum Settings
410 $options = get_option('loginizer_checksums');
411 $loginizer['disable_checksum'] = empty($options['disable_checksum']) ? '' : $options['disable_checksum'];
412 $loginizer['checksum_time'] = empty($options['checksum_time']) ? '' : $options['checksum_time'];
413 $loginizer['checksum_frequency'] = empty($options['checksum_frequency']) ? 7 : $options['checksum_frequency'];
414 $loginizer['no_checksum_email'] = empty($options['no_checksum_email']) ? '' : $options['no_checksum_email'];
415 $loginizer['checksums_last_run'] = get_option('loginizer_checksums_last_run');
416
417 // Auto Blacklist Usernames
418 $loginizer['username_blacklist'] = get_option('loginizer_username_blacklist');
419
420 $loginizer['domains_blacklist'] = get_option('loginizer_domains_blacklist');
421
422 $loginizer['wp_admin_d_msg'] = __('LZ : Not allowed via WP-ADMIN. Please access over the new Admin URL', 'loginizer');
423
424 // ----------------
425 // PRO INIT END
426 // ----------------
427
428 // Is the premium features there ?
429 if(file_exists(LOGINIZER_DIR.'/premium.php')){
430
431 // Include the file
432 include_once(LOGINIZER_DIR.'/premium.php');
433
434 loginizer_security_init();
435
436 // Its the free version
437 }else{
438
439 // The promo time
440 $loginizer['promo_time'] = get_option('loginizer_promo_time');
441 if(empty($loginizer['promo_time'])){
442 $loginizer['promo_time'] = time();
443 update_option('loginizer_promo_time', $loginizer['promo_time']);
444 }
445
446 // Are we to show the loginizer promo
447 if(!empty($loginizer['promo_time']) && $loginizer['promo_time'] > 0 && $loginizer['promo_time'] < (time() - (30*24*3600))){
448
449 add_action('admin_notices', 'loginizer_promo');
450
451 }
452
453 // Are we to disable the promo
454 if(isset($_GET['loginizer_promo']) && (int)$_GET['loginizer_promo'] == 0){
455 update_option('loginizer_promo_time', (0 - time()) );
456 die('DONE');
457 }
458
459 }
460
461 }
462
463 // Show the promo
464 function loginizer_promo(){
465
466 echo '
467 <style>
468 .lz_button {
469 background-color: #4CAF50; /* Green */
470 border: none;
471 color: white;
472 padding: 8px 16px;
473 text-align: center;
474 text-decoration: none;
475 display: inline-block;
476 font-size: 16px;
477 margin: 4px 2px;
478 -webkit-transition-duration: 0.4s; /* Safari */
479 transition-duration: 0.4s;
480 cursor: pointer;
481 }
482
483 .lz_button:focus{
484 border: none;
485 color: white;
486 }
487
488 .lz_button1 {
489 color: white;
490 background-color: #4CAF50;
491 border:3px solid #4CAF50;
492 }
493
494 .lz_button1:hover {
495 box-shadow: 0 6px 8px 0 rgba(0,0,0,0.24), 0 9px 25px 0 rgba(0,0,0,0.19);
496 color: white;
497 border:3px solid #4CAF50;
498 }
499
500 .lz_button2 {
501 color: white;
502 background-color: #0085ba;
503 }
504
505 .lz_button2:hover {
506 box-shadow: 0 6px 8px 0 rgba(0,0,0,0.24), 0 9px 25px 0 rgba(0,0,0,0.19);
507 color: white;
508 }
509
510 .lz_button3 {
511 color: white;
512 background-color: #365899;
513 }
514
515 .lz_button3:hover {
516 box-shadow: 0 6px 8px 0 rgba(0,0,0,0.24), 0 9px 25px 0 rgba(0,0,0,0.19);
517 color: white;
518 }
519
520 .lz_button4 {
521 color: white;
522 background-color: rgb(66, 184, 221);
523 }
524
525 .lz_button4:hover {
526 box-shadow: 0 6px 8px 0 rgba(0,0,0,0.24), 0 9px 25px 0 rgba(0,0,0,0.19);
527 color: white;
528 }
529
530 .loginizer_promo-close{
531 float:right;
532 text-decoration:none;
533 margin: 5px 10px 0px 0px;
534 }
535
536 .loginizer_promo-close:hover{
537 color: red;
538 }
539 </style>
540
541 <script>
542 jQuery(document).ready( function() {
543 (function($) {
544 $("#loginizer_promo .loginizer_promo-close").click(function(){
545 var data;
546
547 // Hide it
548 $("#loginizer_promo").hide();
549
550 // Save this preference
551 $.post("'.admin_url('?loginizer_promo=0').'", data, function(response) {
552 //alert(response);
553 });
554 });
555 })(jQuery);
556 });
557 </script>
558
559 <div class="notice notice-success" id="loginizer_promo" style="min-height:120px">
560 <a class="loginizer_promo-close" href="javascript:" aria-label="Dismiss this Notice">
561 <span class="dashicons dashicons-dismiss"></span> Dismiss
562 </a>
563 <img src="'.LOGINIZER_URL.'/loginizer-200.png" style="float:left; margin:10px 20px 10px 10px" width="100" />
564 <p style="font-size:16px">We are glad you like Loginizer and have been using it since the past few days. It is time to take the next step </p>
565 <p>
566 <a class="lz_button lz_button1" target="_blank" href="https://loginizer.com/features">Upgrade to Pro</a>
567 <a class="lz_button lz_button2" target="_blank" href="https://wordpress.org/support/view/plugin-reviews/loginizer">Rate it 5�
568 \'s</a>
569 <a class="lz_button lz_button3" target="_blank" href="https://www.facebook.com/Loginizer-815504798591884/">Like Us on Facebook</a>
570 <a class="lz_button lz_button4" target="_blank" href="https://twitter.com/home?status='.rawurlencode('I use @loginizer to secure my #WordPress site - https://loginizer.com').'">Tweet about Loginizer</a>
571 </p>
572 </div>';
573
574 }
575
576 // Should return NULL if everything is fine
577 function loginizer_wp_authenticate($user, $username, $password){
578
579 global $loginizer, $lz_error, $lz_cannot_login, $lz_user_pass;
580
581 if(!empty($username) && !empty($password)){
582 $lz_user_pass = 1;
583 }
584
585 // Are you whitelisted ?
586 if(loginizer_is_whitelisted()){
587 $loginizer['ip_is_whitelisted'] = 1;
588 return $user;
589 }
590
591 // Are you blacklisted ?
592 if(loginizer_is_blacklisted()){
593 $lz_cannot_login = 1;
594 return new WP_Error('ip_blacklisted', implode('', $lz_error), 'loginizer');
595 }
596
597 // Is the username blacklisted ?
598 if(function_exists('loginizer_user_blacklisted')){
599 if(loginizer_user_blacklisted($username)){
600 $lz_cannot_login = 1;
601 return new WP_Error('user_blacklisted', implode('', $lz_error), 'loginizer');
602 }
603 }
604
605 if(loginizer_can_login()){
606 return $user;
607 }
608
609 $lz_cannot_login = 1;
610
611 return new WP_Error('ip_blocked', implode('', $lz_error), 'loginizer');
612
613 }
614
615 function loginizer_can_login(){
616
617 global $wpdb, $loginizer, $lz_error;
618
619 // Get the logs
620 $result = lz_selectquery("SELECT * FROM `".$wpdb->prefix."loginizer_logs` WHERE `ip` = '".$loginizer['current_ip']."';");
621
622 if(!empty($result['count']) && ($result['count'] % $loginizer['max_retries']) == 0){
623
624 // Has he reached max lockouts ?
625 if($result['lockout'] >= $loginizer['max_lockouts']){
626 $loginizer['lockout_time'] = $loginizer['lockouts_extend'];
627 }
628
629 // Is he in the lockout time ?
630 if($result['time'] >= (time() - $loginizer['lockout_time'])){
631 $banlift = ceil((($result['time'] + $loginizer['lockout_time']) - time()) / 60);
632
633 //echo 'Current Time '.date('d/M/Y H:i:s P', time()).'<br />';
634 //echo 'Last attempt '.date('d/M/Y H:i:s P', $result['time']).'<br />';
635 //echo 'Unlock Time '.date('d/M/Y H:i:s P', $result['time'] + $loginizer['lockout_time']).'<br />';
636
637 $_time = $banlift.' '.$loginizer['msg']['minutes_err'];
638
639 if($banlift > 60){
640 $banlift = ceil($banlift / 60);
641 $_time = $banlift.' '.$loginizer['msg']['hours_err'];
642 }
643
644 $lz_error['ip_blocked'] = $loginizer['msg']['lockout_err'].' '.$_time;
645
646 return false;
647 }
648 }
649
650 return true;
651 }
652
653 function loginizer_is_blacklisted(){
654
655 global $wpdb, $loginizer, $lz_error;
656
657 $blacklist = $loginizer['blacklist'];
658
659 foreach($blacklist as $k => $v){
660
661 // Is the IP in the blacklist ?
662 if(inet_ptoi($v['start']) <= inet_ptoi($loginizer['current_ip']) && inet_ptoi($loginizer['current_ip']) <= inet_ptoi($v['end'])){
663 $result = 1;
664 break;
665 }
666
667 // Is it in a wider range ?
668 if(inet_ptoi($v['start']) >= 0 && inet_ptoi($v['end']) < 0){
669
670 // Since the end of the RANGE (i.e. current IP range) is beyond the +ve value of inet_ptoi,
671 // if the current IP is <= than the start of the range, it is within the range
672 // OR
673 // if the current IP is <= than the end of the range, it is within the range
674 if(inet_ptoi($v['start']) <= inet_ptoi($loginizer['current_ip'])
675 || inet_ptoi($loginizer['current_ip']) <= inet_ptoi($v['end'])){
676 $result = 1;
677 break;
678 }
679
680 }
681
682 }
683
684 // You are blacklisted
685 if(!empty($result)){
686 $lz_error['ip_blacklisted'] = $loginizer['msg']['ip_blacklisted'];
687 return true;
688 }
689
690 return false;
691
692 }
693
694 function loginizer_is_whitelisted(){
695
696 global $wpdb, $loginizer, $lz_error;
697
698 $whitelist = $loginizer['whitelist'];
699
700 foreach($whitelist as $k => $v){
701
702 // Is the IP in the blacklist ?
703 if(inet_ptoi($v['start']) <= inet_ptoi($loginizer['current_ip']) && inet_ptoi($loginizer['current_ip']) <= inet_ptoi($v['end'])){
704 $result = 1;
705 break;
706 }
707
708 // Is it in a wider range ?
709 if(inet_ptoi($v['start']) >= 0 && inet_ptoi($v['end']) < 0){
710
711 // Since the end of the RANGE (i.e. current IP range) is beyond the +ve value of inet_ptoi,
712 // if the current IP is <= than the start of the range, it is within the range
713 // OR
714 // if the current IP is <= than the end of the range, it is within the range
715 if(inet_ptoi($v['start']) <= inet_ptoi($loginizer['current_ip'])
716 || inet_ptoi($loginizer['current_ip']) <= inet_ptoi($v['end'])){
717 $result = 1;
718 break;
719 }
720
721 }
722
723 }
724
725 // You are whitelisted
726 if(!empty($result)){
727 return true;
728 }
729
730 return false;
731
732 }
733
734
735 // When the login fails, then this is called
736 // We need to update the database
737 function loginizer_login_failed($username, $is_2fa = ''){
738
739 global $wpdb, $loginizer, $lz_cannot_login;
740
741 $fail_type = 'Login';
742
743 if(!empty($is_2fa)){
744 $fail_type = '2FA';
745 }
746
747 if(empty($lz_cannot_login) && empty($loginizer['ip_is_whitelisted']) && empty($loginizer['no_loginizer_logs'])){
748
749 $url = @addslashes((!empty($_SERVER['HTTPS']) ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
750 $url = esc_url($url);
751
752 $result = lz_selectquery("SELECT * FROM `".$wpdb->prefix."loginizer_logs` WHERE `ip` = '".$loginizer['current_ip']."';");
753
754 if(!empty($result)){
755 $lockout = floor((($result['count']+1) / $loginizer['max_retries']));
756 $sresult = $wpdb->query("UPDATE `".$wpdb->prefix."loginizer_logs` SET `username` = '".$username."', `time` = '".time()."', `count` = `count`+1, `lockout` = '".$lockout."', `url` = '".$url."' WHERE `ip` = '".$loginizer['current_ip']."';");
757
758 // Do we need to email admin ?
759 if(!empty($loginizer['notify_email']) && $lockout >= $loginizer['notify_email']){
760
761 $sitename = lz_is_multisite() ? get_site_option('site_name') : get_option('blogname');
762 $mail = array();
763 $mail['to'] = lz_is_multisite() ? get_site_option('admin_email') : get_option('admin_email');
764 $mail['subject'] = 'Failed '.$fail_type.' Attempts from IP '.$loginizer['current_ip'].' ('.$sitename.')';
765 $mail['message'] = 'Hi,
766
767 '.($result['count']+1).' failed '.strtolower($fail_type).' attempts and '.$lockout.' lockout(s) from IP '.$loginizer['current_ip'].' on your site :
768 '.home_url().'
769
770 Last '.$fail_type.' Attempt : '.date('d/M/Y H:i:s P', time()).'
771 Last User Attempt : '.$username.'
772 IP has been blocked until : '.date('d/M/Y H:i:s P', time() + $loginizer['lockout_time']).'
773
774 Regards,
775 Loginizer';
776
777 @wp_mail($mail['to'], $mail['subject'], $mail['message']);
778 }
779 }else{
780 $result = array();
781 $result['count'] = 0;
782 $insert = $wpdb->query("INSERT INTO `".$wpdb->prefix."loginizer_logs` SET `username` = '".$username."', `time` = '".time()."', `count` = '1', `ip` = '".$loginizer['current_ip']."', `lockout` = '0', `url` = '".$url."';");
783 }
784
785 // We need to add one as this is a failed attempt as well
786 $result['count'] = $result['count'] + 1;
787 $loginizer['retries_left'] = ($loginizer['max_retries'] - ($result['count'] % $loginizer['max_retries']));
788 $loginizer['retries_left'] = $loginizer['retries_left'] == $loginizer['max_retries'] ? 0 : $loginizer['retries_left'];
789
790 }
791 }
792
793 // Handles the error of the password not being there
794 function loginizer_error_handler($errors, $redirect_to){
795
796 global $wpdb, $loginizer, $lz_user_pass, $lz_cannot_login;
797
798 //echo 'loginizer_error_handler :';print_r($errors->errors);echo '<br>';
799
800 // Remove the empty password error
801 if(is_wp_error($errors)){
802
803 $codes = $errors->get_error_codes();
804
805 foreach($codes as $k => $v){
806 if($v == 'invalid_username' || $v == 'incorrect_password'){
807 $show_error = 1;
808 }
809 }
810
811 $errors->remove('invalid_username');
812 $errors->remove('incorrect_password');
813
814 }
815
816 // Add the error
817 if(!empty($lz_user_pass) && !empty($show_error) && empty($lz_cannot_login)){
818 $errors->add('invalid_userpass', '<b>ERROR:</b> ' . $loginizer['msg']['inv_userpass']);
819 }
820
821 // Add the number of retires left as well
822 if(count($errors->get_error_codes()) > 0 && isset($loginizer['retries_left'])){
823 $errors->add('retries_left', loginizer_retries_left());
824 }
825
826 return $errors;
827
828 }
829
830
831
832 // Handles the error of the password not being there
833 function loginizer_woocommerce_error_handler(){
834
835 global $wpdb, $loginizer, $lz_user_pass, $lz_cannot_login;
836
837 if(function_exists('wc_add_notice')){
838 wc_add_notice( loginizer_retries_left(), 'error' );
839 }
840
841 }
842
843 // Returns a string with the number of retries left
844 function loginizer_retries_left(){
845
846 global $wpdb, $loginizer, $lz_user_pass, $lz_cannot_login;
847
848 // If we are to show the number of retries left
849 if(isset($loginizer['retries_left'])){
850 return '<b>'.$loginizer['retries_left'].'</b> '.$loginizer['msg']['attempts_left'];
851 }
852
853 }
854
855 function loginizer_reset_retries(){
856
857 global $wpdb, $loginizer;
858
859 $deltime = time() - $loginizer['reset_retries'];
860 $result = $wpdb->query("DELETE FROM `".$wpdb->prefix."loginizer_logs` WHERE `time` <= '".$deltime."';");
861
862 update_option('loginizer_last_reset', time());
863
864 }
865
866 add_filter("plugin_action_links_$plugin_loginizer", 'loginizer_plugin_action_links');
867
868 // Add settings link on plugin page
869 function loginizer_plugin_action_links($links) {
870
871 if(!defined('LOGINIZER_PREMIUM')){
872 $links[] = '<a href="'.LOGINIZER_PRO_URL.'" style="color:#3db634;" target="_blank">'._x('Upgrade', 'Plugin action link label.', 'loginizer').'</a>';
873 }
874
875 $settings_link = '<a href="admin.php?page=loginizer">Settings</a>';
876 array_unshift($links, $settings_link);
877
878 return $links;
879 }
880
881 add_action('admin_menu', 'loginizer_admin_menu');
882
883 // Shows the admin menu of Loginizer
884 function loginizer_admin_menu() {
885
886 global $wp_version, $loginizer;
887
888 if(!defined('SITEPAD')){
889
890 // Add the menu page
891 add_menu_page(__('Loginizer Dashboard', 'loginizer'), __('Loginizer Security', 'loginizer'), 'activate_plugins', 'loginizer', 'loginizer_page_dashboard');
892
893 // Dashboard
894 add_submenu_page('loginizer', __('Loginizer Dashboard', 'loginizer'), __('Dashboard', 'loginizer'), 'activate_plugins', 'loginizer', 'loginizer_page_dashboard');
895
896 }else{
897
898 // Add the menu page
899 add_menu_page(__('Security', 'loginizer'), __('Security', 'loginizer'), 'activate_plugins', 'loginizer', 'loginizer_page_security', 'dashicons-shield', 85);
900
901 // Rename Login
902 add_submenu_page('loginizer', __('Security Settings', 'loginizer'), __('Rename Login', 'loginizer'), 'activate_plugins', 'loginizer', 'loginizer_page_security');
903
904 }
905
906 // Brute Force
907 add_submenu_page('loginizer', __('Brute Force Settings', 'loginizer'), __('Brute Force', 'loginizer'), 'activate_plugins', 'loginizer_brute_force', 'loginizer_page_brute_force');
908
909 // PasswordLess
910 add_submenu_page('loginizer', __($loginizer['prefix'].'PasswordLess Settings', 'loginizer'), __('PasswordLess', 'loginizer'), 'activate_plugins', 'loginizer_passwordless', 'loginizer_page_passwordless');
911
912 // Security Settings
913 if(!defined('SITEPAD')){
914
915 // Two Factor Auth
916 add_submenu_page('loginizer', __($loginizer['prefix'].' Two Factor Authentication', 'loginizer'), __('Two Factor Auth', 'loginizer'), 'activate_plugins', 'loginizer_2fa', 'loginizer_page_2fa');
917
918 }
919
920 // reCaptcha
921 add_submenu_page('loginizer', __($loginizer['prefix'].'reCAPTCHA Settings', 'loginizer'), __('reCAPTCHA', 'loginizer'), 'activate_plugins', 'loginizer_recaptcha', 'loginizer_page_recaptcha');
922
923 // Security Settings
924 if(!defined('SITEPAD')){
925
926 // Security Settings
927 add_submenu_page('loginizer', __($loginizer['prefix'].'Security Settings', 'loginizer'), __('Security Settings', 'loginizer'), 'activate_plugins', 'loginizer_security', 'loginizer_page_security');
928
929 // File Checksums
930 add_submenu_page('loginizer', __('Loginizer File Checksums', 'loginizer'), __('File Checksums', 'loginizer'), 'activate_plugins', 'loginizer_checksums', 'loginizer_page_checksums');
931
932 }
933
934 if(!defined('LOGINIZER_PREMIUM') && !empty($loginizer['ins_time']) && $loginizer['ins_time'] < (time() - (30*24*3600))){
935
936 // Go Pro link
937 add_submenu_page('loginizer', __('Loginizer Go Pro', 'loginizer'), __('Go Pro', 'loginizer'), 'activate_plugins', LOGINIZER_PRO_URL);
938
939 }
940
941 }
942
943 // The Loginizer Admin Options Page
944 function loginizer_page_header($title = 'Loginizer'){
945
946 global $loginizer;
947
948 ?>
949 <style>
950 .lz-right-ul{
951 padding-left: 10px !important;
952 }
953
954 .lz-right-ul li{
955 list-style: circle !important;
956 }
957 </style>
958 <?php
959
960 echo '<div style="margin: 10px 20px 0 2px;">
961 <div class="metabox-holder columns-2">
962 <div class="postbox-container">
963 <div id="top-sortables" class="meta-box-sortables ui-sortable">
964
965 <table cellpadding="2" cellspacing="1" width="100%" class="fixed" border="0">
966 <tr>
967 <td valign="top"><h3>'.$loginizer['prefix'].$title.'</h3></td>';
968
969 if(!defined('SITEPAD')){
970
971 echo '<td align="right"><a target="_blank" class="button button-primary" href="https://wordpress.org/support/view/plugin-reviews/loginizer">'.__('Review Loginizer', 'loginizer').'</a></td>
972 <td align="right" width="40"><a target="_blank" href="https://twitter.com/loginizer"><img src="'.LOGINIZER_URL.'/twitter.png" /></a></td>
973 <td align="right" width="40"><a target="_blank" href="https://www.facebook.com/Loginizer-815504798591884"><img src="'.LOGINIZER_URL.'/facebook.png" /></a></td>';
974
975 }
976
977 echo '
978 </tr>
979 </table>
980 <hr />
981
982 <!--Main Table-->
983 <table cellpadding="8" cellspacing="1" width="100%" class="fixed">
984 <tr>
985 <td valign="top">';
986
987 }
988
989 // The Loginizer Theme footer
990 function loginizer_page_footer(){
991
992 if(!loginizer_is_premium()){
993 echo '<script>
994 jQuery("[loginizer-premium-only]").each(function(index) {
995 jQuery(this).find( "input, textarea, select" ).attr("disabled", true);
996 });
997 </script>';
998 }
999
1000 echo '</td>
1001 <td width="200" valign="top" id="loginizer-right-bar">';
1002
1003 if(!defined('SITEPAD')){
1004
1005 if(!defined('LOGINIZER_PREMIUM')){
1006
1007 echo '
1008 <div class="postbox" style="min-width:0px !important;">
1009 <div class="postbox-header">
1010 <h2 class="hndle ui-sortable-handle">
1011 <span>Premium Version</span>
1012 </h2>
1013 </div>
1014
1015 <div class="inside">
1016 <i>Upgrade to the premium version and get the following features </i>:<br>
1017 <ul class="lz-right-ul">
1018 <li>PasswordLess Login</li>
1019 <li>Two Factor Auth - Email</li>
1020 <li>Two Factor Auth - App</li>
1021 <li>Login Challenge Question</li>
1022 <li>reCAPTCHA</li>
1023 <li>Rename Login Page</li>
1024 <li>Disable XML-RPC</li>
1025 <li>And many more ...</li>
1026 </ul>
1027 <center><a class="button button-primary" target="_blank" href="'.LOGINIZER_PRICING_URL.'">Upgrade</a></center>
1028 </div>
1029 </div>';
1030
1031 }else{
1032
1033 echo '
1034 <div class="postbox" style="min-width:0px !important;">
1035 <div class="postbox-header">
1036 <h2 class="hndle ui-sortable-handle">
1037 <span>Recommendations</span>
1038 </h2>
1039 </div>
1040 <div class="inside">
1041 <i>We recommed that you enable atleast one of the following security features</i>:<br>
1042 <ul class="lz-right-ul">
1043 <li>Rename Login Page</li>
1044 <li>Login Challenge Question</li>
1045 <li>reCAPTCHA</li>
1046 <li>Two Factor Auth - Email</li>
1047 <li>Two Factor Auth - App</li>
1048 <li>Change \'admin\' Username</li>
1049 </ul>
1050 </div>
1051 </div>';
1052 }
1053
1054 echo '
1055 <div class="postbox" style="min-width:0px !important;">
1056 <div class="postbox-header">
1057 <h2 class="hndle ui-sortable-handle">
1058 <span><a target="_blank" href="https://pagelayer.com/?from=loginizer-plugin"><img src="'.LOGINIZER_URL.'/images/pagelayer_product.png" width="100%" /></a></span>
1059 </h2>
1060 </div>
1061 <div class="inside">
1062 <i>Easily manage and make professional pages and content with our Pagelayer builder </i>:<br>
1063 <ul class="lz-right-ul">
1064 <li>30+ Free Widgets</li>
1065 <li>60+ Premium Widgets</li>
1066 <li>400+ Premium Sections</li>
1067 <li>Theme Builder</li>
1068 <li>WooCommerce Builder</li>
1069 <li>Theme Creator and Exporter</li>
1070 <li>Form Builder</li>
1071 <li>Popup Builder</li>
1072 <li>And many more ...</li>
1073 </ul>
1074 <center><a class="button button-primary" target="_blank" href="https://wordpress.org/plugins/pagelayer/">Visit Pagelayer</a></center>
1075 </div>
1076 </div>';
1077
1078 echo '
1079 <div class="postbox" style="min-width:0px !important;">
1080 <div class="postbox-header">
1081 <h2 class="hndle ui-sortable-handle">
1082 <span><a target="_blank" href="https://wpcentral.co/?from=loginizer-plugin"><img src="'.LOGINIZER_URL.'/images/wpcentral_product.png" width="100%" /></a></span>
1083 </h2>
1084 </div>
1085 <div class="inside">
1086 <i>Manage all your WordPress sites from <b>1 dashboard</b> </i>:<br>
1087 <ul class="lz-right-ul">
1088 <li>1-click Admin Access</li>
1089 <li>Update WordPress</li>
1090 <li>Update Themes</li>
1091 <li>Update Plugins</li>
1092 <li>Backup your WordPress Site</li>
1093 <li>Plugins & Theme Management</li>
1094 <li>Post Management</li>
1095 <li>And many more ...</li>
1096 </ul>
1097 <center><a class="button button-primary" target="_blank" href="https://wpcentral.co/?from=loginizer-plugin">Visit wpCentral</a></center>
1098 </div>
1099 </div>';
1100
1101 }
1102
1103 echo '</td>
1104 </tr>
1105 </table>';
1106
1107 if(!defined('SITEPAD')){
1108
1109 echo '<br />
1110 <div style="width:45%;background:#FFF;padding:15px; margin:auto">
1111 <b>Let your friends know that you have secured your website :</b>
1112 <form method="get" action="https://twitter.com/intent/tweet" id="tweet" onsubmit="return dotweet(this);">
1113 <textarea name="text" cols="45" row="3" style="resize:none;">I just secured my @WordPress site against #bruteforce using @loginizer</textarea>
1114 &nbsp; &nbsp; <input type="submit" value="Tweet!" class="button button-primary" onsubmit="return false;" id="twitter-btn" style="margin-top:20px;"/>
1115 </form>
1116
1117 </div>
1118 <br />
1119
1120 <script>
1121 function dotweet(ele){
1122 window.open(jQuery("#"+ele.id).attr("action")+"?"+jQuery("#"+ele.id).serialize(), "_blank", "scrollbars=no, menubar=no, height=400, width=500, resizable=yes, toolbar=no, status=no");
1123 return false;
1124 }
1125 </script>
1126
1127 <hr />
1128 <a href="http://loginizer.com" target="_blank">Loginizer</a> v'.LOGINIZER_VERSION.'. You can report any bugs <a href="http://wordpress.org/support/plugin/loginizer" target="_blank">here</a>.';
1129
1130 }
1131
1132 echo '
1133 </div>
1134 </div>
1135 </div>
1136 </div>';
1137
1138 }
1139
1140 // The Loginizer Admin Options Page
1141 function loginizer_page_dashboard(){
1142
1143 global $loginizer, $lz_error, $lz_env;
1144
1145 if(!current_user_can('manage_options')){
1146 wp_die('Sorry, but you do not have permissions to change settings.');
1147 }
1148
1149 // Dismiss the announcement
1150 if(isset($_GET['dismiss_announcement'])){
1151 update_option('loginizer_no_announcement', 1);
1152 }
1153
1154 /* Make sure post was from this page */
1155 if(count($_POST) > 0){
1156 check_admin_referer('loginizer-options');
1157 }
1158
1159 do_action('loginizer_pre_page_dashboard');
1160
1161 // Is there a IP Method ?
1162 if(isset($_POST['save_lz_ip_method'])){
1163
1164 $ip_method = (int) lz_optpost('lz_ip_method');
1165 $custom_ip_method = lz_optpost('lz_custom_ip_method');
1166
1167 if($ip_method >= 0 && $ip_method <= 3){
1168 update_option('loginizer_ip_method', $ip_method);
1169 }
1170
1171 // Custom Method name ?
1172 if($ip_method == 3){
1173 update_option('loginizer_custom_ip_method', $custom_ip_method);
1174 }
1175
1176 }
1177
1178 loginizer_page_dashboard_T();
1179
1180 }
1181
1182 // The Loginizer Admin Options Page - THEME
1183 function loginizer_page_dashboard_T(){
1184
1185 global $loginizer, $lz_error, $lz_env;
1186
1187 loginizer_page_header('Dashboard');
1188 ?>
1189 <style>
1190 .welcome-panel{
1191 margin: 0px;
1192 padding: 10px;
1193 }
1194
1195 input[type="text"], textarea, select {
1196 width: 70%;
1197 }
1198
1199 .form-table label{
1200 font-weight:bold;
1201 }
1202
1203 .exp{
1204 font-size:12px;
1205 }
1206 </style>
1207
1208 <?php
1209
1210 loginizer_newsletter_subscribe();
1211
1212 $hide_announcement = get_option('loginizer_no_announcement');
1213 if(empty($hide_announcement)){
1214 echo '<div id="message" class="welcome-panel">'. __('<a href="https://loginizer.com/blog/loginizer-has-been-acquired-by-softaculous/" target="_blank" style="text-decoration:none;">We are excited to announce that we have joined forces with Softaculous and have been acquired by them 😊. Read full announcement here.</a>', 'loginizer'). '<a class="welcome-panel-close" style="top:3px;right:2px;" href="'.menu_page_url('loginizer', false).'&dismiss_announcement=1" aria-label="Dismiss announcement"></a></div><br />';
1215 }
1216
1217 echo '<div class="welcome-panel">Thank you for choosing Loginizer! Many more features coming soon... &nbsp; Review Loginizer at WordPress &nbsp; &nbsp; <a href="https://wordpress.org/support/view/plugin-reviews/loginizer" class="button button-primary" target="_blank">Add Review</a></div><br />';
1218
1219 // Saved ?
1220 if(!empty($GLOBALS['lz_saved'])){
1221 echo '<div id="message" class="updated"><p>'. __('The settings were saved successfully', 'loginizer'). '</p></div><br />';
1222 }
1223
1224 // Any errors ?
1225 if(!empty($lz_error)){
1226 lz_report_error($lz_error);echo '<br />';
1227 }
1228
1229 ?>
1230
1231 <div class="postbox">
1232
1233 <div class="postbox-header">
1234 <h2 class="hndle ui-sortable-handle">
1235 <span><?php echo __('Getting Started', 'loginizer'); ?></span>
1236 </h2>
1237 </div>
1238
1239 <div class="inside">
1240
1241 <form action="" method="post" enctype="multipart/form-data">
1242 <?php wp_nonce_field('loginizer-options'); ?>
1243 <table class="form-table">
1244 <tr>
1245 <td scope="row" valign="top" colspan="2" style="line-height:150%">
1246 <i>Welcome to Loginizer Security. By default the <b>Brute Force Protection</b> is immediately enabled. You should start by going over the default settings and tweaking them as per your needs.</i>
1247 <?php
1248 if(defined('LOGINIZER_PREMIUM')){
1249 echo '<br><i>In the Premium version of Loginizer you have many more features. We recommend you enable features like <b>reCAPTCHA, Two Factor Auth or Email based PasswordLess</b> login. These features will improve your websites security.</i>';
1250 }else{
1251 echo '<br><i><a href="'.LOGINIZER_PRICING_URL.'" target="_blank" style="text-decoration:none;color:red;">Upgrade to Pro</a> for more features like <b>reCAPTCHA, Two Factor Auth, Rename wp-admin and wp-login.php pages, Email based PasswordLess</b> login and more. These features will improve your website\'s security.</i>';
1252 }
1253 ?>
1254 </td>
1255 </tr>
1256 </table>
1257 </form>
1258
1259 </div>
1260 </div>
1261
1262 <div class="postbox">
1263
1264 <div class="postbox-header">
1265 <h2 class="hndle ui-sortable-handle">
1266 <span><?php echo __('System Information', 'loginizer'); ?></span>
1267 </h2>
1268 </div>
1269 <div class="inside">
1270
1271 <form action="" method="post" enctype="multipart/form-data">
1272 <?php wp_nonce_field('loginizer-options'); ?>
1273 <table class="wp-list-table fixed striped users" cellspacing="1" border="0" width="95%" cellpadding="10" align="center">
1274 <?php
1275 echo '
1276 <tr>
1277 <th align="left" width="25%">'.__('Loginizer Version', 'loginizer').'</th>
1278 <td>'.LOGINIZER_VERSION.(defined('LOGINIZER_PREMIUM') ? ' (<font color="green">Security PRO Version</font>)' : '').'</td>
1279 </tr>';
1280
1281 do_action('loginizer_system_information');
1282
1283 echo '<tr>
1284 <th align="left">'.__('URL', 'loginizer').'</th>
1285 <td>'.get_site_url().'</td>
1286 </tr>
1287 <tr>
1288 <th align="left">'.__('Path', 'loginizer').'</th>
1289 <td>'.ABSPATH.'</td>
1290 </tr>
1291 <tr>
1292 <th align="left">'.__('Server\'s IP Address', 'loginizer').'</th>
1293 <td>'.@$_SERVER['SERVER_ADDR'].'</td>
1294 </tr>
1295 <tr>
1296 <th align="left">'.__('Your IP Address', 'loginizer').'</th>
1297 <td>'.lz_getip().'
1298 <div style="float:right">
1299 Method :
1300 <select name="lz_ip_method" id="lz_ip_method" style="font-size:11px; width:150px" onchange="lz_ip_method_handle()">
1301 <option value="0" '.lz_POSTselect('lz_ip_method', 0, (@$loginizer['ip_method'] == 0)).'>REMOTE_ADDR</option>
1302 <option value="1" '.lz_POSTselect('lz_ip_method', 1, (@$loginizer['ip_method'] == 1)).'>HTTP_X_FORWARDED_FOR</option>
1303 <option value="2" '.lz_POSTselect('lz_ip_method', 2, (@$loginizer['ip_method'] == 2)).'>HTTP_CLIENT_IP</option>
1304 <option value="3" '.lz_POSTselect('lz_ip_method', 3, (@$loginizer['ip_method'] == 3)).'>CUSTOM</option>
1305 </select>
1306 <input name="lz_custom_ip_method" id="lz_custom_ip_method" type="text" value="'.lz_optpost('lz_custom_ip_method', @$loginizer['custom_ip_method']).'" style="font-size:11px; width:100px; display:none" />
1307 <input name="save_lz_ip_method" class="button button-primary" value="Save" type="submit" />
1308 </div>
1309 </td>
1310 </tr>
1311 <tr>
1312 <th align="left">'.__('wp-config.php is writable', 'loginizer').'</th>
1313 <td>'.(is_writable(ABSPATH.'/wp-config.php') ? '<span style="color:red">Yes</span>' : '<span style="color:green">No</span>').'</td>
1314 </tr>';
1315
1316 if(file_exists(ABSPATH.'/.htaccess')){
1317 echo '
1318 <tr>
1319 <th align="left">'.__('.htaccess is writable', 'loginizer').'</th>
1320 <td>'.(is_writable(ABSPATH.'/.htaccess') ? '<span style="color:red">Yes</span>' : '<span style="color:green">No</span>').'</td>
1321 </tr>';
1322
1323 }
1324
1325 ?>
1326 </table>
1327 </form>
1328
1329 </div>
1330 </div>
1331
1332 <script type="text/javascript">
1333
1334 function lz_ip_method_handle(){
1335 var ele = jQuery('#lz_ip_method');
1336 if(ele.val() == 3){
1337 jQuery('#lz_custom_ip_method').show();
1338 }else{
1339 jQuery('#lz_custom_ip_method').hide();
1340 }
1341 };
1342
1343 lz_ip_method_handle();
1344
1345 </script>
1346
1347 <div id="" class="postbox">
1348
1349 <div class="postbox-header">
1350 <h2 class="hndle ui-sortable-handle">
1351 <span><?php echo __('File Permissions', 'loginizer'); ?></span>
1352 </h2>
1353 </div>
1354
1355 <div class="inside">
1356
1357 <form action="" method="post" enctype="multipart/form-data">
1358 <?php wp_nonce_field('loginizer-options'); ?>
1359 <table class="wp-list-table fixed striped users" border="0" width="95%" cellpadding="10" align="center">
1360 <?php
1361
1362 echo '
1363 <tr>
1364 <th style="background:#EFEFEF;">'.__('Relative Path', 'loginizer').'</th>
1365 <th style="width:10%; background:#EFEFEF;">'.__('Suggested', 'loginizer').'</th>
1366 <th style="width:10%; background:#EFEFEF;">'.__('Actual', 'loginizer').'</th>
1367 </tr>';
1368
1369 $wp_content = basename(dirname(dirname(dirname(__FILE__))));
1370
1371 $files_to_check = array('/' => array('0755', '0750'),
1372 '/wp-admin' => array('0755'),
1373 '/wp-includes' => array('0755'),
1374 '/wp-config.php' => array('0444'),
1375 '/'.$wp_content => array('0755'),
1376 '/'.$wp_content.'/themes' => array('0755'),
1377 '/'.$wp_content.'/plugins' => array('0755'),
1378 '.htaccess' => array('0444'));
1379
1380 $root = ABSPATH;
1381
1382 foreach($files_to_check as $k => $v){
1383
1384 $path = $root.'/'.$k;
1385 $stat = @stat($path);
1386 $suggested = $v;
1387 $actual = substr(sprintf('%o', $stat['mode']), -4);
1388
1389 echo '
1390 <tr>
1391 <td>'.$k.'</td>
1392 <td>'.current($suggested).'</td>
1393 <td><span '.(!in_array($actual, $suggested) ? 'style="color: red;"' : '').'>'.$actual.'</span></td>
1394 </tr>';
1395
1396 }
1397
1398 ?>
1399 </table>
1400 </form>
1401
1402 </div>
1403 </div>
1404
1405 <?php
1406
1407 loginizer_page_footer();
1408
1409 }
1410
1411 // The Loginizer Admin Options Page
1412 function loginizer_page_brute_force(){
1413
1414 global $wpdb, $wp_roles, $loginizer;
1415
1416 if(!current_user_can('manage_options')){
1417 wp_die('Sorry, but you do not have permissions to change settings.');
1418 }
1419
1420 /* Make sure post was from this page */
1421 if(count($_POST) > 0){
1422 check_admin_referer('loginizer-options');
1423 }
1424
1425 // BEGIN THEME
1426 loginizer_page_header('Brute Force Settings');
1427
1428 // Load the blacklist and whitelist
1429 $loginizer['blacklist'] = get_option('loginizer_blacklist');
1430 $loginizer['whitelist'] = get_option('loginizer_whitelist');
1431
1432 // Disable Brute Force
1433 if(isset($_POST['disable_brute_lz'])){
1434
1435 // Save the options
1436 update_option('loginizer_disable_brute', 1);
1437
1438 $loginizer['disable_brute'] = 1;
1439
1440 echo '<div id="message" class="updated"><p>'
1441 . __('The Brute Force Protection feature is now disabled', 'loginizer')
1442 . '</p></div><br />';
1443
1444 }
1445
1446 // Enable brute force
1447 if(isset($_POST['enable_brute_lz'])){
1448
1449 // Save the options
1450 update_option('loginizer_disable_brute', 0);
1451
1452 $loginizer['disable_brute'] = 0;
1453
1454 echo '<div id="message" class="updated"><p>'
1455 . __('The Brute Force Protection feature is now enabled', 'loginizer')
1456 . '</p></div><br />';
1457
1458 }
1459
1460 // The Brute Force Settings
1461 if(isset($_POST['save_lz'])){
1462
1463 $max_retries = (int) lz_optpost('max_retries');
1464 $lockout_time = (int) lz_optpost('lockout_time');
1465 $max_lockouts = (int) lz_optpost('max_lockouts');
1466 $lockouts_extend = (int) lz_optpost('lockouts_extend');
1467 $reset_retries = (int) lz_optpost('reset_retries');
1468 $notify_email = (int) lz_optpost('notify_email');
1469
1470 $lockout_time = $lockout_time * 60;
1471 $lockouts_extend = $lockouts_extend * 60 * 60;
1472 $reset_retries = $reset_retries * 60 * 60;
1473
1474 if(empty($error)){
1475
1476 $option['max_retries'] = $max_retries;
1477 $option['lockout_time'] = $lockout_time;
1478 $option['max_lockouts'] = $max_lockouts;
1479 $option['lockouts_extend'] = $lockouts_extend;
1480 $option['reset_retries'] = $reset_retries;
1481 $option['notify_email'] = $notify_email;
1482
1483 // Save the options
1484 update_option('loginizer_options', $option);
1485
1486 $saved = true;
1487
1488 }else{
1489 lz_report_error($error);
1490 }
1491
1492 if(!empty($notice)){
1493 lz_report_notice($notice);
1494 }
1495
1496 if(!empty($saved)){
1497 echo '<div id="message" class="updated"><p>'
1498 . __('The settings were saved successfully', 'loginizer')
1499 . '</p></div><br />';
1500 }
1501
1502 }
1503
1504 // Delete a Blackist IP range
1505 if(isset($_POST['bdelid'])){
1506
1507 $delid = (int) lz_optreq('bdelid');
1508
1509 // Unset and save
1510 $blacklist = $loginizer['blacklist'];
1511 unset($blacklist[$delid]);
1512 update_option('loginizer_blacklist', $blacklist);
1513
1514 echo '<div id="message" class="updated fade"><p>'
1515 . __('The Blacklist IP range has been deleted successfully', 'loginizer')
1516 . '</p></div><br />';
1517
1518 }
1519
1520 // Delete all Blackist IP ranges
1521 if(isset($_POST['del_all_blacklist'])){
1522
1523 // Unset and save
1524 update_option('loginizer_blacklist', array());
1525
1526 echo '<div id="message" class="updated fade"><p>'
1527 . __('The Blacklist IP range(s) have been cleared successfully', 'loginizer')
1528 . '</p></div><br />';
1529
1530 }
1531
1532 // Delete a Whitelist IP range
1533 if(isset($_POST['delid'])){
1534
1535 $delid = (int) lz_optreq('delid');
1536
1537 // Unset and save
1538 $whitelist = $loginizer['whitelist'];
1539 unset($whitelist[$delid]);
1540 update_option('loginizer_whitelist', $whitelist);
1541
1542 echo '<div id="message" class="updated fade"><p>'
1543 . __('The Whitelist IP range has been deleted successfully', 'loginizer')
1544 . '</p></div><br />';
1545
1546 }
1547
1548 // Delete all Blackist IP ranges
1549 if(isset($_POST['del_all_whitelist'])){
1550
1551 // Unset and save
1552 update_option('loginizer_whitelist', array());
1553
1554 echo '<div id="message" class="updated fade"><p>'
1555 . __('The Whitelist IP range(s) have been cleared successfully', 'loginizer')
1556 . '</p></div><br />';
1557
1558 }
1559
1560 // Reset All Logs
1561 if(isset($_POST['lz_reset_all_ip'])){
1562
1563 $result = $wpdb->query("DELETE FROM `".$wpdb->prefix."loginizer_logs`
1564 WHERE `time` > 0");
1565
1566 echo '<div id="message" class="updated fade"><p>'
1567 . __('All the IP Logs have been cleared', 'loginizer')
1568 . '</p></div><br />';
1569 }
1570
1571 // Reset Logs
1572 if(isset($_POST['lz_reset_ips']) && is_array($_POST['lz_reset_ips'])){
1573
1574 $ips = $_POST['lz_reset_ips'];
1575
1576 foreach($ips as $ip){
1577 if(!lz_valid_ip($ip)){
1578 $error[] = 'The IP - '.$ip.' is invalid !';
1579 }
1580 }
1581
1582 if(count($ips) < 1){
1583 $error[] = __('There are no IPs submitted', 'loginizer');
1584 }
1585
1586 // Should we start deleting logs
1587 if(empty($error)){
1588
1589 $result = $wpdb->query("DELETE FROM `".$wpdb->prefix."loginizer_logs`
1590 WHERE `ip` IN ('".implode("', '", $ips)."')");
1591
1592 if(empty($error)){
1593
1594 echo '<div id="message" class="updated fade"><p>'
1595 . __('The selected IP Logs have been reset', 'loginizer')
1596 . '</p></div><br />';
1597
1598 }
1599
1600 }
1601
1602 if(!empty($error)){
1603 lz_report_error($error);echo '<br />';
1604 }
1605
1606 }
1607
1608 if(isset($_POST['blacklist_iprange'])){
1609
1610 $start_ip = lz_optpost('start_ip');
1611 $end_ip = lz_optpost('end_ip');
1612
1613 if(empty($start_ip)){
1614 $error[] = __('Please enter the Start IP', 'loginizer');
1615 }
1616
1617 // If no end IP we consider only 1 IP
1618 if(empty($end_ip)){
1619 $end_ip = $start_ip;
1620 }
1621
1622 if(!lz_valid_ip($start_ip)){
1623 $error[] = __('Please provide a valid start IP', 'loginizer');
1624 }
1625
1626 if(!lz_valid_ip($end_ip)){
1627 $error[] = __('Please provide a valid end IP', 'loginizer');
1628 }
1629
1630 // Regular ranges will work
1631 if(inet_ptoi($start_ip) > inet_ptoi($end_ip)){
1632
1633 // BUT, if 0.0.0.1 - 255.255.255.255 is given, it will not work
1634 if(inet_ptoi($start_ip) >= 0 && inet_ptoi($end_ip) < 0){
1635 // This is right
1636 }else{
1637 $error[] = __('The End IP cannot be smaller than the Start IP', 'loginizer');
1638 }
1639
1640 }
1641
1642 if(empty($error)){
1643
1644 $blacklist = $loginizer['blacklist'];
1645
1646 foreach($blacklist as $k => $v){
1647
1648 // This is to check if there is any other range exists with the same Start or End IP
1649 if(( inet_ptoi($start_ip) <= inet_ptoi($v['start']) && inet_ptoi($v['start']) <= inet_ptoi($end_ip) )
1650 || ( inet_ptoi($start_ip) <= inet_ptoi($v['end']) && inet_ptoi($v['end']) <= inet_ptoi($end_ip) )
1651 ){
1652 $error[] = __('The Start IP or End IP submitted conflicts with an existing IP range !', 'loginizer');
1653 break;
1654 }
1655
1656 // This is to check if there is any other range exists with the same Start IP
1657 if(inet_ptoi($v['start']) <= inet_ptoi($start_ip) && inet_ptoi($start_ip) <= inet_ptoi($v['end'])){
1658 $error[] = __('The Start IP is present in an existing range !', 'loginizer');
1659 break;
1660 }
1661
1662 // This is to check if there is any other range exists with the same End IP
1663 if(inet_ptoi($v['start']) <= inet_ptoi($end_ip) && inet_ptoi($end_ip) <= inet_ptoi($v['end'])){
1664 $error[] = __('The End IP is present in an existing range!', 'loginizer');
1665 break;
1666 }
1667
1668 }
1669
1670 $newid = ( empty($blacklist) ? 0 : max(array_keys($blacklist)) ) + 1;
1671
1672 if(empty($error)){
1673
1674 $blacklist[$newid] = array();
1675 $blacklist[$newid]['start'] = $start_ip;
1676 $blacklist[$newid]['end'] = $end_ip;
1677 $blacklist[$newid]['time'] = time();
1678
1679 update_option('loginizer_blacklist', $blacklist);
1680
1681 echo '<div id="message" class="updated fade"><p>'
1682 . __('Blacklist IP range added successfully', 'loginizer')
1683 . '</p></div><br />';
1684
1685 }
1686
1687 }
1688
1689 if(!empty($error)){
1690 lz_report_error($error);echo '<br />';
1691 }
1692
1693 }
1694
1695 if(isset($_POST['whitelist_iprange'])){
1696
1697 $start_ip = lz_optpost('start_ip_w');
1698 $end_ip = lz_optpost('end_ip_w');
1699
1700 if(empty($start_ip)){
1701 $error[] = __('Please enter the Start IP', 'loginizer');
1702 }
1703
1704 // If no end IP we consider only 1 IP
1705 if(empty($end_ip)){
1706 $end_ip = $start_ip;
1707 }
1708
1709 if(!lz_valid_ip($start_ip)){
1710 $error[] = __('Please provide a valid start IP', 'loginizer');
1711 }
1712
1713 if(!lz_valid_ip($end_ip)){
1714 $error[] = __('Please provide a valid end IP', 'loginizer');
1715 }
1716
1717 if(inet_ptoi($start_ip) > inet_ptoi($end_ip)){
1718
1719 // BUT, if 0.0.0.1 - 255.255.255.255 is given, it will not work
1720 if(inet_ptoi($start_ip) >= 0 && inet_ptoi($end_ip) < 0){
1721 // This is right
1722 }else{
1723 $error[] = __('The End IP cannot be smaller than the Start IP', 'loginizer');
1724 }
1725
1726 }
1727
1728 if(empty($error)){
1729
1730 $whitelist = $loginizer['whitelist'];
1731
1732 foreach($whitelist as $k => $v){
1733
1734 // This is to check if there is any other range exists with the same Start or End IP
1735 if(( inet_ptoi($start_ip) <= inet_ptoi($v['start']) && inet_ptoi($v['start']) <= inet_ptoi($end_ip) )
1736 || ( inet_ptoi($start_ip) <= inet_ptoi($v['end']) && inet_ptoi($v['end']) <= inet_ptoi($end_ip) )
1737 ){
1738 $error[] = __('The Start IP or End IP submitted conflicts with an existing IP range !', 'loginizer');
1739 break;
1740 }
1741
1742 // This is to check if there is any other range exists with the same Start IP
1743 if(inet_ptoi($v['start']) <= inet_ptoi($start_ip) && inet_ptoi($start_ip) <= inet_ptoi($v['end'])){
1744 $error[] = __('The Start IP is present in an existing range !', 'loginizer');
1745 break;
1746 }
1747
1748 // This is to check if there is any other range exists with the same End IP
1749 if(inet_ptoi($v['start']) <= inet_ptoi($end_ip) && inet_ptoi($end_ip) <= inet_ptoi($v['end'])){
1750 $error[] = __('The End IP is present in an existing range!', 'loginizer');
1751 break;
1752 }
1753
1754 }
1755
1756 $newid = ( empty($whitelist) ? 0 : max(array_keys($whitelist)) ) + 1;
1757
1758 if(empty($error)){
1759
1760 $whitelist[$newid] = array();
1761 $whitelist[$newid]['start'] = $start_ip;
1762 $whitelist[$newid]['end'] = $end_ip;
1763 $whitelist[$newid]['time'] = time();
1764
1765 update_option('loginizer_whitelist', $whitelist);
1766
1767 echo '<div id="message" class="updated fade"><p>'
1768 . __('Whitelist IP range added successfully', 'loginizer')
1769 . '</p></div><br />';
1770
1771 }
1772
1773 }
1774
1775 if(!empty($error)){
1776 lz_report_error($error);echo '<br />';
1777 }
1778 }
1779
1780 // Save the messages
1781 if(isset($_POST['save_err_msgs_lz'])){
1782
1783 $msgs['inv_userpass'] = lz_optpost('msg_inv_userpass');
1784 $msgs['ip_blacklisted'] = lz_optpost('msg_ip_blacklisted');
1785 $msgs['attempts_left'] = lz_optpost('msg_attempts_left');
1786 $msgs['lockout_err'] = lz_optpost('msg_lockout_err');
1787 $msgs['minutes_err'] = lz_optpost('msg_minutes_err');
1788 $msgs['hours_err'] = lz_optpost('msg_hours_err');
1789
1790 // Update them
1791 update_option('loginizer_msg', $msgs);
1792
1793 echo '<div id="message" class="updated fade"><p>'
1794 . __('Error messages were saved successfully', 'loginizer')
1795 . '</p></div><br />';
1796
1797 }
1798
1799 // Count the Results
1800 $tmp = lz_selectquery("SELECT COUNT(*) AS num FROM `".$wpdb->prefix."loginizer_logs`");
1801 //print_r($tmp);
1802
1803 // Which Page is it
1804 $lz_env['res_len'] = 10;
1805 $lz_env['cur_page'] = lz_get_page('lzpage', $lz_env['res_len']);
1806 $lz_env['num_res'] = $tmp['num'];
1807 $lz_env['max_page'] = ceil($lz_env['num_res'] / $lz_env['res_len']);
1808
1809 // Get the logs
1810 $result = lz_selectquery("SELECT * FROM `".$wpdb->prefix."loginizer_logs`
1811 ORDER BY `time` DESC
1812 LIMIT ".$lz_env['cur_page'].", ".$lz_env['res_len']."", 1);
1813 //print_r($result);
1814
1815 $lz_env['cur_page'] = ($lz_env['cur_page'] / $lz_env['res_len']) + 1;
1816 $lz_env['cur_page'] = $lz_env['cur_page'] < 1 ? 1 : $lz_env['cur_page'];
1817 $lz_env['next_page'] = ($lz_env['cur_page'] + 1) > $lz_env['max_page'] ? $lz_env['max_page'] : ($lz_env['cur_page'] + 1);
1818 $lz_env['prev_page'] = ($lz_env['cur_page'] - 1) < 1 ? 1 : ($lz_env['cur_page'] - 1);
1819
1820 // Reload the settings
1821 $loginizer['blacklist'] = get_option('loginizer_blacklist');
1822 $loginizer['whitelist'] = get_option('loginizer_whitelist');
1823
1824 $saved_msgs = get_option('loginizer_msg');
1825
1826 ?>
1827
1828 <div id="" class="postbox">
1829
1830 <div class="postbox-header">
1831 <h2 class="hndle ui-sortable-handle">
1832 <?php echo __('<span>Failed Login Attempts Logs</span> &nbsp; (Past '.($loginizer['reset_retries']/60/60).' hours)','loginizer'); ?>
1833 </h2>
1834 </div>
1835
1836 <script>
1837 function yesdsd(){
1838 window.location = '<?php echo menu_page_url('loginizer_brute_force', false);?>&lzpage='+jQuery("#current-page-selector").val();
1839 return false;
1840 }
1841 </script>
1842
1843 <form method="get" onsubmit="return yesdsd();">
1844 <div class="tablenav">
1845 <p class="tablenav-pages" style="margin: 5px 10px" align="right">
1846 <span class="displaying-num"><?php echo $lz_env['num_res'];?> items</span>
1847 <span class="pagination-links">
1848 <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>
1849 <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>
1850 <span class="paging-input">
1851 <label for="current-page-selector" class="screen-reader-text">Current Page</label>
1852 <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>
1853 </span>
1854 <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>
1855 <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>
1856 </span>
1857 </p>
1858 </div>
1859 </form>
1860
1861 <form action="" method="post" enctype="multipart/form-data">
1862 <?php wp_nonce_field('loginizer-options'); ?>
1863 <div class="inside">
1864 <table class="wp-list-table widefat fixed users" border="0">
1865 <tr>
1866 <th scope="row" valign="top" style="background:#EFEFEF;" width="20">#</th>
1867 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('IP','loginizer'); ?></th>
1868 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Attempted Username','loginizer'); ?></th>
1869 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Last Failed Attempt (DD/MM/YYYY)','loginizer'); ?></th>
1870 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Failed Attempts Count','loginizer'); ?></th>
1871 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Lockouts Count','loginizer'); ?></th>
1872 <th scope="row" valign="top" style="background:#EFEFEF;" width="150"><?php echo __('URL Attacked','loginizer'); ?></th>
1873 </tr>
1874 <?php
1875
1876 if(empty($result)){
1877 echo '
1878 <tr>
1879 <td colspan="4">
1880 '.__('No Logs. You will see logs about failed login attempts here.', 'loginizer').'
1881 </td>
1882 </tr>';
1883 }else{
1884 foreach($result as $ik => $iv){
1885 $status_button = (!empty($iv['status']) ? 'disable' : 'enable');
1886 echo '
1887 <tr>
1888 <td>
1889 <input type="checkbox" value="'.$iv['ip'].'" name="lz_reset_ips[]" />
1890 </td>
1891 <td>
1892 '.$iv['ip'].'
1893 </td>
1894 <td>
1895 '.$iv['username'].'
1896 </td>
1897 <td>
1898 '.date('d/M/Y H:i:s P', $iv['time']).'
1899 </td>
1900 <td>
1901 '.$iv['count'].'
1902 </td>
1903 <td>
1904 '.$iv['lockout'].'
1905 </td>
1906 <td>
1907 '.$iv['url'].'
1908 </td>
1909 </tr>';
1910 }
1911 }
1912
1913 ?>
1914 </table>
1915
1916 <br>
1917 <input name="lz_reset_ip" class="button button-primary action" value="<?php echo __('Remove From Logs', 'loginizer'); ?>" type="submit" />
1918 &nbsp; &nbsp;
1919 <input name="lz_reset_all_ip" class="button button-primary action" value="<?php echo __('Clear All Logs', 'loginizer'); ?>" type="submit" />
1920 </div>
1921 </div>
1922 </form>
1923 <br />
1924
1925 <div id="" class="postbox">
1926
1927 <div class="postbox-header">
1928 <h2 class="hndle ui-sortable-handle">
1929 <span><?php echo __('Brute Force Settings', 'loginizer'); ?></span>
1930 </h2>
1931 </div>
1932
1933 <div class="inside">
1934
1935 <form action="" method="post" enctype="multipart/form-data">
1936 <?php wp_nonce_field('loginizer-options'); ?>
1937 <table class="form-table">
1938 <tr>
1939 <th scope="row" valign="top"><label for="max_retries"><?php echo __('Max Retries','loginizer'); ?></label></th>
1940 <td>
1941 <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 />
1942 </td>
1943 </tr>
1944 <tr>
1945 <th scope="row" valign="top"><label for="lockout_time"><?php echo __('Lockout Time','loginizer'); ?></label></th>
1946 <td>
1947 <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 />
1948 </td>
1949 </tr>
1950 <tr>
1951 <th scope="row" valign="top"><label for="max_lockouts"><?php echo __('Max Lockouts','loginizer'); ?></label></th>
1952 <td>
1953 <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 />
1954 </td>
1955 </tr>
1956 <tr>
1957 <th scope="row" valign="top"><label for="lockouts_extend"><?php echo __('Extend Lockout','loginizer'); ?></label></th>
1958 <td>
1959 <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 />
1960 </td>
1961 </tr>
1962 <tr>
1963 <th scope="row" valign="top"><label for="reset_retries"><?php echo __('Reset Retries','loginizer'); ?></label></th>
1964 <td>
1965 <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 />
1966 </td>
1967 </tr>
1968 <tr>
1969 <th scope="row" valign="top"><label for="notify_email"><?php echo __('Email Notification','loginizer'); ?></label></th>
1970 <td>
1971 <?php echo __('after ','loginizer'); ?>
1972 <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'); ?>
1973 </td>
1974 </tr>
1975 </table><br />
1976 <input name="save_lz" class="button button-primary action" value="<?php echo __('Save Settings','loginizer'); ?>" type="submit" />
1977 <?php
1978
1979 if(empty($loginizer['disable_brute'])){
1980
1981 echo '<input name="disable_brute_lz" class="button action" value="'.__('Disable Brute Force Protection','loginizer').'" type="submit" style="float:right" />';
1982
1983 }else{
1984
1985 echo '<input name="enable_brute_lz" class="button button-primary action" value="'.__('Enable Brute Force Protection','loginizer').'" type="submit" style="float:right" />';
1986
1987 }
1988
1989 ?>
1990 </form>
1991
1992 </div>
1993 </div>
1994 <br />
1995
1996 <?php
1997
1998 wp_enqueue_script('jquery-paginate', LOGINIZER_URL.'/jquery-paginate.js', array('jquery'), '1.10.15');
1999
2000 ?>
2001
2002 <style>
2003 .page-navigation a {
2004 margin: 5px 2px;
2005 display: inline-block;
2006 padding: 5px 8px;
2007 color: #0073aa;
2008 background: #e5e5e5 none repeat scroll 0 0;
2009 border: 1px solid #ccc;
2010 text-decoration: none;
2011 transition-duration: 0.05s;
2012 transition-property: border, background, color;
2013 transition-timing-function: ease-in-out;
2014 }
2015
2016 .page-navigation a[data-selected] {
2017 background-color: #00a0d2;
2018 color: #fff;
2019 }
2020 </style>
2021
2022 <script>
2023
2024 jQuery(document).ready(function(){
2025 jQuery('#lz_bl_table').paginate({ limit: 11, navigationWrapper: jQuery('#lz_bl_nav')});
2026 jQuery('#lz_wl_table').paginate({ limit: 11, navigationWrapper: jQuery('#lz_wl_nav')});
2027 });
2028
2029 // Delete a Blacklist / Whitelist IP Range
2030 function del_confirm(field, todo_id, msg){
2031 var ret = confirm(msg);
2032
2033 if(ret){
2034 jQuery('#lz_bl_wl_todo').attr('name', field);
2035 jQuery('#lz_bl_wl_todo').val(todo_id);
2036 jQuery('#lz_bl_wl_form').submit();
2037 }
2038
2039 return false;
2040
2041 }
2042
2043 // Delete all Blacklist / Whitelist IP Ranges
2044 function del_confirm_all(msg){
2045 var ret = confirm(msg);
2046
2047 if(ret){
2048 return true;
2049 }
2050
2051 return false;
2052
2053 }
2054
2055 </script>
2056
2057 <div id="" class="postbox">
2058
2059 <div class="postbox-header">
2060 <h2 class="hndle ui-sortable-handle">
2061 <span><?php echo __('Blacklist IP','loginizer'); ?></span>
2062 </h2>
2063 </div>
2064
2065 <div class="inside">
2066
2067 <?php echo __('Enter the IP you want to blacklist from login','loginizer'); ?>
2068
2069 <form action="" method="post">
2070 <?php wp_nonce_field('loginizer-options'); ?>
2071 <table class="form-table">
2072 <tr>
2073 <th scope="row" valign="top"><label for="start_ip"><?php echo __('Start IP','loginizer'); ?></label></th>
2074 <td>
2075 <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 />
2076 </td>
2077 </tr>
2078 <tr>
2079 <th scope="row" valign="top"><label for="end_ip"><?php echo __('End IP (Optional)','loginizer'); ?></label></th>
2080 <td>
2081 <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 />
2082 </td>
2083 </tr>
2084 </table><br />
2085 <input name="blacklist_iprange" class="button button-primary action" value="<?php echo __('Add Blacklist IP Range','loginizer'); ?>" type="submit" />
2086 <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" />
2087 </form>
2088 </div>
2089
2090 <div id="lz_bl_nav" style="margin: 5px 10px; text-align:right"></div>
2091 <table id="lz_bl_table" class="wp-list-table fixed striped users" border="0" width="95%" cellpadding="10" align="center">
2092 <tr>
2093 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Start IP','loginizer'); ?></th>
2094 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('End IP','loginizer'); ?></th>
2095 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Date (DD/MM/YYYY)','loginizer'); ?></th>
2096 <th scope="row" valign="top" style="background:#EFEFEF;" width="100"><?php echo __('Options','loginizer'); ?></th>
2097 </tr>
2098 <?php
2099 if(empty($loginizer['blacklist'])){
2100 echo '
2101 <tr>
2102 <td colspan="4">
2103 '.__('No Blacklist IPs. You will see blacklisted IP ranges here.', 'loginizer').'
2104 </td>
2105 </tr>';
2106 }else{
2107 foreach($loginizer['blacklist'] as $ik => $iv){
2108 echo '
2109 <tr>
2110 <td>
2111 '.$iv['start'].'
2112 </td>
2113 <td>
2114 '.$iv['end'].'
2115 </td>
2116 <td>
2117 '.date('d/m/Y', $iv['time']).'
2118 </td>
2119 <td>
2120 <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>
2121 </td>
2122 </tr>';
2123 }
2124 }
2125 ?>
2126 </table>
2127 <br />
2128 <form action="" method="post" id="lz_bl_wl_form">
2129 <?php wp_nonce_field('loginizer-options'); ?>
2130 <input type="hidden" value="" name="" id="lz_bl_wl_todo"/>
2131 </form>
2132 </div>
2133
2134 <br />
2135
2136 <div id="" class="postbox">
2137
2138 <div class="postbox-header">
2139 <h2 class="hndle ui-sortable-handle">
2140 <span><?php echo __('Whitelist IP', 'loginizer'); ?></span>
2141 </h2>
2142 </div>
2143
2144 <div class="inside">
2145
2146 <?php echo __('Enter the IP you want to whitelist for login','loginizer'); ?>
2147 <form action="" method="post">
2148 <?php wp_nonce_field('loginizer-options'); ?>
2149 <table class="form-table">
2150 <tr>
2151 <th scope="row" valign="top"><label for="start_ip_w"><?php echo __('Start IP','loginizer'); ?></label></th>
2152 <td>
2153 <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 />
2154 </td>
2155 </tr>
2156 <tr>
2157 <th scope="row" valign="top"><label for="end_ip_w"><?php echo __('End IP (Optional)','loginizer'); ?></label></th>
2158 <td>
2159 <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 />
2160 </td>
2161 </tr>
2162 </table><br />
2163 <input name="whitelist_iprange" class="button button-primary action" value="<?php echo __('Add Whitelist IP Range','loginizer'); ?>" type="submit" />
2164 <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" />
2165 </form>
2166 </div>
2167
2168 <div id="lz_wl_nav" style="margin: 5px 10px; text-align:right"></div>
2169 <table id="lz_wl_table" class="wp-list-table fixed striped users" border="0" width="95%" cellpadding="10" align="center">
2170 <tr>
2171 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Start IP','loginizer'); ?></th>
2172 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('End IP','loginizer'); ?></th>
2173 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Date (DD/MM/YYYY)','loginizer'); ?></th>
2174 <th scope="row" valign="top" style="background:#EFEFEF;" width="100"><?php echo __('Options','loginizer'); ?></th>
2175 </tr>
2176 <?php
2177 if(empty($loginizer['whitelist'])){
2178 echo '
2179 <tr>
2180 <td colspan="4">
2181 '.__('No Whitelist IPs. You will see whitelisted IP ranges here.', 'loginizer').'
2182 </td>
2183 </tr>';
2184 }else{
2185 foreach($loginizer['whitelist'] as $ik => $iv){
2186 echo '
2187 <tr>
2188 <td>
2189 '.$iv['start'].'
2190 </td>
2191 <td>
2192 '.$iv['end'].'
2193 </td>
2194 <td>
2195 '.date('d/m/Y', $iv['time']).'
2196 </td>
2197 <td>
2198 <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>
2199 </td>
2200 </tr>';
2201 }
2202 }
2203 ?>
2204 </table>
2205 <br />
2206
2207 </div>
2208
2209 <div id="" class="postbox">
2210
2211 <div class="postbox-header">
2212 <h2 class="hndle ui-sortable-handle">
2213 <span><?php echo __('Error Messages', 'loginizer'); ?></span>
2214 </h2>
2215 </div>
2216
2217 <div class="inside">
2218
2219 <form action="" method="post" enctype="multipart/form-data">
2220 <?php wp_nonce_field('loginizer-options'); ?>
2221 <table class="form-table">
2222 <tr>
2223 <th scope="row" valign="top"><label for="msg_inv_userpass"><?php echo __('Failed Login Attempt','loginizer'); ?></label></th>
2224 <td>
2225 <input type="text" size="25" value="<?php echo esc_attr(@$saved_msgs['inv_userpass']); ?>" name="msg_inv_userpass" id="msg_inv_userpass" />
2226 <?php echo __('Default: <em>&quot;' . $loginizer['d_msg']['inv_userpass']. '&quot;</em>', 'loginizer'); ?><br />
2227 </td>
2228 </tr>
2229 <tr>
2230 <th scope="row" valign="top"><label for="msg_ip_blacklisted"><?php echo __('Blacklisted IP','loginizer'); ?></label></th>
2231 <td>
2232 <input type="text" size="25" value="<?php echo esc_attr(@$saved_msgs['ip_blacklisted']); ?>" name="msg_ip_blacklisted" id="msg_ip_blacklisted" />
2233 <?php echo __('Default: <em>&quot;' . $loginizer['d_msg']['ip_blacklisted']. '&quot;</em>', 'loginizer'); ?><br />
2234 </td>
2235 </tr>
2236 <tr>
2237 <th scope="row" valign="top"><label for="msg_attempts_left"><?php echo __('Attempts Left','loginizer'); ?></label></th>
2238 <td>
2239 <input type="text" size="25" value="<?php echo esc_attr(@$saved_msgs['attempts_left']); ?>" name="msg_attempts_left" id="msg_attempts_left" />
2240 <?php echo __('Default: <em>&quot;' . $loginizer['d_msg']['attempts_left']. '&quot;</em>', 'loginizer'); ?><br />
2241 </td>
2242 </tr>
2243 <tr>
2244 <th scope="row" valign="top"><label for="msg_lockout_err"><?php echo __('Lockout Error','loginizer'); ?></label></th>
2245 <td>
2246 <input type="text" size="25" value="<?php echo esc_attr(@$saved_msgs['lockout_err']); ?>" name="msg_lockout_err" id="msg_lockout_err" />
2247 <?php echo __('Default: <em>&quot;' . strip_tags($loginizer['d_msg']['lockout_err']). '&quot;</em>', 'loginizer'); ?><br />
2248 </td>
2249 </tr>
2250 <tr>
2251 <th scope="row" valign="top"><label for="msg_minutes_err"><?php echo __('Minutes','loginizer'); ?></label></th>
2252 <td>
2253 <input type="text" size="25" value="<?php echo esc_attr(@$saved_msgs['minutes_err']); ?>" name="msg_minutes_err" id="msg_minutes_err" />
2254 <?php echo __('Default: <em>&quot;' . strip_tags($loginizer['d_msg']['minutes_err']). '&quot;</em>', 'loginizer'); ?><br />
2255 </td>
2256 </tr>
2257 <tr>
2258 <th scope="row" valign="top"><label for="msg_hours_err"><?php echo __('Hours','loginizer'); ?></label></th>
2259 <td>
2260 <input type="text" size="25" value="<?php echo esc_attr(@$saved_msgs['hours_err']); ?>" name="msg_hours_err" id="msg_hours_err" />
2261 <?php echo __('Default: <em>&quot;' . strip_tags($loginizer['d_msg']['hours_err']). '&quot;</em>', 'loginizer'); ?><br />
2262 </td>
2263 </tr>
2264 </table><br />
2265 <input name="save_err_msgs_lz" class="button button-primary action" value="<?php echo __('Save Error Messages','loginizer'); ?>" type="submit" />
2266 </form>
2267 </div>
2268 </div>
2269 <?php
2270
2271 loginizer_page_footer();
2272
2273 }
2274
2275 //---------------------
2276 // Admin Menu Pro Pages
2277 //---------------------
2278
2279 // Loginizer - reCaptcha Page
2280 function loginizer_page_recaptcha(){
2281
2282 global $loginizer, $lz_error, $lz_env;
2283
2284 if(!current_user_can('manage_options')){
2285 wp_die('Sorry, but you do not have permissions to change settings.');
2286 }
2287
2288 if(!loginizer_is_premium() && count($_POST) > 0){
2289 $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');
2290 return loginizer_page_recaptcha_T();
2291 }
2292
2293 /* Make sure post was from this page */
2294 if(count($_POST) > 0){
2295 check_admin_referer('loginizer-options');
2296 }
2297
2298 // Themes
2299 $lz_env['theme']['light'] = 'Light';
2300 $lz_env['theme']['dark'] = 'Dark';
2301
2302 // Langs
2303 $lz_env['lang'][''] = 'Auto Detect';
2304 $lz_env['lang']['ar'] = 'Arabic';
2305 $lz_env['lang']['bg'] = 'Bulgarian';
2306 $lz_env['lang']['ca'] = 'Catalan';
2307 $lz_env['lang']['zh-CN'] = 'Chinese (Simplified)';
2308 $lz_env['lang']['zh-TW'] = 'Chinese (Traditional)';
2309 $lz_env['lang']['hr'] = 'Croatian';
2310 $lz_env['lang']['cs'] = 'Czech';
2311 $lz_env['lang']['da'] = 'Danish';
2312 $lz_env['lang']['nl'] = 'Dutch';
2313 $lz_env['lang']['en-GB'] = 'English (UK)';
2314 $lz_env['lang']['en'] = 'English (US)';
2315 $lz_env['lang']['fil'] = 'Filipino';
2316 $lz_env['lang']['fi'] = 'Finnish';
2317 $lz_env['lang']['fr'] = 'French';
2318 $lz_env['lang']['fr-CA'] = 'French (Canadian)';
2319 $lz_env['lang']['de'] = 'German';
2320 $lz_env['lang']['de-AT'] = 'German (Austria)';
2321 $lz_env['lang']['de-CH'] = 'German (Switzerland)';
2322 $lz_env['lang']['el'] = 'Greek';
2323 $lz_env['lang']['iw'] = 'Hebrew';
2324 $lz_env['lang']['hi'] = 'Hindi';
2325 $lz_env['lang']['hu'] = 'Hungarain';
2326 $lz_env['lang']['id'] = 'Indonesian';
2327 $lz_env['lang']['it'] = 'Italian';
2328 $lz_env['lang']['ja'] = 'Japanese';
2329 $lz_env['lang']['ko'] = 'Korean';
2330 $lz_env['lang']['lv'] = 'Latvian';
2331 $lz_env['lang']['lt'] = 'Lithuanian';
2332 $lz_env['lang']['no'] = 'Norwegian';
2333 $lz_env['lang']['fa'] = 'Persian';
2334 $lz_env['lang']['pl'] = 'Polish';
2335 $lz_env['lang']['pt'] = 'Portuguese';
2336 $lz_env['lang']['pt-BR'] = 'Portuguese (Brazil)';
2337 $lz_env['lang']['pt-PT'] = 'Portuguese (Portugal)';
2338 $lz_env['lang']['ro'] = 'Romanian';
2339 $lz_env['lang']['ru'] = 'Russian';
2340 $lz_env['lang']['sr'] = 'Serbian';
2341 $lz_env['lang']['sk'] = 'Slovak';
2342 $lz_env['lang']['sl'] = 'Slovenian';
2343 $lz_env['lang']['es'] = 'Spanish';
2344 $lz_env['lang']['es-419'] = 'Spanish (Latin America)';
2345 $lz_env['lang']['sv'] = 'Swedish';
2346 $lz_env['lang']['th'] = 'Thai';
2347 $lz_env['lang']['tr'] = 'Turkish';
2348 $lz_env['lang']['uk'] = 'Ukrainian';
2349 $lz_env['lang']['vi'] = 'Vietnamese';
2350
2351 // Sizes
2352 $lz_env['size']['normal'] = 'Normal';
2353 $lz_env['size']['compact'] = 'Compact';
2354
2355 if(isset($_POST['save_lz'])){
2356
2357 // Google Captcha
2358 $option['captcha_type'] = lz_optpost('captcha_type');
2359 $option['captcha_key'] = lz_optpost('captcha_key');
2360 $option['captcha_secret'] = lz_optpost('captcha_secret');
2361 $option['captcha_theme'] = lz_optpost('captcha_theme');
2362 $option['captcha_size'] = lz_optpost('captcha_size');
2363 $option['captcha_lang'] = lz_optpost('captcha_lang');
2364
2365 // No Google Captcha
2366 $option['captcha_text'] = lz_optpost('captcha_text');
2367 $option['captcha_time'] = (int) lz_optpost('captcha_time');
2368 $option['captcha_words'] = (int) lz_optpost('captcha_words');
2369 $option['captcha_add'] = (int) lz_optpost('captcha_add');
2370 $option['captcha_subtract'] = (int) lz_optpost('captcha_subtract');
2371 $option['captcha_multiply'] = (int) lz_optpost('captcha_multiply');
2372 $option['captcha_divide'] = (int) lz_optpost('captcha_divide');
2373
2374 // Checkboxes
2375 $option['captcha_user_hide'] = (int) lz_optpost('captcha_user_hide');
2376 $option['captcha_no_css_login'] = (int) lz_optpost('captcha_no_css_login');
2377 $option['captcha_login'] = (int) lz_optpost('captcha_login');
2378 $option['captcha_lostpass'] = (int) lz_optpost('captcha_lostpass');
2379 $option['captcha_resetpass'] = (int) lz_optpost('captcha_resetpass');
2380 $option['captcha_register'] = (int) lz_optpost('captcha_register');
2381 $option['captcha_comment'] = (int) lz_optpost('captcha_comment');
2382 $option['captcha_wc_checkout'] = (int) lz_optpost('captcha_wc_checkout');
2383
2384 // Are we to use Math Captcha ?
2385 if(isset($_POST['captcha_no_google'])){
2386
2387 $option['captcha_no_google'] = 1;
2388
2389 // Make the checks
2390 if(strlen($option['captcha_text']) < 1){
2391 $lz_error['captcha_text'] = __('The Captcha key was not submitted', 'loginizer');
2392 }
2393
2394 }else{
2395
2396 // Make the checks
2397 if(strlen($option['captcha_key']) < 32 || strlen($option['captcha_key']) > 50){
2398 $lz_error['captcha_key'] = __('The reCAPTCHA key is invalid', 'loginizer');
2399 }
2400
2401 // Is secret valid ?
2402 if(strlen($option['captcha_secret']) < 32 || strlen($option['captcha_secret']) > 50){
2403 $lz_error['captcha_secret'] = __('The reCAPTCHA secret is invalid', 'loginizer');
2404 }
2405
2406 // Is theme valid ?
2407 if(empty($lz_env['theme'][$option['captcha_theme']])){
2408 $lz_error['captcha_theme'] = __('The reCAPTCHA theme is invalid', 'loginizer');
2409 }
2410
2411 // Is size valid ?
2412 if(empty($lz_env['size'][$option['captcha_size']])){
2413 $lz_error['captcha_size'] = __('The reCAPTCHA size is invalid', 'loginizer');
2414 }
2415
2416 // Is lang valid ?
2417 if(empty($lz_env['lang'][$option['captcha_lang']])){
2418 $lz_error['captcha_lang'] = __('The reCAPTCHA language is invalid', 'loginizer');
2419 }
2420
2421 }
2422
2423 // Is there an error ?
2424 if(!empty($lz_error)){
2425 return loginizer_page_recaptcha_T();
2426 }
2427
2428 // Save the options
2429 update_option('loginizer_captcha', $option);
2430
2431 // Mark as saved
2432 $GLOBALS['lz_saved'] = true;
2433
2434 }
2435
2436 // Clear this
2437 if(isset($_POST['clear_captcha_lz'])){
2438
2439 // Save the options
2440 update_option('loginizer_captcha', '');
2441
2442 // Mark as saved
2443 $GLOBALS['lz_cleared'] = true;
2444
2445 }
2446
2447 // Call the theme
2448 loginizer_page_recaptcha_T();
2449
2450 }
2451
2452 // Loginizer - reCaptcha Page Theme
2453 function loginizer_page_recaptcha_T(){
2454
2455 global $loginizer, $lz_error, $lz_env;
2456
2457 // Universal header
2458 loginizer_page_header('reCAPTCHA Settings');
2459
2460 loginizer_feature_available('reCAPTCHA');
2461
2462 // Saved ?
2463 if(!empty($GLOBALS['lz_saved'])){
2464 echo '<div id="message" class="updated"><p>'. __('The settings were saved successfully', 'loginizer'). '</p></div><br />';
2465 }
2466
2467 // Cleared ?
2468 if(!empty($GLOBALS['lz_cleared'])){
2469 echo '<div id="message" class="updated"><p>'. __('reCAPTCHA has been disabled !', 'loginizer'). '</p></div><br />';
2470 }
2471
2472 // Any errors ?
2473 if(!empty($lz_error)){
2474 lz_report_error($lz_error);echo '<br />';
2475 }
2476
2477 ?>
2478
2479 <style>
2480 input[type="text"], textarea, select {
2481 width: 70%;
2482 }
2483 </style>
2484
2485 <div id="" class="postbox">
2486
2487 <div class="postbox-header">
2488 <h2 class="hndle ui-sortable-handle">
2489 <span><?php echo __('reCAPTCHA Settings', 'loginizer'); ?></span>
2490 </h2>
2491 </div>
2492
2493 <div class="inside">
2494
2495 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
2496 <?php wp_nonce_field('loginizer-options'); ?>
2497 <table class="form-table">
2498 <tr class="lz_google_cap">
2499 <td scope="row" valign="top" style="width:300px !important; padding-left:0px"><label><b><?php echo __('reCAPTCHA type', 'loginizer'); ?></b></label><br>
2500 <?php echo __('Choose the type of reCAPTCHA', 'loginizer'); ?><br />
2501 <?php echo __('<a href="https://g.co/recaptcha/sitetypes/" target="_blank">See Site Types for more details</a>', 'loginizer'); ?>
2502 </td>
2503 <td>
2504 <input type="radio" value="v3" onchange="google_recaptcha_type(this)" <?php echo lz_POSTradio('captcha_type', 'v3', $loginizer['captcha_type']); ?> name="captcha_type" id="captcha_type_v3" /> <label for="captcha_type_v3"><?php echo __('reCAPTCHA v3', 'loginizer'); ?></label><br /><br />
2505 <input type="radio" value="" onchange="google_recaptcha_type(this)" <?php echo lz_POSTradio('captcha_type', '', $loginizer['captcha_type']); ?> name="captcha_type" id="captcha_type_v2" /> <label for="captcha_type_v2"><?php echo __('reCAPTCHA v2 - Checkbox', 'loginizer'); ?></label><br /><br />
2506 <input type="radio" value="v2_invisible" onchange="google_recaptcha_type(this)" <?php echo lz_POSTradio('captcha_type', 'v2_invisible', $loginizer['captcha_type']); ?> name="captcha_type" id="captcha_type_v2_invisible" /> <label for="captcha_type_v2_invisible"><?php echo __('reCAPTCHA v2 - Invisible', 'loginizer'); ?></label><br />
2507 </td>
2508 </tr>
2509 <tr class="lz_google_cap">
2510 <td scope="row" valign="top" style="width:300px !important; padding-left:0px"><label><b><?php echo __('Site Key', 'loginizer'); ?></b></label><br>
2511 <?php echo __('Make sure you enter the correct keys as per the reCAPTCHA type selected above', 'loginizer'); ?>
2512 </td>
2513 <td>
2514 <input type="text" size="50" value="<?php echo lz_optpost('captcha_key', $loginizer['captcha_key']); ?>" name="captcha_key" /><br />
2515 <?php echo __('Get the Site Key and Secret Key from <a href="https://www.google.com/recaptcha/" target="_blank">Google</a>', 'loginizer'); ?>
2516 </td>
2517 </tr>
2518 <tr class="lz_google_cap">
2519 <th scope="row" valign="top"><label><?php echo __('Secret Key', 'loginizer'); ?></label></th>
2520 <td>
2521 <input type="text" size="50" value="<?php echo lz_optpost('captcha_secret', $loginizer['captcha_secret']); ?>" name="captcha_secret" />
2522 </td>
2523 </tr>
2524 <tr class="lz_google_cap">
2525 <th scope="row" valign="top"><label><?php echo __('Theme', 'loginizer'); ?></label></th>
2526 <td>
2527 <select name="captcha_theme">
2528 <?php
2529 foreach($lz_env['theme'] as $k => $v){
2530 echo '<option '.lz_POSTselect('captcha_theme', $k, ($loginizer['captcha_theme'] == $k ? true : false)).' value="'.$k.'">'.$v.'</value>';
2531 }
2532 ?>
2533 </select>
2534 </td>
2535 </tr>
2536 <tr class="lz_google_cap">
2537 <th scope="row" valign="top"><label><?php echo __('Language', 'loginizer'); ?></label></th>
2538 <td>
2539 <select name="captcha_lang">
2540 <?php
2541 foreach($lz_env['lang'] as $k => $v){
2542 echo '<option '.lz_POSTselect('captcha_lang', $k, ($loginizer['captcha_lang'] == $k ? true : false)).' value="'.$k.'">'.$v.'</value>';
2543 }
2544 ?>
2545 </select>
2546 </td>
2547 </tr>
2548 <tr class="lz_google_cap lz_google_cap_size">
2549 <th scope="row" valign="top"><label><?php echo __('Size', 'loginizer'); ?></label></th>
2550 <td>
2551 <select name="captcha_size">
2552 <?php
2553 foreach($lz_env['size'] as $k => $v){
2554 echo '<option '.lz_POSTselect('captcha_size', $k, ($loginizer['captcha_size'] == $k ? true : false)).' value="'.$k.'">'.$v.'</value>';
2555 }
2556 ?>
2557 </select>
2558 </td>
2559 </tr>
2560 <tr>
2561 <td scope="row" valign="top" style="padding-left:0px">
2562 <label><b><?php echo __('Don\'t use Google reCAPTCHA', 'loginizer'); ?></b></label><br>
2563 <?php echo __('If selected, '.$loginizer['prefix'].' will use a simple Math Captcha instead of Google reCAPTCHA', 'loginizer'); ?>
2564 </td>
2565 <td>
2566 <input type="checkbox" onclick="no_google_recaptcha(this)" id="captcha_no_google" value="1" name="captcha_no_google" <?php echo lz_POSTchecked('captcha_no_google', (empty($loginizer['captcha_no_google']) ? false : true)); ?> />
2567 </td>
2568 </tr>
2569 <tr class="lz_math_cap">
2570 <td scope="row" valign="top" style="width:300px !important; padding-left:0px">
2571 <label><b><?php echo __('Captcha Text', 'loginizer'); ?></b></label><br>
2572 <?php echo __('The text to be shown for the Captcha Field', 'loginizer'); ?>
2573 </td>
2574 <td>
2575 <input type="text" size="30" value="<?php echo lz_optpost('captcha_text', @$loginizer['captcha_text']); ?>" name="captcha_text" />
2576 </td>
2577 </tr>
2578 <tr class="lz_math_cap">
2579 <td scope="row" valign="top" style="padding-left:0px">
2580 <label><b><?php echo __('Captcha Time', 'loginizer'); ?></b></label><br>
2581 <?php echo __('Enter the number of seconds, a user has to enter captcha value.', 'loginizer'); ?>
2582 </td>
2583 <td>
2584 <input type="text" size="30" value="<?php echo lz_optpost('captcha_time', @$loginizer['captcha_time']); ?>" name="captcha_time" />
2585 </td>
2586 </tr>
2587 <tr class="lz_math_cap">
2588 <td scope="row" valign="top" style="padding-left:0px">
2589 <label><b><?php echo __('Display Captcha in Words', 'loginizer'); ?></b></label><br>
2590 <?php echo __('If selected the Captcha will be displayed in words rather than numbers', 'loginizer'); ?>
2591 </td>
2592 <td>
2593 <input type="checkbox" value="1" name="captcha_words" <?php echo lz_POSTchecked('captcha_words', (empty($loginizer['captcha_words']) ? false : true));?> />
2594 </td>
2595 </tr>
2596 <tr class="lz_math_cap">
2597 <td scope="row" valign="top" style="vertical-align: top !important; padding-left:0px">
2598 <label><b><?php echo __('Mathematical operations', 'loginizer'); ?></b></label><br>
2599 <?php echo __('The Mathematical operations to use for Captcha', 'loginizer'); ?>
2600 </td>
2601 <td valign="top">
2602 <table class="wp-list-table fixed users" cellpadding="8" cellspacing="1">
2603 <?php echo '
2604 <tr>
2605 <td>'.__('Addition (+)', 'loginizer').'</td>
2606 <td><input type="checkbox" value="1" name="captcha_add" '.lz_POSTchecked('captcha_add', (empty($loginizer['captcha_add']) ? false : true)).' /></td>
2607 </tr>
2608 <tr>
2609 <td>'.__('Subtraction (-)', 'loginizer').'</td>
2610 <td><input type="checkbox" value="1" name="captcha_subtract" '.lz_POSTchecked('captcha_subtract', (empty($loginizer['captcha_subtract']) ? false : true)).' /></td>
2611 </tr>
2612 <tr>
2613 <td>'.__('Multiplication (x)', 'loginizer').'</td>
2614 <td><input type="checkbox" value="1" name="captcha_multiply" '.lz_POSTchecked('captcha_multiply', (empty($loginizer['captcha_multiply']) ? false : true)).' /></td>
2615 </tr>
2616 <tr>
2617 <td>'.__('Division (รท)', 'loginizer').'</td>
2618 <td><input type="checkbox" value="1" name="captcha_divide" '.lz_POSTchecked('captcha_divide', (empty($loginizer['captcha_divide']) ? false : true)).' /></td>
2619 </tr>';
2620 ?>
2621 </table>
2622 </td>
2623 </tr>
2624 <tr>
2625 <th scope="row" valign="top"><label><?php echo __('Show Captcha On', 'loginizer'); ?></label></th>
2626 <td valign="top">
2627 <table class="wp-list-table fixed users" cellpadding="8" cellspacing="1">
2628 <?php echo '
2629 <tr>
2630 <td>'.__('Login Form', 'loginizer').'</td>
2631 <td><input type="checkbox" value="1" name="captcha_login" '.lz_POSTchecked('captcha_login', (empty($loginizer['captcha_login']) ? false : true)).' /></td>
2632 </tr>
2633 <tr>
2634 <td>'.__('Lost Password Form', 'loginizer').'</td>
2635 <td><input type="checkbox" value="1" name="captcha_lostpass" '.lz_POSTchecked('captcha_lostpass', (empty($loginizer['captcha_lostpass']) ? false : true)).' /></td>
2636 </tr>
2637 <tr>
2638 <td>'.__('Reset Password Form', 'loginizer').'</td>
2639 <td><input type="checkbox" value="1" name="captcha_resetpass" '.lz_POSTchecked('captcha_resetpass', (empty($loginizer['captcha_resetpass']) ? false : true)).' /></td>
2640 </tr>
2641 <tr>
2642 <td>'.__('Registration Form', 'loginizer').'</td>
2643 <td><input type="checkbox" value="1" name="captcha_register" '.lz_POSTchecked('captcha_register', (empty($loginizer['captcha_register']) ? false : true)).' /></td>
2644 </tr>
2645 <tr>
2646 <td>'.__('Comment Form', 'loginizer').'</td>
2647 <td><input type="checkbox" value="1" name="captcha_comment" '.lz_POSTchecked('captcha_comment', (empty($loginizer['captcha_comment']) ? false : true)).' /></td>
2648 </tr>';
2649
2650 if(!defined('SITEPAD')){
2651
2652 echo '<tr>
2653 <td>'.__('WooCommerce Checkout', 'loginizer').'</td>
2654 <td><input type="checkbox" value="1" name="captcha_wc_checkout" '.lz_POSTchecked('captcha_wc_checkout', (empty($loginizer['captcha_wc_checkout']) ? false : true)).' /></td>
2655 </tr>';
2656
2657 }
2658
2659 ?>
2660 </table>
2661 </td>
2662 </tr>
2663 <tr>
2664 <th scope="row" valign="top"><label><?php echo __('Hide CAPTCHA for logged in Users', 'loginizer'); ?></label></th>
2665 <td>
2666 <input type="checkbox" value="1" name="captcha_user_hide" <?php echo lz_POSTchecked('captcha_user_hide', (empty($loginizer['captcha_user_hide']) ? false : true)); ?> />
2667 </td>
2668 </tr>
2669 <tr class="lz_google_cap">
2670 <th scope="row" valign="top"><label><?php echo __('Disable CSS inserted on Login Page', 'loginizer'); ?></label></th>
2671 <td>
2672 <input type="checkbox" value="1" name="captcha_no_css_login" <?php echo lz_POSTchecked('captcha_no_css_login', (empty($loginizer['captcha_no_css_login']) ? false : true)); ?> />
2673 </td>
2674 </tr>
2675 </table><br />
2676 <center><input name="save_lz" class="button button-primary action" value="<?php echo __('Save Settings','loginizer'); ?>" type="submit" />
2677 <input style="float:right" name="clear_captcha_lz" class="button action" value="<?php echo __('Disable reCAPTCHA','loginizer'); ?>" type="submit" /></center>
2678 </form>
2679
2680 </div>
2681 </div>
2682 <br />
2683
2684 <script type="text/javascript">
2685
2686 function no_google_recaptcha(obj){
2687
2688 if(obj.checked){
2689 jQuery(".lz_google_cap").hide();
2690 jQuery(".lz_math_cap").show();
2691 }else{
2692 jQuery(".lz_google_cap").show();
2693 jQuery(".lz_math_cap").hide();
2694 }
2695
2696 var cur_captcha_type = jQuery("input:radio[name='captcha_type']:checked").val();
2697
2698 if(cur_captcha_type == 'v3' || cur_captcha_type == 'v2_invisible'){
2699 jQuery(".lz_google_cap_size").hide();
2700 }else{
2701 jQuery(".lz_google_cap_size").show();
2702 }
2703
2704 }
2705
2706 no_google_recaptcha(jQuery("#captcha_no_google")[0]);
2707
2708 function google_recaptcha_type(obj){
2709 if(obj.value == 'v3' || obj.value == 'v2_invisible'){
2710 jQuery(".lz_google_cap_size").hide();
2711 }else{
2712 jQuery(".lz_google_cap_size").show();
2713 }
2714 }
2715
2716
2717 </script>
2718
2719 <?php
2720 loginizer_page_footer();
2721
2722 }
2723
2724
2725 // Loginizer - Two Factor Auth Page
2726 function loginizer_page_2fa(){
2727
2728 global $loginizer, $lz_error, $lz_env, $lz_roles, $lz_options, $saved_msgs;
2729
2730 if(!current_user_can('manage_options')){
2731 wp_die('Sorry, but you do not have permissions to change settings.');
2732 }
2733
2734 if(!loginizer_is_premium() && count($_POST) > 0){
2735 $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');
2736 return loginizer_page_2fa_T();
2737 }
2738
2739 $lz_roles = get_editable_roles();
2740
2741 /* Make sure post was from this page */
2742 if(count($_POST) > 0){
2743 check_admin_referer('loginizer-options');
2744 }
2745
2746 // Settings submitted
2747 if(isset($_POST['save_lz'])){
2748
2749 // In the future there can be more settings
2750 $option['2fa_app'] = (int) lz_optpost('2fa_app');
2751 $option['2fa_email'] = (int) lz_optpost('2fa_email');
2752 $option['question'] = (int) lz_optpost('question');
2753 $option['2fa_email_force'] = (int) lz_optpost('2fa_email_force');
2754
2755 // Any roles to apply to ?
2756 foreach($lz_roles as $k => $v){
2757
2758 if(lz_optpost('2fa_roles_'.$k)){
2759 $option['2fa_roles'][$k] = 1;
2760 }
2761
2762 }
2763
2764 // If its all, then blank it
2765 if(lz_optpost('2fa_roles_all') || empty($option['2fa_roles'])){
2766 $option['2fa_roles'] = '';
2767 }
2768
2769 // Is there an error ?
2770 if(!empty($lz_error)){
2771 return loginizer_page_2fa_T();
2772 }
2773
2774 // Save the options
2775 update_option('loginizer_2fa', $option);
2776
2777 // Mark as saved
2778 $GLOBALS['lz_saved'] = true;
2779
2780 }
2781
2782 // Reset a users 2FA
2783 if(isset($_POST['reset_user_lz'])){
2784
2785 $_username = lz_optpost('lz_user_2fa_disable');
2786
2787 // Try to get the user
2788 $user_search = get_user_by('login', $_username);
2789
2790 // If not found then search by email
2791 if(empty($user_search)){
2792 $user_search = get_user_by('email', $_username);
2793 }
2794
2795 // If not found then give error
2796 if(empty($user_search)){
2797 $lz_error['2fa_user_not'] = __('There is no such user with the email or username you submitted', 'loginizer');
2798 return loginizer_page_2fa_T();
2799 }
2800
2801 // Get the user prefences
2802 $user_pref = get_user_meta($user_search->ID, 'loginizer_user_settings');
2803
2804 // Blank it
2805 $user_pref['pref'] = 'none';
2806
2807 // Save it
2808 update_user_meta($user_search->ID, 'loginizer_user_settings', $user_pref);
2809
2810 // Mark as saved
2811 $GLOBALS['lz_saved'] = __('The user\'s 2FA settings have been reset', 'loginizer');
2812
2813 }
2814
2815 if(isset($_POST['save_2fa_email_template_lz'])){
2816
2817 // In the future there can be more settings
2818 $option['2fa_email_sub'] = lz_optpost('lz_2fa_email_sub');
2819 $option['2fa_email_msg'] = lz_optpost('lz_2fa_email_msg');
2820
2821 // Is there an error ?
2822 if(!empty($lz_error)){
2823 return loginizer_page_2fa_T();
2824 }
2825
2826 // Save the options
2827 update_option('loginizer_2fa_email_template', $option);
2828
2829 // Mark as saved
2830 $GLOBALS['lz_saved'] = true;
2831
2832 }
2833
2834 // Save the messages
2835 if(isset($_POST['save_msgs_lz'])){
2836
2837 $msgs['otp_app'] = lz_optpost('msg_otp_app');
2838 $msgs['otp_email'] = lz_optpost('msg_otp_email');
2839 $msgs['otp_field'] = lz_optpost('msg_otp_field');
2840 $msgs['otp_question'] = lz_optpost('msg_otp_question');
2841 $msgs['otp_answer'] = lz_optpost('msg_otp_answer');
2842
2843 // Update them
2844 update_option('loginizer_2fa_msg', $msgs);
2845
2846 // Mark as saved
2847 $GLOBALS['lz_saved'] = __('Messages were saved successfully', 'loginizer');
2848
2849 }
2850
2851 // Delete a Whitelist IP range
2852 if(isset($_POST['delid'])){
2853
2854 $delid = (int) lz_optreq('delid');
2855
2856 // Unset and save
2857 $whitelist = $loginizer['2fa_whitelist'];
2858 unset($whitelist[$delid]);
2859 update_option('loginizer_2fa_whitelist', $whitelist);
2860
2861 // Mark as saved
2862 $GLOBALS['lz_saved'] = __('The Whitelist IP range has been deleted successfully', 'loginizer');
2863
2864 }
2865
2866 // Delete all Blackist IP ranges
2867 if(isset($_POST['del_all_whitelist'])){
2868
2869 // Unset and save
2870 update_option('loginizer_2fa_whitelist', array());
2871
2872 // Mark as saved
2873 $GLOBALS['lz_saved'] = __('The Whitelist IP range(s) have been cleared successfully', 'loginizer');
2874
2875 }
2876
2877 // Add IP range to 2FA whitelist
2878 if(isset($_POST['2fa_whitelist_iprange'])){
2879
2880 $start_ip = lz_optpost('start_ip_w_2fa');
2881 $end_ip = lz_optpost('end_ip_w_2fa');
2882
2883 if(empty($start_ip)){
2884 $lz_error[] = __('Please enter the Start IP', 'loginizer');
2885 return loginizer_page_2fa_T();
2886 }
2887
2888 // If no end IP we consider only 1 IP
2889 if(empty($end_ip)){
2890 $end_ip = $start_ip;
2891 }
2892
2893 if(!lz_valid_ip($start_ip)){
2894 $lz_error[] = __('Please provide a valid start IP', 'loginizer');
2895 }
2896
2897 if(!lz_valid_ip($end_ip)){
2898 $lz_error[] = __('Please provide a valid end IP', 'loginizer');
2899 }
2900
2901 if(inet_ptoi($start_ip) > inet_ptoi($end_ip)){
2902
2903 // BUT, if 0.0.0.1 - 255.255.255.255 is given, it will not work
2904 if(inet_ptoi($start_ip) >= 0 && inet_ptoi($end_ip) < 0){
2905 // This is right
2906 }else{
2907 $lz_error[] = __('The End IP cannot be smaller than the Start IP', 'loginizer');
2908 }
2909
2910 }
2911
2912 if(empty($lz_error)){
2913
2914 $whitelist = $loginizer['2fa_whitelist'];
2915
2916 foreach($whitelist as $k => $v){
2917
2918 // This is to check if there is any other range exists with the same Start or End IP
2919 if(( inet_ptoi($start_ip) <= inet_ptoi($v['start']) && inet_ptoi($v['start']) <= inet_ptoi($end_ip) )
2920 || ( inet_ptoi($start_ip) <= inet_ptoi($v['end']) && inet_ptoi($v['end']) <= inet_ptoi($end_ip) )
2921 ){
2922 $lz_error[] = __('The Start IP or End IP submitted conflicts with an existing IP range !', 'loginizer');
2923 break;
2924 }
2925
2926 // This is to check if there is any other range exists with the same Start IP
2927 if(inet_ptoi($v['start']) <= inet_ptoi($start_ip) && inet_ptoi($start_ip) <= inet_ptoi($v['end'])){
2928 $lz_error[] = __('The Start IP is present in an existing range !', 'loginizer');
2929 break;
2930 }
2931
2932 // This is to check if there is any other range exists with the same End IP
2933 if(inet_ptoi($v['start']) <= inet_ptoi($end_ip) && inet_ptoi($end_ip) <= inet_ptoi($v['end'])){
2934 $lz_error[] = __('The End IP is present in an existing range!', 'loginizer');
2935 break;
2936 }
2937
2938 }
2939
2940 $newid = ( empty($whitelist) ? 0 : max(array_keys($whitelist)) ) + 1;
2941
2942 if(empty($lz_error)){
2943
2944 $whitelist[$newid] = array();
2945 $whitelist[$newid]['start'] = $start_ip;
2946 $whitelist[$newid]['end'] = $end_ip;
2947 $whitelist[$newid]['time'] = time();
2948
2949 update_option('loginizer_2fa_whitelist', $whitelist);
2950
2951 // Mark as saved
2952 $GLOBALS['lz_saved'] = __('Whitelist IP range for Two Factor Authentication added successfully', 'loginizer');
2953
2954 }
2955
2956 }
2957 }
2958
2959
2960 $lz_options = get_option('loginizer_2fa_email_template');
2961 $saved_msgs = get_option('loginizer_2fa_msg');
2962 $loginizer['2fa_whitelist'] = get_option('loginizer_2fa_whitelist');
2963
2964 // Call theme
2965 loginizer_page_2fa_T();
2966
2967 }
2968
2969
2970 // Loginizer - Two Factor Auth Page
2971 function loginizer_page_2fa_T(){
2972
2973 global $loginizer, $lz_error, $lz_env, $lz_roles, $lz_options, $saved_msgs;
2974
2975 // Universal header
2976 loginizer_page_header('Two Factor Authentication');
2977
2978 loginizer_feature_available('Two-Factor Authentication');
2979
2980 // Saved ?
2981 if(!empty($GLOBALS['lz_saved'])){
2982 echo '<div id="message" class="updated"><p>'. __(is_string($GLOBALS['lz_saved']) ? $GLOBALS['lz_saved'] : 'The settings were saved successfully', 'loginizer'). '</p></div><br />';
2983 }
2984
2985 // Any errors ?
2986 if(!empty($lz_error)){
2987 lz_report_error($lz_error);echo '<br />';
2988 }
2989
2990 ?>
2991
2992 <style>
2993 input[type="text"], textarea, select {
2994 width: 70%;
2995 }
2996
2997 .form-table label{
2998 font-weight:bold;
2999 }
3000
3001 .exp{
3002 font-size:12px;
3003 }
3004 </style>
3005
3006 <div id="" class="postbox">
3007
3008 <div class="postbox-header">
3009 <h2 class="hndle ui-sortable-handle">
3010 <span><?php echo __('Two Factor Authentication Settings', 'loginizer'); ?></span>
3011 </h2>
3012 </div>
3013
3014 <div class="inside">
3015
3016 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
3017 <?php wp_nonce_field('loginizer-options'); ?>
3018 <table class="form-table">
3019 <tr>
3020 <td scope="row" valign="top" colspan="2">
3021 <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>
3022 </td>
3023 </tr>
3024 <tr>
3025 <td scope="row" valign="top" style="width:70% !important">
3026 <label><?php echo __('OTP via App', 'loginizer'); ?></label><br>
3027 <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>
3028 </td>
3029 <td>
3030 <input type="checkbox" value="1" name="2fa_app" <?php echo lz_POSTchecked('2fa_app', (empty($loginizer['2fa_app']) ? false : true), 'save_lz'); ?> />
3031 </td>
3032 </tr>
3033 <tr>
3034 <td scope="row" valign="top">
3035 <label><?php echo __('OTP via Email', 'loginizer'); ?></label><br>
3036 <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>
3037 </td>
3038 <td>
3039 <input type="checkbox" value="1" name="2fa_email" <?php echo lz_POSTchecked('2fa_email', (empty($loginizer['2fa_email']) ? false : true), 'save_lz'); ?> />
3040 </td>
3041 </tr>
3042 <tr>
3043 <td scope="row" valign="top">
3044 <label><?php echo __('User Defined Question & Answer', 'loginizer'); ?></label><br>
3045 <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>
3046 </td>
3047 <td>
3048 <input type="checkbox" value="1" name="question" <?php echo lz_POSTchecked('question', (empty($loginizer['question']) ? false : true), 'save_lz'); ?> />
3049 </td>
3050 </tr>
3051 </table><br />
3052
3053 <table class="form-table">
3054 <tr>
3055 <td scope="row" valign="top" style="width:70% !important">
3056 <label><?php echo __('Force OTP via Email', 'loginizer'); ?></label><br>
3057 <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>
3058 </td>
3059 <td>
3060 <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'); ?> />
3061 </td>
3062 </tr>
3063 <tr>
3064 <td scope="row" valign="top" style="width:70% !important">
3065 <label><?php echo __('Apply 2FA to Roles', 'loginizer'); ?></label><br>
3066 <span class="exp"><?php echo __('Select the Roles to which 2FA should be applied.', 'loginizer'); ?></span>
3067 </td>
3068 <td>
3069 <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 />
3070 <?php
3071
3072 foreach($lz_roles as $k => $v){
3073 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>';
3074 }
3075
3076 ?>
3077 </td>
3078 </tr>
3079 </table><br />
3080 <center><input name="save_lz" class="button button-primary action" value="<?php echo __('Save Settings', 'loginizer'); ?>" type="submit" /></center>
3081 </form>
3082
3083 </div>
3084 </div>
3085
3086 <script type="text/javascript">
3087
3088 function lz_roles_handle(){
3089
3090 var obj = jQuery("#2fa_roles_all")[0];
3091
3092 if(obj.checked){
3093 jQuery(".lz_roles").hide();
3094 }else{
3095 jQuery(".lz_roles").show();
3096 }
3097
3098 }
3099
3100 lz_roles_handle();
3101
3102 </script>
3103
3104 <div id="" class="postbox">
3105
3106 <div class="postbox-header">
3107 <h2 class="hndle ui-sortable-handle">
3108 <span><?php echo __('OTP via Email Template', 'loginizer'); ?></span>
3109 </h2>
3110 </div>
3111
3112 <div class="inside">
3113
3114 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
3115 <?php wp_nonce_field('loginizer-options'); ?>
3116 <table class="form-table">
3117 <tr>
3118 <td colspan="2" valign="top">
3119 <?php echo __('Customize the email template to be used when sending the OTP to login via Email for 2FA.', 'loginizer'); ?><br>
3120 <?php echo __('If you do not make changes below the default email template will be used !', 'loginizer'); ?>
3121 </td>
3122 </tr>
3123 <tr>
3124 <td scope="row" valign="top" style="width:350px !important">
3125 <label><?php echo __('Email Subject', 'loginizer'); ?></label><br>
3126 <span class="exp"><?php echo __('Set blank to reset to the default subject', 'loginizer'); ?></span>
3127 <br />Default : <?php echo @$loginizer['2fa_email_d_sub']; ?>
3128 </td>
3129 <td valign="top">
3130 <input type="text" size="40" value="<?php echo lz_optpost('lz_2fa_email_sub', @$lz_options['2fa_email_sub']); ?>" name="lz_2fa_email_sub" />
3131 </td>
3132 </tr>
3133 <tr>
3134 <td scope="row" valign="top">
3135 <label><?php echo __('Email Body', 'loginizer'); ?></label><br>
3136 <span class="exp"><?php echo __('Set blank to reset to the default message', 'loginizer'); ?></span>
3137 <br />Default : <pre style="font-size:10px"><?php echo @$loginizer['2fa_email_d_msg']; ?></pre>
3138 </td>
3139 <td valign="top">
3140 <textarea rows="10" name="lz_2fa_email_msg"><?php echo lz_optpost('lz_2fa_email_msg', @$lz_options['2fa_email_msg']); ?></textarea>
3141 <br />
3142 Variables :
3143 <br />$otp - The OTP for login
3144 <br />$site_name - The Site Name
3145 <br />$site_url - The Site URL
3146 <br />$email - Users Email
3147 <br />$display_name - Users Display Name
3148 <br />$user_login - Username
3149 <br />$first_name - Users First Name
3150 <br />$last_name - Users Last Name
3151 </td>
3152 </tr>
3153 </table><br />
3154 <center><input name="save_2fa_email_template_lz" class="button button-primary action" value="<?php echo __('Save Settings', 'loginizer'); ?>" type="submit" /></center>
3155 </form>
3156
3157 </div>
3158 </div>
3159
3160 <div id="" class="postbox">
3161
3162 <div class="postbox-header">
3163 <h2 class="hndle ui-sortable-handle">
3164 <span><?php echo __('Custom Messages for OTP', 'loginizer'); ?></span>
3165 </h2>
3166 </div>
3167
3168 <div class="inside">
3169
3170 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
3171 <?php wp_nonce_field('loginizer-options'); ?>
3172 <table class="form-table">
3173 <tr>
3174 <td colspan="2" valign="top">
3175 <?php echo __('Customize the title for OTP field displayed to the user on the login form.', 'loginizer'); ?><br>
3176 <?php echo __('If you do not make changes below the default messages will be used !', 'loginizer'); ?>
3177 </td>
3178 </tr>
3179 <tr>
3180 <td scope="row" valign="top" style="width:350px !important">
3181 <label for="msg_otp_app"><?php echo __('OTP via APP','loginizer'); ?></label><br />
3182 <?php echo __('Default: <em>&quot;' . $loginizer['2fa_d_msg']['otp_app']. '&quot;</em>', 'loginizer'); ?>
3183 </td>
3184 <td>
3185 <input type="text" size="50" value="<?php echo esc_attr(@$saved_msgs['otp_app']); ?>" name="msg_otp_app" id="msg_otp_app" style="width:auto !important;" />
3186 <br />
3187 </td>
3188 </tr>
3189 <tr>
3190 <td scope="row" valign="top" style="width:350px !important">
3191 <label for="msg_otp_email"><?php echo __('OTP via Email','loginizer'); ?></label><br />
3192 <?php echo __('Default: <em>&quot;' . $loginizer['2fa_d_msg']['otp_email']. '&quot;</em>', 'loginizer'); ?>
3193 </td>
3194 <td>
3195 <input type="text" size="50" value="<?php echo esc_attr(@$saved_msgs['otp_email']); ?>" name="msg_otp_email" id="msg_otp_email" style="width:auto !important;" />
3196 <br />
3197 </td>
3198 </tr>
3199 <tr>
3200 <td scope="row" valign="top" style="width:350px !important">
3201 <label for="msg_otp_field"><?php echo __('Title for OTP field','loginizer'); ?></label><br />
3202 <?php echo __('Default: <em>&quot;' . $loginizer['2fa_d_msg']['otp_field']. '&quot;</em>', 'loginizer'); ?>
3203 </td>
3204 <td>
3205 <input type="text" size="50" value="<?php echo esc_attr(@$saved_msgs['otp_field']); ?>" name="msg_otp_field" id="msg_otp_field" style="width:auto !important;" />
3206 <br />
3207 </td>
3208 </tr>
3209 <tr>
3210 <td scope="row" valign="top" style="width:350px !important">
3211 <label for="msg_otp_question"><?php echo __('Title for Security Question','loginizer'); ?></label><br />
3212 <?php echo __('Default: <em>&quot;' . $loginizer['2fa_d_msg']['otp_question']. '&quot;</em>', 'loginizer'); ?>
3213 </td>
3214 <td>
3215 <input type="text" size="50" value="<?php echo esc_attr(@$saved_msgs['otp_question']); ?>" name="msg_otp_question" id="msg_otp_question" style="width:auto !important;" />
3216 <br />
3217 </td>
3218 </tr>
3219 <tr>
3220 <td scope="row" valign="top" style="width:350px !important">
3221 <label for="msg_otp_answer"><?php echo __('Title for Security Answer','loginizer'); ?></label><br />
3222 <?php echo __('Default: <em>&quot;' . $loginizer['2fa_d_msg']['otp_answer']. '&quot;</em>', 'loginizer'); ?>
3223 </td>
3224 <td>
3225 <input type="text" size="50" value="<?php echo esc_attr(@$saved_msgs['otp_answer']); ?>" name="msg_otp_answer" id="msg_otp_answer" style="width:auto !important;" />
3226 <br />
3227 </td>
3228 </tr>
3229 </table><br />
3230 <center><input name="save_msgs_lz" class="button button-primary action" value="<?php echo __('Save Messages','loginizer'); ?>" type="submit" /></center>
3231 </form>
3232 </div>
3233 </div>
3234
3235 <!--Bypass a single user-->
3236 <div id="" class="postbox">
3237
3238 <div class="postbox-header">
3239 <h2 class="hndle ui-sortable-handle">
3240 <span><?php echo __('Disable Two Factor Authentication for a User', 'loginizer'); ?></span>
3241 </h2>
3242 </div>
3243
3244 <div class="inside">
3245
3246 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
3247 <?php wp_nonce_field('loginizer-options'); ?>
3248 <table class="form-table">
3249 <tr>
3250 <td scope="row" valign="top" colspan="2">
3251 <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>
3252 </td>
3253 </tr>
3254 <tr>
3255 <td scope="row" valign="top">
3256 <label><?php echo __('Username / Email', 'loginizer'); ?></label><br>
3257 <span class="exp"><?php echo __('The username or email of the user whose 2FA you would like to disable', 'loginizer'); ?></span>
3258 </td>
3259 <td>
3260 <input type="text" size="50" value="<?php echo lz_optpost('lz_user_2fa_disable', ''); ?>" name="lz_user_2fa_disable" />
3261 </td>
3262 </tr>
3263 </table><br />
3264
3265 <center><input name="reset_user_lz" class="button button-primary action" value="<?php echo __('Reset 2FA for User', 'loginizer'); ?>" type="submit" /></center>
3266 </form>
3267
3268 </div>
3269 </div>
3270
3271 <br />
3272
3273 <?php
3274
3275 wp_enqueue_script('jquery-paginate', LOGINIZER_URL.'/jquery-paginate.js', array('jquery'), '1.10.15');
3276
3277 ?>
3278
3279 <style>
3280 .page-navigation a {
3281 margin: 5px 2px;
3282 display: inline-block;
3283 padding: 5px 8px;
3284 color: #0073aa;
3285 background: #e5e5e5 none repeat scroll 0 0;
3286 border: 1px solid #ccc;
3287 text-decoration: none;
3288 transition-duration: 0.05s;
3289 transition-property: border, background, color;
3290 transition-timing-function: ease-in-out;
3291 }
3292
3293 .page-navigation a[data-selected] {
3294 background-color: #00a0d2;
3295 color: #fff;
3296 }
3297 </style>
3298
3299 <script>
3300
3301 jQuery(document).ready(function(){
3302 jQuery('#lz_wl_2fa_table').paginate({ limit: 11, navigationWrapper: jQuery('#lz_wl_2fa_nav')});
3303 });
3304
3305 // Delete a 2FA Whitelist IP Range
3306 function del_2fa_confirm(field, todo_id, msg){
3307 var ret = confirm(msg);
3308
3309 if(ret){
3310 jQuery('#lz_wl_2fa_todo').attr('name', field);
3311 jQuery('#lz_wl_2fa_todo').val(todo_id);
3312 jQuery('#lz_wl_2fa_form').submit();
3313 }
3314
3315 return false;
3316
3317 }
3318
3319 // Delete all 2FA Whitelist IP Ranges
3320 function del_2fa_confirm_all(msg){
3321 var ret = confirm(msg);
3322
3323 if(ret){
3324 return true;
3325 }
3326
3327 return false;
3328
3329 }
3330
3331 </script>
3332
3333 <div id="" class="postbox">
3334
3335 <div class="postbox-header">
3336 <h2 class="hndle ui-sortable-handle">
3337 <span><?php echo __('Disable Two Factor Authentication for IP', 'loginizer'); ?></span>
3338 </h2>
3339 </div>
3340
3341 <div class="inside">
3342
3343 <?php echo __('Enter the IP you want to whitelist for two factor authentication', 'loginizer'); ?>
3344 <form action="" method="post" loginizer-premium-only="1">
3345 <?php wp_nonce_field('loginizer-options'); ?>
3346 <table class="form-table">
3347 <tr>
3348 <th scope="row" valign="top"><label for="start_ip_w_2fa"><?php echo __('Start IP','loginizer'); ?></label></th>
3349 <td>
3350 <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 />
3351 </td>
3352 </tr>
3353 <tr>
3354 <th scope="row" valign="top"><label for="end_ip_w_2fa"><?php echo __('End IP (Optional)','loginizer'); ?></label></th>
3355 <td>
3356 <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 />
3357 </td>
3358 </tr>
3359 </table><br />
3360 <input name="2fa_whitelist_iprange" class="button button-primary action" value="<?php echo __('Add Whitelist IP Range','loginizer'); ?>" type="submit" />
3361 <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" />
3362 </form>
3363 </div>
3364
3365 <div id="lz_wl_2fa_nav" style="margin: 5px 10px; text-align:right"></div>
3366 <table id="lz_wl_2fa_table" class="wp-list-table fixed striped users" border="0" width="95%" cellpadding="10" align="center">
3367 <tr>
3368 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Start IP','loginizer'); ?></th>
3369 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('End IP','loginizer'); ?></th>
3370 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Date (DD/MM/YYYY)','loginizer'); ?></th>
3371 <th scope="row" valign="top" style="background:#EFEFEF;" width="100"><?php echo __('Options','loginizer'); ?></th>
3372 </tr>
3373 <?php
3374 if(empty($loginizer['2fa_whitelist'])){
3375 echo '
3376 <tr>
3377 <td colspan="4">
3378 '.__('No Whitelist IPs for Two Factor Authentication. You will see whitelisted IP ranges here.', 'loginizer').'
3379 </td>
3380 </tr>';
3381 }else{
3382 foreach($loginizer['2fa_whitelist'] as $ik => $iv){
3383 echo '
3384 <tr>
3385 <td>
3386 '.$iv['start'].'
3387 </td>
3388 <td>
3389 '.$iv['end'].'
3390 </td>
3391 <td>
3392 '.date('d/m/Y', $iv['time']).'
3393 </td>
3394 <td>
3395 <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>
3396 </td>
3397 </tr>';
3398 }
3399 }
3400 ?>
3401 </table>
3402 <br />
3403 <form action="" method="post" id="lz_wl_2fa_form">
3404 <?php wp_nonce_field('loginizer-options'); ?>
3405 <input type="hidden" value="" name="" id="lz_wl_2fa_todo"/>
3406 </form>
3407 <br />
3408
3409 </div>
3410
3411 <?php
3412 loginizer_page_footer();
3413
3414 }
3415
3416 // Loginizer - PasswordLess Page
3417 function loginizer_page_passwordless(){
3418
3419 global $loginizer, $lz_error, $lz_env;
3420
3421 if(!current_user_can('manage_options')){
3422 wp_die('Sorry, but you do not have permissions to change settings.');
3423 }
3424
3425 if(!loginizer_is_premium() && count($_POST) > 0){
3426 $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');
3427 return loginizer_page_passwordless_T();
3428 }
3429
3430 /* Make sure post was from this page */
3431 if(count($_POST) > 0){
3432 check_admin_referer('loginizer-options');
3433 }
3434
3435 if(isset($_POST['save_lz'])){
3436
3437 // In the future there can be more settings
3438 $option['email_pass_less'] = (int) lz_optpost('email_pass_less');
3439 $option['passwordless_sub'] = lz_optpost('lz_passwordless_sub');
3440 $option['passwordless_msg'] = lz_optpost('lz_passwordless_msg');
3441 $option['passwordless_html'] = (int) lz_optpost('lz_passwordless_html');
3442
3443 // Is there an error ?
3444 if(!empty($lz_error)){
3445 return loginizer_page_passwordless_T();
3446 }
3447
3448 // Save the options
3449 update_option('loginizer_epl', $option);
3450
3451 // Mark as saved
3452 $GLOBALS['lz_saved'] = true;
3453
3454 }
3455
3456 // Call theme
3457 loginizer_page_passwordless_T();
3458 }
3459
3460 // Loginizer - PasswordLess Page Theme
3461 function loginizer_page_passwordless_T(){
3462
3463 global $loginizer, $lz_error, $lz_env;
3464
3465 $lz_options = get_option('loginizer_epl');
3466
3467 // Universal header
3468 loginizer_page_header('PasswordLess Settings');
3469
3470 loginizer_feature_available('PasswordLess Login');
3471
3472 // Saved ?
3473 if(!empty($GLOBALS['lz_saved'])){
3474 echo '<div id="message" class="updated"><p>'. __('The settings were saved successfully', 'loginizer'). '</p></div><br />';
3475 }
3476
3477 // Any errors ?
3478 if(!empty($lz_error)){
3479 lz_report_error($lz_error);echo '<br />';
3480 }
3481
3482 ?>
3483
3484 <style>
3485 input[type="text"], textarea, select {
3486 width: 90%;
3487 }
3488
3489 .form-table label{
3490 font-weight:bold;
3491 }
3492
3493 .form-table td{
3494 vertical-align:top;
3495 }
3496
3497 .exp{
3498 font-size:12px;
3499 }
3500 </style>
3501
3502 <div id="" class="postbox">
3503
3504 <div class="postbox-header">
3505 <h2 class="hndle ui-sortable-handle">
3506 <span><?php echo __('PasswordLess Settings', 'loginizer'); ?></span>
3507 </h2>
3508 </div>
3509
3510 <div class="inside">
3511
3512 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
3513 <?php wp_nonce_field('loginizer-options'); ?>
3514 <table class="form-table">
3515 <tr>
3516 <th scope="row" valign="top" style="width:350px !important"><label for="email_pass_less"><?php echo __('Enable PasswordLess Login', 'loginizer'); ?></label></th>
3517 <td>
3518 <input type="checkbox" value="1" name="email_pass_less" id="email_pass_less" <?php echo lz_POSTchecked('email_pass_less', (empty($loginizer['email_pass_less']) ? false : true)); echo (defined('SITEPAD') ? 'disabled="disabled"' : '') ?> />
3519 </td>
3520 </tr>
3521 <tr>
3522 <td colspan="2" valign="top">
3523 <?php echo __('If enabled, the login screen will just ask for the username <b>OR</b> email address of the user. If such a user exists, an email with a <b>One Time Login </b> link will be sent to the email address of the user. The link will be valid for 10 minutes only.', 'loginizer'); ?><br><br>
3524 <?php echo __('If a wrong username/email is given, the brute force checker will prevent any brute force attempt !', 'loginizer'); ?>
3525 </td>
3526 </tr>
3527 <tr>
3528 <td scope="row" valign="top">
3529 <label for="lz_passwordless_sub"><?php echo __('Email Subject', 'loginizer'); ?></label><br>
3530 <span class="exp"><?php echo __('Set blank to reset to the default subject', 'loginizer'); ?></span>
3531 <br />Default : <?php echo @$loginizer['pl_d_sub']; ?>
3532 </td>
3533 <td valign="top">
3534 <input type="text" size="40" value="<?php echo lz_optpost('lz_passwordless_sub', @$lz_options['passwordless_sub']); ?>" name="lz_passwordless_sub" id="lz_passwordless_sub" />
3535 </td>
3536 </tr>
3537 <tr>
3538 <td scope="row" valign="top">
3539 <label for="lz_passwordless_msg"><?php echo __('Email Body', 'loginizer'); ?></label><br>
3540 <span class="exp"><?php echo __('Set blank to reset to the default message', 'loginizer'); ?></span>
3541 <br />Default : <pre style="font-size:10px"><?php echo @$loginizer['pl_d_msg']; ?></pre>
3542 </td>
3543 <td valign="top">
3544 <textarea rows="10" name="lz_passwordless_msg" id="lz_passwordless_msg"><?php echo lz_optpost('lz_passwordless_msg', @$lz_options['passwordless_msg']); ?></textarea>
3545 <br />
3546 Variables :
3547 <br />$email - Users Email
3548 <br />$site_name - The Site Name
3549 <br />$site_url - The Site URL
3550 <br />$login_url - The Login URL
3551 </td>
3552 </tr>
3553 <tr>
3554 <th scope="row" valign="top" style="width:350px !important"><label for="lz_passwordless_html"><?php echo __('Send email as HTML', 'loginizer'); ?></label></th>
3555 <td>
3556 <input type="checkbox" value="1" name="lz_passwordless_html" id="lz_passwordless_html" <?php echo lz_POSTchecked('lz_passwordless_html', (empty($loginizer['passwordless_html']) ? false : true)); ?> />
3557 </td>
3558 </tr>
3559 </table><br />
3560 <center><input name="save_lz" class="button button-primary action" value="<?php echo __('Save Settings', 'loginizer'); ?>" type="submit" /></center>
3561 </form>
3562
3563 </div>
3564 </div>
3565 <br />
3566
3567 <?php
3568 loginizer_page_footer();
3569
3570 }
3571
3572 // Loginizer - Security Settings Page
3573 function loginizer_page_security(){
3574
3575 global $loginizer, $lz_error, $lz_env, $wpdb;
3576
3577 if(!current_user_can('manage_options')){
3578 wp_die('Sorry, but you do not have permissions to change settings.');
3579 }
3580
3581 if(!loginizer_is_premium() && count($_POST) > 0){
3582 $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');
3583 return loginizer_page_security_T();
3584 }
3585
3586 /* Make sure post was from this page */
3587 if(count($_POST) > 0){
3588 check_admin_referer('loginizer-options');
3589 }
3590
3591 if(isset($_POST['save_lz'])){
3592
3593 $option['login_slug'] = lz_optpost('login_slug');
3594 $option['rename_login_secret'] = (int) lz_optpost('rename_login_secret');
3595 $option['xmlrpc_slug'] = lz_optpost('xmlrpc_slug');
3596 $option['xmlrpc_disable'] = (int) lz_optpost('xmlrpc_disable');
3597 $option['pingbacks_disable'] = (int) lz_optpost('pingbacks_disable');
3598
3599 // Login Slug Valid ?
3600 if(!empty($option['login_slug'])){
3601 if(strlen($option['login_slug']) <= 4 || strlen($option['login_slug']) > 50){
3602 $lz_error['login_slug'] = __('The Login slug length must be greater than <b>4</b> chars and upto <b>50</b> chars long', 'loginizer');
3603 }
3604 }
3605
3606 // XML-RPC Slug Valid ?
3607 if(!empty($option['xmlrpc_slug'])){
3608 if(strlen($option['xmlrpc_slug']) <= 4 || strlen($option['xmlrpc_slug']) > 50){
3609 $lz_error['xmlrpc_slug'] = __('The XML-RPC slug length must be greater than <b>4</b> chars and upto <b>50</b> chars long', 'loginizer');
3610 }
3611 }
3612
3613 // Is there an error ?
3614 if(!empty($lz_error)){
3615 return loginizer_page_security_T();
3616 }
3617
3618 // Save the options
3619 update_option('loginizer_security', $option);
3620
3621 // Mark as saved
3622 $GLOBALS['lz_saved'] = true;
3623
3624 }
3625
3626 // Reset the username
3627 if(isset($_POST['save_lz_admin'])){
3628
3629 // Get the new username
3630 $current_username = lz_optpost('current_username');
3631 $new_username = lz_optpost('new_username');
3632
3633 if(empty($current_username)){
3634 $lz_error['current_username_empty'] = __('Current username is required', 'loginizer');
3635 return loginizer_page_security_T();
3636 }
3637
3638 if(empty($new_username)){
3639 $lz_error['new_username_empty'] = __('New username is required', 'loginizer');
3640 return loginizer_page_security_T();
3641 }
3642
3643 // Is the starting of the username having 'admin' ?
3644 if(@strtolower(substr($new_username, 0, 5)) == 'admin'){
3645 $lz_error['user_exists'] = __('The username begins with <b>admin</b>. Please change it !', 'loginizer');
3646 return loginizer_page_security_T();
3647 }
3648
3649 // Lets check if there is such a user
3650 $found = get_user_by('login', $new_username);
3651
3652 // Found one !
3653 if(!empty($found->ID)){
3654 $lz_error['user_exists'] = __('The new username is already assigned to another user', 'loginizer');
3655 return loginizer_page_security_T();
3656 }
3657
3658 $old_user = get_user_by('login', $current_username);
3659
3660 if(empty($old_user->ID)){
3661 $lz_error['current_username_invalid'] = __('No user found with the current username provided', 'loginizer');
3662 return loginizer_page_security_T();
3663 }
3664
3665 if(empty($old_user->caps['administrator'])){
3666 $lz_error['user_not_admin'] = __('The user is not an administrator. Only administrator user\'s username can be changed.', 'loginizer');
3667 return loginizer_page_security_T();
3668 }
3669
3670 // Update the username
3671 $wpdb->query("UPDATE `".$wpdb->prefix."users`
3672 SET user_login = '$new_username'
3673 WHERE `ID` = '".$old_user->ID."'");
3674
3675 // Mark as saved
3676 $GLOBALS['lz_saved'] = true;
3677
3678 }
3679
3680 // Change the wp-admin slug
3681 if(isset($_POST['save_lz_wp_admin'])){
3682
3683 // Get the new username
3684 $option['admin_slug'] = lz_optpost('admin_slug');
3685 $option['restrict_wp_admin'] = (int) lz_optpost('restrict_wp_admin');
3686 $option['wp_admin_msg'] = @stripslashes($_POST['wp_admin_msg']);
3687 $lz_wp_admin_docs = (int) lz_optpost('lz_wp_admin_docs');
3688
3689 // Did you agree to this ?
3690 if(!empty($option['admin_slug']) && empty($lz_wp_admin_docs)){
3691 $lz_error['lz_wp_admin_docs'] = __('You have not confirmed that you have read the guide and configured .htaccess. Please read the guide, configure .htaccess and then save these settings and check this checkbox', 'loginizer');
3692 return loginizer_page_security_T();
3693 }
3694
3695 // Length
3696 if(!empty($option['admin_slug']) && (strlen($option['admin_slug']) <= 4 || strlen($option['admin_slug']) > 50)){
3697 $lz_error['admin_slug'] = __('The new Admin slug length must be greater than <b>4</b> chars and upto <b>50</b> chars long', 'loginizer');
3698 return loginizer_page_security_T();
3699 }
3700
3701 // Only regular characters
3702 if(preg_match('/[^\w\d\-_]/is', $option['admin_slug'])){
3703 $lz_error['admin_slug_chars'] = __('Special characters are not allowed', 'loginizer');
3704 return loginizer_page_security_T();
3705 }
3706
3707 // Update the option
3708 update_option('loginizer_wp_admin', $option);
3709
3710 // Mark as saved
3711 $GLOBALS['lz_saved'] = true;
3712
3713 }
3714
3715
3716 // Save blacklisted usernames
3717 if(isset($_POST['save_lz_bl_users'])){
3718
3719 $usernames = isset($_POST['lz_bl_users']) && is_array($_POST['lz_bl_users']) ? $_POST['lz_bl_users'] : array();
3720
3721 // Process the usernames i.e. remove blanks
3722 foreach($usernames as $k => $v){
3723 $v = trim($v);
3724
3725 // Unset blank values
3726 if(empty($v)){
3727 unset($usernames[$k]);
3728 }
3729
3730 // Disallow these special characters to avoid XSS or any other security vulnerability
3731 if(preg_match('/[\<\>\"\']/', $v)){
3732 unset($usernames[$k]);
3733 }
3734 }
3735
3736 // Update the blacklist
3737 update_option('loginizer_username_blacklist', array_values($usernames));
3738
3739 // Mark as saved
3740 $GLOBALS['lz_saved'] = true;
3741
3742 }
3743
3744
3745 // Save blacklisted domains
3746 if(isset($_POST['save_lz_bl_domains'])){
3747
3748 $domains = isset($_POST['lz_bl_domains']) && is_array($_POST['lz_bl_domains']) ? $_POST['lz_bl_domains'] : array();
3749
3750 // Process the domains i.e. remove blanks
3751 foreach($domains as $k => $v){
3752 $v = trim($v);
3753
3754 // Unset blank values
3755 if(empty($v)){
3756 unset($domains[$k]);
3757 }
3758
3759 // Disallow these special characters to avoid XSS or any other security vulnerability
3760 if(preg_match('/[\<\>\"\']/', $v)){
3761 unset($domains[$k]);
3762 }
3763 }
3764
3765 // Update the blacklist
3766 update_option('loginizer_domains_blacklist', array_values($domains));
3767
3768 // Mark as saved
3769 $GLOBALS['lz_saved'] = true;
3770
3771 }
3772
3773 // Call theme
3774 loginizer_page_security_T();
3775
3776 }
3777
3778 // Loginizer - Security Settings Page Theme
3779 function loginizer_page_security_T(){
3780
3781 global $loginizer, $lz_error, $lz_env;
3782
3783 // Universal header
3784 loginizer_page_header('Security Settings');
3785
3786 loginizer_feature_available('Security Settings');
3787
3788 // Saved ?
3789 if(!empty($GLOBALS['lz_saved'])){
3790 echo '<div id="message" class="updated"><p>'. __('The settings were saved successfully', 'loginizer'). '</p></div><br />';
3791 }
3792
3793 // Any errors ?
3794 if(!empty($lz_error)){
3795 lz_report_error($lz_error);echo '<br />';
3796 }
3797
3798 $current_admin = get_user_by('id', 1);
3799
3800 ?>
3801
3802 <style>
3803 input[type="text"], textarea, select {
3804 width: 70%;
3805 }
3806
3807 .form-table label{
3808 font-weight:bold;
3809 }
3810
3811 .exp{
3812 font-size:12px;
3813 }
3814 </style>
3815
3816 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
3817
3818 <div id="" class="postbox">
3819
3820 <div class="postbox-header">
3821 <h2 class="hndle ui-sortable-handle">
3822 <span><?php echo __('Rename Login Page', 'loginizer'); ?></span>
3823 </h2>
3824 </div>
3825
3826 <div class="inside">
3827
3828 <?php wp_nonce_field('loginizer-options'); ?>
3829 <table class="form-table">
3830 <tr>
3831 <td scope="row" valign="top" colspan="2">
3832 <i>You can rename your Login page from <b><?php echo $loginizer['login_basename']; ?></b> to anything of your choice e.g. mylogin. This would make it very difficult for automated attack bots to know where to login !</i>
3833 </td>
3834 </tr>
3835 <tr>
3836 <td scope="row" valign="top" style="width:40% !important">
3837 <label><?php echo __('New Login Slug', 'loginizer'); ?></label><br>
3838 <span class="exp"><?php echo __('Set blank to reset to the original login URL', 'loginizer'); ?></span>
3839 </td>
3840 <td>
3841 <input type="text" size="50" value="<?php echo lz_POSTval('login_slug', $loginizer['login_slug']); ?>" name="login_slug" />
3842 </td>
3843 </tr>
3844
3845 <?php
3846
3847 if(!defined('SITEPAD')){
3848
3849 ?>
3850 <tr>
3851 <td scope="row" valign="top" style="width:200px !important">
3852 <label><?php echo __('Access Secretly Only', 'loginizer'); ?></label><br>
3853 <span class="exp"><?php echo __('If set, then all Login URL\'s will still point to '.$loginizer['login_basename'].' and users will have to access the New Login Slug by typing it in the browser.', 'loginizer'); ?></span>
3854 </td>
3855 <td>
3856 <input type="checkbox" value="1" name="rename_login_secret" <?php echo lz_POSTchecked('rename_login_secret', (empty($loginizer['rename_login_secret']) ? false : true)); ?> />
3857 </td>
3858 </tr>
3859
3860 <?php
3861
3862 }
3863
3864 ?>
3865 </table><br />
3866 <center><input name="save_lz" class="button button-primary action" value="<?php echo __('Save Settings', 'loginizer'); ?>" type="submit" /></center>
3867
3868 </div>
3869 </div>
3870 <br />
3871
3872 <?php
3873
3874 if(!defined('SITEPAD')){
3875
3876 ?>
3877
3878 <div id="" class="postbox">
3879
3880 <div class="postbox-header">
3881 <h2 class="hndle ui-sortable-handle">
3882 <span><?php echo __('XML-RPC Settings', 'loginizer'); ?></span>
3883 </h2>
3884 </div>
3885
3886 <div class="inside">
3887
3888 <?php wp_nonce_field('loginizer-options'); ?>
3889 <table class="form-table">
3890 <tr>
3891 <td scope="row" valign="top" colspan="2">
3892 <i><?php echo __('WordPress\'s XML-RPC feature allows external services to access and modify content on the site. Services like the Jetpack plugin, the WordPress mobile app, pingbacks, etc make use of the XML-RPC feature. If this site does not use a service that requires XML-RPC, please <b>disable</b> the XML-RPC feature as it prevents attackers from using the feature to attack the site. If your service can use a custom XML-RPC URL, you can also <b>rename</b> the XML-RPC page to a <b>custom slug</b>.', 'loginizer'); ?></i>
3893 </td>
3894 </tr>
3895 <tr>
3896 <td scope="row" valign="top" style="width:40% !important">
3897 <label><?php echo __('Disable XML-RPC', 'loginizer'); ?></label>
3898 </td>
3899 <td>
3900 <input type="checkbox" value="1" name="xmlrpc_disable" <?php echo lz_POSTchecked('xmlrpc_disable', (empty($loginizer['xmlrpc_disable']) ? false : true)); ?> />
3901 </td>
3902 </tr>
3903 <tr>
3904 <td scope="row" valign="top" style="width:40% !important">
3905 <label><?php echo __('Disable Pingbacks', 'loginizer'); ?></label>
3906 </td>
3907 <td>
3908 <input type="checkbox" value="1" name="pingbacks_disable" <?php echo lz_POSTchecked('pingbacks_disable', (empty($loginizer['pingbacks_disable']) ? false : true)); ?> />
3909 </td>
3910 </tr>
3911 <tr>
3912 <td scope="row" valign="top">
3913 <label><?php echo __('New XML-RPC Slug', 'loginizer'); ?></label><br>
3914 <span class="exp"><?php echo __('Set blank to reset to the original XML-RPC URL', 'loginizer'); ?></span>
3915 </td>
3916 <td>
3917 <input type="text" size="50" value="<?php echo lz_optpost('xmlrpc_slug', $loginizer['xmlrpc_slug']); ?>" name="xmlrpc_slug" />
3918 </td>
3919 </tr>
3920 </table><br />
3921 <center><input name="save_lz" class="button button-primary action" value="<?php echo __('Save Settings', 'loginizer'); ?>" type="submit" /></center>
3922
3923 </div>
3924 </div>
3925 <br />
3926
3927 <?php
3928
3929 }
3930
3931 ?>
3932
3933 </form>
3934
3935 <?php
3936
3937 if(!defined('SITEPAD')){
3938
3939 ?>
3940
3941 <script type="text/javascript">
3942
3943
3944 function dirname(path) {
3945 return path.replace(/\\/g, '/').replace(/\/[^/]*\/?$/, '');
3946 }
3947
3948 function lz_test_wp_admin(){
3949
3950 var data = new Object();
3951 data["action"] = "loginizer_wp_admin";
3952 data["nonce"] = "<?php echo wp_create_nonce('loginizer_admin_ajax');?>";
3953
3954 var new_ajaxurl = dirname(dirname(ajaxurl))+'/'+jQuery('#lz_admin_slug').val()+'/admin-ajax.php';
3955
3956 // AJAX and on success function
3957 jQuery.post(new_ajaxurl, data, function(response){
3958
3959 if(response['result'] == 1){
3960 alert("<?php echo __('Everything seems to be good. You can proceed to save the settings !', 'loginizer'); ?>");
3961 }
3962
3963 // Throw an error for failures
3964 }).fail(function() {
3965 alert("<?php echo __('There was an error connecting to WordPress with the new Admin Slug. Did you configure everything properly ?', 'loginizer'); ?>");
3966 });
3967 //jQuery.ajax('<input type="text" size="30" value="" name="lz_bl_users[]" class="lz_bl_users" />');
3968 return false;
3969 };
3970
3971 </script>
3972
3973 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
3974 <div id="" class="postbox">
3975
3976 <div class="postbox-header">
3977 <h2 class="hndle ui-sortable-handle">
3978 <span><?php echo __('Rename wp-admin access', 'loginizer'); ?></span>
3979 </h2>
3980 </div>
3981
3982 <div class="inside">
3983
3984 <?php wp_nonce_field('loginizer-options'); ?>
3985 <table class="form-table">
3986 <?php
3987 if(preg_match('/(apache|litespeed|lsws)/is', $_SERVER["SERVER_SOFTWARE"])){
3988 // Supported. Do nothing
3989 }else{
3990 echo '<tr>
3991 <td scope="row" valign="top" colspan="2">
3992 <div style="color:#a94442; background-color:#f2dede; border-color:#ebccd1; padding:15px; border:1px solid transparent; border-radius:4px;">'.__('Rename wp-admin access feature is supported only on Apache and Litespeed', 'loginizer').'</div>
3993 </td>
3994 </tr>';
3995 }
3996 ?>
3997 <tr>
3998 <td scope="row" valign="top" colspan="2">
3999 <i>You can rename your WordPress Admin access URL <b>wp-admin</b> to anything of your choice e.g. my-admin. This will require you to change .htaccess, so please follow <a href="<?php echo LOGINIZER_DOCS;?>Renaming_the_WP-Admin_Area" target="_blank">our guide</a> on how to do so !</i>
4000 </td>
4001 </tr>
4002 <tr>
4003 <td scope="row" valign="top" style="width:40% !important">
4004 <label><?php echo __('New wp-admin Slug', 'loginizer'); ?></label><br>
4005 <span class="exp"><?php echo __('Set blank to reset to the original wp-admin URL', 'loginizer'); ?></span>
4006 </td>
4007 <td>
4008 <input type="text" size="50" value="<?php echo lz_optpost('admin_slug', $loginizer['admin_slug']); ?>" name="admin_slug" id="lz_admin_slug" />
4009 </td>
4010 </tr>
4011 <tr>
4012 <td scope="row" valign="top" style="width:200px !important">
4013 <label><?php echo __('Disable wp-admin access', 'loginizer'); ?></label><br>
4014 <span class="exp"><?php echo __('If set, then only the new admin slug will work and access to the Old Admin Slug i.e. wp-admin will be disabled. If anyone accesses wp-admin, a warning will be shown.<br><label>NOTE: Please use this option cautiously !</label>', 'loginizer'); ?></span>
4015 </td>
4016 <td>
4017 <input type="checkbox" id="lz_restrict_wp_admin" onchange="lz_wp_admin_msg_toggle()" value="1" name="restrict_wp_admin" <?php echo lz_POSTchecked('restrict_wp_admin', (empty($loginizer['restrict_wp_admin']) ? false : true)); ?> />
4018 </td>
4019 </tr>
4020 <tr id="lz_wp_admin_msg_row" style="display:none">
4021 <td scope="row" valign="top">
4022 <label><?php echo __('WP-Admin Error Message', 'loginizer'); ?></label><br>
4023 <span class="exp"><?php echo __('Error message to show if someone accesses wp-admin', 'loginizer'); ?></span> Default : <?php echo $loginizer['wp_admin_d_msg']; ?>
4024 </td>
4025 <td>
4026 <input type="text" size="50" value="<?php echo lz_htmlizer(!empty($_POST['wp_admin_msg']) ? stripslashes($_POST['wp_admin_msg']) : @$loginizer['wp_admin_msg']); ?>" name="wp_admin_msg" id="lz_wp_admin_msg" />
4027 </td>
4028 </tr>
4029 <tr>
4030 <td scope="row" valign="top" style="width:200px !important">
4031 <label><?php echo __('I have setup .htaccess', 'loginizer'); ?></label><br>
4032 <span class="exp"><?php echo __('You need to confirm that you have configured .htaccess as per <a href="'.LOGINIZER_DOCS.'Renaming_the_WP-Admin_Area" target="_blank">our guide</a> so that we can safely enable this feature', 'loginizer'); ?></span>
4033 </td>
4034 <td>
4035 <input type="checkbox" value="1" name="lz_wp_admin_docs" />
4036 <input type="button" onclick="lz_test_wp_admin()" class="button" style="background: #5cb85c; color:white; border:#5cb85c" value="<?php echo __('Test New WP-Admin Slug', 'loginizer'); ?>" />
4037 </td>
4038 </tr>
4039 </table><br />
4040 <center><input name="save_lz_wp_admin" class="button button-primary action" value="<?php echo __('Save Settings', 'loginizer'); ?>" type="submit" /></center>
4041
4042 </div>
4043 </div>
4044 <br />
4045 </form>
4046
4047 <script type="text/javascript">
4048
4049 function lz_wp_admin_msg_toggle(){
4050 var ele = jQuery('#lz_restrict_wp_admin')[0];
4051 if(ele.checked){
4052 jQuery('#lz_wp_admin_msg_row').show();
4053 }else{
4054 jQuery('#lz_wp_admin_msg_row').hide();
4055 }
4056 };
4057
4058 lz_wp_admin_msg_toggle();
4059
4060 </script>
4061
4062
4063 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
4064 <div id="" class="postbox">
4065
4066 <div class="postbox-header">
4067 <h2 class="hndle ui-sortable-handle">
4068 <span><?php echo __('Change Admin Username', 'loginizer'); ?></span>
4069 </h2>
4070 </div>
4071
4072 <div class="inside">
4073
4074 <?php wp_nonce_field('loginizer-options'); ?>
4075 <table class="form-table">
4076 <tr>
4077 <td scope="row" valign="top" colspan="2">
4078 <i><?php echo __('You can change the Admin Username from here to anything of your choice e.g. iamtheboss. This would make it very difficult for automated attack bots to know what is the admin username !', 'loginizer'); ?></i>
4079 </td>
4080 </tr>
4081 <tr>
4082 <td scope="row" valign="top" style="width:40% !important">
4083 <label for="current_username"><?php echo __('Current Username', 'loginizer'); ?></label><br>
4084 <span class="exp"><?php echo __('The current username you want to change', 'loginizer'); ?></span>
4085 </td>
4086 <td>
4087 <input type="text" size="50" value="<?php echo lz_optpost('current_username', (!empty($current_admin->user_login) ? $current_admin->user_login : '')); ?>" name="current_username" id="current_username" />
4088 </td>
4089 </tr>
4090 <tr>
4091 <td scope="row" valign="top" style="width:40% !important">
4092 <label for="new_username"><?php echo __('New Username', 'loginizer'); ?></label><br>
4093 <span class="exp"><?php echo __('The new username you want to set', 'loginizer'); ?></span>
4094 </td>
4095 <td>
4096 <input type="text" size="50" value="<?php echo lz_optpost('new_username', ''); ?>" name="new_username" id="new_username" />
4097 </td>
4098 </tr>
4099 </table><br />
4100 <i><?php echo __('Note: Username can be changed only for administrator users.'); ?></i>
4101 <center><input name="save_lz_admin" class="button button-primary action" value="<?php echo __('Set the Username', 'loginizer'); ?>" type="submit" /></center>
4102
4103 </div>
4104 </div>
4105 </form>
4106
4107 <script type="text/javascript">
4108 function add_lz_bl_users(){
4109 jQuery("#lz_bl_users").append('<input type="text" size="30" value="" name="lz_bl_users[]" class="lz_bl_users" />');
4110 return false;
4111 };
4112 </script>
4113
4114 <style>
4115 .lz_bl_users, .lz_bl_domains{
4116 margin-bottom:20px;
4117 }
4118 </style>
4119
4120 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
4121 <div id="" class="postbox">
4122
4123 <div class="postbox-header">
4124 <h2 class="hndle ui-sortable-handle">
4125 <span><?php echo __('Username Auto Blacklist', 'loginizer'); ?></span>
4126 </h2>
4127 </div>
4128
4129 <div class="inside">
4130
4131 <?php wp_nonce_field('loginizer-options'); ?>
4132 <table class="form-table">
4133 <tr>
4134 <td scope="row" valign="top" colspan="2">
4135 <i><?php echo __('Attackers generally use common usernames like <b>admin, administrator, or variations of your domain name / business name</b>. You can specify such username here and Loginizer will auto-blacklist the IP Address(s) of clients who try to use such username(s).', 'loginizer'); ?></i>
4136 </td>
4137 </tr>
4138 <tr>
4139 <td scope="row" valign="top" style="width:40% !important; vertical-align:top !important;">
4140 <label><?php echo __('Username(s)', 'loginizer'); ?></label><br>
4141 <span class="exp"><?php echo __('You can use - <b>*</b> (Star)- as a wild card as well. Blank fields will be ignored', 'loginizer'); ?></span>
4142 </td>
4143 <td>
4144 <div id="lz_bl_users">
4145 <?php
4146
4147 $usernames = isset($_POST['lz_bl_users']) && is_array($_POST['lz_bl_users']) ? $_POST['lz_bl_users'] : $loginizer['username_blacklist'];
4148
4149 if(empty($usernames)){
4150 $usernames[] = '';
4151 }
4152
4153 foreach($usernames as $_user){
4154 echo '<input type="text" size="30" value="'.$_user.'" name="lz_bl_users[]" class="lz_bl_users" />';
4155 }
4156
4157 ?>
4158 </div>
4159 <br />
4160 <input class="button" type="button" value="<?php echo __('Add New Username', 'loginizer'); ?>" onclick="return add_lz_bl_users();" style="float:right" />
4161 </td>
4162 </tr>
4163 </table><br />
4164 <center><input name="save_lz_bl_users" class="button button-primary action" value="<?php echo __('Save Username(s)', 'loginizer'); ?>" type="submit" /></center>
4165
4166 </div>
4167 </div>
4168 </form>
4169
4170 <script type="text/javascript">
4171 function add_lz_bl_domains(){
4172 jQuery("#lz_bl_domains").append('<input type="text" size="30" value="" name="lz_bl_domains[]" class="lz_bl_domains" />');
4173 return false;
4174 };
4175 </script>
4176
4177
4178 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
4179 <div id="" class="postbox">
4180
4181 <div class="postbox-header">
4182 <h2 class="hndle ui-sortable-handle">
4183 <span><?php echo __('New Registration Domain Blacklist', 'loginizer'); ?></span>
4184 </h2>
4185 </div>
4186
4187 <div class="inside">
4188
4189 <?php wp_nonce_field('loginizer-options'); ?>
4190 <table class="form-table">
4191 <tr>
4192 <td scope="row" valign="top" colspan="2">
4193 <i>If you would like to ban new registrations from a particular domain, you can use this utility to do so.</i>
4194 </td>
4195 </tr>
4196 <tr>
4197 <td scope="row" valign="top" style="width:40% !important; vertical-align:top !important;">
4198 <label><?php echo __('Domain(s)', 'loginizer'); ?></label><br>
4199 <span class="exp"><?php echo __('You can use - <b>*</b> (Star)- as a wild card as well. Blank fields will be ignored', 'loginizer'); ?></span>
4200 </td>
4201 <td>
4202 <div id="lz_bl_domains">
4203 <?php
4204
4205 $domains = isset($_POST['lz_bl_domains']) && is_array($_POST['lz_bl_domains']) ? $_POST['lz_bl_domains'] : $loginizer['domains_blacklist'];
4206
4207 if(empty($domains)){
4208 $domains[] = '';
4209 }
4210
4211 foreach($domains as $_domain){
4212 echo '<input type="text" size="30" value="'.$_domain.'" name="lz_bl_domains[]" class="lz_bl_domains" />';
4213 }
4214
4215 ?>
4216 </div>
4217 <br />
4218 <input class="button" type="button" value="<?php echo __('Add New Domain', 'loginizer'); ?>" onclick="return add_lz_bl_domains();" style="float:right" />
4219 </td>
4220 </tr>
4221 </table><br />
4222 <center><input name="save_lz_bl_domains" class="button button-primary action" value="<?php echo __('Save Domains(s)', 'loginizer'); ?>" type="submit" /></center>
4223
4224 </div>
4225 </div>
4226 </form>
4227
4228 <?php
4229
4230 }
4231
4232 loginizer_page_footer();
4233
4234 }
4235
4236 // Loginizer - Checksum load data
4237 function loginizer_page_checksums_L(&$files, &$_ignores){
4238
4239 global $loginizer, $lz_error, $lz_env;
4240
4241 // Load any mismatched files and ignores
4242 $files = get_option('loginizer_checksums_diff');
4243 $_ignores = get_option('loginizer_checksums_ignore');
4244 $_ignores = is_array($_ignores) ? $_ignores : array(); // SHOULD ALWAYS BE PURE
4245 $ignores = array();
4246
4247 foreach($_ignores as $ik => $iv){
4248 $ignores[$iv] = array();
4249 if(!empty($files[$iv])){
4250 $ignores[$iv] = $files[$iv];
4251 }
4252 }
4253
4254 $lz_env['files'] = $files;
4255 $lz_env['ignores'] = $ignores;
4256
4257 }
4258
4259 // Loginizer - PasswordLess Page
4260 function loginizer_page_checksums(){
4261
4262 global $loginizer, $lz_error, $lz_env;
4263
4264 if(!current_user_can('manage_options')){
4265 wp_die('Sorry, but you do not have permissions to change settings.');
4266 }
4267
4268 if(!loginizer_is_premium() && count($_POST) > 0){
4269 $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');
4270 return loginizer_page_checksums_T();
4271 }
4272
4273 /* Make sure post was from this page */
4274 if(count($_POST) > 0){
4275 check_admin_referer('loginizer-options');
4276 }
4277
4278 // Are we to run it ?
4279 if(isset($_REQUEST['lz_run_checksum'])){
4280 loginizer_checksums();
4281 }
4282
4283 loginizer_page_checksums_L($files, $_ignores);
4284
4285 $lz_env['csum_freq'][1] = __('Once a Day', 'loginizer');
4286 $lz_env['csum_freq'][7] = __('Once a Week', 'loginizer');
4287 $lz_env['csum_freq'][30] = __('Once a Month', 'loginizer');
4288
4289 if(isset($_POST['save_lz'])){
4290
4291 // In the future there can be more settings
4292 $option['disable_checksum'] = (int) lz_optpost('disable_checksum');
4293 $option['no_checksum_email'] = (int) lz_optpost('no_checksum_email');
4294 $option['checksum_frequency'] = (int) lz_optpost('checksum_frequency');
4295 $option['checksum_time'] = lz_optpost('checksum_time');
4296
4297 // Is there an error ?
4298 if(!empty($lz_error)){
4299 return loginizer_page_checksums_T();
4300 }
4301
4302 // Save the options
4303 update_option('loginizer_checksums', $option);
4304
4305 // Mark as saved
4306 $GLOBALS['lz_saved'] = true;
4307
4308 }
4309
4310 // Add or remove from ignore list
4311 if(isset($_POST['save_lz_csum_ig'])){
4312
4313 if(@is_array($_POST['checksum_del_ignore'])){
4314
4315 foreach($_POST['checksum_del_ignore'] as $k => $v){
4316 $key = array_search($v, $_ignores);
4317 if($key !== false){
4318 unset($_ignores[$key]);
4319 }
4320 }
4321
4322 // Save it
4323 update_option('loginizer_checksums_ignore', $_ignores);
4324
4325 }
4326
4327 if(@is_array($_POST['checksum_add_ignore'])){
4328
4329 foreach($_POST['checksum_add_ignore'] as $k => $v){
4330 if(!empty($files[$v])){
4331 $_ignores[] = $v;
4332 }
4333 }
4334
4335 // Save it
4336 update_option('loginizer_checksums_ignore', $_ignores);
4337
4338 }
4339
4340 // Reload
4341 loginizer_page_checksums_L($files, $_ignores);
4342
4343 // Mark as saved
4344 $GLOBALS['lz_saved'] = true;
4345
4346 }
4347
4348 // Call theme
4349 loginizer_page_checksums_T();
4350 }
4351
4352 // Loginizer - PasswordLess Page Theme
4353 function loginizer_page_checksums_T(){
4354
4355 global $loginizer, $lz_error, $lz_env;
4356
4357 // Universal header
4358 loginizer_page_header('File Checksum Settings');
4359
4360 loginizer_feature_available('File Checksum');
4361
4362 wp_enqueue_script('jquery-clockpicker', LOGINIZER_URL.'/jquery-clockpicker.min.js', array('jquery'), '0.0.7');
4363 wp_enqueue_style('jquery-clockpicker', LOGINIZER_URL.'/jquery-clockpicker.min.css', array(), '0.0.7');
4364
4365 // Saved ?
4366 if(!empty($GLOBALS['lz_saved'])){
4367 echo '<div id="message" class="updated"><p>'. __('The settings were saved successfully', 'loginizer'). '</p></div><br />';
4368 }
4369
4370 // Did we just run the checksums
4371 if(isset($_REQUEST['lz_run_checksum'])){
4372 echo '<div id="message" class="updated"><p>'. __('The Checksum process was executed successfully', 'loginizer'). '</p></div><br />';
4373 }
4374
4375 // Any errors ?
4376 if(!empty($lz_error)){
4377 lz_report_error($lz_error);echo '<br />';
4378 }
4379
4380 ?>
4381
4382 <style>
4383 input[type="text"], textarea, select {
4384 width: 70%;
4385 }
4386
4387 .form-table label{
4388 font-weight:bold;
4389 }
4390
4391 .exp{
4392 font-size:12px;
4393 }
4394 </style>
4395
4396 <script>
4397 function lz_apply_status(ele, the_class){
4398
4399 var status = ele.checked;
4400 jQuery(the_class).each(function(){
4401 this.checked = status;
4402 });
4403
4404 }
4405 </script>
4406
4407 <div id="" class="postbox">
4408 <div class="postbox-header">
4409 <h2 class="hndle ui-sortable-handle">
4410 <span><?php echo __('Checksum Settings', 'loginizer'); ?></span>
4411 </h2>
4412 </div>
4413 <div class="inside">
4414
4415 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
4416 <?php wp_nonce_field('loginizer-options'); ?>
4417 <table class="form-table">
4418 <tr>
4419 <td scope="row" valign="top" style="width:400px !important">
4420 <label><?php echo __('Disable Checksum of WP Core', 'loginizer'); ?></label><br>
4421 <span class="exp"><?php echo __('If disabled, Loginizer will not check your sites core files against the WordPress checksum list.', 'loginizer'); ?></span>
4422 </td>
4423 <td valign="top">
4424 <input type="checkbox" value="1" name="disable_checksum" <?php echo lz_POSTchecked('disable_checksum', (empty($loginizer['disable_checksum']) ? false : true)); ?> />
4425 </td>
4426 </tr>
4427 <tr>
4428 <td scope="row" valign="top" style="width:400px !important">
4429 <label><?php echo __('Disable Email of Checksum Results', 'loginizer'); ?></label><br>
4430 <span class="exp"><?php echo __('If checked, Loginizer will not email you the checksum results.', 'loginizer'); ?></span>
4431 </td>
4432 <td valign="top">
4433 <input type="checkbox" value="1" name="no_checksum_email" <?php echo lz_POSTchecked('no_checksum_email', (empty($loginizer['no_checksum_email']) ? false : true)); ?> />
4434 </td>
4435 </tr>
4436 <tr>
4437 <td scope="row" valign="top" style="width:400px !important">
4438 <label><?php echo __('Checksum Frequency', 'loginizer'); ?></label><br>
4439 <span class="exp"><?php echo __('If Checksum is enabled, at what frequency should the checksums be performed.', 'loginizer'); ?></span>
4440 </td>
4441 <td valign="top">
4442 <select name="checksum_frequency">
4443 <?php
4444 foreach($lz_env['csum_freq'] as $k => $v){
4445 echo '<option '.lz_POSTselect('checksum_frequency', $k, ($loginizer['checksum_frequency'] == $k ? true : false)).' value="'.$k.'">'.$v.'</value>';
4446 }
4447 ?>
4448 </select>
4449 </td>
4450 </tr>
4451 <tr id="lz_checksum_time">
4452 <td scope="row" valign="top" style="width:400px !important">
4453 <label><?php echo __('Time of Day', 'loginizer'); ?></label><br>
4454 <span class="exp"><?php echo __('If Checksum is enabled, what time of day should Loginizer do the check. Note : The check will be done on or after this time has elapsed as per the accesses being made.', 'loginizer'); ?></span>
4455 </td>
4456 <td valign="top">
4457 <div class="input-group clockpicker" data-autoclose="true">
4458 <input type="text" name="checksum_time" class="form-control" value="<?php echo (empty($loginizer['checksum_time']) ? '00:00' : $loginizer['checksum_time']);?>">
4459 <span class="input-group-addon">
4460 <span class="glyphicon glyphicon-time"></span>
4461 </span>
4462 </div>
4463 <script type="text/javascript">
4464 jQuery(document).ready(function(){
4465 (function($) {
4466 $('.clockpicker').clockpicker({donetext: 'Done'});
4467 })(jQuery);
4468 });
4469 </script>
4470 </td>
4471 </tr>
4472 <tr>
4473 <td colspan="2">
4474 <?php echo __('If disabled, Loginizer will not check your sites core files against the WordPress checksum list.', 'loginizer'); ?>
4475 </td>
4476 </tr>
4477 </table><br />
4478 <center><input name="save_lz" class="button button-primary action" value="<?php echo __('Save Settings', 'loginizer'); ?>" type="submit" /><input name="lz_run_checksum" style="float:right; background: #5cb85c; color:white; border:#5cb85c" class="button button-secondary" value="<?php echo __('Do a Checksum Now', 'loginizer'); ?>" type="submit" /></center>
4479 </form>
4480
4481 </div>
4482 </div>
4483
4484 <div id="" class="postbox">
4485
4486 <div class="postbox-header">
4487 <h2 class="hndle ui-sortable-handle">
4488 <span><?php echo __('Mismatching Files', 'loginizer'); ?></span>
4489 </h2>
4490 </div>
4491
4492 <div class="inside">
4493
4494 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
4495 <?php wp_nonce_field('loginizer-options'); ?>
4496 <table class="wp-list-table fixed striped users" border="0" width="100%" cellpadding="10" align="center">
4497 <?php
4498
4499 $files = $lz_env['files'];
4500
4501 // Avoid undefined notice for $files
4502 if(!empty($files)){
4503 foreach($files as $k => $v){
4504 if(!empty($lz_env['ignores'][$k])){
4505 unset($files[$k]);
4506 }
4507 }
4508 }
4509
4510 echo '
4511 <tr>
4512 <th style="background:#EFEFEF;">'.__('Relative Path', 'loginizer').'</th>
4513 <th style="width:240px; background:#EFEFEF;">'.__('Found', 'loginizer').'</th>
4514 <th style="width:240px; background:#EFEFEF;">'.__('Should be', 'loginizer').'</th>
4515 <th style="width:10px; background:#EFEFEF;"><input type="checkbox" onchange="lz_apply_status(this, \'.csum_add_ig\');" /></th>
4516 </tr>';
4517
4518 if(is_array($files) && count($files) > 0){
4519
4520 foreach($files as $k => $v){
4521
4522 echo '
4523 <tr>
4524 <td>'.$k.'</td>
4525 <td>'.$v['cur_md5'].'</td>
4526 <td>'.$v['md5'].'</td>
4527 <td><input type="checkbox" name="checksum_add_ignore[]" class="csum_add_ig" value="'.$k.'" /></td>
4528 </tr>';
4529
4530 }
4531
4532 }else{
4533
4534 echo '
4535 <tr>
4536 <td colspan="4" align="center">'.__('This is great ! No file with any wrong checksum has been found.').'</td>
4537 </tr>';
4538
4539 }
4540
4541 ?>
4542 </table><br />
4543 <center><input name="save_lz_csum_ig" class="button button-primary action" value="<?php echo __('Add Selected to Ignore List', 'loginizer'); ?>" type="submit" /></center>
4544 </form>
4545 </div>
4546
4547 </div>
4548 <br />
4549
4550 <div id="" class="postbox">
4551
4552 <div class="postbox-header">
4553 <h2 class="hndle ui-sortable-handle">
4554 <span><?php echo __('Ignore List', 'loginizer'); ?></span>
4555 </h2>
4556 </div>
4557
4558 <div class="inside">
4559
4560 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
4561 <?php wp_nonce_field('loginizer-options'); ?>
4562 <table class="wp-list-table fixed striped users" border="0" width="100%" cellpadding="10" align="center">
4563 <?php
4564
4565 $ignores = $lz_env['ignores'];
4566
4567 echo '
4568 <tr>
4569 <th style="background:#EFEFEF;">'.__('Relative Path', 'loginizer').'</th>
4570 <th style="width:240px; background:#EFEFEF;">'.__('Found', 'loginizer').'</th>
4571 <th style="width:240px; background:#EFEFEF;">'.__('Should be', 'loginizer').'</th>
4572 <th style="width:10px; background:#EFEFEF;"><input type="checkbox" onchange="lz_apply_status(this, \'.csum_del_ig\');" /></th>
4573 </tr>';
4574
4575 // Load any mismatched files
4576 $files = $ignores;
4577
4578 if(is_array($files) && count($files) > 0){
4579
4580 foreach($files as $k => $v){
4581
4582 echo '
4583 <tr>
4584 <td>'.$k.'</td>
4585 <td>'.$v['cur_md5'].'</td>
4586 <td>'.$v['md5'].'</td>
4587 <td><input type="checkbox" name="checksum_del_ignore[]" class="csum_del_ig" value="'.$k.'" /></td>
4588 </tr>';
4589
4590 }
4591
4592 }else{
4593
4594 echo '
4595 <tr>
4596 <td colspan="4" align="center">'.__('No files have been added to the ignore list').'</td>
4597 </tr>';
4598
4599 }
4600
4601 ?>
4602 </table><br />
4603 <center><input name="save_lz_csum_ig" class="button button-primary action" value="<?php echo __('Remove Selected from Ignore List', 'loginizer'); ?>" type="submit" /></center>
4604 </form>
4605 </div>
4606
4607 </div>
4608 <br />
4609
4610 <?php
4611 loginizer_page_footer();
4612
4613 }
4614
4615 function loginizer_dismiss_newsletter(){
4616
4617 // Some AJAX security
4618 check_ajax_referer('loginizer_admin_ajax', 'nonce');
4619
4620 if(!current_user_can('manage_options')){
4621 wp_die('Sorry, but you do not have permissions to change settings.');
4622 }
4623
4624 update_option('loginizer_dismiss_newsletter', time());
4625 echo 1;
4626 wp_die();
4627 }
4628
4629 add_action('wp_ajax_loginizer_dismiss_newsletter', 'loginizer_dismiss_newsletter');
4630
4631 function loginizer_newsletter_subscribe(){
4632
4633 $newsletter_dismiss = get_option('loginizer_dismiss_newsletter');
4634
4635 if(!empty($newsletter_dismiss)){
4636 return;
4637 }
4638
4639 $env['url'] = 'https://loginizer.com/';
4640
4641 echo '
4642 <style>
4643 .newsletter_container{
4644 color: #000000;
4645 background: #FFFFFF;
4646 text-align:center;
4647 }
4648 .subscribe_form_row{
4649 color: #000000;
4650 padding-bottom:0px !important;
4651 }
4652 .subscribe_heading{
4653 font-size:22px;
4654 }
4655 </style>
4656
4657 <div class="notice my-loginizer-dismiss-notice is-dismissible" style="background:#FFF;padding:15px; border: 1px solid #ccd0d4; width:80%;margin-left:0px;margin:auto;">
4658 <div class="container">
4659 <div class="col-md-6 col-md-offset-3 text-center newsletter_container">
4660 <h2 style="font-weight:100; margin-bottom:20px; margin-top:5px;" class="subscribe_heading">Subscribe to our Newsletter</h2>
4661 <form class="form-inline" action="" method="POST">
4662 <div class="row subscribe_form_row">
4663 <div class="col-md-12">
4664 <input type="email" name="email" size="40" id="subscribe_email" class="" placeholder="email@example.com" value="">&nbsp;
4665 <input type="button" name="subscribe" id="subscribe_button" class="button button-primary" value="Subscribe" onclick="loginizer_email_subscribe();" style="margin-top:0px;">
4666 </div>
4667 <div class="col-md-3">
4668 </div>
4669 </div>
4670 </form>
4671 <p><b>Note :</b> If a Loginizer account does not exist it will be created.</p>
4672 </div>
4673 </div>
4674 </div><br />
4675
4676 <script type="text/javascript">
4677 function loginizer_dismiss_newsletter(){
4678
4679 var data = new Object();
4680 data["action"] = "loginizer_dismiss_newsletter";
4681 data["nonce"] = "'.wp_create_nonce('loginizer_admin_ajax').'";
4682
4683 var admin_url = "'.admin_url().'"+"admin-ajax.php";
4684 jQuery.post(admin_url, data, function(response){
4685
4686 });
4687
4688 }
4689
4690 function loginizer_email_subscribe(){
4691 var subs_location = "'.$env['url'].'?email="+encodeURIComponent(jQuery("#subscribe_email").val());
4692 window.open(subs_location, "_blank");
4693 }
4694 jQuery(document).on("click", ".my-loginizer-dismiss-notice .notice-dismiss", loginizer_dismiss_newsletter);
4695 </script>';
4696
4697 return true;
4698 }
4699
4700
4701 // Sorry to see you going
4702 register_uninstall_hook(LOGINIZER_FILE, 'loginizer_deactivation');
4703
4704 function loginizer_deactivation(){
4705
4706 global $wpdb;
4707
4708 $sql = array();
4709 $sql[] = "DROP TABLE ".$wpdb->prefix."loginizer_logs;";
4710
4711 foreach($sql as $sk => $sv){
4712 $wpdb->query($sv);
4713 }
4714
4715 delete_option('loginizer_version');
4716 delete_option('loginizer_options');
4717 delete_option('loginizer_last_reset');
4718 delete_option('loginizer_whitelist');
4719 delete_option('loginizer_blacklist');
4720 delete_option('loginizer_msg');
4721 delete_option('loginizer_2fa_msg');
4722 delete_option('loginizer_2fa_email_template');
4723 delete_option('loginizer_security');
4724 delete_option('loginizer_wp_admin');
4725
4726 }
4727
4728