PluginProbe
Loginizer / 1.5.8
Loginizer v1.5.8
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.8, at init.php

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