PluginProbe
Loginizer / 1.5.2
Loginizer v1.5.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
loginizer / init.php

init.php in Loginizer 1.5.2, at init.php

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