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

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