public static function regenerate_server_config($add_responses = true) { require_once ITSEC_Core::get_core_dir() . '/lib/class-itsec-lib-config-file.php'; $result = ITSEC_Lib_Config_File::update_server_config(); $success = !is_wp_error($result); $server = ITSEC_Lib_Utility::get_web_server(); if ($add_responses) { if (is_wp_error($result)) { ITSEC_Response::add_error($result); $file = ITSEC_Lib_Config_File::get_server_config_file_path(); } else { if ('nginx' === $server) { ITSEC_Response::add_message(__('You must restart your NGINX server for the changes to take effect.', 'better-wp-security')); } } } return $success; }
/** * Returns the server type of the plugin user. * * Attempts to figure out what http server the visiting user is running. * * @since 4.0.0 * * @return string|bool server type the user is using of false if undetectable. */ public static function get_server() { require_once trailingslashit($GLOBALS['itsec_globals']['plugin_dir']) . 'core/lib/class-itsec-lib-utility.php'; return ITSEC_Lib_Utility::get_web_server(); }
/** * 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.0 * * @return mixed array or false if writing disabled or error message */ public function save_rewrites() { require_once trailingslashit($GLOBALS['itsec_globals']['plugin_dir']) . 'core/lib/class-itsec-lib-config-file.php'; $result = ITSEC_Lib_Config_File::update_server_config(); if (is_wp_error($result)) { $retval = array('success' => false, 'text' => $result->get_error_message()); } else { $server = ITSEC_Lib_Utility::get_web_server(); if ('nginx' === $server) { $retval = array('success' => true, 'text' => __('You must restart your NGINX server for the settings to take effect', 'better-wp-security')); } else { $retval = array('success' => true, 'text' => true); } } return $retval; }
/** * Get the default name for server config files based upon the web server. * * Customize the returned value with the itsec_filter_default_server_config_file_name filter. This filter can be * used to change the name of the config file used for this server, add support for additional server types (Apache * and nginx are supported by default), or to disable modifications for the active server type by returning a blank * string (""). * * @since 1.15.0 * @access protected * * @return string|bool File name of the config file used for the server, a blank string if modifications for the * server config file are disabled, or a boolean false if the server is not recognized. */ protected static function get_default_server_config_file_name() { $server = ITSEC_Lib_Utility::get_web_server(); $defaults = array('apache' => '.htaccess', 'litespeed' => '.htaccess', 'nginx' => 'nginx.conf'); if (isset($defaults[$server])) { $name = $defaults[$server]; } else { $name = false; } return apply_filters('itsec_filter_default_server_config_file_name', $name, $server); }
/** * Returns the server type of the plugin user. * * Attempts to figure out what http server the visiting user is running. * * @since 4.0.0 * * @return string|bool server type the user is using of false if undetectable. */ public static function get_server() { require_once ITSEC_Core::get_core_dir() . '/lib/class-itsec-lib-utility.php'; return ITSEC_Lib_Utility::get_web_server(); }