PluginProbe
Loginizer / 1.5.6
Loginizer v1.5.6
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.6, at init.php

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