PluginProbe
Loginizer / 1.4.9
Loginizer v1.4.9
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
← All changes | init.php +1660 -493 2.1.01.4.9 View file →
@@ -4,13 +4,12 @@
4 4 echo 'You are not allowed to access this page directly.';
5 5 exit;
6 6 }
7 7
8 -define('LOGINIZER_VERSION', '2.1.0');
8 +define('LOGINIZER_VERSION', '1.4.9');
9 9 define('LOGINIZER_DIR', dirname(LOGINIZER_FILE));
10 10 define('LOGINIZER_URL', plugins_url('', LOGINIZER_FILE));
11 11 define('LOGINIZER_PRO_URL', 'https://loginizer.com/features#compare');
12 -define('LOGINIZER_PRICING_URL', 'https://loginizer.com/pricing');
13 12 define('LOGINIZER_DOCS', 'https://loginizer.com/docs/');
14 13
15 14 include_once(LOGINIZER_DIR.'/functions.php');
16 15
@@ -24,9 +23,9 @@
24 23
25 24 $sql = array();
26 25
27 26 $sql[] = "DROP TABLE IF EXISTS `".$wpdb->prefix."loginizer_logs`";
28 -
27 +
29 28 $sql[] = "CREATE TABLE `".$wpdb->prefix."loginizer_logs` (
30 29 `username` varchar(255) NOT NULL DEFAULT '',
31 30 `time` int(10) NOT NULL DEFAULT '0',
32 31 `count` int(10) NOT NULL DEFAULT '0',
@@ -33,9 +32,9 @@
33 32 `lockout` int(10) NOT NULL DEFAULT '0',
34 33 `ip` varchar(255) NOT NULL DEFAULT '',
35 34 `url` varchar(255) NOT NULL DEFAULT '',
36 35 UNIQUE KEY `ip` (`ip`)
37 - ) DEFAULT CHARSET=utf8;";
36 + ) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
38 37
39 38 foreach($sql as $sk => $sv){
40 39 $wpdb->query($sv);
41 40 }
@@ -44,24 +43,12 @@
44 43 add_option('loginizer_options', array());
45 44 add_option('loginizer_last_reset', 0);
46 45 add_option('loginizer_whitelist', array());
47 46 add_option('loginizer_blacklist', array());
48 - add_option('loginizer_2fa_whitelist', array());
49 -
50 - // TODO:: REMOVE THIS AFTER MARCH 2025
51 - $softwp_upgrade = get_option('loginizer_softwp_upgrade', 0);
52 - if(!defined('SITEPAD') && empty($softwp_upgrade)){
53 - loginizer_check_softaculous();
54 - }
47 +
55 48 }
56 49
57 -/**
58 - * Updates the database structure for Loginizer
59 - *
60 - * If the plugin files are updated but database structure is not updated
61 - * this function will update the database structure as per the plugin version
62 - * NOTE: This does not update plugin files it just updates the database structure
63 - */
50 +// Checks if we are to update ?
64 51 function loginizer_update_check(){
65 52
66 53 global $wpdb;
67 54
@@ -89,9 +76,9 @@
89 76 // Trick the following if conditions to not run
90 77 $version = (int) str_replace('.', '', LOGINIZER_VERSION);
91 78
92 79 }
93 -
80 +
94 81 // Is it less than 1.0.1 ?
95 82 if($version < 101){
96 83
97 84 // TODO : GET the existing settings
@@ -121,17 +108,9 @@
121 108
122 109 // Update the existing failed logs to new table
123 110 if(is_array($lz_failed_logs)){
124 111 foreach($lz_failed_logs as $fk => $fv){
125 - $insert_data = array('username' => $fv['username'],
126 - 'time' => $fv['time'],
127 - 'count' => $fv['count'],
128 - 'lockout' => $fv['lockout'],
129 - 'ip' => $fv['ip']);
130 -
131 - $format = array('%s','%d','%d','%d','%s');
132 -
133 - $wpdb->insert($wpdb->prefix.'loginizer_logs', $insert_data, $format);
112 + $wpdb->query("INSERT INTO ".$wpdb->prefix."loginizer_logs SET `username` = '".$fv['username']."', `time` = '".$fv['time']."', `count` = '".$fv['count']."', `lockout` = '".$fv['lockout']."', `ip` = '".$fv['ip']."';");
134 113 }
135 114 }
136 115
137 116 // Update the existing options to new structure
@@ -187,38 +166,11 @@
187 166 $wpdb->query("ALTER TABLE ".$wpdb->prefix."loginizer_logs ADD `url` VARCHAR(255) NOT NULL DEFAULT '' AFTER `ip`;");
188 167
189 168 }
190 169
191 - // Setting alignment to left in social login ?
192 - if($version < 201){
193 - $social_settings = get_option('loginizer_social_settings', []);
194 -
195 - if(!empty($social_settings)){
196 - if(!empty($social_settings['login']) && (!empty($social_settings['login']['login_form']) || !empty($social_settings['login']['registration_form']))){
197 - $social_settings['login']['button_alignment'] = 'left';
198 - }
199 -
200 - if(!empty($social_settings['woocommerce']) && (!empty($social_settings['woocommmerce']['login_form']) || !empty($social_settings['woocommerce']['registration_form']))){
201 - $social_settings['woocommerce']['button_alignment'] = 'left';
202 - }
203 -
204 - if(!empty($social_settings['comment']) && !empty($social_settings['comment']['enable_buttons'])){
205 - $social_settings['comment']['button_alignment'] = 'left';
206 - }
207 -
208 - update_option('loginizer_social_settings', $social_settings);
209 - }
210 - }
211 -
212 170 // Save the new Version
213 171 update_option('loginizer_version', LOGINIZER_VERSION);
214 172
215 - // TODO:: REMOVE THIS AFTER MARCH 2025
216 - $softwp_upgrade = get_option('loginizer_softwp_upgrade', 0);
217 - if(!defined('SITEPAD') && empty($softwp_upgrade)){
218 - loginizer_check_softaculous();
219 - }
220 -
221 173 // In Sitepad Math Captcha is enabled by default
222 174 if(defined('SITEPAD') && get_option('loginizer_captcha') === false){
223 175 $option['captcha_no_google'] = 1;
224 176 add_option('loginizer_captcha', $option);
@@ -235,13 +187,11 @@
235 187 global $loginizer;
236 188
237 189 // Check if the installed version is outdated
238 190 loginizer_update_check();
239 -
191 +
240 192 // Set the array
241 - if(empty($loginizer)){
242 - $loginizer = array();
243 - }
193 + $loginizer = array();
244 194
245 195 $loginizer['prefix'] = !defined('SITEPAD') ? 'Loginizer ' : 'SitePad ';
246 196 $loginizer['app'] = !defined('SITEPAD') ? 'WordPress' : 'SitePad';
247 197 $loginizer['login_basename'] = !defined('SITEPAD') ? 'wp-login.php' : 'login.php';
@@ -260,43 +210,28 @@
260 210 $loginizer['max_lockouts'] = empty($options['max_lockouts']) ? 5 : $options['max_lockouts'];
261 211 $loginizer['lockouts_extend'] = empty($options['lockouts_extend']) ? 86400 : $options['lockouts_extend']; // 24 hours
262 212 $loginizer['reset_retries'] = empty($options['reset_retries']) ? 86400 : $options['reset_retries']; // 24 hours
263 213 $loginizer['notify_email'] = empty($options['notify_email']) ? 0 : $options['notify_email'];
264 - $loginizer['notify_email_address'] = lz_is_multisite() ? get_site_option('admin_email') : get_option('admin_email');
265 - $loginizer['trusted_ips'] = empty($options['trusted_ips']) ? false : true;
266 - $loginizer['blocked_screen'] = empty($options['blocked_screen']) ? false : true;
267 - $loginizer['social_settings'] = get_option('loginizer_social_settings', []);
268 214
269 - if(!empty($options['notify_email_address'])){
270 - $loginizer['notify_email_address'] = $options['notify_email_address'];
271 - $loginizer['custom_notify_email'] = 1;
272 - }
215 + // Default messages
216 + $loginizer['d_msg']['inv_userpass'] = 'Incorrect Username or Password';
217 + $loginizer['d_msg']['ip_blacklisted'] = 'Your IP has been blacklisted';
273 218
274 - // Login Success Email Notification.
275 - $loginizer['login_mail'] = get_option('loginizer_login_mail', []);
276 - add_action('init', 'loginizer_load_translation_vars', 0);
277 -
278 - $loginizer['login_mail_subject'] = empty($loginizer['login_mail']['subject']) ? '' : $loginizer['login_mail']['subject'];
279 - $loginizer['login_mail_body'] = empty($loginizer['login_mail']['body']) ? '' : $loginizer['login_mail']['body'];
280 -
281 - // Load the blacklist and whitelist
282 - $loginizer['blacklist'] = get_option('loginizer_blacklist', []);
283 - $loginizer['whitelist'] = get_option('loginizer_whitelist', []);
284 - $loginizer['2fa_whitelist'] = get_option('loginizer_2fa_whitelist');
219 + // Message Strings
220 + $loginizer['msg'] = get_option('loginizer_msg');
285 221
286 - // It should not be false
287 - if(empty($loginizer['2fa_whitelist'])){
288 - $loginizer['2fa_whitelist'] = array();
222 + foreach($loginizer['d_msg'] as $lk => $lv){
223 + if(empty($loginizer['msg'][$lk])){
224 + $loginizer['msg'][$lk] = $loginizer['d_msg'][$lk];
225 + }
289 226 }
227 +
228 + // Load the blacklist and whitelist
229 + $loginizer['blacklist'] = get_option('loginizer_blacklist');
230 + $loginizer['whitelist'] = get_option('loginizer_whitelist');
290 231
291 232 // When was the database cleared last time
292 233 $loginizer['last_reset'] = get_option('loginizer_last_reset');
293 -
294 - if(!isset($loginizer['ultimate-member-active'])){
295 - $um_is_active = in_array('ultimate-member/ultimate-member.php', apply_filters('active_plugins', get_option('active_plugins', [])));
296 -
297 - $loginizer['ultimate-member-active'] = !empty($um_is_active) ? true : false;
298 - }
299 234
300 235 //print_r($loginizer);
301 236
302 237 // Clear retries
@@ -332,46 +267,158 @@
332 267 // Is called before displaying the error message so that we dont show that the username is wrong or the password
333 268 // Update Error message
334 269 add_action('wp_login_errors', 'loginizer_error_handler', 10001, 2);
335 270 add_action('woocommerce_login_failed', 'loginizer_woocommerce_error_handler', 10001);
336 - add_action('wp_login', 'loginizer_login_success', 11, 2);
337 - add_action('rsssl_two_factor_user_authenticated', 'loginizer_rsssl_2fa_success');
271 +
272 + }
273 +
274 + // Is the premium features there ?
275 + if(file_exists(LOGINIZER_DIR.'/premium.php')){
338 276
339 - if(!empty($loginizer['ultimate-member-active'])){
340 - add_action('wp_login_failed', 'loginizer_ultimatemember_error_handler', 10001);
277 + // Include the file
278 + include_once(LOGINIZER_DIR.'/premium.php');
279 +
280 + loginizer_security_init();
281 +
282 + // Its the free version
283 + }else{
284 +
285 + // The promo time
286 + $loginizer['promo_time'] = get_option('loginizer_promo_time');
287 + if(empty($loginizer['promo_time'])){
288 + $loginizer['promo_time'] = time();
289 + update_option('loginizer_promo_time', $loginizer['promo_time']);
341 290 }
342 -
343 - if(!empty($_COOKIE['lz_social_error']) && !empty($loginizer['social_settings'])){
344 - add_filter('wp_login_errors', 'loginizer_social_login_error_handler', 10000, 2);
291 +
292 + // Are we to show the loginizer promo
293 + if(!empty($loginizer['promo_time']) && $loginizer['promo_time'] > 0 && $loginizer['promo_time'] < (time() - (30*24*3600))){
294 +
295 + add_action('admin_notices', 'loginizer_promo');
296 +
345 297 }
346 - }
347 -
348 - // Social Login Form Actions
349 - if(!empty($loginizer['social_settings'])){
350 - if(!empty($loginizer['social_settings']['login']['login_form'])){
351 - add_action('login_form', 'loginizer_social_btn_login');
298 +
299 + // Are we to disable the promo
300 + if(isset($_GET['loginizer_promo']) && (int)$_GET['loginizer_promo'] == 0){
301 + update_option('loginizer_promo_time', (0 - time()) );
302 + die('DONE');
352 303 }
304 +
353 305 }
354 306
355 - if((function_exists('wp_doing_ajax') && wp_doing_ajax()) || (defined( 'DOING_AJAX' ) && DOING_AJAX)){
356 - include_once LOGINIZER_DIR . '/main/ajax.php';
357 - }
307 +}
358 308
359 - if(is_admin()){
360 - include_once LOGINIZER_DIR . '/main/admin.php';
361 - }
309 +// Show the promo
310 +function loginizer_promo(){
362 311
363 - // ----------------
364 - // PRO INIT END
365 - // ----------------
366 -
367 - // Secuity checks for social login.
368 - if(!empty($_GET['lz_social_provider']) && loginizer_can_login() && empty($_GET['lz_api'])){
369 - add_action('init', 'loginizer_social_login_load');
370 - return;
371 - }
312 + echo '
313 +<style>
314 +.lz_button {
315 +background-color: #4CAF50; /* Green */
316 +border: none;
317 +color: white;
318 +padding: 8px 16px;
319 +text-align: center;
320 +text-decoration: none;
321 +display: inline-block;
322 +font-size: 16px;
323 +margin: 4px 2px;
324 +-webkit-transition-duration: 0.4s; /* Safari */
325 +transition-duration: 0.4s;
326 +cursor: pointer;
372 327 }
373 328
329 +.lz_button:focus{
330 +border: none;
331 +color: white;
332 +}
333 +
334 +.lz_button1 {
335 +color: white;
336 +background-color: #4CAF50;
337 +border:3px solid #4CAF50;
338 +}
339 +
340 +.lz_button1:hover {
341 +box-shadow: 0 6px 8px 0 rgba(0,0,0,0.24), 0 9px 25px 0 rgba(0,0,0,0.19);
342 +color: white;
343 +border:3px solid #4CAF50;
344 +}
345 +
346 +.lz_button2 {
347 +color: white;
348 +background-color: #0085ba;
349 +}
350 +
351 +.lz_button2:hover {
352 +box-shadow: 0 6px 8px 0 rgba(0,0,0,0.24), 0 9px 25px 0 rgba(0,0,0,0.19);
353 +color: white;
354 +}
355 +
356 +.lz_button3 {
357 +color: white;
358 +background-color: #365899;
359 +}
360 +
361 +.lz_button3:hover {
362 +box-shadow: 0 6px 8px 0 rgba(0,0,0,0.24), 0 9px 25px 0 rgba(0,0,0,0.19);
363 +color: white;
364 +}
365 +
366 +.lz_button4 {
367 +color: white;
368 +background-color: rgb(66, 184, 221);
369 +}
370 +
371 +.lz_button4:hover {
372 +box-shadow: 0 6px 8px 0 rgba(0,0,0,0.24), 0 9px 25px 0 rgba(0,0,0,0.19);
373 +color: white;
374 +}
375 +
376 +.loginizer_promo-close{
377 +float:right;
378 +text-decoration:none;
379 +margin: 5px 10px 0px 0px;
380 +}
381 +
382 +.loginizer_promo-close:hover{
383 +color: red;
384 +}
385 +</style>
386 +
387 +<script>
388 +jQuery(document).ready( function() {
389 + (function($) {
390 + $("#loginizer_promo .loginizer_promo-close").click(function(){
391 + var data;
392 +
393 + // Hide it
394 + $("#loginizer_promo").hide();
395 +
396 + // Save this preference
397 + $.post("'.admin_url('?loginizer_promo=0').'", data, function(response) {
398 + //alert(response);
399 + });
400 + });
401 + })(jQuery);
402 +});
403 +</script>
404 +
405 +<div class="notice notice-success" id="loginizer_promo" style="min-height:120px">
406 + <a class="loginizer_promo-close" href="javascript:" aria-label="Dismiss this Notice">
407 + <span class="dashicons dashicons-dismiss"></span> Dismiss
408 + </a>
409 + <img src="'.LOGINIZER_URL.'/loginizer-200.png" style="float:left; margin:10px 20px 10px 10px" width="100" />
410 + <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>
411 + <p>
412 + <a class="lz_button lz_button1" target="_blank" href="https://loginizer.com/features">Upgrade to Pro</a>
413 + <a class="lz_button lz_button2" target="_blank" href="https://wordpress.org/support/view/plugin-reviews/loginizer">Rate it 5★\'s</a>
414 + <a class="lz_button lz_button3" target="_blank" href="https://www.facebook.com/Loginizer-815504798591884/">Like Us on Facebook</a>
415 + <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>
416 + </p>
417 +</div>';
418 +
419 +}
420 +
374 421 // Should return NULL if everything is fine
375 422 function loginizer_wp_authenticate($user, $username, $password){
376 423
377 424 global $loginizer, $lz_error, $lz_cannot_login, $lz_user_pass;
@@ -383,36 +430,13 @@
383 430 // Are you whitelisted ?
384 431 if(loginizer_is_whitelisted()){
385 432 $loginizer['ip_is_whitelisted'] = 1;
386 433 return $user;
387 -
388 - } else if (!empty($loginizer['trusted_ips'])){
389 - $lz_cannot_login = 1;
390 -
391 - // This is used by WP Activity Log
392 - apply_filters( 'wp_login_blocked', $username );
393 -
394 - // Shows a blocked screen
395 - if(!empty($loginizer['blocked_screen'])){
396 - $lz_error['trusted_ip'] = __('You are restricted from logging in as your IP is not whitelisted.', 'loginizer');
397 - loginizer_blocked_page($lz_error);
398 - }
399 -
400 - return new WP_Error('ip_blacklisted', __('You are restricted from logging in as your IP is not whitelisted.', 'loginizer'));
401 434 }
402 435
403 436 // Are you blacklisted ?
404 437 if(loginizer_is_blacklisted()){
405 438 $lz_cannot_login = 1;
406 -
407 - // This is used by WP Activity Log
408 - apply_filters( 'wp_login_blocked', $username );
409 -
410 - // Shows a blocked screen
411 - if(!empty($loginizer['blocked_screen'])){
412 - loginizer_blocked_page($lz_error);
413 - }
414 -
415 439 return new WP_Error('ip_blacklisted', implode('', $lz_error), 'loginizer');
416 440 }
417 441
418 442 // Is the username blacklisted ?
@@ -418,12 +442,8 @@
418 442 // Is the username blacklisted ?
419 443 if(function_exists('loginizer_user_blacklisted')){
420 444 if(loginizer_user_blacklisted($username)){
421 445 $lz_cannot_login = 1;
422 -
423 - // This is used by WP Activity Log
424 - apply_filters( 'wp_login_blocked', $username );
425 -
426 446 return new WP_Error('user_blacklisted', implode('', $lz_error), 'loginizer');
427 447 }
428 448 }
429 449
@@ -431,19 +451,11 @@
431 451 return $user;
432 452 }
433 453
434 454 $lz_cannot_login = 1;
435 -
436 - // This is used by WP Activity Log
437 - apply_filters( 'wp_login_blocked', $username );
438 455
439 - // Shows a blocked screen
440 - if(!empty($loginizer['blocked_screen'])){
441 - loginizer_blocked_page($lz_error);
442 - }
456 + return new WP_Error('ip_blocked', implode('', $lz_error), 'loginizer');
443 457
444 - return new WP_Error('ip_blocked', implode('', $lz_error), 'loginizer');
445 -
446 458 }
447 459
448 460 function loginizer_can_login(){
449 461
@@ -449,13 +461,12 @@
449 461
450 462 global $wpdb, $loginizer, $lz_error;
451 463
452 464 // Get the logs
453 - $sel_query = $wpdb->prepare("SELECT * FROM `".$wpdb->prefix."loginizer_logs` WHERE `ip` = %s", $loginizer['current_ip']);
454 - $result = lz_selectquery($sel_query);
465 + $result = lz_selectquery("SELECT * FROM `".$wpdb->prefix."loginizer_logs` WHERE `ip` = '".$loginizer['current_ip']."';");
455 466
456 467 if(!empty($result['count']) && ($result['count'] % $loginizer['max_retries']) == 0){
457 -
468 +
458 469 // Has he reached max lockouts ?
459 470 if($result['lockout'] >= $loginizer['max_lockouts']){
460 471 $loginizer['lockout_time'] = $loginizer['lockouts_extend'];
461 472 }
@@ -467,20 +478,17 @@
467 478 //echo 'Current Time '.date('d/M/Y H:i:s P', time()).'<br />';
468 479 //echo 'Last attempt '.date('d/M/Y H:i:s P', $result['time']).'<br />';
469 480 //echo 'Unlock Time '.date('d/M/Y H:i:s P', $result['time'] + $loginizer['lockout_time']).'<br />';
470 481
471 - $_time = $banlift.' '.$loginizer['msg']['minutes_err'];
482 + $_time = $banlift.' minute(s)';
472 483
473 484 if($banlift > 60){
474 485 $banlift = ceil($banlift / 60);
475 - $_time = $banlift.' '.$loginizer['msg']['hours_err'];
486 + $_time = $banlift.' hour(s)';
476 487 }
477 488
478 - $lz_error['ip_blocked'] = $loginizer['msg']['lockout_err'].' '.$_time;
489 + $lz_error['ip_blocked'] = 'You have exceeded maximum login retries<br /> Please try after '.$_time;
479 490
480 - if(!empty($loginizer['ultimate-member-active']) && class_exists('UM')){
481 - \UM()->form()->add_error('blocked_msg', $lz_error['ip_blocked']);
482 - }
483 491 return false;
484 492 }
485 493 }
486 494
@@ -490,36 +498,68 @@
490 498 function loginizer_is_blacklisted(){
491 499
492 500 global $wpdb, $loginizer, $lz_error;
493 501
494 - $blacklist = isset($loginizer['blacklist']) ? $loginizer['blacklist'] : [];
502 + $blacklist = $loginizer['blacklist'];
503 +
504 + foreach($blacklist as $k => $v){
505 +
506 + // Is the IP in the blacklist ?
507 + if(inet_ptoi($v['start']) <= inet_ptoi($loginizer['current_ip']) && inet_ptoi($loginizer['current_ip']) <= inet_ptoi($v['end'])){
508 + $result = 1;
509 + break;
510 + }
511 +
512 + // Is it in a wider range ?
513 + if(inet_ptoi($v['start']) >= 0 && inet_ptoi($v['end']) < 0){
514 +
515 + // Since the end of the RANGE (i.e. current IP range) is beyond the +ve value of inet_ptoi,
516 + // if the current IP is <= than the start of the range, it is within the range
517 + // OR
518 + // if the current IP is <= than the end of the range, it is within the range
519 + if(inet_ptoi($v['start']) <= inet_ptoi($loginizer['current_ip'])
520 + || inet_ptoi($loginizer['current_ip']) <= inet_ptoi($v['end'])){
521 + $result = 1;
522 + break;
523 + }
524 +
525 + }
526 +
527 + }
528 +
529 + // You are blacklisted
530 + if(!empty($result)){
531 + $lz_error['ip_blacklisted'] = $loginizer['msg']['ip_blacklisted'];
532 + return true;
533 + }
495 534
496 - if(empty($blacklist)){
497 - return false;
498 - }
535 + return false;
499 536
500 - $current_ip_inet = inet_ptoi($loginizer['current_ip']);
537 +}
501 538
502 - foreach($blacklist as $k => $v){
503 -
504 - $start_inet = inet_ptoi($v['start']);
505 - $end_inet = inet_ptoi($v['end']);
506 -
539 +function loginizer_is_whitelisted(){
540 +
541 + global $wpdb, $loginizer, $lz_error;
542 +
543 + $whitelist = $loginizer['whitelist'];
544 +
545 + foreach($whitelist as $k => $v){
546 +
507 547 // Is the IP in the blacklist ?
508 - if($start_inet <= $current_ip_inet && $current_ip_inet <= $end_inet){
548 + if(inet_ptoi($v['start']) <= inet_ptoi($loginizer['current_ip']) && inet_ptoi($loginizer['current_ip']) <= inet_ptoi($v['end'])){
509 549 $result = 1;
510 550 break;
511 551 }
512 -
552 +
513 553 // Is it in a wider range ?
514 - if($start_inet >= 0 && $end_inet < 0){
554 + if(inet_ptoi($v['start']) >= 0 && inet_ptoi($v['end']) < 0){
515 555
516 556 // Since the end of the RANGE (i.e. current IP range) is beyond the +ve value of inet_ptoi,
517 557 // if the current IP is <= than the start of the range, it is within the range
518 558 // OR
519 559 // if the current IP is <= than the end of the range, it is within the range
520 - if($start_inet <= $current_ip_inet
521 - || $current_ip_inet <= $end_inet){
560 + if(inet_ptoi($v['start']) <= inet_ptoi($loginizer['current_ip'])
561 + || inet_ptoi($loginizer['current_ip']) <= inet_ptoi($v['end'])){
522 562 $result = 1;
523 563 break;
524 564 }
525 565
@@ -525,12 +565,11 @@
525 565
526 566 }
527 567
528 568 }
529 -
530 - // You are blacklisted
569 +
570 + // You are whitelisted
531 571 if(!empty($result)){
532 - $lz_error['ip_blacklisted'] = $loginizer['msg']['ip_blacklisted'];
533 572 return true;
534 573 }
535 574
536 575 return false;
@@ -536,8 +575,9 @@
536 575 return false;
537 576
538 577 }
539 578
579 +
540 580 // When the login fails, then this is called
541 581 // We need to update the database
542 582 function loginizer_login_failed($username, $is_2fa = ''){
543 583
@@ -542,13 +582,8 @@
542 582 function loginizer_login_failed($username, $is_2fa = ''){
543 583
544 584 global $wpdb, $loginizer, $lz_cannot_login;
545 585
546 - // Some plugins are changing the value for username as null so we need to handle it before using it for the INSERT OR UPDATE query
547 - if(empty($username) || is_null($username)){
548 - $username = '';
549 - }
550 -
551 586 $fail_type = 'Login';
552 587
553 588 if(!empty($is_2fa)){
554 589 $fail_type = '2FA';
@@ -555,423 +590,1567 @@
555 590 }
556 591
557 592 if(empty($lz_cannot_login) && empty($loginizer['ip_is_whitelisted']) && empty($loginizer['no_loginizer_logs'])){
558 593
559 - // The params which comes when social login returns an error, have some characters, which WordPress could not save.
560 - // REQUEST_URI / HTTP_HOST are not always set (WP-CLI, some CGI and XML-RPC setups)
561 - $server_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
562 - $http_host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
594 + $url = @addslashes((!empty($_SERVER['HTTPS']) ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
595 + $url = esc_url($url);
563 596
564 - if(!empty($server_uri) && strpos($server_uri, 'lz_social_provider') !== FALSE){
565 - $request_uri = explode('=', $server_uri);
566 - $server_uri = $request_uri[0];
567 - }
568 -
569 - // No addslashes() here, $wpdb->prepare() below does the escaping
570 - $url = esc_url((!empty($_SERVER['HTTPS']) ? 'https://' : 'http://').$http_host.$server_uri);
597 + $result = lz_selectquery("SELECT * FROM `".$wpdb->prefix."loginizer_logs` WHERE `ip` = '".$loginizer['current_ip']."';");
571 598
572 - // Must never be 0, we divide by it below
573 - $max_retries = (int) $loginizer['max_retries'] < 1 ? 1 : (int) $loginizer['max_retries'];
574 -
575 - // This way is atomic now, the earlier one were causing race condition.
576 - // NOTE : In the UPDATE part `count` is already the new value, as MySQL / MariaDB
577 - // evaluate the assignments from left to right, so lockout must NOT add 1 again
578 - $upsert = $wpdb->prepare(
579 - "INSERT INTO `".$wpdb->prefix."loginizer_logs`
580 - (username, time, count, ip, lockout, url)
581 - VALUES
582 - (%s, %d, 1, %s, FLOOR(1 / %d), %s)
583 - ON DUPLICATE KEY UPDATE
584 - username = VALUES(username),
585 - time = VALUES(time),
586 - count = count + 1,
587 - lockout = FLOOR(count / %d),
588 - url = VALUES(url)",
589 - $username,
590 - time(),
591 - $loginizer['current_ip'],
592 - $max_retries,
593 - $url,
594 - $max_retries
595 - );
596 - $wpdb->query($upsert);
599 + if(!empty($result)){
600 + $lockout = floor((($result['count']+1) / $loginizer['max_retries']));
601 + $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']."';");
602 +
603 + // Do we need to email admin ?
604 + if(!empty($loginizer['notify_email']) && $lockout >= $loginizer['notify_email']){
605 +
606 + $sitename = lz_is_multisite() ? get_site_option('site_name') : get_option('blogname');
607 + $mail = array();
608 + $mail['to'] = lz_is_multisite() ? get_site_option('admin_email') : get_option('admin_email');
609 + $mail['subject'] = 'Failed '.$fail_type.' Attempts from IP '.$loginizer['current_ip'].' ('.$sitename.')';
610 + $mail['message'] = 'Hi,
597 611
598 - // Re-read the persisted row so email/retries-left reflect the actual count
599 - $sel_query = $wpdb->prepare("SELECT * FROM `".$wpdb->prefix."loginizer_logs` WHERE `ip` = %s", $loginizer['current_ip']);
600 - $result = lz_selectquery($sel_query);
612 +'.($result['count']+1).' failed '.strtolower($fail_type).' attempts and '.$lockout.' lockout(s) from IP '.$loginizer['current_ip'].'
601 613
602 - if(empty($result)){
603 - $result = array('count' => 0);
604 - }
605 -
606 - $count = (int) $result['count'];
607 - $lockout = !empty($result['lockout']) ? (int) $result['lockout'] : 0;
608 -
609 - // The lockout goes up only on every max_retries'th failure, which is the
610 - // attempt that actually locks the IP out. On the failures in between there
611 - // is nothing new to report, so we must not email on each one of them
612 - $is_new_lockout = !empty($count) && ($count % $max_retries) == 0;
613 -
614 - // Do we need to email admin ?
615 - if(!empty($loginizer['notify_email']) && !empty($is_new_lockout) && $lockout >= $loginizer['notify_email']){
616 -
617 - $lockout_time = $loginizer['lockout_time'];
618 -
619 - if($lockout >= $loginizer['max_lockouts']){
620 - $lockout_time = $loginizer['lockouts_extend'];
621 - }
622 -
623 - $sitename = lz_is_multisite() ? get_site_option('site_name') : get_option('blogname');
624 - $mail = array();
625 - $mail['to'] = $loginizer['notify_email_address'];
626 - $mail['subject'] = 'Failed '.$fail_type.' Attempts from IP '.$loginizer['current_ip'].' ('.$sitename.')';
627 - $mail['message'] = 'Hi,
628 -
629 -'.(int) $result['count'].' failed '.strtolower($fail_type).' attempts and '.$lockout.' lockout(s) from IP '.$loginizer['current_ip'].' on your site :
630 -'.home_url().'
631 -
632 614 Last '.$fail_type.' Attempt : '.date('d/M/Y H:i:s P', time()).'
633 615 Last User Attempt : '.$username.'
634 -IP has been blocked until : '.date('d/M/Y H:i:s P', time() + $lockout_time).'
616 +IP has been blocked until : '.date('d/M/Y H:i:s P', time() + $loginizer['lockout_time']).'
635 617
636 618 Regards,
637 619 Loginizer';
638 620
639 - @wp_mail($mail['to'], $mail['subject'], $mail['message']);
621 + @wp_mail($mail['to'], $mail['subject'], $mail['message']);
622 + }
623 + }else{
624 + $insert = $wpdb->query("INSERT INTO `".$wpdb->prefix."loginizer_logs` SET `username` = '".$username."', `time` = '".time()."', `count` = '1', `ip` = '".$loginizer['current_ip']."', `lockout` = '0', `url` = '".$url."';");
640 625 }
626 +
627 + // We need to add one as this is a failed attempt as well
628 + $result['count'] = $result['count'] + 1;
629 + $loginizer['retries_left'] = ($loginizer['max_retries'] - ($result['count'] % $loginizer['max_retries']));
630 + $loginizer['retries_left'] = $loginizer['retries_left'] == $loginizer['max_retries'] ? 0 : $loginizer['retries_left'];
631 +
632 + }
633 +}
641 634
642 - loginizer_update_attempt_stats(0);
643 - $loginizer['retries_left'] = $max_retries - ($count % $max_retries);
644 - $loginizer['retries_left'] = $loginizer['retries_left'] == $max_retries ? 0 : $loginizer['retries_left'];
635 +// Handles the error of the password not being there
636 +function loginizer_error_handler($errors, $redirect_to){
637 +
638 + global $wpdb, $loginizer, $lz_user_pass, $lz_cannot_login;
639 +
640 + //echo 'loginizer_error_handler :';print_r($errors->errors);echo '<br>';
641 +
642 + // Remove the empty password error
643 + if(is_wp_error($errors)){
645 644
645 + $codes = $errors->get_error_codes();
646 +
647 + foreach($codes as $k => $v){
648 + if($v == 'invalid_username' || $v == 'incorrect_password'){
649 + $show_error = 1;
650 + }
651 + }
652 +
653 + $errors->remove('invalid_username');
654 + $errors->remove('incorrect_password');
655 +
646 656 }
657 +
658 + // Add the error
659 + if(!empty($lz_user_pass) && !empty($show_error) && empty($lz_cannot_login)){
660 + $errors->add('invalid_userpass', '<b>ERROR:</b> ' . $loginizer['msg']['inv_userpass']);
661 + }
662 +
663 + // Add the number of retires left as well
664 + if(count($errors->get_error_codes()) > 0 && isset($loginizer['retries_left'])){
665 + $errors->add('retries_left', loginizer_retries_left());
666 + }
667 +
668 + return $errors;
669 +
647 670 }
648 671
649 -function loginizer_rsssl_2fa_success($user){
650 - loginizer_login_success('', $user);
651 -}
652 672
653 -function loginizer_login_success($user_login, $user) {
654 - global $wp_version, $loginizer;
655 673
656 - loginizer_update_attempt_stats(1);
674 +// Handles the error of the password not being there
675 +function loginizer_woocommerce_error_handler(){
657 676
658 - if(empty($loginizer['login_mail'])){
659 - return;
677 + global $wpdb, $loginizer, $lz_user_pass, $lz_cannot_login;
678 +
679 + if(function_exists('wc_add_notice')){
680 + wc_add_notice( loginizer_retries_left(), 'error' );
660 681 }
682 +
683 +}
661 684
662 - if(empty($loginizer['login_mail']['enable'])){
663 - return;
685 +// Returns a string with the number of retries left
686 +function loginizer_retries_left(){
687 +
688 + global $wpdb, $loginizer, $lz_user_pass, $lz_cannot_login;
689 +
690 + // If we are to show the number of retries left
691 + if(isset($loginizer['retries_left'])){
692 + return '<b>'.$loginizer['retries_left'].'</b> attempt(s) left';
664 693 }
694 +
695 +}
665 696
666 - if(!empty($loginizer['login_mail']['disable_whitelist'])){
667 - // Check its whitelist ip
668 - if(loginizer_is_whitelisted()){
669 - return;
670 - }
671 - }
697 +function loginizer_reset_retries(){
698 +
699 + global $wpdb, $loginizer;
700 +
701 + $deltime = time() - $loginizer['reset_retries'];
702 + $result = $wpdb->query("DELETE FROM `".$wpdb->prefix."loginizer_logs` WHERE `time` <= '".$deltime."';");
703 +
704 + update_option('loginizer_last_reset', time());
705 +
706 +}
672 707
673 - if(empty($user_login) && empty($user)){
674 - error_log('Loginizer: No user information to send email');
675 - return;
708 +add_filter("plugin_action_links_$plugin_loginizer", 'loginizer_plugin_action_links');
709 +
710 +// Add settings link on plugin page
711 +function loginizer_plugin_action_links($links) {
712 +
713 + if(!defined('LOGINIZER_PREMIUM')){
714 + $links[] = '<a href="'.LOGINIZER_PRO_URL.'" style="color:#3db634;" target="_blank">'._x('Upgrade', 'Plugin action link label.', 'loginizer').'</a>';
676 715 }
677 716
678 - if(empty($user)){
679 - $user = get_user_by('login', $user_login);
680 - }
717 + $settings_link = '<a href="admin.php?page=loginizer">Settings</a>';
718 + array_unshift($links, $settings_link);
719 +
720 + return $links;
721 +}
681 722
682 - if(empty($user)){
683 - error_log('Loginizer: Unable to get the user');
684 - return;
685 - }
723 +add_action('admin_menu', 'loginizer_admin_menu');
686 724
687 - if(empty($loginizer['login_mail']['roles']) || !is_array($loginizer['login_mail']['roles'])){
688 - return;
725 +// Shows the admin menu of Loginizer
726 +function loginizer_admin_menu() {
727 +
728 + global $wp_version, $loginizer;
729 +
730 + if(!defined('SITEPAD')){
731 +
732 + // Add the menu page
733 + add_menu_page(__('Loginizer Dashboard'), __('Loginizer Security'), 'activate_plugins', 'loginizer', 'loginizer_page_dashboard');
734 +
735 + // Dashboard
736 + add_submenu_page('loginizer', __('Loginizer Dashboard'), __('Dashboard'), 'activate_plugins', 'loginizer', 'loginizer_page_dashboard');
737 +
738 + }else{
739 +
740 + // Add the menu page
741 + add_menu_page(__('Security'), __('Security'), 'activate_plugins', 'loginizer', 'loginizer_page_security', 'dashicons-shield', 85);
742 +
743 + // Rename Login
744 + add_submenu_page('loginizer', __('Security Settings'), __('Rename Login'), 'activate_plugins', 'loginizer', 'loginizer_page_security');
745 +
689 746 }
690 -
691 - // Check if the user role is enabled for email notification.
692 - if(!array_intersect($user->roles, $loginizer['login_mail']['roles'])){
693 - return;
747 +
748 + // Brute Force
749 + add_submenu_page('loginizer', __('Brute Force Settings'), __('Brute Force'), 'activate_plugins', 'loginizer_brute_force', 'loginizer_page_brute_force');
750 +
751 + if(defined('LOGINIZER_PREMIUM')){
752 +
753 + // PasswordLess
754 + add_submenu_page('loginizer', __($loginizer['prefix'].'PasswordLess Settings'), __('PasswordLess'), 'activate_plugins', 'loginizer_passwordless', 'loginizer_page_passwordless');
755 +
756 + // Security Settings
757 + if(!defined('SITEPAD')){
758 +
759 + // Two Factor Auth
760 + add_submenu_page('loginizer', __($loginizer['prefix'].' Two Factor Authentication'), __('Two Factor Auth'), 'activate_plugins', 'loginizer_2fa', 'loginizer_page_2fa');
761 +
762 + }
763 +
764 + // reCaptcha
765 + add_submenu_page('loginizer', __($loginizer['prefix'].'reCAPTCHA Settings'), __('reCAPTCHA'), 'activate_plugins', 'loginizer_recaptcha', 'loginizer_page_recaptcha');
766 +
767 + // Security Settings
768 + if(!defined('SITEPAD')){
769 +
770 + // Security Settings
771 + add_submenu_page('loginizer', __($loginizer['prefix'].'Security Settings'), __('Security Settings'), 'activate_plugins', 'loginizer_security', 'loginizer_page_security');
772 +
773 + // File Checksums
774 + add_submenu_page('loginizer', __('Loginizer File Checksums'), __('File Checksums'), 'activate_plugins', 'loginizer_checksums', 'loginizer_page_checksums');
775 +
776 + }
777 +
778 + }elseif(!defined('LOGINIZER_PREMIUM') && !empty($loginizer['ins_time']) && $loginizer['ins_time'] < (time() - (30*24*3600))){
779 +
780 + // Go Pro link
781 + add_submenu_page('loginizer', __('Loginizer Go Pro'), __('Go Pro'), 'activate_plugins', LOGINIZER_PRO_URL);
782 +
694 783 }
784 +
785 +}
695 786
696 - // current_datetime & wp_timezone_string were introduced in WordPress 5.3
697 - if(!empty($wp_version) && version_compare($wp_version, '5.3', '>') && function_exists('current_datetime')){
698 - $time_zone = wp_timezone_string();
787 +// The Loginizer Admin Options Page
788 +function loginizer_page_header($title = 'Loginizer'){
789 +
790 + global $loginizer;
699 791
700 - if(!empty($time_zone) && isset($time_zone[1]) && is_numeric($time_zone[1])){
701 - $time_zone = 'UTC'.$time_zone;
702 - }
792 +?>
793 +<style>
794 +.lz-right-ul{
795 + padding-left: 10px !important;
796 +}
703 797
704 - // Setting up data variables.
705 - $date = current_datetime()->format('Y-m-d H:i:s') .' '. $time_zone;
706 - } else {
707 - $date = date("Y-m-d H:i:s", time()) . ' ' . date_default_timezone_get();
798 +.lz-right-ul li{
799 + list-style: circle !important;
800 +}
801 +</style>
802 +<?php
803 +
804 + echo '<div style="margin: 10px 20px 0 2px;">
805 +<div class="metabox-holder columns-2">
806 +<div class="postbox-container">
807 +<div id="top-sortables" class="meta-box-sortables ui-sortable">
808 +
809 + <table cellpadding="2" cellspacing="1" width="100%" class="fixed" border="0">
810 + <tr>
811 + <td valign="top"><h3>'.$loginizer['prefix'].$title.'</h3></td>';
812 +
813 + if(!defined('SITEPAD')){
814 +
815 + echo '<td align="right"><a target="_blank" class="button button-primary" href="https://wordpress.org/support/view/plugin-reviews/loginizer">Review Loginizer</a></td>
816 + <td align="right" width="40"><a target="_blank" href="https://twitter.com/loginizer"><img src="'.LOGINIZER_URL.'/twitter.png" /></a></td>
817 + <td align="right" width="40"><a target="_blank" href="https://www.facebook.com/Loginizer-815504798591884"><img src="'.LOGINIZER_URL.'/facebook.png" /></a></td>';
818 +
708 819 }
820 +
821 + echo '
822 + </tr>
823 + </table>
824 + <hr />
825 +
826 + <!--Main Table-->
827 + <table cellpadding="8" cellspacing="1" width="100%" class="fixed">
828 + <tr>
829 + <td valign="top">';
709 830
710 - $sitename = lz_is_multisite() ? get_site_option('site_name') : get_option('blogname');
711 - $email = $user->data->user_email;
831 +}
712 832
713 - $vars = array(
714 - 'date' => $date,
715 - 'ip' => esc_html($loginizer['current_ip']),
716 - 'sitename' => $sitename,
717 - 'user_login' => $user_login
718 - );
719 -
720 - $message = lz_lang_vars_name($loginizer['login_mail_body'], $vars);
721 - $subject = lz_lang_vars_name($loginizer['login_mail_subject'], $vars);
833 +// The Loginizer Theme footer
834 +function loginizer_page_footer(){
722 835
723 - $headers = [];
836 + echo '</td>
837 + <td width="200" valign="top" id="loginizer-right-bar">';
838 +
839 + if(!defined('SITEPAD')){
724 840
725 - // Do we need to send the email as HTML ?
726 - if(!empty($loginizer['login_mail']['html_mail'])){
727 - $headers[] = 'Content-Type: text/html; charset=UTF-8';
841 + if(!defined('LOGINIZER_PREMIUM')){
728 842
729 - if(!empty($loginizer['login_mail']['body'])){
730 - $message = html_entity_decode($message);
843 + echo '
844 + <div class="postbox" style="min-width:0px !important;">
845 + <h2 class="hndle ui-sortable-handle">
846 + <span>Premium Version</span>
847 + </h2>
848 + <div class="inside">
849 + <i>Upgrade to the premium version and get the following features </i>:<br>
850 + <ul class="lz-right-ul">
851 + <li>PasswordLess Login</li>
852 + <li>Two Factor Auth - Email</li>
853 + <li>Two Factor Auth - App</li>
854 + <li>Login Challenge Question</li>
855 + <li>reCAPTCHA</li>
856 + <li>Rename Login Page</li>
857 + <li>Disable XML-RPC</li>
858 + <li>And many more ...</li>
859 + </ul>
860 + <center><a class="button button-primary" href="https://loginizer.com/pricing">Upgrade</a></center>
861 + </div>
862 + </div>';
863 +
731 864 }else{
732 - $message = preg_replace("/\<br\s*\/\>/i", "<br/>", $message);
733 - $message = preg_replace('/(?<!<br\/>)\n/i', "<br/>\n", $message);
865 +
866 + echo '
867 + <div class="postbox" style="min-width:0px !important;">
868 + <h2 class="hndle ui-sortable-handle">
869 + <span>Recommendations</span>
870 + </h2>
871 + <div class="inside">
872 + <i>We recommed that you enable atleast one of the following security features</i>:<br>
873 + <ul class="lz-right-ul">
874 + <li>Rename Login Page</li>
875 + <li>Login Challenge Question</li>
876 + <li>reCAPTCHA</li>
877 + <li>Two Factor Auth - Email</li>
878 + <li>Two Factor Auth - App</li>
879 + <li>Change \'admin\' Username</li>
880 + </ul>
881 + </div>
882 + </div>';
734 883 }
884 +
885 + echo '
886 + <div class="postbox" style="min-width:0px !important;">
887 + <h2 class="hndle ui-sortable-handle">
888 + <span><a target="_blank" href="https://pagelayer.com/?from=loginizer-plugin"><img src="'.LOGINIZER_URL.'/images/pagelayer_product.png" width="100%" /></a></span>
889 + </h2>
890 + <div class="inside">
891 + <i>Easily manage and make professional pages and content with our Pagelayer builder </i>:<br>
892 + <ul class="lz-right-ul">
893 + <li>30+ Free Widgets</li>
894 + <li>60+ Premium Widgets</li>
895 + <li>400+ Premium Sections</li>
896 + <li>Theme Builder</li>
897 + <li>WooCommerce Builder</li>
898 + <li>Theme Creator and Exporter</li>
899 + <li>Form Builder</li>
900 + <li>Popup Builder</li>
901 + <li>And many more ...</li>
902 + </ul>
903 + <center><a class="button button-primary" target="_blank" href="https://wordpress.org/plugins/pagelayer/">Visit Pagelayer</a></center>
904 + </div>
905 + </div>';
906 +
907 + echo '
908 + <div class="postbox" style="min-width:0px !important;">
909 + <h2 class="hndle ui-sortable-handle">
910 + <span><a target="_blank" href="https://wpcentral.co/?from=loginizer-plugin"><img src="'.LOGINIZER_URL.'/images/wpcentral_product.png" width="100%" /></a></span>
911 + </h2>
912 + <div class="inside">
913 + <i>Manage all your WordPress sites from <b>1 dashboard</b> </i>:<br>
914 + <ul class="lz-right-ul">
915 + <li>1-click Admin Access</li>
916 + <li>Update WordPress</li>
917 + <li>Update Themes</li>
918 + <li>Update Plugins</li>
919 + <li>Backup your WordPress Site</li>
920 + <li>Plugins & Theme Management</li>
921 + <li>Post Management</li>
922 + <li>And many more ...</li>
923 + </ul>
924 + <center><a class="button button-primary" target="_blank" href="https://wpcentral.co/?from=loginizer-plugin">Visit wpCentral</a></center>
925 + </div>
926 + </div>';
927 +
735 928 }
736 -
737 - // Sending notification
738 - if(empty(wp_mail($email, $subject, $message, $headers))){
739 - error_log(__('There was a problem sending your email.', 'loginizer'));
740 - return;
929 +
930 + echo '</td>
931 + </tr>
932 + </table>';
933 +
934 + if(!defined('SITEPAD')){
935 +
936 + echo '<br />
937 + <div style="width:45%;background:#FFF;padding:15px; margin:auto">
938 + <b>Let your friends know that you have secured your website :</b>
939 + <form method="get" action="https://twitter.com/intent/tweet" id="tweet" onsubmit="return dotweet(this);">
940 + <textarea name="text" cols="45" row="3" style="resize:none;">I just secured my @WordPress site against #bruteforce using @loginizer</textarea>
941 + &nbsp; &nbsp; <input type="submit" value="Tweet!" class="button button-primary" onsubmit="return false;" id="twitter-btn" style="margin-top:20px;"/>
942 + </form>
943 +
944 + </div>
945 + <br />
946 +
947 + <script>
948 + function dotweet(ele){
949 + 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");
950 + return false;
741 951 }
742 -}
743 -
744 -function loginizer_update_attempt_stats($type){
745 -
746 - $stats = get_option('loginizer_login_attempt_stats', []);
747 - $time = strtotime(date('Y-m-d H:00:00'));
952 + </script>
748 953
749 - if(empty($stats[$time][$type])){
750 - $stats[$time][$type] = 0;
954 + <hr />
955 + <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>.';
956 +
751 957 }
958 +
959 + echo '
960 +</div>
961 +</div>
962 +</div>
963 +</div>';
752 964
753 - $stats[$time][$type] += 1;
754 -
755 - update_option('loginizer_login_attempt_stats', $stats, false);
756 965 }
757 966
758 -// Handles the error of the password not being there
759 -function loginizer_error_handler($errors, $redirect_to){
967 +// The Loginizer Admin Options Page
968 +function loginizer_page_dashboard(){
760 969
761 - global $wpdb, $loginizer, $lz_user_pass, $lz_cannot_login;
970 + global $loginizer, $lz_error, $lz_env;
971 +
972 + if(!current_user_can('manage_options')){
973 + wp_die('Sorry, but you do not have permissions to change settings.');
974 + }
975 +
976 + // Dismiss the announcement
977 + if(isset($_GET['dismiss_announcement'])){
978 + update_option('loginizer_no_announcement', 1);
979 + }
762 980
763 - //echo 'loginizer_error_handler :';print_r($errors->errors);echo '<br>';
764 - if(is_null($errors) || empty($errors)){
765 - return true;
981 + /* Make sure post was from this page */
982 + if(count($_POST) > 0){
983 + check_admin_referer('loginizer-options');
766 984 }
767 985
768 - // Remove the empty password error
769 - if(is_wp_error($errors)){
986 + // Is there a license key ?
987 + if(isset($_POST['save_lz'])){
988 +
989 + $license = lz_optpost('lz_license');
770 990
771 - $codes = $errors->get_error_codes();
991 + // Check if its a valid license
992 + if(empty($license)){
993 + $lz_error['lic_invalid'] = __('The license key was not submitted', 'loginizer');
994 + return loginizer_page_dashboard_T();
995 + }
772 996
773 - foreach($codes as $k => $v){
774 - if($v == 'invalid_username' || $v == 'incorrect_password'){
775 - $show_error = 1;
776 - }
997 + $resp = wp_remote_get(LOGINIZER_API.'license.php?license='.$license, array('timeout' => 30));
998 +
999 + if(is_array($resp)){
1000 + $json = json_decode($resp['body'], true);
1001 + //print_r($json);
1002 + }else{
1003 +
1004 + $lz_error['resp_invalid'] = __('The response was malformed<br>'.var_export($resp, true), 'loginizer');
1005 + return loginizer_page_dashboard_T();
1006 +
777 1007 }
778 1008
779 - $errors->remove('invalid_username');
780 - $errors->remove('incorrect_password');
1009 + // Save the License
1010 + if(empty($json['license'])){
1011 +
1012 + $lz_error['lic_invalid'] = __('The license key is invalid', 'loginizer');
1013 + return loginizer_page_dashboard_T();
1014 +
1015 + }else{
1016 +
1017 + update_option('loginizer_license', $json);
1018 +
1019 + // Mark as saved
1020 + $GLOBALS['lz_saved'] = true;
1021 + }
1022 +
1023 + }
781 1024
782 - // Add the error
783 - if(!empty($lz_user_pass) && !empty($show_error) && empty($lz_cannot_login)){
784 - $errors->add('invalid_userpass', '<b>ERROR:</b> ' . $loginizer['msg']['inv_userpass']);
1025 +
1026 + // Is there a IP Method ?
1027 + if(isset($_POST['save_lz_ip_method'])){
1028 +
1029 + $ip_method = (int) lz_optpost('lz_ip_method');
1030 + $custom_ip_method = lz_optpost('lz_custom_ip_method');
1031 +
1032 + if($ip_method >= 0 && $ip_method <= 3){
1033 + update_option('loginizer_ip_method', $ip_method);
785 1034 }
786 1035
787 - // Add the number of retires left as well
788 - if(count($errors->get_error_codes()) > 0 && isset($loginizer['retries_left'])){
789 - $errors->add('retries_left', loginizer_retries_left());
1036 + // Custom Method name ?
1037 + if($ip_method == 3){
1038 + update_option('loginizer_custom_ip_method', $custom_ip_method);
790 1039 }
791 -
1040 +
792 1041 }
793 1042
794 - return $errors;
1043 + loginizer_page_dashboard_T();
795 1044
796 1045 }
797 1046
798 -// Handles the error of the password not being there
799 -function loginizer_woocommerce_error_handler(){
1047 +// The Loginizer Admin Options Page - THEME
1048 +function loginizer_page_dashboard_T(){
1049 +
1050 + global $loginizer, $lz_error, $lz_env;
800 1051
801 - global $wpdb, $loginizer, $lz_user_pass, $lz_cannot_login;
802 -
803 - if(function_exists('wc_add_notice')){
804 - wc_add_notice( loginizer_retries_left(), 'error' );
805 - }
1052 + loginizer_page_header('Dashboard');
1053 +?>
1054 +<style>
1055 +.welcome-panel{
1056 + margin: 0px;
1057 + padding: 10px;
806 1058 }
807 1059
808 -function loginizer_ultimatemember_error_handler(){
809 -
810 - if(class_exists('UM')){
811 - \UM()->form()->add_error('remaining_tries', loginizer_retries_left());
812 - }
1060 +input[type="text"], textarea, select {
1061 + width: 70%;
813 1062 }
814 1063
815 -// Handles social login URL
816 -function loginizer_social_login_error_handler($errors = '', $redirect_to = ''){
817 - global $loginizer;
1064 +.form-table label{
1065 + font-weight:bold;
1066 +}
1067 +
1068 +.exp{
1069 + font-size:12px;
1070 +}
1071 +</style>
818 1072
819 - if(loginizer_is_blacklisted()){
820 - return $errors;
1073 + <?php
1074 +
1075 + $hide_announcement = get_option('loginizer_no_announcement');
1076 + if(empty($hide_announcement)){
1077 + 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 />';
821 1078 }
1079 +
1080 + echo '<script src="https://api.loginizer.com/'.(defined('LOGINIZER_PREMIUM') ? 'news_security.js' : 'news.js').'"></script><br>';
822 1081
823 - loginizer_get_social_error();
824 -
825 - if(empty($loginizer['social_errors'])){
826 - return $errors;
1082 + // Saved ?
1083 + if(!empty($GLOBALS['lz_saved'])){
1084 + echo '<div id="message" class="updated"><p>'. __('The settings were saved successfully', 'loginizer'). '</p></div><br />';
827 1085 }
828 -
829 - if(is_null($errors) || empty($errors) || !is_wp_error($errors)){
830 - $errors = new WP_Error();
1086 +
1087 + // Any errors ?
1088 + if(!empty($lz_error)){
1089 + lz_report_error($lz_error);echo '<br />';
831 1090 }
832 -
833 - foreach($loginizer['social_errors'] as $key => $text){
834 - $errors->add($key, $text);
835 - }
836 -
837 - return $errors;
838 -}
839 -
840 -// Returns a string with the number of retries left
841 -function loginizer_retries_left(){
842 1091
843 - global $wpdb, $loginizer, $lz_user_pass, $lz_cannot_login;
1092 + ?>
844 1093
845 - // If we are to show the number of retries left
846 - if(isset($loginizer['retries_left'])){
847 - $retries_left = apply_filters('loginizer_retries_left_num', $loginizer['retries_left']);
1094 + <div class="postbox">
1095 +
1096 + <button class="handlediv button-link" aria-expanded="true" type="button">
1097 + <span class="screen-reader-text">Toggle panel: Getting Started</span>
1098 + <span class="toggle-indicator" aria-hidden="true"></span>
1099 + </button>
848 1100
849 - return '<b>'.esc_html($retries_left).'</b> '.$loginizer['msg']['attempts_left'];
850 - }
1101 + <h2 class="hndle ui-sortable-handle">
1102 + <span><?php echo __('Getting Started', 'loginizer'); ?></span>
1103 + </h2>
1104 +
1105 + <div class="inside">
1106 +
1107 + <form action="" method="post" enctype="multipart/form-data">
1108 + <?php wp_nonce_field('loginizer-options'); ?>
1109 + <table class="form-table">
1110 + <tr>
1111 + <td scope="row" valign="top" colspan="2" style="line-height:150%">
1112 + <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>
1113 + <?php
1114 + if(defined('LOGINIZER_PREMIUM')){
1115 + 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>';
1116 + }
1117 + ?>
1118 + </td>
1119 + </tr>
1120 + </table>
1121 + </form>
1122 +
1123 + </div>
1124 + </div>
851 1125
852 -}
1126 + <div class="postbox">
1127 +
1128 + <button class="handlediv button-link" aria-expanded="true" type="button">
1129 + <span class="screen-reader-text">Toggle panel: System Information</span>
1130 + <span class="toggle-indicator" aria-hidden="true"></span>
1131 + </button>
1132 +
1133 + <h2 class="hndle ui-sortable-handle">
1134 + <span><?php echo __('System Information', 'loginizer'); ?></span>
1135 + </h2>
1136 +
1137 + <div class="inside">
1138 +
1139 + <form action="" method="post" enctype="multipart/form-data">
1140 + <?php wp_nonce_field('loginizer-options'); ?>
1141 + <table class="wp-list-table fixed striped users" cellspacing="1" border="0" width="95%" cellpadding="10" align="center">
1142 + <?php
1143 + echo '
1144 + <tr>
1145 + <th align="left" width="25%">'.__('Loginizer Version', 'loginizer').'</th>
1146 + <td>'.LOGINIZER_VERSION.(defined('LOGINIZER_PREMIUM') ? ' (Security PRO Version)' : '').'</td>
1147 + </tr>';
1148 +
1149 + if(defined('LOGINIZER_PREMIUM')){
1150 + echo '
1151 + <tr>
1152 + <th align="left" valign="top">'.__('Loginizer License', 'loginizer').'</th>
1153 + <td align="left">
1154 + '.(empty($loginizer['license']) ? '<span style="color:red">Unlicensed</span> &nbsp; &nbsp;' : '').'
1155 + <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;
1156 + <input name="save_lz" class="button button-primary" value="Update License" type="submit" />';
1157 +
1158 + if(!empty($loginizer['license'])){
1159 +
1160 + $expires = $loginizer['license']['expires'];
1161 + $expires = substr($expires, 0, 4).'/'.substr($expires, 4, 2).'/'.substr($expires, 6);
1162 +
1163 + echo '<div style="margin-top:10px;">License Active : '.(empty($loginizer['license']['active']) ? '<span style="color:red">No</span>' : 'Yes').' &nbsp; &nbsp; &nbsp;
1164 + License Expires : '.($loginizer['license']['expires'] <= date('Ymd') ? '<span style="color:red">'.$expires.'</span>' : $expires).'
1165 + </div>';
1166 + }
1167 +
1168 +
1169 + echo
1170 + '</td>
1171 + </tr>';
1172 + }
1173 +
1174 + echo '<tr>
1175 + <th align="left">'.__('URL', 'loginizer').'</th>
1176 + <td>'.get_site_url().'</td>
1177 + </tr>
1178 + <tr>
1179 + <th align="left">'.__('Path', 'loginizer').'</th>
1180 + <td>'.ABSPATH.'</td>
1181 + </tr>
1182 + <tr>
1183 + <th align="left">'.__('Server\'s IP Address', 'loginizer').'</th>
1184 + <td>'.@$_SERVER['SERVER_ADDR'].'</td>
1185 + </tr>
1186 + <tr>
1187 + <th align="left">'.__('Your IP Address', 'loginizer').'</th>
1188 + <td>'.lz_getip().'
1189 + <div style="float:right">
1190 + Method :
1191 + <select name="lz_ip_method" id="lz_ip_method" style="font-size:11px; width:150px" onchange="lz_ip_method_handle()">
1192 + <option value="0" '.lz_POSTselect('lz_ip_method', 0, (@$loginizer['ip_method'] == 0)).'>REMOTE_ADDR</option>
1193 + <option value="1" '.lz_POSTselect('lz_ip_method', 1, (@$loginizer['ip_method'] == 1)).'>HTTP_X_FORWARDED_FOR</option>
1194 + <option value="2" '.lz_POSTselect('lz_ip_method', 2, (@$loginizer['ip_method'] == 2)).'>HTTP_CLIENT_IP</option>
1195 + <option value="3" '.lz_POSTselect('lz_ip_method', 3, (@$loginizer['ip_method'] == 3)).'>CUSTOM</option>
1196 + </select>
1197 + <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" />
1198 + <input name="save_lz_ip_method" class="button button-primary" value="Save" type="submit" />
1199 + </div>
1200 + </td>
1201 + </tr>
1202 + <tr>
1203 + <th align="left">'.__('wp-config.php is writable', 'loginizer').'</th>
1204 + <td>'.(is_writable(ABSPATH.'/wp-config.php') ? '<span style="color:red">Yes</span>' : '<span style="color:green">No</span>').'</td>
1205 + </tr>';
1206 +
1207 + if(file_exists(ABSPATH.'/.htaccess')){
1208 + echo '
1209 + <tr>
1210 + <th align="left">'.__('.htaccess is writable', 'loginizer').'</th>
1211 + <td>'.(is_writable(ABSPATH.'/.htaccess') ? '<span style="color:red">Yes</span>' : '<span style="color:green">No</span>').'</td>
1212 + </tr>';
1213 +
1214 + }
1215 +
1216 + ?>
1217 + </table>
1218 + </form>
1219 +
1220 + </div>
1221 + </div>
853 1222
854 -function loginizer_reset_retries(){
1223 +<script type="text/javascript">
855 1224
856 - global $wpdb, $loginizer;
1225 +function lz_ip_method_handle(){
1226 + var ele = jQuery('#lz_ip_method');
1227 + if(ele.val() == 3){
1228 + jQuery('#lz_custom_ip_method').show();
1229 + }else{
1230 + jQuery('#lz_custom_ip_method').hide();
1231 + }
1232 +};
857 1233
858 - $deltime = time() - $loginizer['reset_retries'];
1234 +lz_ip_method_handle();
859 1235
860 - $del_query = $wpdb->prepare("DELETE FROM `".$wpdb->prefix."loginizer_logs` WHERE `time` <= %d", $deltime);
861 - $result = $wpdb->query($del_query);
1236 +</script>
1237 +
1238 + <div id="" class="postbox">
1239 +
1240 + <button class="handlediv button-link" aria-expanded="true" type="button">
1241 + <span class="screen-reader-text">Toggle panel: File Permissions</span>
1242 + <span class="toggle-indicator" aria-hidden="true"></span>
1243 + </button>
1244 +
1245 + <h2 class="hndle ui-sortable-handle">
1246 + <span><?php echo __('File Permissions', 'loginizer'); ?></span>
1247 + </h2>
1248 +
1249 + <div class="inside">
1250 +
1251 + <form action="" method="post" enctype="multipart/form-data">
1252 + <?php wp_nonce_field('loginizer-options'); ?>
1253 + <table class="wp-list-table fixed striped users" border="0" width="95%" cellpadding="10" align="center">
1254 + <?php
1255 +
1256 + echo '
1257 + <tr>
1258 + <th style="background:#EFEFEF;">'.__('Relative Path', 'loginizer').'</th>
1259 + <th style="width:10%; background:#EFEFEF;">'.__('Suggested', 'loginizer').'</th>
1260 + <th style="width:10%; background:#EFEFEF;">'.__('Actual', 'loginizer').'</th>
1261 + </tr>';
1262 +
1263 + $wp_content = basename(dirname(dirname(dirname(__FILE__))));
1264 +
1265 + $files_to_check = array('/' => '0755',
1266 + '/wp-admin' => '0755',
1267 + '/wp-includes' => '0755',
1268 + '/wp-config.php' => '0444',
1269 + '/'.$wp_content => '0755',
1270 + '/'.$wp_content.'/themes' => '0755',
1271 + '/'.$wp_content.'/plugins' => '0755',
1272 + '.htaccess' => '0444');
1273 +
1274 + $root = ABSPATH;
1275 +
1276 + foreach($files_to_check as $k => $v){
1277 +
1278 + $path = $root.'/'.$k;
1279 + $stat = @stat($path);
1280 + $suggested = $v;
1281 + $actual = substr(sprintf('%o', $stat['mode']), -4);
1282 +
1283 + echo '
1284 + <tr>
1285 + <td>'.$k.'</td>
1286 + <td>'.$suggested.'</td>
1287 + <td><span '.($suggested != $actual ? 'style="color: red;"' : '').'>'.$actual.'</span></td>
1288 + </tr>';
1289 +
1290 + }
1291 +
1292 + ?>
1293 + </table>
1294 + </form>
1295 +
1296 + </div>
1297 + </div>
862 1298
863 - update_option('loginizer_last_reset', time());
1299 +<?php
1300 +
1301 + loginizer_page_footer();
864 1302
865 1303 }
866 1304
867 -function loginizer_load_translation_vars(){
868 - global $loginizer;
869 -
870 - $loginizer['login_mail_default_sub'] = __('Login Successful at $sitename', 'loginizer');
871 - $loginizer['login_mail_default_msg'] = __('Hello $user_login,
1305 +// The Loginizer Admin Options Page
1306 +function loginizer_page_brute_force(){
872 1307
873 -Your account was recently logged in from the IP : $ip
874 -Time : $date
875 -If it was not you who logged in then please report this to us immediately.
1308 + global $wpdb, $wp_roles, $loginizer;
1309 +
1310 + if(!current_user_can('manage_options')){
1311 + wp_die('Sorry, but you do not have permissions to change settings.');
1312 + }
876 1313
877 -Regards,
878 -$sitename','loginizer');
879 -
880 - if(empty($loginizer['login_mail_subject'])){
881 - $loginizer['login_mail_subject'] = $loginizer['login_mail_default_sub'];
1314 + /* Make sure post was from this page */
1315 + if(count($_POST) > 0){
1316 + check_admin_referer('loginizer-options');
882 1317 }
883 1318
884 - if(empty($loginizer['login_mail_body'])){
885 - $loginizer['login_mail_body'] = $loginizer['login_mail_default_msg'];
1319 + // BEGIN THEME
1320 + loginizer_page_header('Brute Force Settings');
1321 +
1322 + // Load the blacklist and whitelist
1323 + $loginizer['blacklist'] = get_option('loginizer_blacklist');
1324 + $loginizer['whitelist'] = get_option('loginizer_whitelist');
1325 +
1326 + // Disable Brute Force
1327 + if(isset($_POST['disable_brute_lz'])){
1328 +
1329 + // Save the options
1330 + update_option('loginizer_disable_brute', 1);
1331 +
1332 + $loginizer['disable_brute'] = 1;
1333 +
1334 + echo '<div id="message" class="updated"><p>'
1335 + . __('The Brute Force Protection feature is now disabled', 'loginizer')
1336 + . '</p></div><br />';
1337 +
886 1338 }
887 1339
888 - // Default messages
889 - $loginizer['d_msg']['inv_userpass'] = __('Incorrect Username or Password', 'loginizer');
890 - $loginizer['d_msg']['ip_blacklisted'] = __('Your IP has been blacklisted', 'loginizer');
891 - $loginizer['d_msg']['attempts_left'] = __('attempt(s) left', 'loginizer');
892 - $loginizer['d_msg']['lockout_err'] = __('You have exceeded maximum login retries<br /> Please try after', 'loginizer');
893 - $loginizer['d_msg']['minutes_err'] = __('minute(s)', 'loginizer');
894 - $loginizer['d_msg']['hours_err'] = __('hour(s)', 'loginizer');
1340 + // Enable brute force
1341 + if(isset($_POST['enable_brute_lz'])){
1342 +
1343 + // Save the options
1344 + update_option('loginizer_disable_brute', 0);
1345 +
1346 + $loginizer['disable_brute'] = 0;
1347 +
1348 + echo '<div id="message" class="updated"><p>'
1349 + . __('The Brute Force Protection feature is now enabled', 'loginizer')
1350 + . '</p></div><br />';
1351 +
1352 + }
895 1353
896 - // Message Strings
897 - $loginizer['msg'] = get_option('loginizer_msg', []);
1354 + // The Brute Force Settings
1355 + if(isset($_POST['save_lz'])){
1356 +
1357 + $max_retries = (int) lz_optpost('max_retries');
1358 + $lockout_time = (int) lz_optpost('lockout_time');
1359 + $max_lockouts = (int) lz_optpost('max_lockouts');
1360 + $lockouts_extend = (int) lz_optpost('lockouts_extend');
1361 + $reset_retries = (int) lz_optpost('reset_retries');
1362 + $notify_email = (int) lz_optpost('notify_email');
1363 +
1364 + $lockout_time = $lockout_time * 60;
1365 + $lockouts_extend = $lockouts_extend * 60 * 60;
1366 + $reset_retries = $reset_retries * 60 * 60;
1367 +
1368 + if(empty($error)){
1369 +
1370 + $option['max_retries'] = $max_retries;
1371 + $option['lockout_time'] = $lockout_time;
1372 + $option['max_lockouts'] = $max_lockouts;
1373 + $option['lockouts_extend'] = $lockouts_extend;
1374 + $option['reset_retries'] = $reset_retries;
1375 + $option['notify_email'] = $notify_email;
1376 +
1377 + // Save the options
1378 + update_option('loginizer_options', $option);
1379 +
1380 + $saved = true;
1381 +
1382 + }else{
1383 + lz_report_error($error);
1384 + }
898 1385
899 - foreach($loginizer['d_msg'] as $lk => $lv){
900 - if(empty($loginizer['msg'][$lk])){
901 - $loginizer['msg'][$lk] = $loginizer['d_msg'][$lk];
1386 + if(!empty($notice)){
1387 + lz_report_notice($notice);
902 1388 }
1389 +
1390 + if(!empty($saved)){
1391 + echo '<div id="message" class="updated"><p>'
1392 + . __('The settings were saved successfully', 'loginizer')
1393 + . '</p></div><br />';
1394 + }
1395 +
903 1396 }
904 1397
905 - $loginizer['2fa_d_msg']['otp_app'] = __('Please enter the OTP as seen in your App', 'loginizer');
906 - $loginizer['2fa_d_msg']['otp_email'] = __('Please enter the OTP emailed to you', 'loginizer');
907 - $loginizer['2fa_d_msg']['otp_field'] = __('One Time Password', 'loginizer');
908 - $loginizer['2fa_d_msg']['otp_question'] = __('Please answer your security question', 'loginizer');
909 - $loginizer['2fa_d_msg']['otp_answer'] = __('Your Answer', 'loginizer');
1398 + // Delete a Blackist IP range
1399 + if(isset($_POST['bdelid'])){
1400 +
1401 + $delid = (int) lz_optreq('bdelid');
1402 +
1403 + // Unset and save
1404 + $blacklist = $loginizer['blacklist'];
1405 + unset($blacklist[$delid]);
1406 + update_option('loginizer_blacklist', $blacklist);
1407 +
1408 + echo '<div id="message" class="updated fade"><p>'
1409 + . __('The Blacklist IP range has been deleted successfully', 'loginizer')
1410 + . '</p></div><br />';
1411 +
1412 + }
910 1413
911 - // Message Strings
912 - $loginizer['2fa_msg'] = get_option('loginizer_2fa_msg', []);
1414 + // Delete all Blackist IP ranges
1415 + if(isset($_POST['del_all_blacklist'])){
1416 +
1417 + // Unset and save
1418 + update_option('loginizer_blacklist', array());
1419 +
1420 + echo '<div id="message" class="updated fade"><p>'
1421 + . __('The Blacklist IP range(s) have been cleared successfully', 'loginizer')
1422 + . '</p></div><br />';
1423 +
1424 + }
913 1425
914 - foreach($loginizer['2fa_d_msg'] as $lk => $lv){
915 - if(empty($loginizer['2fa_msg'][$lk])){
916 - $loginizer['2fa_msg'][$lk] = $loginizer['2fa_d_msg'][$lk];
1426 + // Delete a Whitelist IP range
1427 + if(isset($_POST['delid'])){
1428 +
1429 + $delid = (int) lz_optreq('delid');
1430 +
1431 + // Unset and save
1432 + $whitelist = $loginizer['whitelist'];
1433 + unset($whitelist[$delid]);
1434 + update_option('loginizer_whitelist', $whitelist);
1435 +
1436 + echo '<div id="message" class="updated fade"><p>'
1437 + . __('The Whitelist IP range has been deleted successfully', 'loginizer')
1438 + . '</p></div><br />';
1439 +
1440 + }
1441 +
1442 + // Delete all Blackist IP ranges
1443 + if(isset($_POST['del_all_whitelist'])){
1444 +
1445 + // Unset and save
1446 + update_option('loginizer_whitelist', array());
1447 +
1448 + echo '<div id="message" class="updated fade"><p>'
1449 + . __('The Whitelist IP range(s) have been cleared successfully', 'loginizer')
1450 + . '</p></div><br />';
1451 +
1452 + }
1453 +
1454 + // Reset All Logs
1455 + if(isset($_POST['lz_reset_all_ip'])){
1456 +
1457 + $result = $wpdb->query("DELETE FROM `".$wpdb->prefix."loginizer_logs`
1458 + WHERE `time` > 0");
1459 +
1460 + echo '<div id="message" class="updated fade"><p>'
1461 + . __('All the IP Logs have been cleared', 'loginizer')
1462 + . '</p></div><br />';
1463 + }
1464 +
1465 + // Reset Logs
1466 + if(isset($_POST['lz_reset_ips']) && is_array($_POST['lz_reset_ips'])){
1467 +
1468 + $ips = $_POST['lz_reset_ips'];
1469 +
1470 + foreach($ips as $ip){
1471 + if(!lz_valid_ip($ip)){
1472 + $error[] = 'The IP - '.$ip.' is invalid !';
1473 + }
917 1474 }
1475 +
1476 + if(count($ips) < 1){
1477 + $error[] = 'There are no IPs submitted';
1478 + }
1479 +
1480 + // Should we start deleting logs
1481 + if(empty($error)){
1482 +
1483 + $result = $wpdb->query("DELETE FROM `".$wpdb->prefix."loginizer_logs`
1484 + WHERE `ip` IN ('".implode("', '", $ips)."')");
1485 +
1486 + if(empty($error)){
1487 +
1488 + echo '<div id="message" class="updated fade"><p>'
1489 + . __('The selected IP Logs have been reset', 'loginizer')
1490 + . '</p></div><br />';
1491 +
1492 + }
1493 +
1494 + }
1495 +
1496 + if(!empty($error)){
1497 + lz_report_error($error);echo '<br />';
1498 + }
1499 +
918 1500 }
919 1501
1502 + if(isset($_POST['blacklist_iprange'])){
1503 +
1504 + $start_ip = lz_optpost('start_ip');
1505 + $end_ip = lz_optpost('end_ip');
1506 +
1507 + if(empty($start_ip)){
1508 + $error[] = 'Please enter the Start IP';
1509 + }
1510 +
1511 + // If no end IP we consider only 1 IP
1512 + if(empty($end_ip)){
1513 + $end_ip = $start_ip;
1514 + }
1515 +
1516 + if(!lz_valid_ip($start_ip)){
1517 + $error[] = 'Please provide a valid start IP';
1518 + }
1519 +
1520 + if(!lz_valid_ip($end_ip)){
1521 + $error[] = 'Please provide a valid end IP';
1522 + }
1523 +
1524 + // Regular ranges will work
1525 + if(inet_ptoi($start_ip) > inet_ptoi($end_ip)){
1526 +
1527 + // BUT, if 0.0.0.1 - 255.255.255.255 is given, it will not work
1528 + if(inet_ptoi($start_ip) >= 0 && inet_ptoi($end_ip) < 0){
1529 + // This is right
1530 + }else{
1531 + $error[] = 'The End IP cannot be smaller than the Start IP';
1532 + }
1533 +
1534 + }
1535 +
1536 + if(empty($error)){
1537 +
1538 + $blacklist = $loginizer['blacklist'];
1539 +
1540 + foreach($blacklist as $k => $v){
1541 +
1542 + // This is to check if there is any other range exists with the same Start or End IP
1543 + if(( inet_ptoi($start_ip) <= inet_ptoi($v['start']) && inet_ptoi($v['start']) <= inet_ptoi($end_ip) )
1544 + || ( inet_ptoi($start_ip) <= inet_ptoi($v['end']) && inet_ptoi($v['end']) <= inet_ptoi($end_ip) )
1545 + ){
1546 + $error[] = 'The Start IP or End IP submitted conflicts with an existing IP range !';
1547 + break;
1548 + }
1549 +
1550 + // This is to check if there is any other range exists with the same Start IP
1551 + if(inet_ptoi($v['start']) <= inet_ptoi($start_ip) && inet_ptoi($start_ip) <= inet_ptoi($v['end'])){
1552 + $error[] = 'The Start IP is present in an existing range !';
1553 + break;
1554 + }
1555 +
1556 + // This is to check if there is any other range exists with the same End IP
1557 + if(inet_ptoi($v['start']) <= inet_ptoi($end_ip) && inet_ptoi($end_ip) <= inet_ptoi($v['end'])){
1558 + $error[] = 'The End IP is present in an existing range!';
1559 + break;
1560 + }
1561 +
1562 + }
1563 +
1564 + $newid = ( empty($blacklist) ? 0 : max(array_keys($blacklist)) ) + 1;
1565 +
1566 + if(empty($error)){
1567 +
1568 + $blacklist[$newid] = array();
1569 + $blacklist[$newid]['start'] = $start_ip;
1570 + $blacklist[$newid]['end'] = $end_ip;
1571 + $blacklist[$newid]['time'] = time();
1572 +
1573 + update_option('loginizer_blacklist', $blacklist);
1574 +
1575 + echo '<div id="message" class="updated fade"><p>'
1576 + . __('Blacklist IP range added successfully', 'loginizer')
1577 + . '</p></div><br />';
1578 +
1579 + }
1580 +
1581 + }
1582 +
1583 + if(!empty($error)){
1584 + lz_report_error($error);echo '<br />';
1585 + }
1586 +
1587 + }
1588 +
1589 + if(isset($_POST['whitelist_iprange'])){
1590 +
1591 + $start_ip = lz_optpost('start_ip_w');
1592 + $end_ip = lz_optpost('end_ip_w');
1593 +
1594 + if(empty($start_ip)){
1595 + $error[] = 'Please enter the Start IP';
1596 + }
1597 +
1598 + // If no end IP we consider only 1 IP
1599 + if(empty($end_ip)){
1600 + $end_ip = $start_ip;
1601 + }
1602 +
1603 + if(!lz_valid_ip($start_ip)){
1604 + $error[] = 'Please provide a valid start IP';
1605 + }
1606 +
1607 + if(!lz_valid_ip($end_ip)){
1608 + $error[] = 'Please provide a valid end IP';
1609 + }
1610 +
1611 + if(inet_ptoi($start_ip) > inet_ptoi($end_ip)){
1612 +
1613 + // BUT, if 0.0.0.1 - 255.255.255.255 is given, it will not work
1614 + if(inet_ptoi($start_ip) >= 0 && inet_ptoi($end_ip) < 0){
1615 + // This is right
1616 + }else{
1617 + $error[] = 'The End IP cannot be smaller than the Start IP';
1618 + }
1619 +
1620 + }
1621 +
1622 + if(empty($error)){
1623 +
1624 + $whitelist = $loginizer['whitelist'];
1625 +
1626 + foreach($whitelist as $k => $v){
1627 +
1628 + // This is to check if there is any other range exists with the same Start or End IP
1629 + if(( inet_ptoi($start_ip) <= inet_ptoi($v['start']) && inet_ptoi($v['start']) <= inet_ptoi($end_ip) )
1630 + || ( inet_ptoi($start_ip) <= inet_ptoi($v['end']) && inet_ptoi($v['end']) <= inet_ptoi($end_ip) )
1631 + ){
1632 + $error[] = 'The Start IP or End IP submitted conflicts with an existing IP range !';
1633 + break;
1634 + }
1635 +
1636 + // This is to check if there is any other range exists with the same Start IP
1637 + if(inet_ptoi($v['start']) <= inet_ptoi($start_ip) && inet_ptoi($start_ip) <= inet_ptoi($v['end'])){
1638 + $error[] = 'The Start IP is present in an existing range !';
1639 + break;
1640 + }
1641 +
1642 + // This is to check if there is any other range exists with the same End IP
1643 + if(inet_ptoi($v['start']) <= inet_ptoi($end_ip) && inet_ptoi($end_ip) <= inet_ptoi($v['end'])){
1644 + $error[] = 'The End IP is present in an existing range!';
1645 + break;
1646 + }
1647 +
1648 + }
1649 +
1650 + $newid = ( empty($whitelist) ? 0 : max(array_keys($whitelist)) ) + 1;
1651 +
1652 + if(empty($error)){
1653 +
1654 + $whitelist[$newid] = array();
1655 + $whitelist[$newid]['start'] = $start_ip;
1656 + $whitelist[$newid]['end'] = $end_ip;
1657 + $whitelist[$newid]['time'] = time();
1658 +
1659 + update_option('loginizer_whitelist', $whitelist);
1660 +
1661 + echo '<div id="message" class="updated fade"><p>'
1662 + . __('Whitelist IP range added successfully', 'loginizer')
1663 + . '</p></div><br />';
1664 +
1665 + }
1666 +
1667 + }
1668 +
1669 + if(!empty($error)){
1670 + lz_report_error($error);echo '<br />';
1671 + }
1672 + }
1673 +
1674 + // Save the messages
1675 + if(isset($_POST['save_err_msgs_lz'])){
1676 +
1677 + $msgs['inv_userpass'] = lz_optpost('msg_inv_userpass');
1678 + $msgs['ip_blacklisted'] = lz_optpost('msg_ip_blacklisted');
1679 +
1680 + // Update them
1681 + update_option('loginizer_msg', $msgs);
1682 +
1683 + echo '<div id="message" class="updated fade"><p>'
1684 + . __('Error messages were saved successfully', 'loginizer')
1685 + . '</p></div><br />';
1686 +
1687 + }
1688 +
1689 + // Count the Results
1690 + $tmp = lz_selectquery("SELECT COUNT(*) AS num FROM `".$wpdb->prefix."loginizer_logs`");
1691 + //print_r($tmp);
1692 +
1693 + // Which Page is it
1694 + $lz_env['res_len'] = 10;
1695 + $lz_env['cur_page'] = lz_get_page('lzpage', $lz_env['res_len']);
1696 + $lz_env['num_res'] = $tmp['num'];
1697 + $lz_env['max_page'] = ceil($lz_env['num_res'] / $lz_env['res_len']);
1698 +
1699 + // Get the logs
1700 + $result = lz_selectquery("SELECT * FROM `".$wpdb->prefix."loginizer_logs`
1701 + ORDER BY `time` DESC
1702 + LIMIT ".$lz_env['cur_page'].", ".$lz_env['res_len']."", 1);
1703 + //print_r($result);
1704 +
1705 + $lz_env['cur_page'] = ($lz_env['cur_page'] / $lz_env['res_len']) + 1;
1706 + $lz_env['cur_page'] = $lz_env['cur_page'] < 1 ? 1 : $lz_env['cur_page'];
1707 + $lz_env['next_page'] = ($lz_env['cur_page'] + 1) > $lz_env['max_page'] ? $lz_env['max_page'] : ($lz_env['cur_page'] + 1);
1708 + $lz_env['prev_page'] = ($lz_env['cur_page'] - 1) < 1 ? 1 : ($lz_env['cur_page'] - 1);
1709 +
1710 + // Reload the settings
1711 + $loginizer['blacklist'] = get_option('loginizer_blacklist');
1712 + $loginizer['whitelist'] = get_option('loginizer_whitelist');
1713 +
1714 + $saved_msgs = get_option('loginizer_msg');
1715 +
1716 + ?>
1717 +
1718 + <div id="" class="postbox">
1719 +
1720 + <button class="handlediv button-link" aria-expanded="true" type="button">
1721 + <span class="screen-reader-text">Toggle panel: Failed Login Attempts Logs</span>
1722 + <span class="toggle-indicator" aria-hidden="true"></span>
1723 + </button>
1724 +
1725 + <h2 class="hndle ui-sortable-handle">
1726 + <?php echo __('<span>Failed Login Attempts Logs</span> &nbsp; (Past '.($loginizer['reset_retries']/60/60).' hours)','loginizer'); ?>
1727 + </h2>
1728 +
1729 + <script>
1730 + function yesdsd(){
1731 + window.location = '<?php echo menu_page_url('loginizer_brute_force', false);?>&lzpage='+jQuery("#current-page-selector").val();
1732 + return false;
1733 + }
1734 + </script>
1735 +
1736 + <form method="get" onsubmit="return yesdsd();">
1737 + <div class="tablenav">
1738 + <p class="tablenav-pages" style="margin: 5px 10px" align="right">
1739 + <span class="displaying-num"><?php echo $lz_env['num_res'];?> items</span>
1740 + <span class="pagination-links">
1741 + <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>
1742 + <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>
1743 + <span class="paging-input">
1744 + <label for="current-page-selector" class="screen-reader-text">Current Page</label>
1745 + <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>
1746 + </span>
1747 + <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>
1748 + <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>
1749 + </span>
1750 + </p>
1751 + </div>
1752 + </form>
1753 +
1754 + <form action="" method="post" enctype="multipart/form-data">
1755 + <?php wp_nonce_field('loginizer-options'); ?>
1756 + <div class="inside">
1757 + <table class="wp-list-table widefat fixed users" border="0">
1758 + <tr>
1759 + <th scope="row" valign="top" style="background:#EFEFEF;" width="20">#</th>
1760 + <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('IP','loginizer'); ?></th>
1761 + <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Attempted Username','loginizer'); ?></th>
1762 + <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Last Failed Attempt (DD/MM/YYYY)','loginizer'); ?></th>
1763 + <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Failed Attempts Count','loginizer'); ?></th>
1764 + <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Lockouts Count','loginizer'); ?></th>
1765 + <th scope="row" valign="top" style="background:#EFEFEF;" width="150"><?php echo __('URL Attacked','loginizer'); ?></th>
1766 + </tr>
1767 + <?php
1768 +
1769 + if(empty($result)){
1770 + echo '
1771 + <tr>
1772 + <td colspan="4">
1773 + No Logs. You will see logs about failed login attempts here.
1774 + </td>
1775 + </tr>';
1776 + }else{
1777 + foreach($result as $ik => $iv){
1778 + $status_button = (!empty($iv['status']) ? 'disable' : 'enable');
1779 + echo '
1780 + <tr>
1781 + <td>
1782 + <input type="checkbox" value="'.$iv['ip'].'" name="lz_reset_ips[]" />
1783 + </td>
1784 + <td>
1785 + '.$iv['ip'].'
1786 + </td>
1787 + <td>
1788 + '.$iv['username'].'
1789 + </td>
1790 + <td>
1791 + '.date('d/M/Y H:i:s P', $iv['time']).'
1792 + </td>
1793 + <td>
1794 + '.$iv['count'].'
1795 + </td>
1796 + <td>
1797 + '.$iv['lockout'].'
1798 + </td>
1799 + <td>
1800 + '.$iv['url'].'
1801 + </td>
1802 + </tr>';
1803 + }
1804 + }
1805 +
1806 + ?>
1807 + </table>
1808 +
1809 + <br>
1810 + <input name="lz_reset_ip" class="button button-primary action" value="<?php echo __('Remove From Logs', 'loginizer'); ?>" type="submit" />
1811 + &nbsp; &nbsp;
1812 + <input name="lz_reset_all_ip" class="button button-primary action" value="<?php echo __('Clear All Logs', 'loginizer'); ?>" type="submit" />
1813 + </div>
1814 + </div>
1815 + </form>
1816 + <br />
1817 +
1818 + <div id="" class="postbox">
1819 +
1820 + <button class="handlediv button-link" aria-expanded="true" type="button">
1821 + <span class="screen-reader-text">Toggle panel: Brute Force Settings</span>
1822 + <span class="toggle-indicator" aria-hidden="true"></span>
1823 + </button>
1824 +
1825 + <h2 class="hndle ui-sortable-handle">
1826 + <span><?php echo __('Brute Force Settings', 'loginizer'); ?></span>
1827 + </h2>
1828 +
1829 + <div class="inside">
1830 +
1831 + <form action="" method="post" enctype="multipart/form-data">
1832 + <?php wp_nonce_field('loginizer-options'); ?>
1833 + <table class="form-table">
1834 + <tr>
1835 + <th scope="row" valign="top"><label for="max_retries"><?php echo __('Max Retries','loginizer'); ?></label></th>
1836 + <td>
1837 + <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 />
1838 + </td>
1839 + </tr>
1840 + <tr>
1841 + <th scope="row" valign="top"><label for="lockout_time"><?php echo __('Lockout Time','loginizer'); ?></label></th>
1842 + <td>
1843 + <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 />
1844 + </td>
1845 + </tr>
1846 + <tr>
1847 + <th scope="row" valign="top"><label for="max_lockouts"><?php echo __('Max Lockouts','loginizer'); ?></label></th>
1848 + <td>
1849 + <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 />
1850 + </td>
1851 + </tr>
1852 + <tr>
1853 + <th scope="row" valign="top"><label for="lockouts_extend"><?php echo __('Extend Lockout','loginizer'); ?></label></th>
1854 + <td>
1855 + <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 />
1856 + </td>
1857 + </tr>
1858 + <tr>
1859 + <th scope="row" valign="top"><label for="reset_retries"><?php echo __('Reset Retries','loginizer'); ?></label></th>
1860 + <td>
1861 + <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 />
1862 + </td>
1863 + </tr>
1864 + <tr>
1865 + <th scope="row" valign="top"><label for="notify_email"><?php echo __('Email Notification','loginizer'); ?></label></th>
1866 + <td>
1867 + <?php echo __('after ','loginizer'); ?>
1868 + <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'); ?>
1869 + </td>
1870 + </tr>
1871 + </table><br />
1872 + <input name="save_lz" class="button button-primary action" value="<?php echo __('Save Settings','loginizer'); ?>" type="submit" />
1873 + <?php
1874 +
1875 + if(empty($loginizer['disable_brute'])){
1876 +
1877 + echo '<input name="disable_brute_lz" class="button action" value="'.__('Disable Brute Force Protection','loginizer').'" type="submit" style="float:right" />';
1878 +
1879 + }else{
1880 +
1881 + echo '<input name="enable_brute_lz" class="button button-primary action" value="'.__('Enable Brute Force Protection','loginizer').'" type="submit" style="float:right" />';
1882 +
1883 + }
1884 +
1885 + ?>
1886 + </form>
1887 +
1888 + </div>
1889 + </div>
1890 + <br />
1891 +
1892 +<?php
1893 +
1894 + wp_enqueue_script('jquery-paginate', LOGINIZER_URL.'/jquery-paginate.js', array('jquery'), '1.10.15');
1895 +
1896 +?>
1897 +
1898 +<style>
1899 +.page-navigation a {
1900 +margin: 5px 2px;
1901 +display: inline-block;
1902 +padding: 5px 8px;
1903 +color: #0073aa;
1904 +background: #e5e5e5 none repeat scroll 0 0;
1905 +border: 1px solid #ccc;
1906 +text-decoration: none;
1907 +transition-duration: 0.05s;
1908 +transition-property: border, background, color;
1909 +transition-timing-function: ease-in-out;
920 1910 }
1911 +
1912 +.page-navigation a[data-selected] {
1913 +background-color: #00a0d2;
1914 +color: #fff;
1915 +}
1916 +</style>
921 1917
922 -function loginizer_social_login_load(){
923 - include_once LOGINIZER_DIR . '/main/social-login.php';
924 -}
1918 +<script>
925 1919
926 -// Checks if softaculous is installed on the server.
927 -function loginizer_check_softaculous(){
1920 +jQuery(document).ready(function(){
1921 + jQuery('#lz_bl_table').paginate({ limit: 11, navigationWrapper: jQuery('#lz_bl_nav')});
1922 + jQuery('#lz_wl_table').paginate({ limit: 11, navigationWrapper: jQuery('#lz_wl_nav')});
1923 +});
928 1924
929 - // Checking if we have Softaculous installed?
930 - if(!preg_match('/^\/home(?:\d+)?\/.*\//U', ABSPATH, $matches)){
931 - return false;
1925 +// Delete a Blacklist / Whitelist IP Range
1926 +function del_confirm(field, todo_id, msg){
1927 + var ret = confirm(msg);
1928 +
1929 + if(ret){
1930 + jQuery('#lz_bl_wl_todo').attr('name', field);
1931 + jQuery('#lz_bl_wl_todo').val(todo_id);
1932 + jQuery('#lz_bl_wl_form').submit();
932 1933 }
1934 +
1935 + return false;
1936 +
1937 +}
933 1938
934 - if(empty($matches) || empty($matches[0])){
935 - return false;
1939 +// Delete all Blacklist / Whitelist IP Ranges
1940 +function del_confirm_all(msg){
1941 + var ret = confirm(msg);
1942 +
1943 + if(ret){
1944 + return true;
936 1945 }
1946 +
1947 + return false;
1948 +
1949 +}
937 1950
938 - $softaculous_path = $matches[0] . '.softaculous/installations.php';
939 - if(!file_exists($softaculous_path)){
940 - return false;
941 - }
1951 +</script>
942 1952
943 - // Checking if users has changed the branding of Softaculous.
944 - $universal_file = '';
945 - // Plesk, ISPManager, ISPConfig, InterWorx, H-Sphere, CentOS Web Panel, Softaculous Remote and Softaculous Enterprise
946 - if(file_exists('/usr/local/softaculous/enduser/universal.php')){
947 - $universal_file = '/usr/local/softaculous/enduser/universal.php';
948 - }else if(file_exists('/usr/local/cpanel/whostmgr/docroot/cgi/softaculous/enduser/universal.php')){
949 - $universal_file = '/usr/local/cpanel/whostmgr/docroot/cgi/softaculous/enduser/universal.php';
950 - }else if(file_exists('/usr/local/directadmin/plugins/softaculous/enduser/universal.php')){
951 - $universal_file = '/usr/local/directadmin/plugins/softaculous/enduser/universal.php';
952 - }else if(file_exists('/usr/local/vesta/softaculous/enduser/universal.php')){
953 - $universal_file = '/usr/local/vesta/softaculous/enduser/universal.php';
954 - }
1953 + <div id="" class="postbox">
1954 +
1955 + <button class="handlediv button-link" aria-expanded="true" type="button">
1956 + <span class="screen-reader-text">Toggle panel: Blacklist IP</span>
1957 + <span class="toggle-indicator" aria-hidden="true"></span>
1958 + </button>
1959 +
1960 + <h2 class="hndle ui-sortable-handle">
1961 + <span><?php echo __('Blacklist IP','loginizer'); ?></span>
1962 + </h2>
1963 +
1964 + <div class="inside">
1965 +
1966 + <?php echo __('Enter the IP you want to blacklist from login','loginizer'); ?>
1967 +
1968 + <form action="" method="post">
1969 + <?php wp_nonce_field('loginizer-options'); ?>
1970 + <table class="form-table">
1971 + <tr>
1972 + <th scope="row" valign="top"><label for="start_ip"><?php echo __('Start IP','loginizer'); ?></label></th>
1973 + <td>
1974 + <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 />
1975 + </td>
1976 + </tr>
1977 + <tr>
1978 + <th scope="row" valign="top"><label for="end_ip"><?php echo __('End IP (Optional)','loginizer'); ?></label></th>
1979 + <td>
1980 + <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 />
1981 + </td>
1982 + </tr>
1983 + </table><br />
1984 + <input name="blacklist_iprange" class="button button-primary action" value="<?php echo __('Add Blacklist IP Range','loginizer'); ?>" type="submit" />
1985 + <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" />
1986 + </form>
1987 + </div>
1988 +
1989 + <div id="lz_bl_nav" style="margin: 5px 10px; text-align:right"></div>
1990 + <table id="lz_bl_table" class="wp-list-table fixed striped users" border="0" width="95%" cellpadding="10" align="center">
1991 + <tr>
1992 + <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Start IP','loginizer'); ?></th>
1993 + <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('End IP','loginizer'); ?></th>
1994 + <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Date (DD/MM/YYYY)','loginizer'); ?></th>
1995 + <th scope="row" valign="top" style="background:#EFEFEF;" width="100"><?php echo __('Options','loginizer'); ?></th>
1996 + </tr>
1997 + <?php
1998 + if(empty($loginizer['blacklist'])){
1999 + echo '
2000 + <tr>
2001 + <td colspan="4">
2002 + No Blacklist IPs. You will see blacklisted IP ranges here.
2003 + </td>
2004 + </tr>';
2005 + }else{
2006 + foreach($loginizer['blacklist'] as $ik => $iv){
2007 + echo '
2008 + <tr>
2009 + <td>
2010 + '.$iv['start'].'
2011 + </td>
2012 + <td>
2013 + '.$iv['end'].'
2014 + </td>
2015 + <td>
2016 + '.date('d/m/Y', $iv['time']).'
2017 + </td>
2018 + <td>
2019 + <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>
2020 + </td>
2021 + </tr>';
2022 + }
2023 + }
2024 + ?>
2025 + </table>
2026 + <br />
2027 + <form action="" method="post" id="lz_bl_wl_form">
2028 + <?php wp_nonce_field('loginizer-options'); ?>
2029 + <input type="hidden" value="" name="" id="lz_bl_wl_todo"/>
2030 + </form>
2031 + </div>
2032 +
2033 + <br />
2034 +
2035 + <div id="" class="postbox">
2036 +
2037 + <button class="handlediv button-link" aria-expanded="true" type="button">
2038 + <span class="screen-reader-text">Toggle panel: Whitelist IP</span>
2039 + <span class="toggle-indicator" aria-hidden="true"></span>
2040 + </button>
2041 +
2042 + <h2 class="hndle ui-sortable-handle">
2043 + <span><?php echo __('Whitelist IP', 'loginizer'); ?></span>
2044 + </h2>
2045 +
2046 + <div class="inside">
2047 +
2048 + <?php echo __('Enter the IP you want to whitelist for login','loginizer'); ?>
2049 + <form action="" method="post">
2050 + <?php wp_nonce_field('loginizer-options'); ?>
2051 + <table class="form-table">
2052 + <tr>
2053 + <th scope="row" valign="top"><label for="start_ip_w"><?php echo __('Start IP','loginizer'); ?></label></th>
2054 + <td>
2055 + <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 />
2056 + </td>
2057 + </tr>
2058 + <tr>
2059 + <th scope="row" valign="top"><label for="end_ip_w"><?php echo __('End IP (Optional)','loginizer'); ?></label></th>
2060 + <td>
2061 + <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 />
2062 + </td>
2063 + </tr>
2064 + </table><br />
2065 + <input name="whitelist_iprange" class="button button-primary action" value="<?php echo __('Add Whitelist IP Range','loginizer'); ?>" type="submit" />
2066 + <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" />
2067 + </form>
2068 + </div>
2069 +
2070 + <div id="lz_wl_nav" style="margin: 5px 10px; text-align:right"></div>
2071 + <table id="lz_wl_table" class="wp-list-table fixed striped users" border="0" width="95%" cellpadding="10" align="center">
2072 + <tr>
2073 + <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Start IP','loginizer'); ?></th>
2074 + <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('End IP','loginizer'); ?></th>
2075 + <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Date (DD/MM/YYYY)','loginizer'); ?></th>
2076 + <th scope="row" valign="top" style="background:#EFEFEF;" width="100"><?php echo __('Options','loginizer'); ?></th>
2077 + </tr>
2078 + <?php
2079 + if(empty($loginizer['whitelist'])){
2080 + echo '
2081 + <tr>
2082 + <td colspan="4">
2083 + No Whitelist IPs. You will see whitelisted IP ranges here.
2084 + </td>
2085 + </tr>';
2086 + }else{
2087 + foreach($loginizer['whitelist'] as $ik => $iv){
2088 + echo '
2089 + <tr>
2090 + <td>
2091 + '.$iv['start'].'
2092 + </td>
2093 + <td>
2094 + '.$iv['end'].'
2095 + </td>
2096 + <td>
2097 + '.date('d/m/Y', $iv['time']).'
2098 + </td>
2099 + <td>
2100 + <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>
2101 + </td>
2102 + </tr>';
2103 + }
2104 + }
2105 + ?>
2106 + </table>
2107 + <br />
2108 +
2109 + </div>
955 2110
956 - if(empty($universal_file)){
957 - return false;
958 - }
2111 + <div id="" class="postbox">
959 2112
960 - $universal = file_get_contents($universal_file);
2113 + <button class="handlediv button-link" aria-expanded="true" type="button">
2114 + <span class="screen-reader-text">Toggle panel: Error Messages</span>
2115 + <span class="toggle-indicator" aria-hidden="true"></span>
2116 + </button>
961 2117
962 - if(empty($universal)){
963 - return false;
964 - }
2118 + <h2 class="hndle ui-sortable-handle">
2119 + <span><?php echo __('Error Messages', 'loginizer'); ?></span>
2120 + </h2>
965 2121
966 - // Checking if Softaculous is being whitelabeled
967 - if(preg_match('/\$globals\[["\']sn["\']\]\s.?=\s.?["\']Softaculous["\']/', $universal)){
968 - update_option('loginizer_softwp_upgrade', time());
969 - }
2122 + <div class="inside">
970 2123
971 - return false;
2124 + <form action="" method="post" enctype="multipart/form-data">
2125 + <?php wp_nonce_field('loginizer-options'); ?>
2126 + <table class="form-table">
2127 + <tr>
2128 + <th scope="row" valign="top"><label for="msg_inv_userpass"><?php echo __('Failed Login Attempt','loginizer'); ?></label></th>
2129 + <td>
2130 + <input type="text" size="25" value="<?php echo esc_attr(@$saved_msgs['inv_userpass']); ?>" name="msg_inv_userpass" id="msg_inv_userpass" />
2131 + <?php echo __('Default: <em>&quot;' . $loginizer['d_msg']['inv_userpass']. '&quot;</em>', 'loginizer'); ?><br />
2132 + </td>
2133 + </tr>
2134 + <tr>
2135 + <th scope="row" valign="top"><label for="msg_ip_blacklisted"><?php echo __('Blacklisted IP','loginizer'); ?></label></th>
2136 + <td>
2137 + <input type="text" size="25" value="<?php echo esc_attr(@$saved_msgs['ip_blacklisted']); ?>" name="msg_ip_blacklisted" id="msg_ip_blacklisted" />
2138 + <?php echo __('Default: <em>&quot;' . $loginizer['d_msg']['ip_blacklisted']. '&quot;</em>', 'loginizer'); ?><br />
2139 + </td>
2140 + </tr>
2141 + </table><br />
2142 + <input name="save_err_msgs_lz" class="button button-primary action" value="<?php echo __('Save Error Messages','loginizer'); ?>" type="submit" />
2143 + </form>
2144 + </div>
2145 + </div>
2146 +<?php
2147 +
2148 +loginizer_page_footer();
2149 +
972 2150 }
973 2151
2152 +
974 2153 // Sorry to see you going
975 2154 register_uninstall_hook(LOGINIZER_FILE, 'loginizer_deactivation');
976 2155
977 2156 function loginizer_deactivation(){
@@ -990,21 +2169,9 @@
990 2169 delete_option('loginizer_last_reset');
991 2170 delete_option('loginizer_whitelist');
992 2171 delete_option('loginizer_blacklist');
993 2172 delete_option('loginizer_msg');
994 - delete_option('loginizer_2fa_msg');
995 - delete_option('loginizer_2fa_email_template');
996 2173 delete_option('loginizer_security');
997 2174 delete_option('loginizer_wp_admin');
998 - delete_option('loginizer_csrf_promo_time');
999 - delete_option('loginizer_backuply_promo_time');
1000 - delete_option('loginizer_promo_time');
1001 - delete_option('loginizer_ins_time');
1002 - delete_option('loginizer_2fa_whitelist');
1003 - delete_option('loginizer_checksums_last_run');
1004 - delete_option('loginizer_checksums_diff');
1005 - delete_option('loginizer_ip_method');
1006 - delete_option('loginizer_2fa_custom_redirect');
1007 - delete_option('external_updates-loginizer-security');
1008 - delete_option('loginizer_login_attempt_stats');
1009 2175
1010 -}
2176 +}
2177 +