PluginProbe
Loginizer / 1.5.4
Loginizer v1.5.4
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.4, at init.php

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