PluginProbe
Loginizer / 1.6.4
Loginizer v1.6.4
2.1.0 2.0.9 2.0.8 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 All 74 releases
loginizer / init.php

init.php in Loginizer 1.6.4, at init.php

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