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