PluginProbe
Loginizer / 1.5.0
Loginizer v1.5.0
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.5.0, at init.php

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