PluginProbe
Loginizer / 1.6.2
Loginizer v1.6.2
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.6.2, at init.php

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