芝麻web文件管理V1.00
编辑当前文件:/home/paymbalq/public_html/wp-content/plugins/loginizer/main/settings/security.php
0){ $lz_error['not_in_free'] = __('This feature is not available in the Free version.
Upgrade to Pro
', 'loginizer'); return loginizer_page_security_T(); } /* Make sure post was from this page */ if(count($_POST) > 0){ check_admin_referer('loginizer-options'); } if(isset($_POST['save_lz'])){ $option['login_slug'] = lz_optpost('login_slug'); $option['rename_login_secret'] = (int) lz_optpost('rename_login_secret'); $option['hide_wp_admin'] = !empty($_POST['hide_wp_admin']); $option['login_redirect_url'] = lz_optpost('login_redirect_url'); $option['xmlrpc_slug'] = lz_optpost('xmlrpc_slug'); $option['xmlrpc_disable'] = (int) lz_optpost('xmlrpc_disable'); $option['pingbacks_disable'] = (int) lz_optpost('pingbacks_disable'); // Login Slug Valid ? if(!empty($option['login_slug'])){ if(strlen($option['login_slug']) <= 4 || strlen($option['login_slug']) > 50){ $lz_error['login_slug'] = __('The Login slug length must be greater than
4
chars and upto
50
chars long', 'loginizer'); } } // login slug and admin slug cannot be the same $_loginizer_wp_admin = get_option('loginizer_wp_admin'); if(!empty($_loginizer_wp_admin['admin_slug']) && $_loginizer_wp_admin['admin_slug'] == $option['login_slug']){ $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'); return loginizer_page_security_T(); } // XML-RPC Slug Valid ? if(!empty($option['xmlrpc_slug'])){ if(strlen($option['xmlrpc_slug']) <= 4 || strlen($option['xmlrpc_slug']) > 50){ $lz_error['xmlrpc_slug'] = __('The XML-RPC slug length must be greater than
4
chars and upto
50
chars long', 'loginizer'); } } // Is there an error ? if(!empty($lz_error)){ return loginizer_page_security_T(); } // Save the options update_option('loginizer_security', $option); // Mark as saved $GLOBALS['lz_saved'] = true; } // Reset the username if(isset($_POST['save_lz_admin'])){ // Get the new username $current_username = lz_optpost('current_username'); $new_username = lz_optpost('new_username'); if(empty($current_username)){ $lz_error['current_username_empty'] = __('Current username is required', 'loginizer'); return loginizer_page_security_T(); } if(empty($new_username)){ $lz_error['new_username_empty'] = __('New username is required', 'loginizer'); return loginizer_page_security_T(); } // Is the starting of the username having 'admin' ? if(@strtolower(substr($new_username, 0, 5)) == 'admin'){ $lz_error['user_exists'] = __('The username begins with
admin
. Please change it !', 'loginizer'); return loginizer_page_security_T(); } // Lets check if there is such a user $found = get_user_by('login', $new_username); // Found one ! if(!empty($found->ID)){ $lz_error['user_exists'] = __('The new username is already assigned to another user', 'loginizer'); return loginizer_page_security_T(); } $old_user = get_user_by('login', $current_username); if(empty($old_user->ID)){ $lz_error['current_username_invalid'] = __('No user found with the current username provided', 'loginizer'); return loginizer_page_security_T(); } if(empty($old_user->caps['administrator'])){ $lz_error['user_not_admin'] = __('The user is not an administrator. Only administrator user\'s username can be changed.', 'loginizer'); return loginizer_page_security_T(); } $is_super_admin = 0; if(is_multisite() && is_super_admin($old_user->ID)){ $is_super_admin = 1; } // Update the username $update_data = array('user_login' => $new_username); $where_data = array('ID' => $old_user->ID); $format = array('%s'); $where_format = array('%d'); $wpdb->update($wpdb->prefix.'users', $update_data, $where_data, $format, $where_format); // Update the super admins list for multisite if(!empty($is_super_admin)){ $super_admins = get_site_option('site_admins'); foreach($super_admins as $sk => $sv){ // Remove the existing username from super admins list if($sv == $current_username){ unset($super_admins[$sk]); } } // Add the new username $super_admins[] = $new_username; update_site_option( 'site_admins', $super_admins ); } // Mark as saved $GLOBALS['lz_saved'] = true; } // Change the wp-admin slug if(isset($_POST['save_lz_wp_admin'])){ // Get the new username $option['admin_slug'] = lz_optpost('admin_slug'); $option['restrict_wp_admin'] = (int) lz_optpost('restrict_wp_admin'); $option['wp_admin_msg'] = @stripslashes($_POST['wp_admin_msg']); $lz_wp_admin_docs = (int) lz_optpost('lz_wp_admin_docs'); // login slug and admin slug cannot be the same $_loginizer_security = get_option('loginizer_security'); if(!empty($_loginizer_security['login_slug']) && $_loginizer_security['login_slug'] == $option['admin_slug']){ $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'); return loginizer_page_security_T(); } // Did you agree to this ? if(!empty($option['admin_slug']) && empty($lz_wp_admin_docs)){ $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'); return loginizer_page_security_T(); } // Length if(!empty($option['admin_slug']) && (strlen($option['admin_slug']) <= 4 || strlen($option['admin_slug']) > 50)){ $lz_error['admin_slug'] = __('The new Admin slug length must be greater than
4
chars and upto
50
chars long', 'loginizer'); return loginizer_page_security_T(); } // Only regular characters if(preg_match('/[^\w\d\-_]/is', $option['admin_slug'])){ $lz_error['admin_slug_chars'] = __('Special characters are not allowed', 'loginizer'); return loginizer_page_security_T(); } // Update the option update_option('loginizer_wp_admin', $option); // Mark as saved $GLOBALS['lz_saved'] = true; } // Save blacklisted usernames if(isset($_POST['save_lz_bl_users'])){ $usernames = isset($_POST['lz_bl_users']) && is_array($_POST['lz_bl_users']) ? $_POST['lz_bl_users'] : array(); // Process the usernames i.e. remove blanks foreach($usernames as $k => $v){ $v = trim($v); // Unset blank values if(empty($v)){ unset($usernames[$k]); } // Disallow these special characters to avoid XSS or any other security vulnerability if(preg_match('/[\<\>\"\']/', $v)){ unset($usernames[$k]); } } // Update the blacklist update_option('loginizer_username_blacklist', array_values($usernames)); // Mark as saved $GLOBALS['lz_saved'] = true; } // Save blacklisted domains if(isset($_POST['save_lz_bl_domains'])){ $domains = isset($_POST['lz_bl_domains']) && is_array($_POST['lz_bl_domains']) ? $_POST['lz_bl_domains'] : array(); // Process the domains i.e. remove blanks foreach($domains as $k => $v){ $v = trim($v); // Unset blank values if(empty($v)){ unset($domains[$k]); } // Disallow these special characters to avoid XSS or any other security vulnerability if(preg_match('/[\<\>\"\']/', $v)){ unset($domains[$k]); } } // Update the blacklist update_option('loginizer_domains_blacklist', array_values($domains)); // Mark as saved $GLOBALS['lz_saved'] = true; } if(isset($_POST['save_lz_csrf_protection'])){ update_option('loginizer_csrf_protection', empty(lz_optpost('enable_csrf_protection')) ? false : true); delete_transient('loginizer_csrf_mod_rewrite'); $GLOBALS['lz_saved'] = true; } if(isset($_POST['save_lz_limit_session'])){ $limit_session = map_deep($_POST['limit_session'], 'sanitize_text_field'); if(empty($limit_session)){ delete_option('loginizer_limit_session'); } else { update_option('loginizer_limit_session', $limit_session); } $GLOBALS['lz_saved'] = true; } // Call theme loginizer_page_security_T(); } // Loginizer - Security Settings Page Theme function loginizer_page_security_T(){ global $loginizer, $lz_error, $lz_env; // Universal header loginizer_page_header('Security Settings'); loginizer_feature_available('Security Settings'); // Saved ? if(!empty($GLOBALS['lz_saved'])){ echo '
'. __('The settings were saved successfully', 'loginizer'). '
'; } // Any errors ? if(!empty($lz_error)){ lz_report_error($lz_error);echo '
'; } $current_admin = get_user_by('id', 1); ?>
'. $loginizer['login_basename'].' '.__(' to anything of your choice e.g. mylogin. This would make it very difficult for automated attack bots to know where to login !','loginizer'); ?>
/>
/>
disable 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
rename
the XML-RPC page to a
custom slug
.', 'loginizer'); ?>
/>
/>
'.__('Rename wp-admin access feature is supported only on Apache and Litespeed', 'loginizer').'
'; } if(defined('LOGINIZER_PREMIUM') && !empty($loginizer['enable_csrf_protection']) && empty($loginizer['admin_slug'])){ echo '
'.esc_html__('Note: Be careful while changing the Admin name as your CSRF Protection is on', 'loginizer').'
'; } ?>
wp-admin to anything of your choice e.g. my-admin. This will require you to change .htaccess, so please follow','loginizer'); ?>
'.__('on how to do so !','loginizer'); ?>
NOTE: Please use this option cautiously !
', 'loginizer'); ?>
/>
Default :
our guide so that we can safely enable this feature', 'loginizer'); ?>
/>
admin, administrator, or variations of your domain name / business name. 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'); ?>
* (Star)- as a wild card as well. Blank fields will be ignored', 'loginizer'); ?>
\"\']/', $_user)){ continue; } echo '
'; } ?>
If you would like to ban new registrations from a particular domain, you can use this utility to do so.
* (Star)- as a wild card as well. Blank fields will be ignored', 'loginizer'); ?>
\"\']/', $_domain)){ continue; } echo '
'; } ?>
New
'; } ?>
/>
/>
'.__('Block', 'loginizer') . ' : ' . __('Blocks all the login attempts if limit is reached', 'loginizer'); ?>
/>
'.__('Destroy', 'loginizer') . ' : ' . __('Revokes all the sessions on successful login', 'loginizer'); ?>
roles as $key => $role){ $checked = ''; if(!empty($_POST['limit_session']['roles']) && in_array($key, $_POST['limit_session']['roles']) || !empty($loginizer['limit_session']['roles']) && in_array($key, $loginizer['limit_session']['roles'])){ $checked = 'checked'; } echo '
'. esc_html($role['name']) . '
'; } ?>
' . "\n"; $rule .= 'RewriteEngine On' . "\n"; $rule .= 'RewriteBase ' . $home_root . "\n\n"; $rule .= 'RewriteRule ^' . $admin_slug . '(-lzs.{20})?(/?)(.*) wp-admin/$3 [L]' . "\n"; $rule .= '' . "\n"; $rule .= '# END Loginizer' . "\n"; if(is_writable(ABSPATH . '/.htaccess')){ echo '
'. esc_html__('Update .htaccess', 'loginizer').'
'. (!empty($is_csrf) ? esc_html__('Rewrites rule for CSRF session URL', 'loginizer') : esc_html__('Rewrites rule to change wp-admin and if you have a Multisite then check', 'loginizer') . '
our guide
') . '
Update .htaccess
Show Rewrite Rule
' . trim($rule) . '</textarea>
'; } else { echo '
'. esc_html__('Manually Update .htaccess', 'loginizer') . '
' . esc_html__('You can manually update your .htaccess by adding the given code at the top of your .htaccess file', 'loginizer'). '
' . trim($rule) . '</textarea>
'; } }