本文整理汇总了PHP中ITSEC_Modules::get_setting方法的典型用法代码示例。如果您正苦于以下问题:PHP ITSEC_Modules::get_setting方法的具体用法?PHP ITSEC_Modules::get_setting怎么用?PHP ITSEC_Modules::get_setting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITSEC_Modules
的用法示例。
在下文中一共展示了ITSEC_Modules::get_setting方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate_new_salts
public function generate_new_salts()
{
if (!ITSEC_Modules::get_setting('global', 'write_files')) {
return new WP_Error('itsec-wordpress-salts-utilities-write-files-disabled', __('The "Write to Files" setting is disabled in Global Settings. In order to use this feature, you must enable the "Write to Files" setting.', 'better-wp-security'));
}
require_once ITSEC_Core::get_core_dir() . '/lib/class-itsec-lib-config-file.php';
require_once ITSEC_Core::get_core_dir() . '/lib/class-itsec-lib-file.php';
$config_file_path = ITSEC_Lib_Config_File::get_wp_config_file_path();
$config = ITSEC_Lib_File::read($config_file_path);
if (is_wp_error($config)) {
return new WP_Error('itsec-wordpress-salts-utilities-cannot-read-wp-config.php', sprintf(__('Unable to read the <code>wp-config.php</code> file in order to update the salts. You will need to manually update the file. Error details as follows: %1$s (%2$s)', 'better-wp-security'), $config->get_error_message(), $config->get_error_code()));
}
$defines = array('AUTH_KEY', 'SECURE_AUTH_KEY', 'LOGGED_IN_KEY', 'NONCE_KEY', 'AUTH_SALT', 'SECURE_AUTH_SALT', 'LOGGED_IN_SALT', 'NONCE_SALT');
foreach ($defines as $define) {
if (empty($salts)) {
$salts = self::get_new_salts();
}
$salt = array_pop($salts);
if (empty($salt)) {
$salt = wp_generate_password(64, true, true);
}
$salt = str_replace('$', '\\$', $salt);
$regex = "/(define\\s*\\(\\s*(['\"]){$define}\\2\\s*,\\s*)(['\"]).+?\\3(\\s*\\)\\s*;)/";
$config = preg_replace($regex, "\${1}'{$salt}'\${4}", $config);
}
$write_result = ITSEC_Lib_File::write($config_file_path, $config);
if (is_wp_error($write_result)) {
return new WP_Error('itsec-wordpress-salts-utilities-cannot-save-wp-config.php', sprintf(__('Unable to update the <code>wp-config.php</code> file in order to update the salts. You will need to manually update the file. Error details as follows: %1$s (%2$s)', 'better-wp-security'), $config->get_error_message(), $config->get_error_code()));
}
return true;
}
示例2: __construct
public function __construct()
{
if (!ITSEC_Modules::get_setting('file-change', 'show_warning')) {
return;
}
add_action('init', array($this, 'init'));
}
示例3: run
function run()
{
if (1 === ITSEC_Modules::get_setting('ssl', 'frontend')) {
add_action('post_submitbox_misc_actions', array($this, 'ssl_enable_per_content'));
add_action('save_post', array($this, 'save_post'));
}
}
示例4: validate_settings
protected function validate_settings()
{
if (!$this->can_save()) {
return;
}
if (!$this->settings['regenerate']) {
unset($this->settings['regenerate']);
if (defined('DOING_AJAX') && DOING_AJAX && !empty($_POST['module']) && $this->get_id() === $_POST['module']) {
// Request to modify just this module.
$this->set_can_save(false);
if (ITSEC_Modules::get_setting('global', 'write_files')) {
$this->add_error(new WP_Error('itsec-wordpress-salts-skipping-regeneration-empty-checkbox', __('You must check the Change WordPress Salts checkbox in order to change the WordPress salts.', 'better-wp-security')));
} else {
$this->add_error(new WP_Error('itsec-wordpress-salts-skipping-regeneration-write-files-disabled', __('The "Write to Files" setting is disabled in Global Settings. In order to use this feature, you must enable the "Write to Files" setting.', 'better-wp-security')));
}
}
return;
}
unset($this->settings['regenerate']);
require_once dirname(__FILE__) . '/utilities.php';
$result = ITSEC_WordPress_Salts_Utilities::generate_new_salts();
if (is_wp_error($result)) {
$this->add_error($result);
$this->set_can_save(false);
} else {
$this->add_message(__('The WordPress salts were successfully regenerated.', 'better-wp-security'));
$this->settings['last_generated'] = ITSEC_Core::get_current_time_gmt();
ITSEC_Response::force_logout();
}
}
示例5: send_new_login_url
private function send_new_login_url($url)
{
if (ITSEC_Core::doing_data_upgrade()) {
// Do not send emails when upgrading data. This prevents spamming users with notifications just because the
// data was ported from an old version to a new version.
return;
}
$message = '<p>' . __('Dear Site Admin,', 'better-wp-security') . "</p>\n";
/* translators: 1: Site name, 2: Site address, 3: New login address */
$message .= '<p>' . sprintf(__('The login address for %1$s (<code>%2$s</code>) has changed. The new login address is <code>%3$s</code>. You will be unable to use the old login address.', 'better-wp-security'), get_bloginfo('name'), esc_url(get_site_url()), esc_url($url)) . "</p>\n";
if (defined('ITSEC_DEBUG') && ITSEC_DEBUG === true) {
$message .= '<p>Debug info (source page): ' . esc_url($_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]) . "</p>\n";
}
$message = "<html>\n{$message}</html>\n";
//Setup the remainder of the email
$recipients = ITSEC_Modules::get_setting('global', 'notification_email');
$subject = sprintf(__('[%1$s] WordPress Login Address Changed', 'better-wp-security'), get_site_url());
$subject = apply_filters('itsec_lockout_email_subject', $subject);
$headers = 'From: ' . get_bloginfo('name') . ' <' . get_option('admin_email') . '>' . "\r\n";
//Use HTML Content type
add_filter('wp_mail_content_type', array($this, 'get_html_content_type'));
//Send emails to all recipients
foreach ($recipients as $recipient) {
$recipient = trim($recipient);
if (is_email($recipient)) {
wp_mail($recipient, $subject, $message, $headers);
}
}
//Remove HTML Content type
remove_filter('wp_mail_content_type', array($this, 'get_html_content_type'));
}
示例6: itsec_ban_users_handle_new_blacklisted_ip
function itsec_ban_users_handle_new_blacklisted_ip($ip)
{
$host_list = ITSEC_Modules::get_setting('ban-users', 'host_list', array());
if (!is_array($host_list)) {
$host_list = array();
}
$host_list[] = $ip;
ITSEC_Modules::set_setting('ban-users', 'host_list', $host_list);
}
示例7: filter_body_classes
public function filter_body_classes($classes)
{
if (ITSEC_Modules::get_setting('global', 'show_error_codes')) {
$classes .= ' itsec-show-error-codes';
}
if (ITSEC_Modules::get_setting('global', 'write_files')) {
$classes .= ' itsec-write-files-enabled';
} else {
$classes .= ' itsec-write-files-disabled';
}
$classes = trim($classes);
return $classes;
}
示例8: add_hooks
public function add_hooks()
{
if ($this->hooks_added) {
return;
}
add_filter('itsec_filter_apache_server_config_modification', array($this, 'filter_apache_server_config_modification'));
add_filter('itsec_filter_nginx_server_config_modification', array($this, 'filter_nginx_server_config_modification'));
add_filter('itsec_filter_litespeed_server_config_modification', array($this, 'filter_litespeed_server_config_modification'));
if (ITSEC_Modules::get_setting('system-tweaks', 'long_url_strings')) {
add_action('itsec_initialized', array($this, 'block_long_urls'));
}
$this->hooks_added = true;
}
示例9: add_scripts
public function add_scripts()
{
foreach ($this->modules as $id => $module) {
$module->enqueue_scripts_and_styles();
}
foreach ($this->widgets as $id => $widget) {
$widget->enqueue_scripts_and_styles();
}
$vars = array('ajax_action' => 'itsec_settings_page', 'ajax_nonce' => wp_create_nonce('itsec-settings-nonce'), 'show_security_check' => ITSEC_Modules::get_setting('global', 'show_security_check'), 'translations' => $this->translations);
if ($vars['show_security_check']) {
ITSEC_Modules::set_setting('global', 'show_security_check', false);
if (!empty($_GET['module']) && 'security-check' === $_GET['module']) {
$vars['show_security_check'] = false;
}
}
wp_enqueue_script('itsec-settings-page-script', plugins_url('js/script.js', __FILE__), array(), $this->version, true);
wp_localize_script('itsec-settings-page-script', 'itsec_page', $vars);
}
示例10: enforce_setting
private static function enforce_setting($module, $setting_name, $setting_value, $description)
{
if (!in_array($module, self::$available_modules)) {
return;
}
if (ITSEC_Modules::get_setting($module, $setting_name) !== $setting_value) {
ITSEC_Modules::set_setting($module, $setting_name, $setting_value);
ob_start();
self::open_container();
echo "<p>{$description}</p>";
echo '</div>';
self::$actions_taken[] = ob_get_clean();
ITSEC_Response::reload_module($module);
}
}
示例11: release_file_lock
/**
* Release the lock.
*
* Releases a file lock to allow others to use it.
*
* @since 4.0.0
*
* @param string $lock_file file name of lock
*
* @return bool true if released, false otherwise
*/
public function release_file_lock($lock_file)
{
if (ITSEC_Modules::get_setting('global', 'lock_file')) {
return true;
}
require_once ITSEC_Core::get_core_dir() . '/lib/class-itsec-lib-directory.php';
$lock_file = ITSEC_Core::get_storage_dir() . '/' . sanitize_text_field($lock_file) . '.lock';
$result = ITSEC_Lib_Directory::remove($lock_file);
if (is_wp_error($result)) {
return false;
}
return true;
}
示例12: is_jquery_version_safe
/**
* Checks jQuery version.
*
* Checks if the jquery version saved is vulnerable to http://bugs.jquery.com/ticket/9521
*
* @since 4.0.0
*
* @return mixed|bool true if known safe false if unsafe or null if untested
*/
public static function is_jquery_version_safe()
{
$jquery_version = ITSEC_Modules::get_setting('wordpress-tweaks', 'jquery_version');
if (!empty($jquery_version) && version_compare($jquery_version, '1.6.3', '>=')) {
return true;
}
return false;
}
示例13: send_notification_email
/**
* Builds and sends notification email
*
* Sends the notication email too all applicable administrative users notifying them
* that file changes have been detected
*
* @since 4.0.0
*
* @access private
*
* @param array $email_details array of details for the email messge
*
* @return void
*/
private function send_notification_email($email_details)
{
global $itsec_globals;
$itsec_notify = ITSEC_Core::get_itsec_notify();
if (!ITSEC_Modules::get_setting('global', 'digest_email')) {
$headers = 'From: ' . get_bloginfo('name') . ' <' . get_option('admin_email') . '>' . "\r\n";
$subject = '[' . get_option('siteurl') . '] ' . __('WordPress File Change Warning', 'better-wp-security') . ' ' . date('l, F jS, Y \\a\\t g:i a e', $itsec_globals['current_time']);
$body = '<p>' . __('A file (or files) on your site at ', 'better-wp-security') . ' ' . get_option('siteurl') . __(' have been changed. Please review the report below to verify changes are not the result of a compromise.', 'better-wp-security') . '</p>';
$body .= $this->get_email_report($email_details);
//get report
$args = array('headers' => $headers, 'message' => $body, 'subject' => $subject);
$itsec_notify->notify($args);
} else {
$changed = $email_details[0] + $email_details[1] + $email_details[2];
if ($changed > 0) {
$itsec_notify->register_file_change();
}
}
}
示例14: get_server_config_ban_user_agents_rules
public static function get_server_config_ban_user_agents_rules($server_type)
{
$agent_list = ITSEC_Modules::get_setting('ban-users', 'agent_list', array());
if (!is_array($agent_list) || empty($agent_list)) {
return '';
}
$agent_rules = '';
$rewrite_rules = '';
foreach ($agent_list as $index => $agent) {
$agent = trim($agent);
if (empty($agent)) {
continue;
}
$agent = preg_quote($agent);
if (in_array($server_type, array('apache', 'litespeed'))) {
$agent = str_replace(' ', '\\ ', $agent);
$rewrite_rules .= "\t\tRewriteCond %{HTTP_USER_AGENT} ^{$agent} [NC,OR]\n";
} else {
if ('nginx' === $server_type) {
$agent = str_replace('"', '\\"', $agent);
$agent_rules .= "\tif (\$http_user_agent ~* \"^{$agent}\") { return 403; }\n";
}
}
}
if (in_array($server_type, array('apache', 'litespeed')) && !empty($rewrite_rules)) {
$rewrite_rules = preg_replace("/\\[NC,OR\\]\n\$/", "[NC]\n", $rewrite_rules);
$agent_rules .= "\t<IfModule mod_rewrite.c>\n";
$agent_rules .= "\t\tRewriteEngine On\n";
$agent_rules .= $rewrite_rules;
$agent_rules .= "\t\tRewriteRule ^.* - [F]\n";
$agent_rules .= "\t</IfModule>\n";
}
$rules = '';
if (!empty($agent_rules)) {
$rules .= "\n";
$rules .= "\t# " . __('Ban User Agents - Security > Settings > Banned Users', 'better-wp-security') . "\n";
$rules .= $agent_rules;
}
return $rules;
}
示例15: filter_wp_config_modification
public function filter_wp_config_modification($modification)
{
if (ITSEC_Modules::get_setting('ssl', 'admin')) {
$modification .= "define( 'FORCE_SSL_LOGIN', true ); // " . __('Force SSL for Dashboard - Security > Settings > Secure Socket Layers (SSL) > SSL for Dashboard', 'better-wp-security') . "\n";
$modification .= "define( 'FORCE_SSL_ADMIN', true ); // " . __('Force SSL for Dashboard - Security > Settings > Secure Socket Layers (SSL) > SSL for Dashboard', 'better-wp-security') . "\n";
}
return $modification;
}