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

init.php in Loginizer 1.7.2, at init.php

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