PluginProbe
Loginizer / 1.5.3
Loginizer v1.5.3
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.3, at init.php

4,194 lines 137.4 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.3');
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 <div class="postbox-header">
953 <h2 class="hndle ui-sortable-handle">
954 <span>Premium Version</span>
955 </h2>
956 </div>
957
958 <div class="inside">
959 <i>Upgrade to the premium version and get the following features </i>:<br>
960 <ul class="lz-right-ul">
961 <li>PasswordLess Login</li>
962 <li>Two Factor Auth - Email</li>
963 <li>Two Factor Auth - App</li>
964 <li>Login Challenge Question</li>
965 <li>reCAPTCHA</li>
966 <li>Rename Login Page</li>
967 <li>Disable XML-RPC</li>
968 <li>And many more ...</li>
969 </ul>
970 <center><a class="button button-primary" target="_blank" href="'.LOGINIZER_PRICING_URL.'">Upgrade</a></center>
971 </div>
972 </div>';
973
974 }else{
975
976 echo '
977 <div class="postbox" style="min-width:0px !important;">
978 <div class="postbox-header">
979 <h2 class="hndle ui-sortable-handle">
980 <span>Recommendations</span>
981 </h2>
982 </div>
983 <div class="inside">
984 <i>We recommed that you enable atleast one of the following security features</i>:<br>
985 <ul class="lz-right-ul">
986 <li>Rename Login Page</li>
987 <li>Login Challenge Question</li>
988 <li>reCAPTCHA</li>
989 <li>Two Factor Auth - Email</li>
990 <li>Two Factor Auth - App</li>
991 <li>Change \'admin\' Username</li>
992 </ul>
993 </div>
994 </div>';
995 }
996
997 echo '
998 <div class="postbox" style="min-width:0px !important;">
999 <div class="postbox-header">
1000 <h2 class="hndle ui-sortable-handle">
1001 <span><a target="_blank" href="https://pagelayer.com/?from=loginizer-plugin"><img src="'.LOGINIZER_URL.'/images/pagelayer_product.png" width="100%" /></a></span>
1002 </h2>
1003 </div>
1004 <div class="inside">
1005 <i>Easily manage and make professional pages and content with our Pagelayer builder </i>:<br>
1006 <ul class="lz-right-ul">
1007 <li>30+ Free Widgets</li>
1008 <li>60+ Premium Widgets</li>
1009 <li>400+ Premium Sections</li>
1010 <li>Theme Builder</li>
1011 <li>WooCommerce Builder</li>
1012 <li>Theme Creator and Exporter</li>
1013 <li>Form Builder</li>
1014 <li>Popup Builder</li>
1015 <li>And many more ...</li>
1016 </ul>
1017 <center><a class="button button-primary" target="_blank" href="https://wordpress.org/plugins/pagelayer/">Visit Pagelayer</a></center>
1018 </div>
1019 </div>';
1020
1021 echo '
1022 <div class="postbox" style="min-width:0px !important;">
1023 <div class="postbox-header">
1024 <h2 class="hndle ui-sortable-handle">
1025 <span><a target="_blank" href="https://wpcentral.co/?from=loginizer-plugin"><img src="'.LOGINIZER_URL.'/images/wpcentral_product.png" width="100%" /></a></span>
1026 </h2>
1027 </div>
1028 <div class="inside">
1029 <i>Manage all your WordPress sites from <b>1 dashboard</b> </i>:<br>
1030 <ul class="lz-right-ul">
1031 <li>1-click Admin Access</li>
1032 <li>Update WordPress</li>
1033 <li>Update Themes</li>
1034 <li>Update Plugins</li>
1035 <li>Backup your WordPress Site</li>
1036 <li>Plugins & Theme Management</li>
1037 <li>Post Management</li>
1038 <li>And many more ...</li>
1039 </ul>
1040 <center><a class="button button-primary" target="_blank" href="https://wpcentral.co/?from=loginizer-plugin">Visit wpCentral</a></center>
1041 </div>
1042 </div>';
1043
1044 }
1045
1046 echo '</td>
1047 </tr>
1048 </table>';
1049
1050 if(!defined('SITEPAD')){
1051
1052 echo '<br />
1053 <div style="width:45%;background:#FFF;padding:15px; margin:auto">
1054 <b>Let your friends know that you have secured your website :</b>
1055 <form method="get" action="https://twitter.com/intent/tweet" id="tweet" onsubmit="return dotweet(this);">
1056 <textarea name="text" cols="45" row="3" style="resize:none;">I just secured my @WordPress site against #bruteforce using @loginizer</textarea>
1057 &nbsp; &nbsp; <input type="submit" value="Tweet!" class="button button-primary" onsubmit="return false;" id="twitter-btn" style="margin-top:20px;"/>
1058 </form>
1059
1060 </div>
1061 <br />
1062
1063 <script>
1064 function dotweet(ele){
1065 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");
1066 return false;
1067 }
1068 </script>
1069
1070 <hr />
1071 <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>.';
1072
1073 }
1074
1075 echo '
1076 </div>
1077 </div>
1078 </div>
1079 </div>';
1080
1081 }
1082
1083 // The Loginizer Admin Options Page
1084 function loginizer_page_dashboard(){
1085
1086 global $loginizer, $lz_error, $lz_env;
1087
1088 if(!current_user_can('manage_options')){
1089 wp_die('Sorry, but you do not have permissions to change settings.');
1090 }
1091
1092 // Dismiss the announcement
1093 if(isset($_GET['dismiss_announcement'])){
1094 update_option('loginizer_no_announcement', 1);
1095 }
1096
1097 /* Make sure post was from this page */
1098 if(count($_POST) > 0){
1099 check_admin_referer('loginizer-options');
1100 }
1101
1102 // Is there a license key ?
1103 if(isset($_POST['save_lz'])){
1104
1105 $license = lz_optpost('lz_license');
1106
1107 // Check if its a valid license
1108 if(empty($license)){
1109 $lz_error['lic_invalid'] = __('The license key was not submitted', 'loginizer');
1110 return loginizer_page_dashboard_T();
1111 }
1112
1113 $resp = wp_remote_get(LOGINIZER_API.'license.php?license='.$license, array('timeout' => 30));
1114
1115 if(is_array($resp)){
1116 $json = json_decode($resp['body'], true);
1117 //print_r($json);
1118 }else{
1119
1120 $lz_error['resp_invalid'] = __('The response was malformed<br>'.var_export($resp, true), 'loginizer');
1121 return loginizer_page_dashboard_T();
1122
1123 }
1124
1125 // Save the License
1126 if(empty($json['license'])){
1127
1128 $lz_error['lic_invalid'] = __('The license key is invalid', 'loginizer');
1129 return loginizer_page_dashboard_T();
1130
1131 }else{
1132
1133 update_option('loginizer_license', $json);
1134
1135 // Mark as saved
1136 $GLOBALS['lz_saved'] = true;
1137 }
1138
1139 }
1140
1141
1142 // Is there a IP Method ?
1143 if(isset($_POST['save_lz_ip_method'])){
1144
1145 $ip_method = (int) lz_optpost('lz_ip_method');
1146 $custom_ip_method = lz_optpost('lz_custom_ip_method');
1147
1148 if($ip_method >= 0 && $ip_method <= 3){
1149 update_option('loginizer_ip_method', $ip_method);
1150 }
1151
1152 // Custom Method name ?
1153 if($ip_method == 3){
1154 update_option('loginizer_custom_ip_method', $custom_ip_method);
1155 }
1156
1157 }
1158
1159 loginizer_page_dashboard_T();
1160
1161 }
1162
1163 // The Loginizer Admin Options Page - THEME
1164 function loginizer_page_dashboard_T(){
1165
1166 global $loginizer, $lz_error, $lz_env;
1167
1168 loginizer_page_header('Dashboard');
1169 ?>
1170 <style>
1171 .welcome-panel{
1172 margin: 0px;
1173 padding: 10px;
1174 }
1175
1176 input[type="text"], textarea, select {
1177 width: 70%;
1178 }
1179
1180 .form-table label{
1181 font-weight:bold;
1182 }
1183
1184 .exp{
1185 font-size:12px;
1186 }
1187 </style>
1188
1189 <?php
1190
1191 $hide_announcement = get_option('loginizer_no_announcement');
1192 if(empty($hide_announcement)){
1193 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 />';
1194 }
1195
1196 echo '<script src="https://api.loginizer.com/'.(defined('LOGINIZER_PREMIUM') ? 'news_security.js' : 'news.js').'"></script><br>';
1197
1198 // Saved ?
1199 if(!empty($GLOBALS['lz_saved'])){
1200 echo '<div id="message" class="updated"><p>'. __('The settings were saved successfully', 'loginizer'). '</p></div><br />';
1201 }
1202
1203 // Any errors ?
1204 if(!empty($lz_error)){
1205 lz_report_error($lz_error);echo '<br />';
1206 }
1207
1208 ?>
1209
1210 <div class="postbox">
1211
1212 <div class="postbox-header">
1213 <h2 class="hndle ui-sortable-handle">
1214 <span><?php echo __('Getting Started', 'loginizer'); ?></span>
1215 </h2>
1216 </div>
1217
1218 <div class="inside">
1219
1220 <form action="" method="post" enctype="multipart/form-data">
1221 <?php wp_nonce_field('loginizer-options'); ?>
1222 <table class="form-table">
1223 <tr>
1224 <td scope="row" valign="top" colspan="2" style="line-height:150%">
1225 <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>
1226 <?php
1227 if(defined('LOGINIZER_PREMIUM')){
1228 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>';
1229 }else{
1230 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>';
1231 }
1232 ?>
1233 </td>
1234 </tr>
1235 </table>
1236 </form>
1237
1238 </div>
1239 </div>
1240
1241 <div class="postbox">
1242
1243 <div class="postbox-header">
1244 <h2 class="hndle ui-sortable-handle">
1245 <span><?php echo __('System Information', 'loginizer'); ?></span>
1246 </h2>
1247 </div>
1248 <div class="inside">
1249
1250 <form action="" method="post" enctype="multipart/form-data">
1251 <?php wp_nonce_field('loginizer-options'); ?>
1252 <table class="wp-list-table fixed striped users" cellspacing="1" border="0" width="95%" cellpadding="10" align="center">
1253 <?php
1254 echo '
1255 <tr>
1256 <th align="left" width="25%">'.__('Loginizer Version', 'loginizer').'</th>
1257 <td>'.LOGINIZER_VERSION.(defined('LOGINIZER_PREMIUM') ? ' (<font color="green">Security PRO Version</font>)' : '').'</td>
1258 </tr>';
1259
1260 if(defined('LOGINIZER_PREMIUM')){
1261 echo '
1262 <tr>
1263 <th align="left" valign="top">'.__('Loginizer License', 'loginizer').'</th>
1264 <td align="left">
1265 '.(empty($loginizer['license']) ? '<span style="color:red">Unlicensed</span> &nbsp; &nbsp;' : '').'
1266 <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;
1267 <input name="save_lz" class="button button-primary" value="Update License" type="submit" />';
1268
1269 if(!empty($loginizer['license'])){
1270
1271 $expires = $loginizer['license']['expires'];
1272 $expires = substr($expires, 0, 4).'/'.substr($expires, 4, 2).'/'.substr($expires, 6);
1273
1274 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;
1275 License Expires : '.($loginizer['license']['expires'] <= date('Ymd') ? '<span style="color:red">'.$expires.'</span>' : $expires).'
1276 </div>';
1277 }
1278
1279
1280 echo
1281 '</td>
1282 </tr>';
1283 }
1284
1285 echo '<tr>
1286 <th align="left">'.__('URL', 'loginizer').'</th>
1287 <td>'.get_site_url().'</td>
1288 </tr>
1289 <tr>
1290 <th align="left">'.__('Path', 'loginizer').'</th>
1291 <td>'.ABSPATH.'</td>
1292 </tr>
1293 <tr>
1294 <th align="left">'.__('Server\'s IP Address', 'loginizer').'</th>
1295 <td>'.@$_SERVER['SERVER_ADDR'].'</td>
1296 </tr>
1297 <tr>
1298 <th align="left">'.__('Your IP Address', 'loginizer').'</th>
1299 <td>'.lz_getip().'
1300 <div style="float:right">
1301 Method :
1302 <select name="lz_ip_method" id="lz_ip_method" style="font-size:11px; width:150px" onchange="lz_ip_method_handle()">
1303 <option value="0" '.lz_POSTselect('lz_ip_method', 0, (@$loginizer['ip_method'] == 0)).'>REMOTE_ADDR</option>
1304 <option value="1" '.lz_POSTselect('lz_ip_method', 1, (@$loginizer['ip_method'] == 1)).'>HTTP_X_FORWARDED_FOR</option>
1305 <option value="2" '.lz_POSTselect('lz_ip_method', 2, (@$loginizer['ip_method'] == 2)).'>HTTP_CLIENT_IP</option>
1306 <option value="3" '.lz_POSTselect('lz_ip_method', 3, (@$loginizer['ip_method'] == 3)).'>CUSTOM</option>
1307 </select>
1308 <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" />
1309 <input name="save_lz_ip_method" class="button button-primary" value="Save" type="submit" />
1310 </div>
1311 </td>
1312 </tr>
1313 <tr>
1314 <th align="left">'.__('wp-config.php is writable', 'loginizer').'</th>
1315 <td>'.(is_writable(ABSPATH.'/wp-config.php') ? '<span style="color:red">Yes</span>' : '<span style="color:green">No</span>').'</td>
1316 </tr>';
1317
1318 if(file_exists(ABSPATH.'/.htaccess')){
1319 echo '
1320 <tr>
1321 <th align="left">'.__('.htaccess is writable', 'loginizer').'</th>
1322 <td>'.(is_writable(ABSPATH.'/.htaccess') ? '<span style="color:red">Yes</span>' : '<span style="color:green">No</span>').'</td>
1323 </tr>';
1324
1325 }
1326
1327 ?>
1328 </table>
1329 </form>
1330
1331 </div>
1332 </div>
1333
1334 <script type="text/javascript">
1335
1336 function lz_ip_method_handle(){
1337 var ele = jQuery('#lz_ip_method');
1338 if(ele.val() == 3){
1339 jQuery('#lz_custom_ip_method').show();
1340 }else{
1341 jQuery('#lz_custom_ip_method').hide();
1342 }
1343 };
1344
1345 lz_ip_method_handle();
1346
1347 </script>
1348
1349 <div id="" class="postbox">
1350
1351 <div class="postbox-header">
1352 <h2 class="hndle ui-sortable-handle">
1353 <span><?php echo __('File Permissions', 'loginizer'); ?></span>
1354 </h2>
1355 </div>
1356
1357 <div class="inside">
1358
1359 <form action="" method="post" enctype="multipart/form-data">
1360 <?php wp_nonce_field('loginizer-options'); ?>
1361 <table class="wp-list-table fixed striped users" border="0" width="95%" cellpadding="10" align="center">
1362 <?php
1363
1364 echo '
1365 <tr>
1366 <th style="background:#EFEFEF;">'.__('Relative Path', 'loginizer').'</th>
1367 <th style="width:10%; background:#EFEFEF;">'.__('Suggested', 'loginizer').'</th>
1368 <th style="width:10%; background:#EFEFEF;">'.__('Actual', 'loginizer').'</th>
1369 </tr>';
1370
1371 $wp_content = basename(dirname(dirname(dirname(__FILE__))));
1372
1373 $files_to_check = array('/' => '0755',
1374 '/wp-admin' => '0755',
1375 '/wp-includes' => '0755',
1376 '/wp-config.php' => '0444',
1377 '/'.$wp_content => '0755',
1378 '/'.$wp_content.'/themes' => '0755',
1379 '/'.$wp_content.'/plugins' => '0755',
1380 '.htaccess' => '0444');
1381
1382 $root = ABSPATH;
1383
1384 foreach($files_to_check as $k => $v){
1385
1386 $path = $root.'/'.$k;
1387 $stat = @stat($path);
1388 $suggested = $v;
1389 $actual = substr(sprintf('%o', $stat['mode']), -4);
1390
1391 echo '
1392 <tr>
1393 <td>'.$k.'</td>
1394 <td>'.$suggested.'</td>
1395 <td><span '.($suggested != $actual ? 'style="color: red;"' : '').'>'.$actual.'</span></td>
1396 </tr>';
1397
1398 }
1399
1400 ?>
1401 </table>
1402 </form>
1403
1404 </div>
1405 </div>
1406
1407 <?php
1408
1409 loginizer_page_footer();
1410
1411 }
1412
1413 // The Loginizer Admin Options Page
1414 function loginizer_page_brute_force(){
1415
1416 global $wpdb, $wp_roles, $loginizer;
1417
1418 if(!current_user_can('manage_options')){
1419 wp_die('Sorry, but you do not have permissions to change settings.');
1420 }
1421
1422 /* Make sure post was from this page */
1423 if(count($_POST) > 0){
1424 check_admin_referer('loginizer-options');
1425 }
1426
1427 // BEGIN THEME
1428 loginizer_page_header('Brute Force Settings');
1429
1430 // Load the blacklist and whitelist
1431 $loginizer['blacklist'] = get_option('loginizer_blacklist');
1432 $loginizer['whitelist'] = get_option('loginizer_whitelist');
1433
1434 // Disable Brute Force
1435 if(isset($_POST['disable_brute_lz'])){
1436
1437 // Save the options
1438 update_option('loginizer_disable_brute', 1);
1439
1440 $loginizer['disable_brute'] = 1;
1441
1442 echo '<div id="message" class="updated"><p>'
1443 . __('The Brute Force Protection feature is now disabled', 'loginizer')
1444 . '</p></div><br />';
1445
1446 }
1447
1448 // Enable brute force
1449 if(isset($_POST['enable_brute_lz'])){
1450
1451 // Save the options
1452 update_option('loginizer_disable_brute', 0);
1453
1454 $loginizer['disable_brute'] = 0;
1455
1456 echo '<div id="message" class="updated"><p>'
1457 . __('The Brute Force Protection feature is now enabled', 'loginizer')
1458 . '</p></div><br />';
1459
1460 }
1461
1462 // The Brute Force Settings
1463 if(isset($_POST['save_lz'])){
1464
1465 $max_retries = (int) lz_optpost('max_retries');
1466 $lockout_time = (int) lz_optpost('lockout_time');
1467 $max_lockouts = (int) lz_optpost('max_lockouts');
1468 $lockouts_extend = (int) lz_optpost('lockouts_extend');
1469 $reset_retries = (int) lz_optpost('reset_retries');
1470 $notify_email = (int) lz_optpost('notify_email');
1471
1472 $lockout_time = $lockout_time * 60;
1473 $lockouts_extend = $lockouts_extend * 60 * 60;
1474 $reset_retries = $reset_retries * 60 * 60;
1475
1476 if(empty($error)){
1477
1478 $option['max_retries'] = $max_retries;
1479 $option['lockout_time'] = $lockout_time;
1480 $option['max_lockouts'] = $max_lockouts;
1481 $option['lockouts_extend'] = $lockouts_extend;
1482 $option['reset_retries'] = $reset_retries;
1483 $option['notify_email'] = $notify_email;
1484
1485 // Save the options
1486 update_option('loginizer_options', $option);
1487
1488 $saved = true;
1489
1490 }else{
1491 lz_report_error($error);
1492 }
1493
1494 if(!empty($notice)){
1495 lz_report_notice($notice);
1496 }
1497
1498 if(!empty($saved)){
1499 echo '<div id="message" class="updated"><p>'
1500 . __('The settings were saved successfully', 'loginizer')
1501 . '</p></div><br />';
1502 }
1503
1504 }
1505
1506 // Delete a Blackist IP range
1507 if(isset($_POST['bdelid'])){
1508
1509 $delid = (int) lz_optreq('bdelid');
1510
1511 // Unset and save
1512 $blacklist = $loginizer['blacklist'];
1513 unset($blacklist[$delid]);
1514 update_option('loginizer_blacklist', $blacklist);
1515
1516 echo '<div id="message" class="updated fade"><p>'
1517 . __('The Blacklist IP range has been deleted successfully', 'loginizer')
1518 . '</p></div><br />';
1519
1520 }
1521
1522 // Delete all Blackist IP ranges
1523 if(isset($_POST['del_all_blacklist'])){
1524
1525 // Unset and save
1526 update_option('loginizer_blacklist', array());
1527
1528 echo '<div id="message" class="updated fade"><p>'
1529 . __('The Blacklist IP range(s) have been cleared successfully', 'loginizer')
1530 . '</p></div><br />';
1531
1532 }
1533
1534 // Delete a Whitelist IP range
1535 if(isset($_POST['delid'])){
1536
1537 $delid = (int) lz_optreq('delid');
1538
1539 // Unset and save
1540 $whitelist = $loginizer['whitelist'];
1541 unset($whitelist[$delid]);
1542 update_option('loginizer_whitelist', $whitelist);
1543
1544 echo '<div id="message" class="updated fade"><p>'
1545 . __('The Whitelist IP range has been deleted successfully', 'loginizer')
1546 . '</p></div><br />';
1547
1548 }
1549
1550 // Delete all Blackist IP ranges
1551 if(isset($_POST['del_all_whitelist'])){
1552
1553 // Unset and save
1554 update_option('loginizer_whitelist', array());
1555
1556 echo '<div id="message" class="updated fade"><p>'
1557 . __('The Whitelist IP range(s) have been cleared successfully', 'loginizer')
1558 . '</p></div><br />';
1559
1560 }
1561
1562 // Reset All Logs
1563 if(isset($_POST['lz_reset_all_ip'])){
1564
1565 $result = $wpdb->query("DELETE FROM `".$wpdb->prefix."loginizer_logs`
1566 WHERE `time` > 0");
1567
1568 echo '<div id="message" class="updated fade"><p>'
1569 . __('All the IP Logs have been cleared', 'loginizer')
1570 . '</p></div><br />';
1571 }
1572
1573 // Reset Logs
1574 if(isset($_POST['lz_reset_ips']) && is_array($_POST['lz_reset_ips'])){
1575
1576 $ips = $_POST['lz_reset_ips'];
1577
1578 foreach($ips as $ip){
1579 if(!lz_valid_ip($ip)){
1580 $error[] = 'The IP - '.$ip.' is invalid !';
1581 }
1582 }
1583
1584 if(count($ips) < 1){
1585 $error[] = __('There are no IPs submitted', 'loginizer');
1586 }
1587
1588 // Should we start deleting logs
1589 if(empty($error)){
1590
1591 $result = $wpdb->query("DELETE FROM `".$wpdb->prefix."loginizer_logs`
1592 WHERE `ip` IN ('".implode("', '", $ips)."')");
1593
1594 if(empty($error)){
1595
1596 echo '<div id="message" class="updated fade"><p>'
1597 . __('The selected IP Logs have been reset', 'loginizer')
1598 . '</p></div><br />';
1599
1600 }
1601
1602 }
1603
1604 if(!empty($error)){
1605 lz_report_error($error);echo '<br />';
1606 }
1607
1608 }
1609
1610 if(isset($_POST['blacklist_iprange'])){
1611
1612 $start_ip = lz_optpost('start_ip');
1613 $end_ip = lz_optpost('end_ip');
1614
1615 if(empty($start_ip)){
1616 $error[] = __('Please enter the Start IP', 'loginizer');
1617 }
1618
1619 // If no end IP we consider only 1 IP
1620 if(empty($end_ip)){
1621 $end_ip = $start_ip;
1622 }
1623
1624 if(!lz_valid_ip($start_ip)){
1625 $error[] = __('Please provide a valid start IP', 'loginizer');
1626 }
1627
1628 if(!lz_valid_ip($end_ip)){
1629 $error[] = __('Please provide a valid end IP', 'loginizer');
1630 }
1631
1632 // Regular ranges will work
1633 if(inet_ptoi($start_ip) > inet_ptoi($end_ip)){
1634
1635 // BUT, if 0.0.0.1 - 255.255.255.255 is given, it will not work
1636 if(inet_ptoi($start_ip) >= 0 && inet_ptoi($end_ip) < 0){
1637 // This is right
1638 }else{
1639 $error[] = __('The End IP cannot be smaller than the Start IP', 'loginizer');
1640 }
1641
1642 }
1643
1644 if(empty($error)){
1645
1646 $blacklist = $loginizer['blacklist'];
1647
1648 foreach($blacklist as $k => $v){
1649
1650 // This is to check if there is any other range exists with the same Start or End IP
1651 if(( inet_ptoi($start_ip) <= inet_ptoi($v['start']) && inet_ptoi($v['start']) <= inet_ptoi($end_ip) )
1652 || ( inet_ptoi($start_ip) <= inet_ptoi($v['end']) && inet_ptoi($v['end']) <= inet_ptoi($end_ip) )
1653 ){
1654 $error[] = __('The Start IP or End IP submitted conflicts with an existing IP range !', 'loginizer');
1655 break;
1656 }
1657
1658 // This is to check if there is any other range exists with the same Start IP
1659 if(inet_ptoi($v['start']) <= inet_ptoi($start_ip) && inet_ptoi($start_ip) <= inet_ptoi($v['end'])){
1660 $error[] = __('The Start IP is present in an existing range !', 'loginizer');
1661 break;
1662 }
1663
1664 // This is to check if there is any other range exists with the same End IP
1665 if(inet_ptoi($v['start']) <= inet_ptoi($end_ip) && inet_ptoi($end_ip) <= inet_ptoi($v['end'])){
1666 $error[] = __('The End IP is present in an existing range!', 'loginizer');
1667 break;
1668 }
1669
1670 }
1671
1672 $newid = ( empty($blacklist) ? 0 : max(array_keys($blacklist)) ) + 1;
1673
1674 if(empty($error)){
1675
1676 $blacklist[$newid] = array();
1677 $blacklist[$newid]['start'] = $start_ip;
1678 $blacklist[$newid]['end'] = $end_ip;
1679 $blacklist[$newid]['time'] = time();
1680
1681 update_option('loginizer_blacklist', $blacklist);
1682
1683 echo '<div id="message" class="updated fade"><p>'
1684 . __('Blacklist IP range added successfully', 'loginizer')
1685 . '</p></div><br />';
1686
1687 }
1688
1689 }
1690
1691 if(!empty($error)){
1692 lz_report_error($error);echo '<br />';
1693 }
1694
1695 }
1696
1697 if(isset($_POST['whitelist_iprange'])){
1698
1699 $start_ip = lz_optpost('start_ip_w');
1700 $end_ip = lz_optpost('end_ip_w');
1701
1702 if(empty($start_ip)){
1703 $error[] = __('Please enter the Start IP', 'loginizer');
1704 }
1705
1706 // If no end IP we consider only 1 IP
1707 if(empty($end_ip)){
1708 $end_ip = $start_ip;
1709 }
1710
1711 if(!lz_valid_ip($start_ip)){
1712 $error[] = __('Please provide a valid start IP', 'loginizer');
1713 }
1714
1715 if(!lz_valid_ip($end_ip)){
1716 $error[] = __('Please provide a valid end IP', 'loginizer');
1717 }
1718
1719 if(inet_ptoi($start_ip) > inet_ptoi($end_ip)){
1720
1721 // BUT, if 0.0.0.1 - 255.255.255.255 is given, it will not work
1722 if(inet_ptoi($start_ip) >= 0 && inet_ptoi($end_ip) < 0){
1723 // This is right
1724 }else{
1725 $error[] = __('The End IP cannot be smaller than the Start IP', 'loginizer');
1726 }
1727
1728 }
1729
1730 if(empty($error)){
1731
1732 $whitelist = $loginizer['whitelist'];
1733
1734 foreach($whitelist as $k => $v){
1735
1736 // This is to check if there is any other range exists with the same Start or End IP
1737 if(( inet_ptoi($start_ip) <= inet_ptoi($v['start']) && inet_ptoi($v['start']) <= inet_ptoi($end_ip) )
1738 || ( inet_ptoi($start_ip) <= inet_ptoi($v['end']) && inet_ptoi($v['end']) <= inet_ptoi($end_ip) )
1739 ){
1740 $error[] = __('The Start IP or End IP submitted conflicts with an existing IP range !', 'loginizer');
1741 break;
1742 }
1743
1744 // This is to check if there is any other range exists with the same Start IP
1745 if(inet_ptoi($v['start']) <= inet_ptoi($start_ip) && inet_ptoi($start_ip) <= inet_ptoi($v['end'])){
1746 $error[] = __('The Start IP is present in an existing range !', 'loginizer');
1747 break;
1748 }
1749
1750 // This is to check if there is any other range exists with the same End IP
1751 if(inet_ptoi($v['start']) <= inet_ptoi($end_ip) && inet_ptoi($end_ip) <= inet_ptoi($v['end'])){
1752 $error[] = __('The End IP is present in an existing range!', 'loginizer');
1753 break;
1754 }
1755
1756 }
1757
1758 $newid = ( empty($whitelist) ? 0 : max(array_keys($whitelist)) ) + 1;
1759
1760 if(empty($error)){
1761
1762 $whitelist[$newid] = array();
1763 $whitelist[$newid]['start'] = $start_ip;
1764 $whitelist[$newid]['end'] = $end_ip;
1765 $whitelist[$newid]['time'] = time();
1766
1767 update_option('loginizer_whitelist', $whitelist);
1768
1769 echo '<div id="message" class="updated fade"><p>'
1770 . __('Whitelist IP range added successfully', 'loginizer')
1771 . '</p></div><br />';
1772
1773 }
1774
1775 }
1776
1777 if(!empty($error)){
1778 lz_report_error($error);echo '<br />';
1779 }
1780 }
1781
1782 // Save the messages
1783 if(isset($_POST['save_err_msgs_lz'])){
1784
1785 $msgs['inv_userpass'] = lz_optpost('msg_inv_userpass');
1786 $msgs['ip_blacklisted'] = lz_optpost('msg_ip_blacklisted');
1787 $msgs['attempts_left'] = lz_optpost('msg_attempts_left');
1788
1789 // Update them
1790 update_option('loginizer_msg', $msgs);
1791
1792 echo '<div id="message" class="updated fade"><p>'
1793 . __('Error messages were saved successfully', 'loginizer')
1794 . '</p></div><br />';
1795
1796 }
1797
1798 // Count the Results
1799 $tmp = lz_selectquery("SELECT COUNT(*) AS num FROM `".$wpdb->prefix."loginizer_logs`");
1800 //print_r($tmp);
1801
1802 // Which Page is it
1803 $lz_env['res_len'] = 10;
1804 $lz_env['cur_page'] = lz_get_page('lzpage', $lz_env['res_len']);
1805 $lz_env['num_res'] = $tmp['num'];
1806 $lz_env['max_page'] = ceil($lz_env['num_res'] / $lz_env['res_len']);
1807
1808 // Get the logs
1809 $result = lz_selectquery("SELECT * FROM `".$wpdb->prefix."loginizer_logs`
1810 ORDER BY `time` DESC
1811 LIMIT ".$lz_env['cur_page'].", ".$lz_env['res_len']."", 1);
1812 //print_r($result);
1813
1814 $lz_env['cur_page'] = ($lz_env['cur_page'] / $lz_env['res_len']) + 1;
1815 $lz_env['cur_page'] = $lz_env['cur_page'] < 1 ? 1 : $lz_env['cur_page'];
1816 $lz_env['next_page'] = ($lz_env['cur_page'] + 1) > $lz_env['max_page'] ? $lz_env['max_page'] : ($lz_env['cur_page'] + 1);
1817 $lz_env['prev_page'] = ($lz_env['cur_page'] - 1) < 1 ? 1 : ($lz_env['cur_page'] - 1);
1818
1819 // Reload the settings
1820 $loginizer['blacklist'] = get_option('loginizer_blacklist');
1821 $loginizer['whitelist'] = get_option('loginizer_whitelist');
1822
1823 $saved_msgs = get_option('loginizer_msg');
1824
1825 ?>
1826
1827 <div id="" class="postbox">
1828
1829 <div class="postbox-header">
1830 <h2 class="hndle ui-sortable-handle">
1831 <?php echo __('<span>Failed Login Attempts Logs</span> &nbsp; (Past '.($loginizer['reset_retries']/60/60).' hours)','loginizer'); ?>
1832 </h2>
1833 </div>
1834
1835 <script>
1836 function yesdsd(){
1837 window.location = '<?php echo menu_page_url('loginizer_brute_force', false);?>&lzpage='+jQuery("#current-page-selector").val();
1838 return false;
1839 }
1840 </script>
1841
1842 <form method="get" onsubmit="return yesdsd();">
1843 <div class="tablenav">
1844 <p class="tablenav-pages" style="margin: 5px 10px" align="right">
1845 <span class="displaying-num"><?php echo $lz_env['num_res'];?> items</span>
1846 <span class="pagination-links">
1847 <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>
1848 <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>
1849 <span class="paging-input">
1850 <label for="current-page-selector" class="screen-reader-text">Current Page</label>
1851 <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>
1852 </span>
1853 <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>
1854 <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>
1855 </span>
1856 </p>
1857 </div>
1858 </form>
1859
1860 <form action="" method="post" enctype="multipart/form-data">
1861 <?php wp_nonce_field('loginizer-options'); ?>
1862 <div class="inside">
1863 <table class="wp-list-table widefat fixed users" border="0">
1864 <tr>
1865 <th scope="row" valign="top" style="background:#EFEFEF;" width="20">#</th>
1866 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('IP','loginizer'); ?></th>
1867 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Attempted Username','loginizer'); ?></th>
1868 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Last Failed Attempt (DD/MM/YYYY)','loginizer'); ?></th>
1869 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Failed Attempts Count','loginizer'); ?></th>
1870 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Lockouts Count','loginizer'); ?></th>
1871 <th scope="row" valign="top" style="background:#EFEFEF;" width="150"><?php echo __('URL Attacked','loginizer'); ?></th>
1872 </tr>
1873 <?php
1874
1875 if(empty($result)){
1876 echo '
1877 <tr>
1878 <td colspan="4">
1879 '.__('No Logs. You will see logs about failed login attempts here.', 'loginizer').'
1880 </td>
1881 </tr>';
1882 }else{
1883 foreach($result as $ik => $iv){
1884 $status_button = (!empty($iv['status']) ? 'disable' : 'enable');
1885 echo '
1886 <tr>
1887 <td>
1888 <input type="checkbox" value="'.$iv['ip'].'" name="lz_reset_ips[]" />
1889 </td>
1890 <td>
1891 '.$iv['ip'].'
1892 </td>
1893 <td>
1894 '.$iv['username'].'
1895 </td>
1896 <td>
1897 '.date('d/M/Y H:i:s P', $iv['time']).'
1898 </td>
1899 <td>
1900 '.$iv['count'].'
1901 </td>
1902 <td>
1903 '.$iv['lockout'].'
1904 </td>
1905 <td>
1906 '.$iv['url'].'
1907 </td>
1908 </tr>';
1909 }
1910 }
1911
1912 ?>
1913 </table>
1914
1915 <br>
1916 <input name="lz_reset_ip" class="button button-primary action" value="<?php echo __('Remove From Logs', 'loginizer'); ?>" type="submit" />
1917 &nbsp; &nbsp;
1918 <input name="lz_reset_all_ip" class="button button-primary action" value="<?php echo __('Clear All Logs', 'loginizer'); ?>" type="submit" />
1919 </div>
1920 </div>
1921 </form>
1922 <br />
1923
1924 <div id="" class="postbox">
1925
1926 <div class="postbox-header">
1927 <h2 class="hndle ui-sortable-handle">
1928 <span><?php echo __('Brute Force Settings', 'loginizer'); ?></span>
1929 </h2>
1930 </div>
1931
1932 <div class="inside">
1933
1934 <form action="" method="post" enctype="multipart/form-data">
1935 <?php wp_nonce_field('loginizer-options'); ?>
1936 <table class="form-table">
1937 <tr>
1938 <th scope="row" valign="top"><label for="max_retries"><?php echo __('Max Retries','loginizer'); ?></label></th>
1939 <td>
1940 <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 />
1941 </td>
1942 </tr>
1943 <tr>
1944 <th scope="row" valign="top"><label for="lockout_time"><?php echo __('Lockout Time','loginizer'); ?></label></th>
1945 <td>
1946 <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 />
1947 </td>
1948 </tr>
1949 <tr>
1950 <th scope="row" valign="top"><label for="max_lockouts"><?php echo __('Max Lockouts','loginizer'); ?></label></th>
1951 <td>
1952 <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 />
1953 </td>
1954 </tr>
1955 <tr>
1956 <th scope="row" valign="top"><label for="lockouts_extend"><?php echo __('Extend Lockout','loginizer'); ?></label></th>
1957 <td>
1958 <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 />
1959 </td>
1960 </tr>
1961 <tr>
1962 <th scope="row" valign="top"><label for="reset_retries"><?php echo __('Reset Retries','loginizer'); ?></label></th>
1963 <td>
1964 <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 />
1965 </td>
1966 </tr>
1967 <tr>
1968 <th scope="row" valign="top"><label for="notify_email"><?php echo __('Email Notification','loginizer'); ?></label></th>
1969 <td>
1970 <?php echo __('after ','loginizer'); ?>
1971 <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'); ?>
1972 </td>
1973 </tr>
1974 </table><br />
1975 <input name="save_lz" class="button button-primary action" value="<?php echo __('Save Settings','loginizer'); ?>" type="submit" />
1976 <?php
1977
1978 if(empty($loginizer['disable_brute'])){
1979
1980 echo '<input name="disable_brute_lz" class="button action" value="'.__('Disable Brute Force Protection','loginizer').'" type="submit" style="float:right" />';
1981
1982 }else{
1983
1984 echo '<input name="enable_brute_lz" class="button button-primary action" value="'.__('Enable Brute Force Protection','loginizer').'" type="submit" style="float:right" />';
1985
1986 }
1987
1988 ?>
1989 </form>
1990
1991 </div>
1992 </div>
1993 <br />
1994
1995 <?php
1996
1997 wp_enqueue_script('jquery-paginate', LOGINIZER_URL.'/jquery-paginate.js', array('jquery'), '1.10.15');
1998
1999 ?>
2000
2001 <style>
2002 .page-navigation a {
2003 margin: 5px 2px;
2004 display: inline-block;
2005 padding: 5px 8px;
2006 color: #0073aa;
2007 background: #e5e5e5 none repeat scroll 0 0;
2008 border: 1px solid #ccc;
2009 text-decoration: none;
2010 transition-duration: 0.05s;
2011 transition-property: border, background, color;
2012 transition-timing-function: ease-in-out;
2013 }
2014
2015 .page-navigation a[data-selected] {
2016 background-color: #00a0d2;
2017 color: #fff;
2018 }
2019 </style>
2020
2021 <script>
2022
2023 jQuery(document).ready(function(){
2024 jQuery('#lz_bl_table').paginate({ limit: 11, navigationWrapper: jQuery('#lz_bl_nav')});
2025 jQuery('#lz_wl_table').paginate({ limit: 11, navigationWrapper: jQuery('#lz_wl_nav')});
2026 });
2027
2028 // Delete a Blacklist / Whitelist IP Range
2029 function del_confirm(field, todo_id, msg){
2030 var ret = confirm(msg);
2031
2032 if(ret){
2033 jQuery('#lz_bl_wl_todo').attr('name', field);
2034 jQuery('#lz_bl_wl_todo').val(todo_id);
2035 jQuery('#lz_bl_wl_form').submit();
2036 }
2037
2038 return false;
2039
2040 }
2041
2042 // Delete all Blacklist / Whitelist IP Ranges
2043 function del_confirm_all(msg){
2044 var ret = confirm(msg);
2045
2046 if(ret){
2047 return true;
2048 }
2049
2050 return false;
2051
2052 }
2053
2054 </script>
2055
2056 <div id="" class="postbox">
2057
2058 <div class="postbox-header">
2059 <h2 class="hndle ui-sortable-handle">
2060 <span><?php echo __('Blacklist IP','loginizer'); ?></span>
2061 </h2>
2062 </div>
2063
2064 <div class="inside">
2065
2066 <?php echo __('Enter the IP you want to blacklist from login','loginizer'); ?>
2067
2068 <form action="" method="post">
2069 <?php wp_nonce_field('loginizer-options'); ?>
2070 <table class="form-table">
2071 <tr>
2072 <th scope="row" valign="top"><label for="start_ip"><?php echo __('Start IP','loginizer'); ?></label></th>
2073 <td>
2074 <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 />
2075 </td>
2076 </tr>
2077 <tr>
2078 <th scope="row" valign="top"><label for="end_ip"><?php echo __('End IP (Optional)','loginizer'); ?></label></th>
2079 <td>
2080 <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 />
2081 </td>
2082 </tr>
2083 </table><br />
2084 <input name="blacklist_iprange" class="button button-primary action" value="<?php echo __('Add Blacklist IP Range','loginizer'); ?>" type="submit" />
2085 <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" />
2086 </form>
2087 </div>
2088
2089 <div id="lz_bl_nav" style="margin: 5px 10px; text-align:right"></div>
2090 <table id="lz_bl_table" class="wp-list-table fixed striped users" border="0" width="95%" cellpadding="10" align="center">
2091 <tr>
2092 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Start IP','loginizer'); ?></th>
2093 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('End IP','loginizer'); ?></th>
2094 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Date (DD/MM/YYYY)','loginizer'); ?></th>
2095 <th scope="row" valign="top" style="background:#EFEFEF;" width="100"><?php echo __('Options','loginizer'); ?></th>
2096 </tr>
2097 <?php
2098 if(empty($loginizer['blacklist'])){
2099 echo '
2100 <tr>
2101 <td colspan="4">
2102 '.__('No Blacklist IPs. You will see blacklisted IP ranges here.', 'loginizer').'
2103 </td>
2104 </tr>';
2105 }else{
2106 foreach($loginizer['blacklist'] as $ik => $iv){
2107 echo '
2108 <tr>
2109 <td>
2110 '.$iv['start'].'
2111 </td>
2112 <td>
2113 '.$iv['end'].'
2114 </td>
2115 <td>
2116 '.date('d/m/Y', $iv['time']).'
2117 </td>
2118 <td>
2119 <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>
2120 </td>
2121 </tr>';
2122 }
2123 }
2124 ?>
2125 </table>
2126 <br />
2127 <form action="" method="post" id="lz_bl_wl_form">
2128 <?php wp_nonce_field('loginizer-options'); ?>
2129 <input type="hidden" value="" name="" id="lz_bl_wl_todo"/>
2130 </form>
2131 </div>
2132
2133 <br />
2134
2135 <div id="" class="postbox">
2136
2137 <div class="postbox-header">
2138 <h2 class="hndle ui-sortable-handle">
2139 <span><?php echo __('Whitelist IP', 'loginizer'); ?></span>
2140 </h2>
2141 </div>
2142
2143 <div class="inside">
2144
2145 <?php echo __('Enter the IP you want to whitelist for login','loginizer'); ?>
2146 <form action="" method="post">
2147 <?php wp_nonce_field('loginizer-options'); ?>
2148 <table class="form-table">
2149 <tr>
2150 <th scope="row" valign="top"><label for="start_ip_w"><?php echo __('Start IP','loginizer'); ?></label></th>
2151 <td>
2152 <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 />
2153 </td>
2154 </tr>
2155 <tr>
2156 <th scope="row" valign="top"><label for="end_ip_w"><?php echo __('End IP (Optional)','loginizer'); ?></label></th>
2157 <td>
2158 <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 />
2159 </td>
2160 </tr>
2161 </table><br />
2162 <input name="whitelist_iprange" class="button button-primary action" value="<?php echo __('Add Whitelist IP Range','loginizer'); ?>" type="submit" />
2163 <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" />
2164 </form>
2165 </div>
2166
2167 <div id="lz_wl_nav" style="margin: 5px 10px; text-align:right"></div>
2168 <table id="lz_wl_table" class="wp-list-table fixed striped users" border="0" width="95%" cellpadding="10" align="center">
2169 <tr>
2170 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Start IP','loginizer'); ?></th>
2171 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('End IP','loginizer'); ?></th>
2172 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Date (DD/MM/YYYY)','loginizer'); ?></th>
2173 <th scope="row" valign="top" style="background:#EFEFEF;" width="100"><?php echo __('Options','loginizer'); ?></th>
2174 </tr>
2175 <?php
2176 if(empty($loginizer['whitelist'])){
2177 echo '
2178 <tr>
2179 <td colspan="4">
2180 '.__('No Whitelist IPs. You will see whitelisted IP ranges here.', 'loginizer').'
2181 </td>
2182 </tr>';
2183 }else{
2184 foreach($loginizer['whitelist'] as $ik => $iv){
2185 echo '
2186 <tr>
2187 <td>
2188 '.$iv['start'].'
2189 </td>
2190 <td>
2191 '.$iv['end'].'
2192 </td>
2193 <td>
2194 '.date('d/m/Y', $iv['time']).'
2195 </td>
2196 <td>
2197 <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>
2198 </td>
2199 </tr>';
2200 }
2201 }
2202 ?>
2203 </table>
2204 <br />
2205
2206 </div>
2207
2208 <div id="" class="postbox">
2209
2210 <div class="postbox-header">
2211 <h2 class="hndle ui-sortable-handle">
2212 <span><?php echo __('Error Messages', 'loginizer'); ?></span>
2213 </h2>
2214 </div>
2215
2216 <div class="inside">
2217
2218 <form action="" method="post" enctype="multipart/form-data">
2219 <?php wp_nonce_field('loginizer-options'); ?>
2220 <table class="form-table">
2221 <tr>
2222 <th scope="row" valign="top"><label for="msg_inv_userpass"><?php echo __('Failed Login Attempt','loginizer'); ?></label></th>
2223 <td>
2224 <input type="text" size="25" value="<?php echo esc_attr(@$saved_msgs['inv_userpass']); ?>" name="msg_inv_userpass" id="msg_inv_userpass" />
2225 <?php echo __('Default: <em>&quot;' . $loginizer['d_msg']['inv_userpass']. '&quot;</em>', 'loginizer'); ?><br />
2226 </td>
2227 </tr>
2228 <tr>
2229 <th scope="row" valign="top"><label for="msg_ip_blacklisted"><?php echo __('Blacklisted IP','loginizer'); ?></label></th>
2230 <td>
2231 <input type="text" size="25" value="<?php echo esc_attr(@$saved_msgs['ip_blacklisted']); ?>" name="msg_ip_blacklisted" id="msg_ip_blacklisted" />
2232 <?php echo __('Default: <em>&quot;' . $loginizer['d_msg']['ip_blacklisted']. '&quot;</em>', 'loginizer'); ?><br />
2233 </td>
2234 </tr>
2235 <tr>
2236 <th scope="row" valign="top"><label for="msg_attempts_left"><?php echo __('Attempts Left','loginizer'); ?></label></th>
2237 <td>
2238 <input type="text" size="25" value="<?php echo esc_attr(@$saved_msgs['attempts_left']); ?>" name="msg_attempts_left" id="msg_attempts_left" />
2239 <?php echo __('Default: <em>&quot;' . $loginizer['d_msg']['attempts_left']. '&quot;</em>', 'loginizer'); ?><br />
2240 </td>
2241 </tr>
2242 </table><br />
2243 <input name="save_err_msgs_lz" class="button button-primary action" value="<?php echo __('Save Error Messages','loginizer'); ?>" type="submit" />
2244 </form>
2245 </div>
2246 </div>
2247 <?php
2248
2249 loginizer_page_footer();
2250
2251 }
2252
2253 //---------------------
2254 // Admin Menu Pro Pages
2255 //---------------------
2256
2257 // Loginizer - reCaptcha Page
2258 function loginizer_page_recaptcha(){
2259
2260 global $loginizer, $lz_error, $lz_env;
2261
2262 if(!current_user_can('manage_options')){
2263 wp_die('Sorry, but you do not have permissions to change settings.');
2264 }
2265
2266 if(!loginizer_is_premium() && count($_POST) > 0){
2267 $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');
2268 return loginizer_page_recaptcha_T();
2269 }
2270
2271 /* Make sure post was from this page */
2272 if(count($_POST) > 0){
2273 check_admin_referer('loginizer-options');
2274 }
2275
2276 // Themes
2277 $lz_env['theme']['light'] = 'Light';
2278 $lz_env['theme']['dark'] = 'Dark';
2279
2280 // Langs
2281 $lz_env['lang'][''] = 'Auto Detect';
2282 $lz_env['lang']['ar'] = 'Arabic';
2283 $lz_env['lang']['bg'] = 'Bulgarian';
2284 $lz_env['lang']['ca'] = 'Catalan';
2285 $lz_env['lang']['zh-CN'] = 'Chinese (Simplified)';
2286 $lz_env['lang']['zh-TW'] = 'Chinese (Traditional)';
2287 $lz_env['lang']['hr'] = 'Croatian';
2288 $lz_env['lang']['cs'] = 'Czech';
2289 $lz_env['lang']['da'] = 'Danish';
2290 $lz_env['lang']['nl'] = 'Dutch';
2291 $lz_env['lang']['en-GB'] = 'English (UK)';
2292 $lz_env['lang']['en'] = 'English (US)';
2293 $lz_env['lang']['fil'] = 'Filipino';
2294 $lz_env['lang']['fi'] = 'Finnish';
2295 $lz_env['lang']['fr'] = 'French';
2296 $lz_env['lang']['fr-CA'] = 'French (Canadian)';
2297 $lz_env['lang']['de'] = 'German';
2298 $lz_env['lang']['de-AT'] = 'German (Austria)';
2299 $lz_env['lang']['de-CH'] = 'German (Switzerland)';
2300 $lz_env['lang']['el'] = 'Greek';
2301 $lz_env['lang']['iw'] = 'Hebrew';
2302 $lz_env['lang']['hi'] = 'Hindi';
2303 $lz_env['lang']['hu'] = 'Hungarain';
2304 $lz_env['lang']['id'] = 'Indonesian';
2305 $lz_env['lang']['it'] = 'Italian';
2306 $lz_env['lang']['ja'] = 'Japanese';
2307 $lz_env['lang']['ko'] = 'Korean';
2308 $lz_env['lang']['lv'] = 'Latvian';
2309 $lz_env['lang']['lt'] = 'Lithuanian';
2310 $lz_env['lang']['no'] = 'Norwegian';
2311 $lz_env['lang']['fa'] = 'Persian';
2312 $lz_env['lang']['pl'] = 'Polish';
2313 $lz_env['lang']['pt'] = 'Portuguese';
2314 $lz_env['lang']['pt-BR'] = 'Portuguese (Brazil)';
2315 $lz_env['lang']['pt-PT'] = 'Portuguese (Portugal)';
2316 $lz_env['lang']['ro'] = 'Romanian';
2317 $lz_env['lang']['ru'] = 'Russian';
2318 $lz_env['lang']['sr'] = 'Serbian';
2319 $lz_env['lang']['sk'] = 'Slovak';
2320 $lz_env['lang']['sl'] = 'Slovenian';
2321 $lz_env['lang']['es'] = 'Spanish';
2322 $lz_env['lang']['es-419'] = 'Spanish (Latin America)';
2323 $lz_env['lang']['sv'] = 'Swedish';
2324 $lz_env['lang']['th'] = 'Thai';
2325 $lz_env['lang']['tr'] = 'Turkish';
2326 $lz_env['lang']['uk'] = 'Ukrainian';
2327 $lz_env['lang']['vi'] = 'Vietnamese';
2328
2329 // Sizes
2330 $lz_env['size']['normal'] = 'Normal';
2331 $lz_env['size']['compact'] = 'Compact';
2332
2333 if(isset($_POST['save_lz'])){
2334
2335 // Google Captcha
2336 $option['captcha_type'] = lz_optpost('captcha_type');
2337 $option['captcha_key'] = lz_optpost('captcha_key');
2338 $option['captcha_secret'] = lz_optpost('captcha_secret');
2339 $option['captcha_theme'] = lz_optpost('captcha_theme');
2340 $option['captcha_size'] = lz_optpost('captcha_size');
2341 $option['captcha_lang'] = lz_optpost('captcha_lang');
2342
2343 // No Google Captcha
2344 $option['captcha_text'] = lz_optpost('captcha_text');
2345 $option['captcha_time'] = (int) lz_optpost('captcha_time');
2346 $option['captcha_words'] = (int) lz_optpost('captcha_words');
2347 $option['captcha_add'] = (int) lz_optpost('captcha_add');
2348 $option['captcha_subtract'] = (int) lz_optpost('captcha_subtract');
2349 $option['captcha_multiply'] = (int) lz_optpost('captcha_multiply');
2350 $option['captcha_divide'] = (int) lz_optpost('captcha_divide');
2351
2352 // Checkboxes
2353 $option['captcha_user_hide'] = (int) lz_optpost('captcha_user_hide');
2354 $option['captcha_no_css_login'] = (int) lz_optpost('captcha_no_css_login');
2355 $option['captcha_login'] = (int) lz_optpost('captcha_login');
2356 $option['captcha_lostpass'] = (int) lz_optpost('captcha_lostpass');
2357 $option['captcha_resetpass'] = (int) lz_optpost('captcha_resetpass');
2358 $option['captcha_register'] = (int) lz_optpost('captcha_register');
2359 $option['captcha_comment'] = (int) lz_optpost('captcha_comment');
2360 $option['captcha_wc_checkout'] = (int) lz_optpost('captcha_wc_checkout');
2361
2362 // Are we to use Math Captcha ?
2363 if(isset($_POST['captcha_no_google'])){
2364
2365 $option['captcha_no_google'] = 1;
2366
2367 // Make the checks
2368 if(strlen($option['captcha_text']) < 1){
2369 $lz_error['captcha_text'] = __('The Captcha key was not submitted', 'loginizer');
2370 }
2371
2372 }else{
2373
2374 // Make the checks
2375 if(strlen($option['captcha_key']) < 32 || strlen($option['captcha_key']) > 50){
2376 $lz_error['captcha_key'] = __('The reCAPTCHA key is invalid', 'loginizer');
2377 }
2378
2379 // Is secret valid ?
2380 if(strlen($option['captcha_secret']) < 32 || strlen($option['captcha_secret']) > 50){
2381 $lz_error['captcha_secret'] = __('The reCAPTCHA secret is invalid', 'loginizer');
2382 }
2383
2384 // Is theme valid ?
2385 if(empty($lz_env['theme'][$option['captcha_theme']])){
2386 $lz_error['captcha_theme'] = __('The reCAPTCHA theme is invalid', 'loginizer');
2387 }
2388
2389 // Is size valid ?
2390 if(empty($lz_env['size'][$option['captcha_size']])){
2391 $lz_error['captcha_size'] = __('The reCAPTCHA size is invalid', 'loginizer');
2392 }
2393
2394 // Is lang valid ?
2395 if(empty($lz_env['lang'][$option['captcha_lang']])){
2396 $lz_error['captcha_lang'] = __('The reCAPTCHA language is invalid', 'loginizer');
2397 }
2398
2399 }
2400
2401 // Is there an error ?
2402 if(!empty($lz_error)){
2403 return loginizer_page_recaptcha_T();
2404 }
2405
2406 // Save the options
2407 update_option('loginizer_captcha', $option);
2408
2409 // Mark as saved
2410 $GLOBALS['lz_saved'] = true;
2411
2412 }
2413
2414 // Clear this
2415 if(isset($_POST['clear_captcha_lz'])){
2416
2417 // Save the options
2418 update_option('loginizer_captcha', '');
2419
2420 // Mark as saved
2421 $GLOBALS['lz_cleared'] = true;
2422
2423 }
2424
2425 // Call the theme
2426 loginizer_page_recaptcha_T();
2427
2428 }
2429
2430 // Loginizer - reCaptcha Page Theme
2431 function loginizer_page_recaptcha_T(){
2432
2433 global $loginizer, $lz_error, $lz_env;
2434
2435 // Universal header
2436 loginizer_page_header('reCAPTCHA Settings');
2437
2438 loginizer_feature_available('reCAPTCHA');
2439
2440 // Saved ?
2441 if(!empty($GLOBALS['lz_saved'])){
2442 echo '<div id="message" class="updated"><p>'. __('The settings were saved successfully', 'loginizer'). '</p></div><br />';
2443 }
2444
2445 // Cleared ?
2446 if(!empty($GLOBALS['lz_cleared'])){
2447 echo '<div id="message" class="updated"><p>'. __('reCAPTCHA has been disabled !', 'loginizer'). '</p></div><br />';
2448 }
2449
2450 // Any errors ?
2451 if(!empty($lz_error)){
2452 lz_report_error($lz_error);echo '<br />';
2453 }
2454
2455 ?>
2456
2457 <style>
2458 input[type="text"], textarea, select {
2459 width: 70%;
2460 }
2461 </style>
2462
2463 <div id="" class="postbox">
2464
2465 <div class="postbox-header">
2466 <h2 class="hndle ui-sortable-handle">
2467 <span><?php echo __('reCAPTCHA Settings', 'loginizer'); ?></span>
2468 </h2>
2469 </div>
2470
2471 <div class="inside">
2472
2473 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
2474 <?php wp_nonce_field('loginizer-options'); ?>
2475 <table class="form-table">
2476 <tr class="lz_google_cap">
2477 <td scope="row" valign="top" style="width:300px !important; padding-left:0px"><label><b><?php echo __('reCAPTCHA type', 'loginizer'); ?></b></label><br>
2478 <?php echo __('Choose the type of reCAPTCHA', 'loginizer'); ?><br />
2479 <?php echo __('<a href="https://g.co/recaptcha/sitetypes/" target="_blank">See Site Types for more details</a>', 'loginizer'); ?>
2480 </td>
2481 <td>
2482 <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 />
2483 <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 />
2484 <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 />
2485 </td>
2486 </tr>
2487 <tr class="lz_google_cap">
2488 <td scope="row" valign="top" style="width:300px !important; padding-left:0px"><label><b><?php echo __('Site Key', 'loginizer'); ?></b></label><br>
2489 <?php echo __('Make sure you enter the correct keys as per the reCAPTCHA type selected above', 'loginizer'); ?>
2490 </td>
2491 <td>
2492 <input type="text" size="50" value="<?php echo lz_optpost('captcha_key', $loginizer['captcha_key']); ?>" name="captcha_key" /><br />
2493 <?php echo __('Get the Site Key and Secret Key from <a href="https://www.google.com/recaptcha/" target="_blank">Google</a>', 'loginizer'); ?>
2494 </td>
2495 </tr>
2496 <tr class="lz_google_cap">
2497 <th scope="row" valign="top"><label><?php echo __('Secret Key', 'loginizer'); ?></label></th>
2498 <td>
2499 <input type="text" size="50" value="<?php echo lz_optpost('captcha_secret', $loginizer['captcha_secret']); ?>" name="captcha_secret" />
2500 </td>
2501 </tr>
2502 <tr class="lz_google_cap">
2503 <th scope="row" valign="top"><label><?php echo __('Theme', 'loginizer'); ?></label></th>
2504 <td>
2505 <select name="captcha_theme">
2506 <?php
2507 foreach($lz_env['theme'] as $k => $v){
2508 echo '<option '.lz_POSTselect('captcha_theme', $k, ($loginizer['captcha_theme'] == $k ? true : false)).' value="'.$k.'">'.$v.'</value>';
2509 }
2510 ?>
2511 </select>
2512 </td>
2513 </tr>
2514 <tr class="lz_google_cap">
2515 <th scope="row" valign="top"><label><?php echo __('Language', 'loginizer'); ?></label></th>
2516 <td>
2517 <select name="captcha_lang">
2518 <?php
2519 foreach($lz_env['lang'] as $k => $v){
2520 echo '<option '.lz_POSTselect('captcha_lang', $k, ($loginizer['captcha_lang'] == $k ? true : false)).' value="'.$k.'">'.$v.'</value>';
2521 }
2522 ?>
2523 </select>
2524 </td>
2525 </tr>
2526 <tr class="lz_google_cap lz_google_cap_size">
2527 <th scope="row" valign="top"><label><?php echo __('Size', 'loginizer'); ?></label></th>
2528 <td>
2529 <select name="captcha_size">
2530 <?php
2531 foreach($lz_env['size'] as $k => $v){
2532 echo '<option '.lz_POSTselect('captcha_size', $k, ($loginizer['captcha_size'] == $k ? true : false)).' value="'.$k.'">'.$v.'</value>';
2533 }
2534 ?>
2535 </select>
2536 </td>
2537 </tr>
2538 <tr>
2539 <td scope="row" valign="top" style="padding-left:0px">
2540 <label><b><?php echo __('Don\'t use Google reCAPTCHA', 'loginizer'); ?></b></label><br>
2541 <?php echo __('If selected, '.$loginizer['prefix'].' will use a simple Math Captcha instead of Google reCAPTCHA', 'loginizer'); ?>
2542 </td>
2543 <td>
2544 <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)); ?> />
2545 </td>
2546 </tr>
2547 <tr class="lz_math_cap">
2548 <td scope="row" valign="top" style="width:300px !important; padding-left:0px">
2549 <label><b><?php echo __('Captcha Text', 'loginizer'); ?></b></label><br>
2550 <?php echo __('The text to be shown for the Captcha Field', 'loginizer'); ?>
2551 </td>
2552 <td>
2553 <input type="text" size="30" value="<?php echo lz_optpost('captcha_text', @$loginizer['captcha_text']); ?>" name="captcha_text" />
2554 </td>
2555 </tr>
2556 <tr class="lz_math_cap">
2557 <td scope="row" valign="top" style="padding-left:0px">
2558 <label><b><?php echo __('Captcha Time', 'loginizer'); ?></b></label><br>
2559 <?php echo __('Enter the number of seconds, a user has to enter captcha value.', 'loginizer'); ?>
2560 </td>
2561 <td>
2562 <input type="text" size="30" value="<?php echo lz_optpost('captcha_time', @$loginizer['captcha_time']); ?>" name="captcha_time" />
2563 </td>
2564 </tr>
2565 <tr class="lz_math_cap">
2566 <td scope="row" valign="top" style="padding-left:0px">
2567 <label><b><?php echo __('Display Captcha in Words', 'loginizer'); ?></b></label><br>
2568 <?php echo __('If selected the Captcha will be displayed in words rather than numbers', 'loginizer'); ?>
2569 </td>
2570 <td>
2571 <input type="checkbox" value="1" name="captcha_words" <?php echo lz_POSTchecked('captcha_words', (empty($loginizer['captcha_words']) ? false : true));?> />
2572 </td>
2573 </tr>
2574 <tr class="lz_math_cap">
2575 <td scope="row" valign="top" style="vertical-align: top !important; padding-left:0px">
2576 <label><b><?php echo __('Mathematical operations', 'loginizer'); ?></b></label><br>
2577 <?php echo __('The Mathematical operations to use for Captcha', 'loginizer'); ?>
2578 </td>
2579 <td valign="top">
2580 <table class="wp-list-table fixed users" cellpadding="8" cellspacing="1">
2581 <?php echo '
2582 <tr>
2583 <td>'.__('Addition (+)', 'loginizer').'</td>
2584 <td><input type="checkbox" value="1" name="captcha_add" '.lz_POSTchecked('captcha_add', (empty($loginizer['captcha_add']) ? false : true)).' /></td>
2585 </tr>
2586 <tr>
2587 <td>'.__('Subtraction (-)', 'loginizer').'</td>
2588 <td><input type="checkbox" value="1" name="captcha_subtract" '.lz_POSTchecked('captcha_subtract', (empty($loginizer['captcha_subtract']) ? false : true)).' /></td>
2589 </tr>
2590 <tr>
2591 <td>'.__('Multiplication (x)', 'loginizer').'</td>
2592 <td><input type="checkbox" value="1" name="captcha_multiply" '.lz_POSTchecked('captcha_multiply', (empty($loginizer['captcha_multiply']) ? false : true)).' /></td>
2593 </tr>
2594 <tr>
2595 <td>'.__('Division (รท)', 'loginizer').'</td>
2596 <td><input type="checkbox" value="1" name="captcha_divide" '.lz_POSTchecked('captcha_divide', (empty($loginizer['captcha_divide']) ? false : true)).' /></td>
2597 </tr>';
2598 ?>
2599 </table>
2600 </td>
2601 </tr>
2602 <tr>
2603 <th scope="row" valign="top"><label><?php echo __('Show Captcha On', 'loginizer'); ?></label></th>
2604 <td valign="top">
2605 <table class="wp-list-table fixed users" cellpadding="8" cellspacing="1">
2606 <?php echo '
2607 <tr>
2608 <td>'.__('Login Form', 'loginizer').'</td>
2609 <td><input type="checkbox" value="1" name="captcha_login" '.lz_POSTchecked('captcha_login', (empty($loginizer['captcha_login']) ? false : true)).' /></td>
2610 </tr>
2611 <tr>
2612 <td>'.__('Lost Password Form', 'loginizer').'</td>
2613 <td><input type="checkbox" value="1" name="captcha_lostpass" '.lz_POSTchecked('captcha_lostpass', (empty($loginizer['captcha_lostpass']) ? false : true)).' /></td>
2614 </tr>
2615 <tr>
2616 <td>'.__('Reset Password Form', 'loginizer').'</td>
2617 <td><input type="checkbox" value="1" name="captcha_resetpass" '.lz_POSTchecked('captcha_resetpass', (empty($loginizer['captcha_resetpass']) ? false : true)).' /></td>
2618 </tr>
2619 <tr>
2620 <td>'.__('Registration Form', 'loginizer').'</td>
2621 <td><input type="checkbox" value="1" name="captcha_register" '.lz_POSTchecked('captcha_register', (empty($loginizer['captcha_register']) ? false : true)).' /></td>
2622 </tr>
2623 <tr>
2624 <td>'.__('Comment Form', 'loginizer').'</td>
2625 <td><input type="checkbox" value="1" name="captcha_comment" '.lz_POSTchecked('captcha_comment', (empty($loginizer['captcha_comment']) ? false : true)).' /></td>
2626 </tr>';
2627
2628 if(!defined('SITEPAD')){
2629
2630 echo '<tr>
2631 <td>'.__('WooCommerce Checkout', 'loginizer').'</td>
2632 <td><input type="checkbox" value="1" name="captcha_wc_checkout" '.lz_POSTchecked('captcha_wc_checkout', (empty($loginizer['captcha_wc_checkout']) ? false : true)).' /></td>
2633 </tr>';
2634
2635 }
2636
2637 ?>
2638 </table>
2639 </td>
2640 </tr>
2641 <tr>
2642 <th scope="row" valign="top"><label><?php echo __('Hide CAPTCHA for logged in Users', 'loginizer'); ?></label></th>
2643 <td>
2644 <input type="checkbox" value="1" name="captcha_user_hide" <?php echo lz_POSTchecked('captcha_user_hide', (empty($loginizer['captcha_user_hide']) ? false : true)); ?> />
2645 </td>
2646 </tr>
2647 <tr class="lz_google_cap">
2648 <th scope="row" valign="top"><label><?php echo __('Disable CSS inserted on Login Page', 'loginizer'); ?></label></th>
2649 <td>
2650 <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)); ?> />
2651 </td>
2652 </tr>
2653 </table><br />
2654 <center><input name="save_lz" class="button button-primary action" value="<?php echo __('Save Settings','loginizer'); ?>" type="submit" />
2655 <input style="float:right" name="clear_captcha_lz" class="button action" value="<?php echo __('Disable reCAPTCHA','loginizer'); ?>" type="submit" /></center>
2656 </form>
2657
2658 </div>
2659 </div>
2660 <br />
2661
2662 <script type="text/javascript">
2663
2664 function no_google_recaptcha(obj){
2665
2666 if(obj.checked){
2667 jQuery(".lz_google_cap").hide();
2668 jQuery(".lz_math_cap").show();
2669 }else{
2670 jQuery(".lz_google_cap").show();
2671 jQuery(".lz_math_cap").hide();
2672 }
2673
2674 var cur_captcha_type = jQuery("input:radio[name='captcha_type']:checked").val();
2675
2676 if(cur_captcha_type == 'v3' || cur_captcha_type == 'v2_invisible'){
2677 jQuery(".lz_google_cap_size").hide();
2678 }else{
2679 jQuery(".lz_google_cap_size").show();
2680 }
2681
2682 }
2683
2684 no_google_recaptcha(jQuery("#captcha_no_google")[0]);
2685
2686 function google_recaptcha_type(obj){
2687 if(obj.value == 'v3' || obj.value == 'v2_invisible'){
2688 jQuery(".lz_google_cap_size").hide();
2689 }else{
2690 jQuery(".lz_google_cap_size").show();
2691 }
2692 }
2693
2694
2695 </script>
2696
2697 <?php
2698 loginizer_page_footer();
2699
2700 }
2701
2702
2703 // Loginizer - Two Factor Auth Page
2704 function loginizer_page_2fa(){
2705
2706 global $loginizer, $lz_error, $lz_env, $lz_roles;
2707
2708 if(!current_user_can('manage_options')){
2709 wp_die('Sorry, but you do not have permissions to change settings.');
2710 }
2711
2712 if(!loginizer_is_premium() && count($_POST) > 0){
2713 $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');
2714 return loginizer_page_2fa_T();
2715 }
2716
2717 $lz_roles = get_editable_roles();
2718
2719 /* Make sure post was from this page */
2720 if(count($_POST) > 0){
2721 check_admin_referer('loginizer-options');
2722 }
2723
2724 // Settings submitted
2725 if(isset($_POST['save_lz'])){
2726
2727 // In the future there can be more settings
2728 $option['2fa_app'] = (int) lz_optpost('2fa_app');
2729 $option['2fa_email'] = (int) lz_optpost('2fa_email');
2730 $option['question'] = (int) lz_optpost('question');
2731 $option['2fa_email_force'] = (int) lz_optpost('2fa_email_force');
2732
2733 // Any roles to apply to ?
2734 foreach($lz_roles as $k => $v){
2735
2736 if(lz_optpost('2fa_roles_'.$k)){
2737 $option['2fa_roles'][$k] = 1;
2738 }
2739
2740 }
2741
2742 // If its all, then blank it
2743 if(lz_optpost('2fa_roles_all') || empty($option['2fa_roles'])){
2744 $option['2fa_roles'] = '';
2745 }
2746
2747 // Is there an error ?
2748 if(!empty($lz_error)){
2749 return loginizer_page_2fa_T();
2750 }
2751
2752 // Save the options
2753 update_option('loginizer_2fa', $option);
2754
2755 // Mark as saved
2756 $GLOBALS['lz_saved'] = true;
2757
2758 }
2759
2760 // Reset a users 2FA
2761 if(isset($_POST['reset_user_lz'])){
2762
2763 $_username = lz_optpost('lz_user_2fa_disable');
2764
2765 // Try to get the user
2766 $user_search = get_user_by('login', $_username);
2767
2768 // If not found then search by email
2769 if(empty($user_search)){
2770 $user_search = get_user_by('email', $_username);
2771 }
2772
2773 // If not found then give error
2774 if(empty($user_search)){
2775 $lz_error['2fa_user_not'] = __('There is no such user with the email or username you submitted', 'loginizer');
2776 return loginizer_page_2fa_T();
2777 }
2778
2779 // Get the user prefences
2780 $user_pref = get_user_meta($user_search->ID, 'loginizer_user_settings');
2781
2782 // Blank it
2783 $user_pref['pref'] = 'none';
2784
2785 // Save it
2786 update_user_meta($user_search->ID, 'loginizer_user_settings', $user_pref);
2787
2788 // Mark as saved
2789 $GLOBALS['lz_saved'] = __('The user\'s 2FA settings have been reset', 'loginizer');
2790
2791 }
2792
2793 // Call theme
2794 loginizer_page_2fa_T();
2795
2796 }
2797
2798
2799 // Loginizer - Two Factor Auth Page
2800 function loginizer_page_2fa_T(){
2801
2802 global $loginizer, $lz_error, $lz_env, $lz_roles;
2803
2804 // Universal header
2805 loginizer_page_header('Two Factor Authentication');
2806
2807 loginizer_feature_available('Two-Factor Authentication');
2808
2809 // Saved ?
2810 if(!empty($GLOBALS['lz_saved'])){
2811 echo '<div id="message" class="updated"><p>'. __(is_string($GLOBALS['lz_saved']) ? $GLOBALS['lz_saved'] : 'The settings were saved successfully', 'loginizer'). '</p></div><br />';
2812 }
2813
2814 // Any errors ?
2815 if(!empty($lz_error)){
2816 lz_report_error($lz_error);echo '<br />';
2817 }
2818
2819 ?>
2820
2821 <style>
2822 input[type="text"], textarea, select {
2823 width: 70%;
2824 }
2825
2826 .form-table label{
2827 font-weight:bold;
2828 }
2829
2830 .exp{
2831 font-size:12px;
2832 }
2833 </style>
2834
2835 <div id="" class="postbox">
2836
2837 <div class="postbox-header">
2838 <h2 class="hndle ui-sortable-handle">
2839 <span><?php echo __('Two Factor Authentication Settings', 'loginizer'); ?></span>
2840 </h2>
2841 </div>
2842
2843 <div class="inside">
2844
2845 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
2846 <?php wp_nonce_field('loginizer-options'); ?>
2847 <table class="form-table">
2848 <tr>
2849 <td scope="row" valign="top" colspan="2">
2850 <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>
2851 </td>
2852 </tr>
2853 <tr>
2854 <td scope="row" valign="top" style="width:70% !important">
2855 <label><?php echo __('OTP via App', 'loginizer'); ?></label><br>
2856 <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>
2857 </td>
2858 <td>
2859 <input type="checkbox" value="1" name="2fa_app" <?php echo lz_POSTchecked('2fa_app', (empty($loginizer['2fa_app']) ? false : true)); ?> />
2860 </td>
2861 </tr>
2862 <tr>
2863 <td scope="row" valign="top">
2864 <label><?php echo __('OTP via Email', 'loginizer'); ?></label><br>
2865 <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>
2866 </td>
2867 <td>
2868 <input type="checkbox" value="1" name="2fa_email" <?php echo lz_POSTchecked('2fa_email', (empty($loginizer['2fa_email']) ? false : true)); ?> />
2869 </td>
2870 </tr>
2871 <tr>
2872 <td scope="row" valign="top">
2873 <label><?php echo __('User Defined Question & Answer', 'loginizer'); ?></label><br>
2874 <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>
2875 </td>
2876 <td>
2877 <input type="checkbox" value="1" name="question" <?php echo lz_POSTchecked('question', (empty($loginizer['question']) ? false : true)); ?> />
2878 </td>
2879 </tr>
2880 </table><br />
2881
2882 <table class="form-table">
2883 <tr>
2884 <td scope="row" valign="top" style="width:70% !important">
2885 <label><?php echo __('Force OTP via Email', 'loginizer'); ?></label><br>
2886 <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>
2887 </td>
2888 <td>
2889 <input type="checkbox" value="1" name="2fa_email_force" <?php echo lz_POSTchecked('2fa_email_force', (empty($loginizer['2fa_email_force']) ? false : true)); ?> />
2890 </td>
2891 </tr>
2892 <tr>
2893 <td scope="row" valign="top" style="width:70% !important">
2894 <label><?php echo __('Apply 2FA to Roles', 'loginizer'); ?></label><br>
2895 <span class="exp"><?php echo __('Select the Roles to which 2FA should be applied.', 'loginizer'); ?></span>
2896 </td>
2897 <td>
2898 <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 />
2899 <?php
2900
2901 foreach($lz_roles as $k => $v){
2902 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>';
2903 }
2904
2905 ?>
2906 </td>
2907 </tr>
2908 </table><br />
2909 <center><input name="save_lz" class="button button-primary action" value="<?php echo __('Save Settings', 'loginizer'); ?>" type="submit" /></center>
2910 </form>
2911
2912 </div>
2913 </div>
2914
2915 <script type="text/javascript">
2916
2917 function lz_roles_handle(){
2918
2919 var obj = jQuery("#2fa_roles_all")[0];
2920
2921 if(obj.checked){
2922 jQuery(".lz_roles").hide();
2923 }else{
2924 jQuery(".lz_roles").show();
2925 }
2926
2927 }
2928
2929 lz_roles_handle();
2930
2931 </script>
2932
2933 <!--Bypass a single user-->
2934 <div id="" class="postbox">
2935
2936 <div class="postbox-header">
2937 <h2 class="hndle ui-sortable-handle">
2938 <span><?php echo __('Disable Two Factor Authentication for a User', 'loginizer'); ?></span>
2939 </h2>
2940 </div>
2941
2942 <div class="inside">
2943
2944 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
2945 <?php wp_nonce_field('loginizer-options'); ?>
2946 <table class="form-table">
2947 <tr>
2948 <td scope="row" valign="top" colspan="2">
2949 <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>
2950 </td>
2951 </tr>
2952 <tr>
2953 <td scope="row" valign="top">
2954 <label><?php echo __('Username / Email', 'loginizer'); ?></label><br>
2955 <span class="exp"><?php echo __('The username or email of the user whose 2FA you would like to disable', 'loginizer'); ?></span>
2956 </td>
2957 <td>
2958 <input type="text" size="50" value="<?php echo lz_optpost('lz_user_2fa_disable', ''); ?>" name="lz_user_2fa_disable" />
2959 </td>
2960 </tr>
2961 </table><br />
2962
2963 <center><input name="reset_user_lz" class="button button-primary action" value="<?php echo __('Reset 2FA for User', 'loginizer'); ?>" type="submit" /></center>
2964 </form>
2965
2966 </div>
2967 </div>
2968
2969 <br />
2970
2971 <?php
2972 loginizer_page_footer();
2973
2974 }
2975
2976 // Loginizer - PasswordLess Page
2977 function loginizer_page_passwordless(){
2978
2979 global $loginizer, $lz_error, $lz_env;
2980
2981 if(!current_user_can('manage_options')){
2982 wp_die('Sorry, but you do not have permissions to change settings.');
2983 }
2984
2985 if(!loginizer_is_premium() && count($_POST) > 0){
2986 $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');
2987 return loginizer_page_passwordless_T();
2988 }
2989
2990 /* Make sure post was from this page */
2991 if(count($_POST) > 0){
2992 check_admin_referer('loginizer-options');
2993 }
2994
2995 if(isset($_POST['save_lz'])){
2996
2997 // In the future there can be more settings
2998 $option['email_pass_less'] = (int) lz_optpost('email_pass_less');
2999 $option['passwordless_sub'] = lz_optpost('lz_passwordless_sub');
3000 $option['passwordless_msg'] = lz_optpost('lz_passwordless_msg');
3001
3002 // Is there an error ?
3003 if(!empty($lz_error)){
3004 return loginizer_page_passwordless_T();
3005 }
3006
3007 // Save the options
3008 update_option('loginizer_epl', $option);
3009
3010 // Mark as saved
3011 $GLOBALS['lz_saved'] = true;
3012
3013 }
3014
3015 // Call theme
3016 loginizer_page_passwordless_T();
3017 }
3018
3019 // Loginizer - PasswordLess Page Theme
3020 function loginizer_page_passwordless_T(){
3021
3022 global $loginizer, $lz_error, $lz_env;
3023
3024 $lz_options = get_option('loginizer_epl');
3025
3026 // Universal header
3027 loginizer_page_header('PasswordLess Settings');
3028
3029 loginizer_feature_available('PasswordLess Login');
3030
3031 // Saved ?
3032 if(!empty($GLOBALS['lz_saved'])){
3033 echo '<div id="message" class="updated"><p>'. __('The settings were saved successfully', 'loginizer'). '</p></div><br />';
3034 }
3035
3036 // Any errors ?
3037 if(!empty($lz_error)){
3038 lz_report_error($lz_error);echo '<br />';
3039 }
3040
3041 ?>
3042
3043 <style>
3044 input[type="text"], textarea, select {
3045 width: 90%;
3046 }
3047
3048 .form-table label{
3049 font-weight:bold;
3050 }
3051
3052 .form-table td{
3053 vertical-align:top;
3054 }
3055
3056 .exp{
3057 font-size:12px;
3058 }
3059 </style>
3060
3061 <div id="" class="postbox">
3062
3063 <div class="postbox-header">
3064 <h2 class="hndle ui-sortable-handle">
3065 <span><?php echo __('PasswordLess Settings', 'loginizer'); ?></span>
3066 </h2>
3067 </div>
3068
3069 <div class="inside">
3070
3071 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
3072 <?php wp_nonce_field('loginizer-options'); ?>
3073 <table class="form-table">
3074 <tr>
3075 <th scope="row" valign="top" style="width:350px !important"><label><?php echo __('Enable PasswordLess Login', 'loginizer'); ?></label></th>
3076 <td>
3077 <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"' : '') ?> />
3078 </td>
3079 </tr>
3080 <tr>
3081 <td colspan="2" valign="top">
3082 <?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>
3083 <?php echo __('If a wrong username/email is given, the brute force checker will prevent any brute force attempt !', 'loginizer'); ?>
3084 </td>
3085 </tr>
3086 <tr>
3087 <td scope="row" valign="top">
3088 <label><?php echo __('Email Subject', 'loginizer'); ?></label><br>
3089 <span class="exp"><?php echo __('Set blank to reset to the default subject', 'loginizer'); ?></span>
3090 <br />Default : <?php echo @$loginizer['pl_d_sub']; ?>
3091 </td>
3092 <td valign="top">
3093 <input type="text" size="40" value="<?php echo lz_optpost('lz_passwordless_sub', @$lz_options['passwordless_sub']); ?>" name="lz_passwordless_sub" />
3094 </td>
3095 </tr>
3096 <tr>
3097 <td scope="row" valign="top">
3098 <label><?php echo __('Email Body', 'loginizer'); ?></label><br>
3099 <span class="exp"><?php echo __('Set blank to reset to the default message', 'loginizer'); ?></span>
3100 <br />Default : <pre style="font-size:10px"><?php echo @$loginizer['pl_d_msg']; ?></pre>
3101 </td>
3102 <td valign="top">
3103 <textarea rows="10" name="lz_passwordless_msg"><?php echo lz_optpost('lz_passwordless_msg', @$lz_options['passwordless_msg']); ?></textarea>
3104 <br />
3105 Variables :
3106 <br />$email - Users Email
3107 <br />$site_name - The Site Name
3108 <br />$site_url - The Site URL
3109 <br />$login_url - The Login URL
3110 </td>
3111 </tr>
3112 </table><br />
3113 <center><input name="save_lz" class="button button-primary action" value="<?php echo __('Save Settings', 'loginizer'); ?>" type="submit" /></center>
3114 </form>
3115
3116 </div>
3117 </div>
3118 <br />
3119
3120 <?php
3121 loginizer_page_footer();
3122
3123 }
3124
3125 // Loginizer - Security Settings Page
3126 function loginizer_page_security(){
3127
3128 global $loginizer, $lz_error, $lz_env, $wpdb;
3129
3130 if(!current_user_can('manage_options')){
3131 wp_die('Sorry, but you do not have permissions to change settings.');
3132 }
3133
3134 if(!loginizer_is_premium() && count($_POST) > 0){
3135 $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');
3136 return loginizer_page_security_T();
3137 }
3138
3139 /* Make sure post was from this page */
3140 if(count($_POST) > 0){
3141 check_admin_referer('loginizer-options');
3142 }
3143
3144 if(isset($_POST['save_lz'])){
3145
3146 $option['login_slug'] = lz_optpost('login_slug');
3147 $option['rename_login_secret'] = (int) lz_optpost('rename_login_secret');
3148 $option['xmlrpc_slug'] = lz_optpost('xmlrpc_slug');
3149 $option['xmlrpc_disable'] = (int) lz_optpost('xmlrpc_disable');
3150 $option['pingbacks_disable'] = (int) lz_optpost('pingbacks_disable');
3151
3152 // Login Slug Valid ?
3153 if(!empty($option['login_slug'])){
3154 if(strlen($option['login_slug']) <= 4 || strlen($option['login_slug']) > 50){
3155 $lz_error['login_slug'] = __('The Login slug length must be greater than <b>4</b> chars and upto <b>50</b> chars long', 'loginizer');
3156 }
3157 }
3158
3159 // XML-RPC Slug Valid ?
3160 if(!empty($option['xmlrpc_slug'])){
3161 if(strlen($option['xmlrpc_slug']) <= 4 || strlen($option['xmlrpc_slug']) > 50){
3162 $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');
3163 }
3164 }
3165
3166 // Is there an error ?
3167 if(!empty($lz_error)){
3168 return loginizer_page_security_T();
3169 }
3170
3171 // Save the options
3172 update_option('loginizer_security', $option);
3173
3174 // Mark as saved
3175 $GLOBALS['lz_saved'] = true;
3176
3177 }
3178
3179 // Reset the username
3180 if(isset($_POST['save_lz_admin'])){
3181
3182 // Get the new username
3183 $current_username = lz_optpost('current_username');
3184 $new_username = lz_optpost('new_username');
3185
3186 if(empty($current_username)){
3187 $lz_error['current_username_empty'] = __('Current username is required', 'loginizer');
3188 return loginizer_page_security_T();
3189 }
3190
3191 if(empty($new_username)){
3192 $lz_error['new_username_empty'] = __('New username is required', 'loginizer');
3193 return loginizer_page_security_T();
3194 }
3195
3196 // Is the starting of the username having 'admin' ?
3197 if(@strtolower(substr($new_username, 0, 5)) == 'admin'){
3198 $lz_error['user_exists'] = __('The username begins with <b>admin</b>. Please change it !', 'loginizer');
3199 return loginizer_page_security_T();
3200 }
3201
3202 // Lets check if there is such a user
3203 $found = get_user_by('login', $new_username);
3204
3205 // Found one !
3206 if(!empty($found->ID)){
3207 $lz_error['user_exists'] = __('The new username is already assigned to another user', 'loginizer');
3208 return loginizer_page_security_T();
3209 }
3210
3211 $old_user = get_user_by('login', $current_username);
3212
3213 if(empty($old_user->ID)){
3214 $lz_error['current_username_invalid'] = __('No user found with the current username provided', 'loginizer');
3215 return loginizer_page_security_T();
3216 }
3217
3218 if(empty($old_user->caps['administrator'])){
3219 $lz_error['user_not_admin'] = __('The user is not an administrator. Only administrator user\'s username can be changed.', 'loginizer');
3220 return loginizer_page_security_T();
3221 }
3222
3223 // Update the username
3224 $wpdb->query("UPDATE `".$wpdb->prefix."users`
3225 SET user_login = '$new_username'
3226 WHERE `ID` = '".$old_user->ID."'");
3227
3228 // Mark as saved
3229 $GLOBALS['lz_saved'] = true;
3230
3231 }
3232
3233 // Change the wp-admin slug
3234 if(isset($_POST['save_lz_wp_admin'])){
3235
3236 // Get the new username
3237 $option['admin_slug'] = lz_optpost('admin_slug');
3238 $option['restrict_wp_admin'] = (int) lz_optpost('restrict_wp_admin');
3239 $option['wp_admin_msg'] = @stripslashes($_POST['wp_admin_msg']);
3240 $lz_wp_admin_docs = (int) lz_optpost('lz_wp_admin_docs');
3241
3242 // Did you agree to this ?
3243 if(!empty($option['admin_slug']) && empty($lz_wp_admin_docs)){
3244 $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');
3245 return loginizer_page_security_T();
3246 }
3247
3248 // Length
3249 if(!empty($option['admin_slug']) && (strlen($option['admin_slug']) <= 4 || strlen($option['admin_slug']) > 50)){
3250 $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');
3251 return loginizer_page_security_T();
3252 }
3253
3254 // Only regular characters
3255 if(preg_match('/[^\w\d\-_]/is', $option['admin_slug'])){
3256 $lz_error['admin_slug_chars'] = __('Special characters are not allowed', 'loginizer');
3257 return loginizer_page_security_T();
3258 }
3259
3260 // Update the option
3261 update_option('loginizer_wp_admin', $option);
3262
3263 // Mark as saved
3264 $GLOBALS['lz_saved'] = true;
3265
3266 }
3267
3268
3269 // Save blacklisted usernames
3270 if(isset($_POST['save_lz_bl_users'])){
3271
3272 $usernames = isset($_POST['lz_bl_users']) && is_array($_POST['lz_bl_users']) ? $_POST['lz_bl_users'] : array();
3273
3274 // Process the usernames i.e. remove blanks
3275 foreach($usernames as $k => $v){
3276 $v = trim($v);
3277
3278 // Unset blank values
3279 if(empty($v)){
3280 unset($usernames[$k]);
3281 }
3282
3283 // Disallow these special characters to avoid XSS or any other security vulnerability
3284 if(preg_match('/[\<\>\"\']/', $v)){
3285 unset($usernames[$k]);
3286 }
3287 }
3288
3289 // Update the blacklist
3290 update_option('loginizer_username_blacklist', array_values($usernames));
3291
3292 // Mark as saved
3293 $GLOBALS['lz_saved'] = true;
3294
3295 }
3296
3297
3298 // Save blacklisted domains
3299 if(isset($_POST['save_lz_bl_domains'])){
3300
3301 $domains = isset($_POST['lz_bl_domains']) && is_array($_POST['lz_bl_domains']) ? $_POST['lz_bl_domains'] : array();
3302
3303 // Process the domains i.e. remove blanks
3304 foreach($domains as $k => $v){
3305 $v = trim($v);
3306
3307 // Unset blank values
3308 if(empty($v)){
3309 unset($domains[$k]);
3310 }
3311
3312 // Disallow these special characters to avoid XSS or any other security vulnerability
3313 if(preg_match('/[\<\>\"\']/', $v)){
3314 unset($domains[$k]);
3315 }
3316 }
3317
3318 // Update the blacklist
3319 update_option('loginizer_domains_blacklist', array_values($domains));
3320
3321 // Mark as saved
3322 $GLOBALS['lz_saved'] = true;
3323
3324 }
3325
3326 // Call theme
3327 loginizer_page_security_T();
3328
3329 }
3330
3331 // Loginizer - Security Settings Page Theme
3332 function loginizer_page_security_T(){
3333
3334 global $loginizer, $lz_error, $lz_env;
3335
3336 // Universal header
3337 loginizer_page_header('Security Settings');
3338
3339 loginizer_feature_available('Security Settings');
3340
3341 // Saved ?
3342 if(!empty($GLOBALS['lz_saved'])){
3343 echo '<div id="message" class="updated"><p>'. __('The settings were saved successfully', 'loginizer'). '</p></div><br />';
3344 }
3345
3346 // Any errors ?
3347 if(!empty($lz_error)){
3348 lz_report_error($lz_error);echo '<br />';
3349 }
3350
3351 $current_admin = get_user_by('id', 1);
3352
3353 ?>
3354
3355 <style>
3356 input[type="text"], textarea, select {
3357 width: 70%;
3358 }
3359
3360 .form-table label{
3361 font-weight:bold;
3362 }
3363
3364 .exp{
3365 font-size:12px;
3366 }
3367 </style>
3368
3369 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
3370
3371 <div id="" class="postbox">
3372
3373 <div class="postbox-header">
3374 <h2 class="hndle ui-sortable-handle">
3375 <span><?php echo __('Rename Login Page', 'loginizer'); ?></span>
3376 </h2>
3377 </div>
3378
3379 <div class="inside">
3380
3381 <?php wp_nonce_field('loginizer-options'); ?>
3382 <table class="form-table">
3383 <tr>
3384 <td scope="row" valign="top" colspan="2">
3385 <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>
3386 </td>
3387 </tr>
3388 <tr>
3389 <td scope="row" valign="top" style="width:40% !important">
3390 <label><?php echo __('New Login Slug', 'loginizer'); ?></label><br>
3391 <span class="exp"><?php echo __('Set blank to reset to the original login URL', 'loginizer'); ?></span>
3392 </td>
3393 <td>
3394 <input type="text" size="50" value="<?php echo lz_POSTval('login_slug', $loginizer['login_slug']); ?>" name="login_slug" />
3395 </td>
3396 </tr>
3397
3398 <?php
3399
3400 if(!defined('SITEPAD')){
3401
3402 ?>
3403 <tr>
3404 <td scope="row" valign="top" style="width:200px !important">
3405 <label><?php echo __('Access Secretly Only', 'loginizer'); ?></label><br>
3406 <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>
3407 </td>
3408 <td>
3409 <input type="checkbox" value="1" name="rename_login_secret" <?php echo lz_POSTchecked('rename_login_secret', (empty($loginizer['rename_login_secret']) ? false : true)); ?> />
3410 </td>
3411 </tr>
3412
3413 <?php
3414
3415 }
3416
3417 ?>
3418 </table><br />
3419 <center><input name="save_lz" class="button button-primary action" value="<?php echo __('Save Settings', 'loginizer'); ?>" type="submit" /></center>
3420
3421 </div>
3422 </div>
3423 <br />
3424
3425 <?php
3426
3427 if(!defined('SITEPAD')){
3428
3429 ?>
3430
3431 <div id="" class="postbox">
3432
3433 <div class="postbox-header">
3434 <h2 class="hndle ui-sortable-handle">
3435 <span><?php echo __('XML-RPC Settings', 'loginizer'); ?></span>
3436 </h2>
3437 </div>
3438
3439 <div class="inside">
3440
3441 <?php wp_nonce_field('loginizer-options'); ?>
3442 <table class="form-table">
3443 <tr>
3444 <td scope="row" valign="top" colspan="2">
3445 <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>
3446 </td>
3447 </tr>
3448 <tr>
3449 <td scope="row" valign="top" style="width:40% !important">
3450 <label><?php echo __('Disable XML-RPC', 'loginizer'); ?></label>
3451 </td>
3452 <td>
3453 <input type="checkbox" value="1" name="xmlrpc_disable" <?php echo lz_POSTchecked('xmlrpc_disable', (empty($loginizer['xmlrpc_disable']) ? false : true)); ?> />
3454 </td>
3455 </tr>
3456 <tr>
3457 <td scope="row" valign="top" style="width:40% !important">
3458 <label><?php echo __('Disable Pingbacks', 'loginizer'); ?></label>
3459 </td>
3460 <td>
3461 <input type="checkbox" value="1" name="pingbacks_disable" <?php echo lz_POSTchecked('pingbacks_disable', (empty($loginizer['pingbacks_disable']) ? false : true)); ?> />
3462 </td>
3463 </tr>
3464 <tr>
3465 <td scope="row" valign="top">
3466 <label><?php echo __('New XML-RPC Slug', 'loginizer'); ?></label><br>
3467 <span class="exp"><?php echo __('Set blank to reset to the original XML-RPC URL', 'loginizer'); ?></span>
3468 </td>
3469 <td>
3470 <input type="text" size="50" value="<?php echo lz_optpost('xmlrpc_slug', $loginizer['xmlrpc_slug']); ?>" name="xmlrpc_slug" />
3471 </td>
3472 </tr>
3473 </table><br />
3474 <center><input name="save_lz" class="button button-primary action" value="<?php echo __('Save Settings', 'loginizer'); ?>" type="submit" /></center>
3475
3476 </div>
3477 </div>
3478 <br />
3479
3480 <?php
3481
3482 }
3483
3484 ?>
3485
3486 </form>
3487
3488 <?php
3489
3490 if(!defined('SITEPAD')){
3491
3492 ?>
3493
3494 <script type="text/javascript">
3495
3496
3497 function dirname(path) {
3498 return path.replace(/\\/g, '/').replace(/\/[^/]*\/?$/, '');
3499 }
3500
3501 function lz_test_wp_admin(){
3502
3503 var data = new Object();
3504 data["action"] = "loginizer_wp_admin";
3505 data["nonce"] = "<?php echo wp_create_nonce('loginizer_admin_ajax');?>";
3506
3507 var new_ajaxurl = dirname(dirname(ajaxurl))+'/'+jQuery('#lz_admin_slug').val()+'/admin-ajax.php';
3508
3509 // AJAX and on success function
3510 jQuery.post(new_ajaxurl, data, function(response){
3511
3512 if(response['result'] == 1){
3513 alert("<?php echo __('Everything seems to be good. You can proceed to save the settings !', 'loginizer'); ?>");
3514 }
3515
3516 // Throw an error for failures
3517 }).fail(function() {
3518 alert("<?php echo __('There was an error connecting to WordPress with the new Admin Slug. Did you configure everything properly ?', 'loginizer'); ?>");
3519 });
3520 //jQuery.ajax('<input type="text" size="30" value="" name="lz_bl_users[]" class="lz_bl_users" />');
3521 return false;
3522 };
3523
3524 </script>
3525
3526 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
3527 <div id="" class="postbox">
3528
3529 <div class="postbox-header">
3530 <h2 class="hndle ui-sortable-handle">
3531 <span><?php echo __('Rename wp-admin access', 'loginizer'); ?></span>
3532 </h2>
3533 </div>
3534
3535 <div class="inside">
3536
3537 <?php wp_nonce_field('loginizer-options'); ?>
3538 <table class="form-table">
3539 <?php
3540 if(preg_match('/(apache|litespeed|lsws)/is', $_SERVER["SERVER_SOFTWARE"])){
3541 // Supported. Do nothing
3542 }else{
3543 echo '<tr>
3544 <td scope="row" valign="top" colspan="2">
3545 <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>
3546 </td>
3547 </tr>';
3548 }
3549 ?>
3550 <tr>
3551 <td scope="row" valign="top" colspan="2">
3552 <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>
3553 </td>
3554 </tr>
3555 <tr>
3556 <td scope="row" valign="top" style="width:40% !important">
3557 <label><?php echo __('New wp-admin Slug', 'loginizer'); ?></label><br>
3558 <span class="exp"><?php echo __('Set blank to reset to the original wp-admin URL', 'loginizer'); ?></span>
3559 </td>
3560 <td>
3561 <input type="text" size="50" value="<?php echo lz_optpost('admin_slug', $loginizer['admin_slug']); ?>" name="admin_slug" id="lz_admin_slug" />
3562 </td>
3563 </tr>
3564 <tr>
3565 <td scope="row" valign="top" style="width:200px !important">
3566 <label><?php echo __('Disable wp-admin access', 'loginizer'); ?></label><br>
3567 <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>
3568 </td>
3569 <td>
3570 <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)); ?> />
3571 </td>
3572 </tr>
3573 <tr id="lz_wp_admin_msg_row" style="display:none">
3574 <td scope="row" valign="top">
3575 <label><?php echo __('WP-Admin Error Message', 'loginizer'); ?></label><br>
3576 <span class="exp"><?php echo __('Error message to show if someone accesses wp-admin', 'loginizer'); ?></span> Default : <?php echo $loginizer['wp_admin_d_msg']; ?>
3577 </td>
3578 <td>
3579 <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" />
3580 </td>
3581 </tr>
3582 <tr>
3583 <td scope="row" valign="top" style="width:200px !important">
3584 <label><?php echo __('I have setup .htaccess', 'loginizer'); ?></label><br>
3585 <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>
3586 </td>
3587 <td>
3588 <input type="checkbox" value="1" name="lz_wp_admin_docs" />
3589 <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'); ?>" />
3590 </td>
3591 </tr>
3592 </table><br />
3593 <center><input name="save_lz_wp_admin" class="button button-primary action" value="<?php echo __('Save Settings', 'loginizer'); ?>" type="submit" /></center>
3594
3595 </div>
3596 </div>
3597 <br />
3598 </form>
3599
3600 <script type="text/javascript">
3601
3602 function lz_wp_admin_msg_toggle(){
3603 var ele = jQuery('#lz_restrict_wp_admin')[0];
3604 if(ele.checked){
3605 jQuery('#lz_wp_admin_msg_row').show();
3606 }else{
3607 jQuery('#lz_wp_admin_msg_row').hide();
3608 }
3609 };
3610
3611 lz_wp_admin_msg_toggle();
3612
3613 </script>
3614
3615
3616 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
3617 <div id="" class="postbox">
3618
3619 <div class="postbox-header">
3620 <h2 class="hndle ui-sortable-handle">
3621 <span><?php echo __('Change Admin Username', 'loginizer'); ?></span>
3622 </h2>
3623 </div>
3624
3625 <div class="inside">
3626
3627 <?php wp_nonce_field('loginizer-options'); ?>
3628 <table class="form-table">
3629 <tr>
3630 <td scope="row" valign="top" colspan="2">
3631 <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>
3632 </td>
3633 </tr>
3634 <tr>
3635 <td scope="row" valign="top" style="width:40% !important">
3636 <label for="current_username"><?php echo __('Current Username', 'loginizer'); ?></label><br>
3637 <span class="exp"><?php echo __('The current username you want to change', 'loginizer'); ?></span>
3638 </td>
3639 <td>
3640 <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" />
3641 </td>
3642 </tr>
3643 <tr>
3644 <td scope="row" valign="top" style="width:40% !important">
3645 <label for="new_username"><?php echo __('New Username', 'loginizer'); ?></label><br>
3646 <span class="exp"><?php echo __('The new username you want to set', 'loginizer'); ?></span>
3647 </td>
3648 <td>
3649 <input type="text" size="50" value="<?php echo lz_optpost('new_username', ''); ?>" name="new_username" id="new_username" />
3650 </td>
3651 </tr>
3652 </table><br />
3653 <i><?php echo __('Note: Username can be changed only for administrator users.'); ?></i>
3654 <center><input name="save_lz_admin" class="button button-primary action" value="<?php echo __('Set the Username', 'loginizer'); ?>" type="submit" /></center>
3655
3656 </div>
3657 </div>
3658 </form>
3659
3660 <script type="text/javascript">
3661 function add_lz_bl_users(){
3662 jQuery("#lz_bl_users").append('<input type="text" size="30" value="" name="lz_bl_users[]" class="lz_bl_users" />');
3663 return false;
3664 };
3665 </script>
3666
3667 <style>
3668 .lz_bl_users, .lz_bl_domains{
3669 margin-bottom:20px;
3670 }
3671 </style>
3672
3673 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
3674 <div id="" class="postbox">
3675
3676 <div class="postbox-header">
3677 <h2 class="hndle ui-sortable-handle">
3678 <span><?php echo __('Username Auto Blacklist', 'loginizer'); ?></span>
3679 </h2>
3680 </div>
3681
3682 <div class="inside">
3683
3684 <?php wp_nonce_field('loginizer-options'); ?>
3685 <table class="form-table">
3686 <tr>
3687 <td scope="row" valign="top" colspan="2">
3688 <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>
3689 </td>
3690 </tr>
3691 <tr>
3692 <td scope="row" valign="top" style="width:40% !important; vertical-align:top !important;">
3693 <label><?php echo __('Username(s)', 'loginizer'); ?></label><br>
3694 <span class="exp"><?php echo __('You can use - <b>*</b> (Star)- as a wild card as well. Blank fields will be ignored', 'loginizer'); ?></span>
3695 </td>
3696 <td>
3697 <div id="lz_bl_users">
3698 <?php
3699
3700 $usernames = isset($_POST['lz_bl_users']) && is_array($_POST['lz_bl_users']) ? $_POST['lz_bl_users'] : $loginizer['username_blacklist'];
3701
3702 if(empty($usernames)){
3703 $usernames[] = '';
3704 }
3705
3706 foreach($usernames as $_user){
3707 echo '<input type="text" size="30" value="'.$_user.'" name="lz_bl_users[]" class="lz_bl_users" />';
3708 }
3709
3710 ?>
3711 </div>
3712 <br />
3713 <input class="button" type="button" value="<?php echo __('Add New Username', 'loginizer'); ?>" onclick="return add_lz_bl_users();" style="float:right" />
3714 </td>
3715 </tr>
3716 </table><br />
3717 <center><input name="save_lz_bl_users" class="button button-primary action" value="<?php echo __('Save Username(s)', 'loginizer'); ?>" type="submit" /></center>
3718
3719 </div>
3720 </div>
3721 </form>
3722
3723 <script type="text/javascript">
3724 function add_lz_bl_domains(){
3725 jQuery("#lz_bl_domains").append('<input type="text" size="30" value="" name="lz_bl_domains[]" class="lz_bl_domains" />');
3726 return false;
3727 };
3728 </script>
3729
3730
3731 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
3732 <div id="" class="postbox">
3733
3734 <div class="postbox-header">
3735 <h2 class="hndle ui-sortable-handle">
3736 <span><?php echo __('New Registration Domain Blacklist', 'loginizer'); ?></span>
3737 </h2>
3738 </div>
3739
3740 <div class="inside">
3741
3742 <?php wp_nonce_field('loginizer-options'); ?>
3743 <table class="form-table">
3744 <tr>
3745 <td scope="row" valign="top" colspan="2">
3746 <i>If you would like to ban new registrations from a particular domain, you can use this utility to do so.</i>
3747 </td>
3748 </tr>
3749 <tr>
3750 <td scope="row" valign="top" style="width:40% !important; vertical-align:top !important;">
3751 <label><?php echo __('Domain(s)', 'loginizer'); ?></label><br>
3752 <span class="exp"><?php echo __('You can use - <b>*</b> (Star)- as a wild card as well. Blank fields will be ignored', 'loginizer'); ?></span>
3753 </td>
3754 <td>
3755 <div id="lz_bl_domains">
3756 <?php
3757
3758 $domains = isset($_POST['lz_bl_domains']) && is_array($_POST['lz_bl_domains']) ? $_POST['lz_bl_domains'] : $loginizer['domains_blacklist'];
3759
3760 if(empty($domains)){
3761 $domains[] = '';
3762 }
3763
3764 foreach($domains as $_domain){
3765 echo '<input type="text" size="30" value="'.$_domain.'" name="lz_bl_domains[]" class="lz_bl_domains" />';
3766 }
3767
3768 ?>
3769 </div>
3770 <br />
3771 <input class="button" type="button" value="<?php echo __('Add New Domain', 'loginizer'); ?>" onclick="return add_lz_bl_domains();" style="float:right" />
3772 </td>
3773 </tr>
3774 </table><br />
3775 <center><input name="save_lz_bl_domains" class="button button-primary action" value="<?php echo __('Save Domains(s)', 'loginizer'); ?>" type="submit" /></center>
3776
3777 </div>
3778 </div>
3779 </form>
3780
3781 <?php
3782
3783 }
3784
3785 loginizer_page_footer();
3786
3787 }
3788
3789 // Loginizer - Checksum load data
3790 function loginizer_page_checksums_L(&$files, &$_ignores){
3791
3792 global $loginizer, $lz_error, $lz_env;
3793
3794 // Load any mismatched files and ignores
3795 $files = get_option('loginizer_checksums_diff');
3796 $_ignores = get_option('loginizer_checksums_ignore');
3797 $_ignores = is_array($_ignores) ? $_ignores : array(); // SHOULD ALWAYS BE PURE
3798 $ignores = array();
3799
3800 foreach($_ignores as $ik => $iv){
3801 $ignores[$iv] = array();
3802 if(!empty($files[$iv])){
3803 $ignores[$iv] = $files[$iv];
3804 }
3805 }
3806
3807 $lz_env['files'] = $files;
3808 $lz_env['ignores'] = $ignores;
3809
3810 }
3811
3812 // Loginizer - PasswordLess Page
3813 function loginizer_page_checksums(){
3814
3815 global $loginizer, $lz_error, $lz_env;
3816
3817 if(!current_user_can('manage_options')){
3818 wp_die('Sorry, but you do not have permissions to change settings.');
3819 }
3820
3821 if(!loginizer_is_premium() && count($_POST) > 0){
3822 $lz_error['not_in_free'] = __('This feature is not available in the Free version. <a href="'.LOGINIZER_PRICING_URL.'" target="_blank" style="text-decoration:none; color:green;"><b>Upgrade to Pro</b></a>', 'loginizer');
3823 return loginizer_page_checksums_T();
3824 }
3825
3826 /* Make sure post was from this page */
3827 if(count($_POST) > 0){
3828 check_admin_referer('loginizer-options');
3829 }
3830
3831 // Are we to run it ?
3832 if(isset($_REQUEST['lz_run_checksum'])){
3833 loginizer_checksums();
3834 }
3835
3836 loginizer_page_checksums_L($files, $_ignores);
3837
3838 $lz_env['csum_freq'][1] = __('Once a Day', 'loginizer');
3839 $lz_env['csum_freq'][7] = __('Once a Week', 'loginizer');
3840 $lz_env['csum_freq'][30] = __('Once a Month', 'loginizer');
3841
3842 if(isset($_POST['save_lz'])){
3843
3844 // In the future there can be more settings
3845 $option['disable_checksum'] = (int) lz_optpost('disable_checksum');
3846 $option['no_checksum_email'] = (int) lz_optpost('no_checksum_email');
3847 $option['checksum_frequency'] = (int) lz_optpost('checksum_frequency');
3848 $option['checksum_time'] = lz_optpost('checksum_time');
3849
3850 // Is there an error ?
3851 if(!empty($lz_error)){
3852 return loginizer_page_checksums_T();
3853 }
3854
3855 // Save the options
3856 update_option('loginizer_checksums', $option);
3857
3858 // Mark as saved
3859 $GLOBALS['lz_saved'] = true;
3860
3861 }
3862
3863 // Add or remove from ignore list
3864 if(isset($_POST['save_lz_csum_ig'])){
3865
3866 if(@is_array($_POST['checksum_del_ignore'])){
3867
3868 foreach($_POST['checksum_del_ignore'] as $k => $v){
3869 $key = array_search($v, $_ignores);
3870 if($key !== false){
3871 unset($_ignores[$key]);
3872 }
3873 }
3874
3875 // Save it
3876 update_option('loginizer_checksums_ignore', $_ignores);
3877
3878 }
3879
3880 if(@is_array($_POST['checksum_add_ignore'])){
3881
3882 foreach($_POST['checksum_add_ignore'] as $k => $v){
3883 if(!empty($files[$v])){
3884 $_ignores[] = $v;
3885 }
3886 }
3887
3888 // Save it
3889 update_option('loginizer_checksums_ignore', $_ignores);
3890
3891 }
3892
3893 // Reload
3894 loginizer_page_checksums_L($files, $_ignores);
3895
3896 // Mark as saved
3897 $GLOBALS['lz_saved'] = true;
3898
3899 }
3900
3901 // Call theme
3902 loginizer_page_checksums_T();
3903 }
3904
3905 // Loginizer - PasswordLess Page Theme
3906 function loginizer_page_checksums_T(){
3907
3908 global $loginizer, $lz_error, $lz_env;
3909
3910 // Universal header
3911 loginizer_page_header('File Checksum Settings');
3912
3913 loginizer_feature_available('File Checksum');
3914
3915 wp_enqueue_script('jquery-clockpicker', LOGINIZER_URL.'/jquery-clockpicker.min.js', array('jquery'), '0.0.7');
3916 wp_enqueue_style('jquery-clockpicker', LOGINIZER_URL.'/jquery-clockpicker.min.css', array(), '0.0.7');
3917
3918 // Saved ?
3919 if(!empty($GLOBALS['lz_saved'])){
3920 echo '<div id="message" class="updated"><p>'. __('The settings were saved successfully', 'loginizer'). '</p></div><br />';
3921 }
3922
3923 // Did we just run the checksums
3924 if(isset($_REQUEST['lz_run_checksum'])){
3925 echo '<div id="message" class="updated"><p>'. __('The Checksum process was executed successfully', 'loginizer'). '</p></div><br />';
3926 }
3927
3928 // Any errors ?
3929 if(!empty($lz_error)){
3930 lz_report_error($lz_error);echo '<br />';
3931 }
3932
3933 ?>
3934
3935 <style>
3936 input[type="text"], textarea, select {
3937 width: 70%;
3938 }
3939
3940 .form-table label{
3941 font-weight:bold;
3942 }
3943
3944 .exp{
3945 font-size:12px;
3946 }
3947 </style>
3948
3949 <script>
3950 function lz_apply_status(ele, the_class){
3951
3952 var status = ele.checked;
3953 jQuery(the_class).each(function(){
3954 this.checked = status;
3955 });
3956
3957 }
3958 </script>
3959
3960 <div id="" class="postbox">
3961 <div class="postbox-header">
3962 <h2 class="hndle ui-sortable-handle">
3963 <span><?php echo __('Checksum Settings', 'loginizer'); ?></span>
3964 </h2>
3965 </div>
3966 <div class="inside">
3967
3968 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
3969 <?php wp_nonce_field('loginizer-options'); ?>
3970 <table class="form-table">
3971 <tr>
3972 <td scope="row" valign="top" style="width:400px !important">
3973 <label><?php echo __('Disable Checksum of WP Core', 'loginizer'); ?></label><br>
3974 <span class="exp"><?php echo __('If disabled, Loginizer will not check your sites core files against the WordPress checksum list.', 'loginizer'); ?></span>
3975 </td>
3976 <td valign="top">
3977 <input type="checkbox" value="1" name="disable_checksum" <?php echo lz_POSTchecked('disable_checksum', (empty($loginizer['disable_checksum']) ? false : true)); ?> />
3978 </td>
3979 </tr>
3980 <tr>
3981 <td scope="row" valign="top" style="width:400px !important">
3982 <label><?php echo __('Disable Email of Checksum Results', 'loginizer'); ?></label><br>
3983 <span class="exp"><?php echo __('If checked, Loginizer will not email you the checksum results.', 'loginizer'); ?></span>
3984 </td>
3985 <td valign="top">
3986 <input type="checkbox" value="1" name="no_checksum_email" <?php echo lz_POSTchecked('no_checksum_email', (empty($loginizer['no_checksum_email']) ? false : true)); ?> />
3987 </td>
3988 </tr>
3989 <tr>
3990 <td scope="row" valign="top" style="width:400px !important">
3991 <label><?php echo __('Checksum Frequency', 'loginizer'); ?></label><br>
3992 <span class="exp"><?php echo __('If Checksum is enabled, at what frequency should the checksums be performed.', 'loginizer'); ?></span>
3993 </td>
3994 <td valign="top">
3995 <select name="checksum_frequency">
3996 <?php
3997 foreach($lz_env['csum_freq'] as $k => $v){
3998 echo '<option '.lz_POSTselect('checksum_frequency', $k, ($loginizer['checksum_frequency'] == $k ? true : false)).' value="'.$k.'">'.$v.'</value>';
3999 }
4000 ?>
4001 </select>
4002 </td>
4003 </tr>
4004 <tr id="lz_checksum_time">
4005 <td scope="row" valign="top" style="width:400px !important">
4006 <label><?php echo __('Time of Day', 'loginizer'); ?></label><br>
4007 <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>
4008 </td>
4009 <td valign="top">
4010 <div class="input-group clockpicker" data-autoclose="true">
4011 <input type="text" name="checksum_time" class="form-control" value="<?php echo (empty($loginizer['checksum_time']) ? '00:00' : $loginizer['checksum_time']);?>">
4012 <span class="input-group-addon">
4013 <span class="glyphicon glyphicon-time"></span>
4014 </span>
4015 </div>
4016 <script type="text/javascript">
4017 jQuery(document).ready(function(){
4018 (function($) {
4019 $('.clockpicker').clockpicker({donetext: 'Done'});
4020 })(jQuery);
4021 });
4022 </script>
4023 </td>
4024 </tr>
4025 <tr>
4026 <td colspan="2">
4027 <?php echo __('If disabled, Loginizer will not check your sites core files against the WordPress checksum list.', 'loginizer'); ?>
4028 </td>
4029 </tr>
4030 </table><br />
4031 <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>
4032 </form>
4033
4034 </div>
4035 </div>
4036
4037 <div id="" class="postbox">
4038
4039 <div class="postbox-header">
4040 <h2 class="hndle ui-sortable-handle">
4041 <span><?php echo __('Mismatching Files', 'loginizer'); ?></span>
4042 </h2>
4043 </div>
4044
4045 <div class="inside">
4046
4047 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
4048 <?php wp_nonce_field('loginizer-options'); ?>
4049 <table class="wp-list-table fixed striped users" border="0" width="100%" cellpadding="10" align="center">
4050 <?php
4051
4052 $files = $lz_env['files'];
4053
4054 // Avoid undefined notice for $files
4055 if(!empty($files)){
4056 foreach($files as $k => $v){
4057 if(!empty($lz_env['ignores'][$k])){
4058 unset($files[$k]);
4059 }
4060 }
4061 }
4062
4063 echo '
4064 <tr>
4065 <th style="background:#EFEFEF;">'.__('Relative Path', 'loginizer').'</th>
4066 <th style="width:240px; background:#EFEFEF;">'.__('Found', 'loginizer').'</th>
4067 <th style="width:240px; background:#EFEFEF;">'.__('Should be', 'loginizer').'</th>
4068 <th style="width:10px; background:#EFEFEF;"><input type="checkbox" onchange="lz_apply_status(this, \'.csum_add_ig\');" /></th>
4069 </tr>';
4070
4071 if(is_array($files) && count($files) > 0){
4072
4073 foreach($files as $k => $v){
4074
4075 echo '
4076 <tr>
4077 <td>'.$k.'</td>
4078 <td>'.$v['cur_md5'].'</td>
4079 <td>'.$v['md5'].'</td>
4080 <td><input type="checkbox" name="checksum_add_ignore[]" class="csum_add_ig" value="'.$k.'" /></td>
4081 </tr>';
4082
4083 }
4084
4085 }else{
4086
4087 echo '
4088 <tr>
4089 <td colspan="4" align="center">'.__('This is great ! No file with any wrong checksum has been found.').'</td>
4090 </tr>';
4091
4092 }
4093
4094 ?>
4095 </table><br />
4096 <center><input name="save_lz_csum_ig" class="button button-primary action" value="<?php echo __('Add Selected to Ignore List', 'loginizer'); ?>" type="submit" /></center>
4097 </form>
4098 </div>
4099
4100 </div>
4101 <br />
4102
4103 <div id="" class="postbox">
4104
4105 <div class="postbox-header">
4106 <h2 class="hndle ui-sortable-handle">
4107 <span><?php echo __('Ignore List', 'loginizer'); ?></span>
4108 </h2>
4109 </div>
4110
4111 <div class="inside">
4112
4113 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
4114 <?php wp_nonce_field('loginizer-options'); ?>
4115 <table class="wp-list-table fixed striped users" border="0" width="100%" cellpadding="10" align="center">
4116 <?php
4117
4118 $ignores = $lz_env['ignores'];
4119
4120 echo '
4121 <tr>
4122 <th style="background:#EFEFEF;">'.__('Relative Path', 'loginizer').'</th>
4123 <th style="width:240px; background:#EFEFEF;">'.__('Found', 'loginizer').'</th>
4124 <th style="width:240px; background:#EFEFEF;">'.__('Should be', 'loginizer').'</th>
4125 <th style="width:10px; background:#EFEFEF;"><input type="checkbox" onchange="lz_apply_status(this, \'.csum_del_ig\');" /></th>
4126 </tr>';
4127
4128 // Load any mismatched files
4129 $files = $ignores;
4130
4131 if(is_array($files) && count($files) > 0){
4132
4133 foreach($files as $k => $v){
4134
4135 echo '
4136 <tr>
4137 <td>'.$k.'</td>
4138 <td>'.$v['cur_md5'].'</td>
4139 <td>'.$v['md5'].'</td>
4140 <td><input type="checkbox" name="checksum_del_ignore[]" class="csum_del_ig" value="'.$k.'" /></td>
4141 </tr>';
4142
4143 }
4144
4145 }else{
4146
4147 echo '
4148 <tr>
4149 <td colspan="4" align="center">'.__('No files have been added to the ignore list').'</td>
4150 </tr>';
4151
4152 }
4153
4154 ?>
4155 </table><br />
4156 <center><input name="save_lz_csum_ig" class="button button-primary action" value="<?php echo __('Remove Selected from Ignore List', 'loginizer'); ?>" type="submit" /></center>
4157 </form>
4158 </div>
4159
4160 </div>
4161 <br />
4162
4163 <?php
4164 loginizer_page_footer();
4165
4166 }
4167
4168
4169 // Sorry to see you going
4170 register_uninstall_hook(LOGINIZER_FILE, 'loginizer_deactivation');
4171
4172 function loginizer_deactivation(){
4173
4174 global $wpdb;
4175
4176 $sql = array();
4177 $sql[] = "DROP TABLE ".$wpdb->prefix."loginizer_logs;";
4178
4179 foreach($sql as $sk => $sv){
4180 $wpdb->query($sv);
4181 }
4182
4183 delete_option('loginizer_version');
4184 delete_option('loginizer_options');
4185 delete_option('loginizer_last_reset');
4186 delete_option('loginizer_whitelist');
4187 delete_option('loginizer_blacklist');
4188 delete_option('loginizer_msg');
4189 delete_option('loginizer_security');
4190 delete_option('loginizer_wp_admin');
4191
4192 }
4193
4194