PluginProbe
Loginizer / 1.6.1
Loginizer v1.6.1
2.1.0 2.0.9 2.0.8 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 All 74 releases
loginizer / init.php

init.php in Loginizer 1.6.1, at init.php

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