本文整理汇总了PHP中ITSEC_Lib::get_server方法的典型用法代码示例。如果您正苦于以下问题:PHP ITSEC_Lib::get_server方法的具体用法?PHP ITSEC_Lib::get_server怎么用?PHP ITSEC_Lib::get_server使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITSEC_Lib
的用法示例。
在下文中一共展示了ITSEC_Lib::get_server方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: build_rewrite_rules
/**
* Build rewrite rules
*
* @since 4.0
*
* @param array $input options to build rules from
*
* @return array rules to write
*/
public static function build_rewrite_rules($input = null)
{
$home_root = ITSEC_Lib::get_home_root();
$server_type = ITSEC_Lib::get_server();
//Get the server type to build the right rules
//Get the rules from the database if input wasn't sent
if ($input === null) {
$input = get_site_option('itsec_hide_backend');
}
$rules = '';
//initialize all rules to blank string
//don't add any rules if the module hasn't been enabled
if ($input['enabled'] == true) {
if ($server_type == 'nginx') {
$rules .= "\t# " . __('Rules to hide the dashboard', 'it-l10n-ithemes-security-pro') . PHP_EOL . "\trewrite ^(" . $home_root . ")?" . $input['slug'] . "/?\$ " . $home_root . "wp-login.php?\$query_string break;" . PHP_EOL;
} else {
$rules .= "\t# " . __('Rules to hide the dashboard', 'it-l10n-ithemes-security-pro') . PHP_EOL . "\tRewriteRule ^(" . $home_root . ")?" . $input['slug'] . "/?\$ " . $home_root . "wp-login.php [QSA,L]" . PHP_EOL;
}
if ($input['register'] != 'wp-register.php') {
if ($server_type == 'nginx') {
$rules .= "\trewrite ^(" . $home_root . ")?" . $input['register'] . "/?\$ " . $home_root . $input['slug'] . "?action=register break;" . PHP_EOL;
} else {
$rules .= "\tRewriteRule ^(" . $home_root . ")?" . $input['register'] . "/?\$ /wplogin?action=register [QSA,L]" . PHP_EOL;
}
}
}
if (strlen($rules) > 0) {
$rules = explode(PHP_EOL, $rules);
} else {
$rules = false;
}
//create a proper array for writing
return array('type' => 'htaccess', 'priority' => 9, 'name' => 'Hide Backend', 'rules' => $rules);
}
示例2: sanitize_settings
protected function sanitize_settings()
{
if (is_dir(WP_PLUGIN_DIR . '/iwp-client')) {
$this->sanitize_setting('bool', 'infinitewp_compatibility', __('Add InfiniteWP Compatibility', 'better-wp-security'));
} else {
$this->settings['infinitewp_compatibility'] = $this->previous_settings['infinitewp_compatibility'];
}
if ('nginx' === ITSEC_Lib::get_server()) {
$this->sanitize_setting('writable-file', 'nginx_file', __('NGINX Conf File', 'better-wp-security'), false);
} else {
$this->settings['nginx_file'] = $this->previous_settings['nginx_file'];
}
$this->set_previous_if_empty(array('did_upgrade', 'log_info', 'show_new_dashboard_notice', 'show_security_check'));
$this->set_default_if_empty(array('log_location', 'nginx_file'));
$this->sanitize_setting('bool', 'write_files', __('Write to Files', 'better-wp-security'));
$this->sanitize_setting('bool', 'digest_email', __('Send Digest Email', 'better-wp-security'));
$this->sanitize_setting('bool', 'blacklist', __('Blacklist Repeat Offender', 'better-wp-security'));
$this->sanitize_setting('bool', 'email_notifications', __('Email Lockout Notifications', 'better-wp-security'));
$this->sanitize_setting('bool', 'allow_tracking', __('Allow Data Tracking', 'better-wp-security'));
$this->sanitize_setting('bool', 'lock_file', __('Disable File Locking', 'better-wp-security'));
$this->sanitize_setting('bool', 'proxy_override', __('Override Proxy Detection', 'better-wp-security'));
$this->sanitize_setting('bool', 'hide_admin_bar', __('Hide Security Menu in Admin Bar', 'better-wp-security'));
$this->sanitize_setting('bool', 'show_error_codes', __('Show Error Codes', 'better-wp-security'));
$this->sanitize_setting('string', 'lockout_message', __('Host Lockout Message', 'better-wp-security'));
$this->sanitize_setting('string', 'user_lockout_message', __('User Lockout Message', 'better-wp-security'));
$this->sanitize_setting('string', 'community_lockout_message', __('Community Lockout Message', 'better-wp-security'));
$this->sanitize_setting('writable-directory', 'log_location', __('Path to Log Files', 'better-wp-security'));
$this->sanitize_setting('positive-int', 'blacklist_count', __('Blacklist Threshold', 'better-wp-security'));
$this->sanitize_setting('positive-int', 'blacklist_period', __('Blacklist Lockout Period', 'better-wp-security'));
$this->sanitize_setting('positive-int', 'lockout_period', __('Lockout Period', 'better-wp-security'));
$this->sanitize_setting('positive-int', 'log_rotation', __('Days to Keep Database Logs', 'better-wp-security'));
$log_types = array_keys($this->get_valid_log_types());
$this->sanitize_setting($log_types, 'log_type', __('Log Type', 'better-wp-security'));
$this->sanitize_setting('newline-separated-ips', 'lockout_white_list', __('Lockout White List', 'better-wp-security'));
$this->sanitize_setting('newline-separated-emails', 'notification_email', __('Notification Email', 'better-wp-security'));
$this->sanitize_setting('newline-separated-emails', 'backup_email', __('Backup Delivery Email', 'better-wp-security'));
$allowed_tags = array('a' => array('href' => array(), 'title' => array()), 'br' => array(), 'em' => array(), 'strong' => array(), 'h1' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(), 'div' => array('style' => array()));
$this->settings['lockout_message'] = trim(wp_kses($this->settings['lockout_message'], $allowed_tags));
$this->settings['user_lockout_message'] = trim(wp_kses($this->settings['user_lockout_message'], $allowed_tags));
$this->settings['community_lockout_message'] = trim(wp_kses($this->settings['community_lockout_message'], $allowed_tags));
}
示例3: show_network_admin_notice
/**
* Setup and call admin messages.
*
* Sets up messages and registers actions for WordPress admin messages.
*
* @since 4.0
*
* @param object $messages WordPress error object or string of message to display
*
* @return void
*/
public function show_network_admin_notice($errors)
{
global $itsec_saved_network_notices;
//use global to transfer to add_action callback
$itsec_saved_network_notices = '';
//initialize so we can get multiple error messages (if needed)
if (function_exists('apc_store')) {
apc_clear_cache();
//Let's clear APC (if it exists) when big stuff is saved.
}
if ((!defined('DOING_AJAX') || DOING_AJAX == false) && function_exists('get_current_screen') && isset(get_current_screen()->id) && (strpos(get_current_screen()->id, 'security_page_toplevel_page_itsec_settings') !== false || strpos(get_current_screen()->id, 'security_page_toplevel_page_itsec_advanced') !== false || strpos(get_current_screen()->id, 'security_page_toplevel_page_itsec_pro') !== false)) {
if ($errors === false && isset($_GET['settings-updated']) && sanitize_text_field($_GET['settings-updated']) == 'true') {
$updated = '';
if (get_site_option('itsec_manual_update') == true) {
delete_site_option('itsec_manual_update');
if (ITSEC_Lib::get_server() == 'nginx') {
$server = __('NGINX conf file and/or restart your NGINX server', 'it-l10n-better-wp-security');
} else {
$server = __('.htaccess file', 'it-l10n-better-wp-security');
}
$updated = sprintf('<br />%s %s %s', __('As you have not allowed this plugin to update system files you must update your', 'it-l10n-better-wp-security'), $server, __('as well as your wp-config.php file manually. Rules to insert in both files can be found on the Dashboard page.', 'it-l10n-better-wp-security'));
}
$itsec_saved_network_notices = '<div id="setting-error-settings_updated" class="updated settings-error"><p><strong>' . __('Settings Updated', 'it-l10n-better-wp-security') . $updated . '</strong></p></div>';
} elseif (is_wp_error($errors)) {
//see if object is even an error
$error_messages = $errors->get_error_messages();
//get all errors if it is
$type = key($errors->errors);
foreach ($error_messages as $error) {
$itsec_saved_network_notices = '<div id="setting-error-settings_updated" class="' . sanitize_text_field($type) . ' settings-error"><p><strong>' . sanitize_text_field($error) . '</strong></p></div>';
}
}
//register appropriate message actions
add_action('admin_notices', array($this, 'print_network_admin_notice'));
add_action('network_admin_notices', array($this, 'print_network_admin_notice'));
}
}
示例4: initialize_admin
/**
* Execute admin initializations
*
* @return void
*/
public function initialize_admin() {
add_settings_section(
'tweaks_server',
__( 'Configure Server Tweaks', 'it-l10n-ithemes-security-pro' ),
'__return_empty_string',
'security_page_toplevel_page_itsec_settings'
);
add_settings_section(
'tweaks_wordpress',
__( 'Configure WordPress Tweaks', 'it-l10n-ithemes-security-pro' ),
'__return_empty_string',
'security_page_toplevel_page_itsec_settings'
);
add_settings_section(
'tweaks_multisite',
__( 'Configure Multisite Tweaks', 'it-l10n-ithemes-security-pro' ),
'__return_empty_string',
'security_page_toplevel_page_itsec_settings'
);
//Add settings fields
add_settings_field(
'itsec_tweaks[protect_files]',
__( 'System Files', 'it-l10n-ithemes-security-pro' ),
array( $this, 'tweaks_server_protect_files' ),
'security_page_toplevel_page_itsec_settings',
'tweaks_server'
);
if ( ITSEC_Lib::get_server() != 'nginx' ) {
add_settings_field(
'itsec_tweaks[directory_browsing]',
__( 'Directory Browsing', 'it-l10n-ithemes-security-pro' ),
array( $this, 'tweaks_server_directory_browsing' ),
'security_page_toplevel_page_itsec_settings',
'tweaks_server'
);
}
add_settings_field(
'itsec_tweaks[request_methods]',
__( 'Request Methods', 'it-l10n-ithemes-security-pro' ),
array( $this, 'tweaks_server_request_methods' ),
'security_page_toplevel_page_itsec_settings',
'tweaks_server'
);
add_settings_field(
'itsec_tweaks[suspicious_query_strings]',
__( 'Suspicious Query Strings', 'it-l10n-ithemes-security-pro' ),
array( $this, 'tweaks_server_suspicious_query_strings' ),
'security_page_toplevel_page_itsec_settings',
'tweaks_server'
);
add_settings_field(
'itsec_tweaks[non_english_characters]',
__( 'Non-English Characters', 'it-l10n-ithemes-security-pro' ),
array( $this, 'tweaks_server_non_english_characters' ),
'security_page_toplevel_page_itsec_settings',
'tweaks_server'
);
add_settings_field(
'itsec_tweaks[long_url_strings]',
__( 'Long URL Strings', 'it-l10n-ithemes-security-pro' ),
array( $this, 'tweaks_server_long_url_strings' ),
'security_page_toplevel_page_itsec_settings',
'tweaks_server'
);
add_settings_field(
'itsec_tweaks[write_permissions]',
__( 'File Writing Permissions', 'it-l10n-ithemes-security-pro' ),
array( $this, 'tweaks_server_write_permissions' ),
'security_page_toplevel_page_itsec_settings',
'tweaks_server'
);
add_settings_field(
'itsec_tweaks[uploads_php]',
__( 'Uploads', 'it-l10n-ithemes-security-pro' ),
array( $this, 'tweaks_wordpress_uploads_php' ),
'security_page_toplevel_page_itsec_settings',
'tweaks_server'
);
add_settings_field(
'itsec_tweaks[wlwmanifest_header]',
__( 'Windows Live Writer Header', 'it-l10n-ithemes-security-pro' ),
//.........这里部分代码省略.........
示例5: get_htaccess
/**
* Gets location of .htaccess
*
* Finds and returns path to .htaccess or nginx.conf if appropriate
*
* @since 4.0.0
*
* @return string path to .htaccess
*/
public static function get_htaccess()
{
global $itsec_globals;
if ('nginx' === ITSEC_Lib::get_server()) {
return $itsec_globals['settings']['nginx_file'];
} else {
return ITSEC_Lib::get_home_path() . '.htaccess';
}
}
示例6: quick_ban
/**
* Process quick ban of host.
*
* Immediately adds the supplied host to the .htaccess file for banning.
*
* @since 4.0.0
*
* @param string $host the host to ban
*
* @return bool true on success or false on failure
*/
public static function quick_ban($host)
{
$host = trim($host);
if (!class_exists('ITSEC_Lib_IP_Tools')) {
$itsec_core = ITSEC_Core::get_instance();
require_once dirname($itsec_core->get_plugin_file()) . '/core/lib/class-itsec-lib-ip-tools.php';
}
if (!ITSEC_Lib_IP_Tools::validate($host)) {
return false;
}
$host_rule = '# ' . __('Quick ban IP. Will be updated on next formal rules save.', 'better-wp-security') . "\n";
if ('nginx' === ITSEC_Lib::get_server()) {
$host_rule .= "\tdeny {$host};\n";
} else {
if ('apache' === ITSEC_Lib::get_server()) {
$dhost = str_replace('.', '\\.', $host);
//re-define $dhost to match required output for SetEnvIf-RegEX
$host_rule .= "SetEnvIF REMOTE_ADDR \"^{$dhost}\$\" DenyAccess\n";
//Ban IP
$host_rule .= "SetEnvIF X-FORWARDED-FOR \"^{$dhost}\$\" DenyAccess\n";
//Ban IP from Proxy-User
$host_rule .= "SetEnvIF X-CLUSTER-CLIENT-IP \"^{$dhost}\$\" DenyAccess\n";
//Ban IP for Cluster/Cloud-hosted WP-Installs
$host_rule .= "<IfModule mod_authz_core.c>\n";
$host_rule .= "\t<RequireAll>\n";
$host_rule .= "\t\tRequire all granted\n";
$host_rule .= "\t\tRequire not env DenyAccess\n";
$host_rule .= "\t\tRequire not ip {$host}\n";
$host_rule .= "\t</RequireAll>\n";
$host_rule .= "</IfModule>\n";
$host_rule .= "<IfModule !mod_authz_core.c>\n";
$host_rule .= "\tOrder allow,deny\n";
$host_rule .= "\tDeny from env=DenyAccess\n";
$host_rule .= "\tDeny from {$host}\n";
$host_rule .= "\tAllow from all\n";
$host_rule .= "</IfModule>\n";
}
}
require_once trailingslashit($GLOBALS['itsec_globals']['plugin_dir']) . 'core/lib/class-itsec-lib-config-file.php';
$result = ITSEC_Lib_Config_File::append_server_config($host_rule);
if (is_wp_error($result)) {
return false;
}
return true;
}
示例7: release_lockout
public function release_lockout()
{
global $wpdb, $itsec_globals;
if (!class_exists('ITSEC_Lib')) {
require trailingslashit($itsec_globals['plugin_dir']) . '/core/class-itsec-lib.php';
}
$lockout_ids = $_POST['lockout_ids'];
if (!is_array($lockout_ids)) {
$lockout_ids = array();
}
$type = 'updated';
$message = __('The selected lockouts have been cleared.', 'better-wp-security');
foreach ($lockout_ids as $value) {
$wpdb->update($wpdb->base_prefix . 'itsec_lockouts', array('lockout_active' => 0), array('lockout_id' => intval($value)));
}
ITSEC_Lib::clear_caches();
if (!is_multisite()) {
if (!function_exists('add_settings_error')) {
require_once ABSPATH . '/wp-admin/includes/template.php';
}
add_settings_error('itsec', esc_attr('settings_updated'), $message, $type);
}
$site_status = array('username_admin_exists' => username_exists('admin') ? 1 : 0, 'user_id1_exists' => ITSEC_Lib::user_id_exists(1) ? 1 : 0, 'backup' => $this->backup_status(), 'permalink_structure' => get_option('permalink_structure'), 'is_multisite' => is_multisite() ? 1 : 0, 'users_can_register' => get_site_option('users_can_register') ? 1 : 0, 'force_ssl_login' => defined('FORCE_SSL_LOGIN') && FORCE_SSL_LOGIN === true ? 1 : 0, 'force_ssl_admin' => defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN === true ? 1 : 0, 'server_nginx' => 'nginx' === ITSEC_Lib::get_server() ? 1 : 0, 'lockouts_host' => $this->get_lockouts('host', true), 'lockouts_user' => $this->get_lockouts('user', true), 'lockouts_username' => $this->get_lockouts('username', true));
return array('result' => 'success', 'site_status' => $site_status);
}
示例8: get_htaccess
/**
* Gets location of .htaccess
*
* Finds and returns path to .htaccess or nginx.conf if appropriate
*
* @return string path to .htaccess
*
* */
public static function get_htaccess()
{
global $itsec_globals;
if (ITSEC_Lib::get_server() === 'nginx') {
return $itsec_globals['settings']['nginx_file'];
} else {
return ABSPATH . '.htaccess';
}
}
示例9: settings_field_write_files
/**
* echos write files Field
*
* @since 4.0
*
* @return void
*/
public function settings_field_write_files()
{
global $itsec_globals;
if (isset($this->settings['write_files']) && $this->settings['write_files'] === true) {
$write_files = 1;
} else {
$write_files = 0;
}
if (ITSEC_Lib::get_server() == 'nginx') {
$server_file = '';
} else {
$server_file = ' and .htaccess';
}
echo '<input type="checkbox" id="itsec_global_write_files" name="itsec_global[write_files]" value="1" ' . checked(1, $write_files, false) . '/>';
printf('<label for="itsec_global_write_files">%s %s %s%s.</label>', __('Allow', 'better-wp-security'), $itsec_globals['plugin_name'], __('to write to wp-config.php', 'better-wp-security'), $server_file);
printf('<p class="description">%s %s %s%s%s</p>', __('Whether or not', 'better-wp-security'), $itsec_globals['plugin_name'], __('should be allowed to write to wp-config.php', 'better-wp-security'), $server_file, __(' automatically. If disabled you will need to manually place configuration options in those files.', 'better-wp-security'));
}
示例10: build_rewrite_rules
/**
* Build the rewrite rules and sends them to the file writer
*
* @param array $input array of options, ips, etc
* @param boolean $current whether the current IP can be included in the ban list
*
* @return array array of rules to send to file writer
*/
public static function build_rewrite_rules($input = null, $current = false)
{
//setup data structures to write. These are simply lists of all IPs and hosts as well as options to check
if ($input === null) {
//blocking ip on the fly
$input = get_site_option('itsec_ban_users');
}
$default = $input['default'];
$enabled = $input['enabled'];
$raw_host_list = $input['host_list'];
$raw_agent_list = $input['agent_list'];
$server_type = ITSEC_Lib::get_server();
//Get the server type to build the right rules
//initialize lists so we can check later if we've used them
$host_list = '';
$agent_list = '';
$default_list = '';
$host_rule2 = '';
//load the default blacklist if needed
if ($default === true && $server_type === 'nginx') {
$default_list = file_get_contents(plugin_dir_path(__FILE__) . 'lists/hackrepair-nginx.inc');
} elseif ($default === true) {
$default_list = file_get_contents(plugin_dir_path(__FILE__) . 'lists/hackrepair-apache.inc');
}
//Only process other lists if the feature has been enabled
if ($enabled === true) {
//process hosts list
if (is_array($raw_host_list)) {
foreach ($raw_host_list as $host) {
$host = ITSEC_Lib::ip_wild_to_mask($host);
if (!class_exists('ITSEC_Ban_Users')) {
require dirname(__FILE__) . '/class-itsec-ban-users.php';
}
if (!ITSEC_Ban_Users::is_ip_whitelisted($host, null, $current)) {
$converted_host = ITSEC_Lib::ip_mask_to_range($host);
if (strlen(trim($converted_host)) > 1) {
if ($server_type === 'nginx') {
//NGINX rules
$host_rule = "\tdeny " . trim($host) . ';';
} else {
//rules for all other servers
$dhost = str_replace('.', '\\.', trim($converted_host));
//re-define $dhost to match required output for SetEnvIf-RegEX
$host_rule = "SetEnvIF REMOTE_ADDR \"^" . $dhost . "\$\" DenyAccess" . PHP_EOL;
//Ban IP
$host_rule .= "SetEnvIF X-FORWARDED-FOR \"^" . $dhost . "\$\" DenyAccess" . PHP_EOL;
//Ban IP from Proxy-User
$host_rule .= "SetEnvIF X-CLUSTER-CLIENT-IP \"^" . $dhost . "\$\" DenyAccess" . PHP_EOL;
//Ban IP for Cluster/Cloud-hosted WP-Installs
$host_rule2 .= "deny from " . str_replace('.[0-9]+', '', trim($converted_host)) . PHP_EOL;
}
}
$host_list .= $host_rule . PHP_EOL;
//build large string of all hosts
} else {
/**
* @todo warn the user the ip to be banned is whitelisted
*/
}
}
}
//Process the agents list
if (is_array($raw_agent_list)) {
$count = 1;
//to help us find the last one
foreach ($raw_agent_list as $agent) {
if (strlen(trim($agent)) > 1) {
//if it isn't the last rule make sure we add an or
if ($count < sizeof($agent)) {
$end = ' [NC,OR]' . PHP_EOL;
} else {
$end = ' [NC]' . PHP_EOL;
}
if (strlen(trim($agent)) > 1) {
if ($server_type === 'nginx') {
//NGINX rule
$converted_agent = 'if ($http_user_agent ~* "^' . quotemeta(trim($agent)) . '"){ return 403; }' . PHP_EOL;
} else {
//Rule for all other servers
$converted_agent = 'RewriteCond %{HTTP_USER_AGENT} ^' . str_replace(' ', '\\ ', quotemeta(trim($agent))) . $end;
}
}
$agent_list .= $converted_agent;
//build large string of all agents
}
$count++;
}
}
}
$rules = '';
//initialize rules
//Start with default rules if we have them
//.........这里部分代码省略.........
示例11: quick_ban
/**
* Process quick ban of host.
*
* Immediately adds the supplied host to the .htaccess file for banning.
*
* @since 4.0.0
*
* @param string $host the host to ban
*
* @return bool true on success or false on failure
*/
public static function quick_ban( $host ) {
$host = trim( $host );
if ( ! ITSEC_Lib::validates_ip_address( $host ) ) {
return false;
}
$host_rule = '# ' . __( 'Quick ban IP. Will be updated on next formal rules save.', 'it-l10n-ithemes-security-pro' ) . "\n";
if ( 'nginx' === ITSEC_Lib::get_server() ) {
$host_rule .= "\tdeny $host;\n";
} else if ( 'apache' === ITSEC_Lib::get_server() ) {
$dhost = str_replace( '.', '\\.', $host ); //re-define $dhost to match required output for SetEnvIf-RegEX
$host_rule .= "SetEnvIF REMOTE_ADDR \"^$dhost$\" DenyAccess\n"; //Ban IP
$host_rule .= "SetEnvIF X-FORWARDED-FOR \"^$dhost$\" DenyAccess\n"; //Ban IP from Proxy-User
$host_rule .= "SetEnvIF X-CLUSTER-CLIENT-IP \"^$dhost$\" DenyAccess\n"; //Ban IP for Cluster/Cloud-hosted WP-Installs
$host_rule .= "<IfModule mod_authz_core.c>\n";
$host_rule .= "\t<RequireAll>\n";
$host_rule .= "\t\tRequire all granted\n";
$host_rule .= "\t\tRequire not env DenyAccess\n";
$host_rule .= "\t\tRequire not ip $host\n";
$host_rule .= "\t</RequireAll>\n";
$host_rule .= "</IfModule>\n";
$host_rule .= "<IfModule !mod_authz_core.c>\n";
$host_rule .= "\tOrder allow,deny\n";
$host_rule .= "\tDeny from env=DenyAccess\n";
$host_rule .= "\tDeny from $host\n";
$host_rule .= "\tAllow from all\n";
$host_rule .= "</IfModule>\n";
}
require_once( trailingslashit( $GLOBALS['itsec_globals']['plugin_dir'] ) . 'core/lib/class-itsec-lib-config-file.php' );
$result = ITSEC_Lib_Config_File::append_server_config( $host_rule );
if ( is_wp_error( $result ) ) {
return false;
}
return true;
}
示例12: save_rewrites
/**
* Saves all rewrite rules to htaccess or similar file.
*
* Gets a file lock for .htaccess and calls the writing function if successful.
*
* @since 4.0
*
* @return mixed array or false if writing disabled or error message
*/
public function save_rewrites()
{
global $itsec_globals;
if (!is_array($this->file_modules)) {
return;
}
foreach ($this->file_modules as $module) {
if (isset($module['rewrite'])) {
call_user_func_array($module['rewrite'], array());
}
}
if (ITSEC_Lib::get_server() == 'nginx' || isset($itsec_globals['settings']['write_files']) && $itsec_globals['settings']['write_files'] === true) {
$success = $this->write_rewrites();
//save the return value for success/error flag
if ($success === true) {
if (ITSEC_Lib::get_server() == 'nginx') {
return array('success' => true, 'text' => sprintf('%s %s. %s', __('Your rewrite rules have been saved to', 'it-l10n-better-wp-security'), $itsec_globals['settings']['nginx_file'], __('You must restart your NGINX server for the settings to take effect', 'it-l10n-better-wp-security')));
} else {
return array('success' => true, 'text' => true);
}
} else {
return array('success' => false, 'text' => __('Unable to write to your .htaccess or nginx.conf file. If the problem persists contact support.', 'it-l10n-better-wp-security'));
}
} else {
return false;
}
}
示例13: render_settings
//.........这里部分代码省略.........
<td>
<?php
$form->add_checkbox('infinitewp_compatibility');
?>
<label for="itsec-global-infinitewp_compatibility"><?php
_e('Enable InfiniteWP Compatibility', 'better-wp-security');
?>
</label>
<p class="description"><?php
printf(__('Turning this feature on will enable compatibility with <a href="%s" target="_blank">InfiniteWP</a>. Do not turn it on unless you use the InfiniteWP service.', 'better-wp-security'), 'http://infinitewp.com');
?>
</p>
</td>
</tr>
<?php
}
?>
<tr>
<th scope="row"><label for="itsec-global-allow_tracking"><?php
_e('Allow Data Tracking', 'better-wp-security');
?>
</label></th>
<td>
<?php
$form->add_checkbox('allow_tracking');
?>
<label for="itsec-global-allow_tracking"><?php
_e('Allow iThemes to track plugin usage via anonymous data.', 'better-wp-security');
?>
</label>
</td>
</tr>
<?php
if ('nginx' === ITSEC_Lib::get_server()) {
?>
<tr>
<th scope="row"><label for="itsec-global-nginx_file"><?php
_e('NGINX Conf File', 'better-wp-security');
?>
</label></th>
<td>
<?php
$form->add_text('nginx_file', array('class' => 'large-text code'));
?>
<p><label for="itsec-global-nginx_file"><?php
_e('The path on your server where the nginx config file is located.', 'better-wp-security');
?>
</label></p>
<p class="description"><?php
_e('This path must be writable by your website. For added security, it is recommended you do not include it in your website root folder.', 'better-wp-security');
?>
</p>
</td>
</tr>
<?php
}
?>
<tr>
<th scope="row"><label for="itsec-global-lock_file"><?php
_e('Disable File Locking', 'better-wp-security');
?>
</label></th>
<td>
<?php
$form->add_checkbox('lock_file');
?>