PluginProbe
Loginizer / 1.5.5
Loginizer v1.5.5
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.5, at init.php

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