/** * Define host column * * @param array $item array of row data * * @return string formatted output * **/ function column_host($item) { require_once ITSEC_Core::get_core_dir() . '/lib/class-itsec-lib-ip-tools.php'; $r = array(); if (!is_array($item['host'])) { $item['host'] = array($item['host']); } foreach ($item['host'] as $host) { if (ITSEC_Lib_IP_Tools::validate($host)) { $r[] = '<a href="http://www.traceip.net/?query=' . urlencode($host) . '" target="_blank">' . esc_html($host) . '</a>'; } } $return = implode('<br />', $r); return $return; }
/** * Define host column * * @param array $item array of row data * * @return string formatted output * **/ function column_host($item) { 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'; } $r = array(); if (!is_array($item['host'])) { $item['host'] = array($item['host']); } foreach ($item['host'] as $host) { if (ITSEC_Lib_IP_Tools::validate($host)) { $r[] = '<a href="http://www.traceip.net/?query=' . urlencode($host) . '" target="_blank">' . esc_html($host) . '</a>'; } } $return = implode('<br />', $r); return $return; }
public function run($arguments) { global $itsec_globals; $direction = isset($arguments['direction']) ? $arguments['direction'] : 'add'; if ($direction === 'add') { if (get_site_option('itsec_temp_whitelist_ip') !== false || !isset($arguments['ip'])) { return false; } $ip = sanitize_text_field($arguments['ip']); 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($ip)) { $response = array('ip' => $ip, 'exp' => $itsec_globals['current_time'] + 86400); add_site_option('itsec_temp_whitelist_ip', $response); return true; } } elseif ($direction === 'remove') { delete_site_option('itsec_temp_whitelist_ip'); return true; } return false; }
/** * 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; }
/** * Locks out given user or host * * @since 4.0 * * @param string $type The type of lockout (for user reference) * @param string $reason Reason for lockout, for notifications * @param string $host Host to lock out * @param int $user user id to lockout * @param string $username username to lockout * * @return void */ private function lockout($type, $reason, $host = null, $user = null, $username = null) { global $wpdb, $itsec_logger, $itsec_globals, $itsec_files; $host_expiration = null; $user_expiration = null; $username = sanitize_text_field(trim($username)); if ($itsec_files->get_file_lock('lockout_' . $host . $user . $username)) { //Do we have a good host to lock out or not if (!is_null($host) && ITSEC_Lib::is_ip_whitelisted(sanitize_text_field($host)) === false && ITSEC_Lib_IP_Tools::validate($host)) { $good_host = sanitize_text_field($host); } else { $good_host = false; } //Do we have a valid user to lockout or not if ($user !== null && ITSEC_Lib::user_id_exists(intval($user)) === true) { $good_user = intval($user); } else { $good_user = false; } //Do we have a valid username to lockout or not if ($username !== null && $username != '') { $good_username = $username; } else { $good_username = false; } $blacklist_host = false; //assume we're not permanently blcking the host //Sanitize the data for later $type = sanitize_text_field($type); $reason = sanitize_text_field($reason); //handle a permanent host ban (if needed) if (isset($itsec_globals['settings']['blacklist']) && $itsec_globals['settings']['blacklist'] === true && $good_host !== false) { //permanent blacklist $blacklist_period = isset($itsec_globals['settings']['blacklist_period']) ? $itsec_globals['settings']['blacklist_period'] * 24 * 60 * 60 : 604800; $host_count = 1 + $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . $wpdb->base_prefix . "itsec_lockouts` WHERE `lockout_expire_gmt` > '%s' AND `lockout_host`='%s';", date('Y-m-d H:i:s', $itsec_globals['current_time_gmt'] - $blacklist_period), $host)); if ($host_count >= $itsec_globals['settings']['blacklist_count'] && isset($itsec_globals['settings']['write_files']) && $itsec_globals['settings']['write_files'] === true) { $host_expiration = false; if (!class_exists('ITSEC_Ban_Users')) { require trailingslashit($itsec_globals['plugin_dir']) . 'core/modules/ban-users/class-itsec-ban-users.php'; } ITSEC_Ban_Users::insert_ip(sanitize_text_field($host)); //Send it to the Ban Users module for banning $blacklist_host = true; //flag it so we don't do a temp ban as well } } //We have temp bans to perform if ($good_host !== false || $good_user !== false || $good_username || $good_username !== false) { if (ITSEC_Lib::is_ip_whitelisted(sanitize_text_field($host))) { $whitelisted = true; $expiration = date('Y-m-d H:i:s', 1); $expiration_gmt = date('Y-m-d H:i:s', 1); } else { $whitelisted = false; $exp_seconds = intval($itsec_globals['settings']['lockout_period']) * 60; $expiration = date('Y-m-d H:i:s', $itsec_globals['current_time'] + $exp_seconds); $expiration_gmt = date('Y-m-d H:i:s', $itsec_globals['current_time_gmt'] + $exp_seconds); } if ($good_host !== false && $blacklist_host === false) { //temp lockout host $host_expiration = $expiration; $wpdb->insert($wpdb->base_prefix . 'itsec_lockouts', array('lockout_type' => $type, 'lockout_start' => date('Y-m-d H:i:s', $itsec_globals['current_time']), 'lockout_start_gmt' => date('Y-m-d H:i:s', $itsec_globals['current_time_gmt']), 'lockout_expire' => $expiration, 'lockout_expire_gmt' => $expiration_gmt, 'lockout_host' => sanitize_text_field($host))); $itsec_logger->log_event(__('lockout', 'better-wp-security'), 10, array('expires' => $expiration, 'expires_gmt' => $expiration_gmt, 'type' => $type), sanitize_text_field($host)); } if ($good_user !== false) { //blacklist host and temp lockout user $user_expiration = $expiration; $wpdb->insert($wpdb->base_prefix . 'itsec_lockouts', array('lockout_type' => $type, 'lockout_start' => date('Y-m-d H:i:s', $itsec_globals['current_time']), 'lockout_start_gmt' => date('Y-m-d H:i:s', $itsec_globals['current_time_gmt']), 'lockout_expire' => $expiration, 'lockout_expire_gmt' => $expiration_gmt, 'lockout_host' => '', 'lockout_user' => intval($user))); if ($whitelisted === false) { $itsec_logger->log_event('lockout', 10, array('expires' => $expiration, 'expires_gmt' => $expiration_gmt, 'type' => $type), '', '', intval($user)); } else { $itsec_logger->log_event('lockout', 10, array(__('White Listed', 'better-wp-security'), 'type' => $type), '', '', intval($user)); } } if ($good_username !== false) { //blacklist host and temp lockout username $user_expiration = $expiration; $wpdb->insert($wpdb->base_prefix . 'itsec_lockouts', array('lockout_type' => $type, 'lockout_start' => date('Y-m-d H:i:s', $itsec_globals['current_time']), 'lockout_start_gmt' => date('Y-m-d H:i:s', $itsec_globals['current_time_gmt']), 'lockout_expire' => $expiration, 'lockout_expire_gmt' => $expiration_gmt, 'lockout_host' => '', 'lockout_username' => $username)); if ($whitelisted === false) { $itsec_logger->log_event('lockout', 10, array('expires' => $expiration, 'expires_gmt' => $expiration_gmt, 'type' => $type), '', '', $username); } else { $itsec_logger->log_event('lockout', 10, array(__('White Listed', 'better-wp-security'), 'type' => $type), '', '', $username); } } if ($whitelisted === false) { if ($itsec_globals['settings']['email_notifications'] === true) { //send email notifications $this->send_lockout_email($good_host, $good_user, $good_username, $host_expiration, $user_expiration, $reason); } if ($good_host !== false) { $itsec_files->release_file_lock('lockout_' . $host . $user . $username); $this->execute_lock(); } else { $itsec_files->release_file_lock('lockout_' . $host . $user . $username); $this->execute_lock(true); } } } $itsec_files->release_file_lock('lockout_' . $host . $user . $username); } }
/** * Locks out given user or host * * @since 4.0 * * @param string $type The type of lockout (for user reference) * @param string $reason Reason for lockout, for notifications * @param string $host Host to lock out * @param int $user user id to lockout * @param string $username username to lockout * * @return void */ private function lockout($type, $reason, $host = null, $user = null, $username = null) { global $wpdb, $itsec_logger, $itsec_globals; $itsec_files = ITSEC_Core::get_itsec_files(); $host_expiration = null; $user_expiration = null; $username = sanitize_text_field(trim($username)); if ($itsec_files->get_file_lock('lockout_' . $host . $user . $username)) { //Do we have a good host to lock out or not if (!is_null($host) && ITSEC_Lib::is_ip_whitelisted(sanitize_text_field($host)) === false && ITSEC_Lib_IP_Tools::validate($host)) { $good_host = sanitize_text_field($host); } else { $good_host = false; } //Do we have a valid user to lockout or not if ($user !== null && ITSEC_Lib::user_id_exists(intval($user)) === true) { $good_user = intval($user); } else { $good_user = false; } //Do we have a valid username to lockout or not if ($username !== null && $username != '') { $good_username = $username; } else { $good_username = false; } $blacklist_host = false; //assume we're not permanently blcking the host //Sanitize the data for later $type = sanitize_text_field($type); $reason = sanitize_text_field($reason); //handle a permanent host ban (if needed) if (ITSEC_Modules::get_setting('global', 'blacklist') && $good_host !== false) { //permanent blacklist $blacklist_period = ITSEC_Modules::get_setting('global', 'blacklist_period', 7); $blacklist_seconds = $blacklist_period * DAY_IN_SECONDS; $host_count = 1 + $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . $wpdb->base_prefix . "itsec_lockouts` WHERE `lockout_expire_gmt` > '%s' AND `lockout_host`='%s';", date('Y-m-d H:i:s', $itsec_globals['current_time_gmt'] - $blacklist_seconds), $host)); if ($host_count >= ITSEC_Modules::get_setting('global', 'blacklist_count') && ITSEC_Files::can_write_to_files()) { $host_expiration = false; $this->blacklist_ip(sanitize_text_field($host)); $blacklist_host = true; //flag it so we don't do a temp ban as well } } //We have temp bans to perform if ($good_host !== false || $good_user !== false || $good_username || $good_username !== false) { if (ITSEC_Lib::is_ip_whitelisted(sanitize_text_field($host))) { $whitelisted = true; $expiration = date('Y-m-d H:i:s', 1); $expiration_gmt = date('Y-m-d H:i:s', 1); } else { $whitelisted = false; $exp_seconds = ITSEC_Modules::get_setting('global', 'lockout_period') * MINUTE_IN_SECONDS; $expiration = date('Y-m-d H:i:s', $itsec_globals['current_time'] + $exp_seconds); $expiration_gmt = date('Y-m-d H:i:s', $itsec_globals['current_time_gmt'] + $exp_seconds); } if ($good_host !== false && $blacklist_host === false) { //temp lockout host $host_expiration = $expiration; $wpdb->insert($wpdb->base_prefix . 'itsec_lockouts', array('lockout_type' => $type, 'lockout_start' => date('Y-m-d H:i:s', $itsec_globals['current_time']), 'lockout_start_gmt' => date('Y-m-d H:i:s', $itsec_globals['current_time_gmt']), 'lockout_expire' => $expiration, 'lockout_expire_gmt' => $expiration_gmt, 'lockout_host' => sanitize_text_field($host))); $itsec_logger->log_event('lockout', 10, array('expires' => $expiration, 'expires_gmt' => $expiration_gmt, 'type' => $type), sanitize_text_field($host)); } if ($good_user !== false) { //blacklist host and temp lockout user $user_expiration = $expiration; $wpdb->insert($wpdb->base_prefix . 'itsec_lockouts', array('lockout_type' => $type, 'lockout_start' => date('Y-m-d H:i:s', $itsec_globals['current_time']), 'lockout_start_gmt' => date('Y-m-d H:i:s', $itsec_globals['current_time_gmt']), 'lockout_expire' => $expiration, 'lockout_expire_gmt' => $expiration_gmt, 'lockout_host' => '', 'lockout_user' => intval($user))); if ($whitelisted === false) { $itsec_logger->log_event('lockout', 10, array('expires' => $expiration, 'expires_gmt' => $expiration_gmt, 'type' => $type), '', '', intval($user)); } else { $itsec_logger->log_event('lockout', 10, array(__('White Listed', 'better-wp-security'), 'type' => $type), '', '', intval($user)); } } if ($good_username !== false) { //blacklist host and temp lockout username $user_expiration = $expiration; $wpdb->insert($wpdb->base_prefix . 'itsec_lockouts', array('lockout_type' => $type, 'lockout_start' => date('Y-m-d H:i:s', $itsec_globals['current_time']), 'lockout_start_gmt' => date('Y-m-d H:i:s', $itsec_globals['current_time_gmt']), 'lockout_expire' => $expiration, 'lockout_expire_gmt' => $expiration_gmt, 'lockout_host' => '', 'lockout_username' => $username)); if ($whitelisted === false) { $itsec_logger->log_event('lockout', 10, array('expires' => $expiration, 'expires_gmt' => $expiration_gmt, 'type' => $type), '', '', $username); } else { $itsec_logger->log_event('lockout', 10, array(__('White Listed', 'better-wp-security'), 'type' => $type), '', '', $username); } } if ($whitelisted === false) { if (ITSEC_Modules::get_setting('global', 'email_notifications')) { //send email notifications $this->send_lockout_email($good_host, $good_user, $good_username, $host_expiration, $user_expiration, $reason); } if ($good_host !== false) { $itsec_files->release_file_lock('lockout_' . $host . $user . $username); $this->execute_lock(); } else { $itsec_files->release_file_lock('lockout_' . $host . $user . $username); $this->execute_lock(true); } } } $itsec_files->release_file_lock('lockout_' . $host . $user . $username); } }
/** * Send offending IP to IPCheck API * * @since 4.5 * * @param string|null $ip ip to report * @param int $type type of behavior to report * * @return int -1 on failure, 0 if report successful and IP not blocked, 1 if IP successful and IP blocked */ public function report_ip($ip = null, $type = 1) { global $itsec_globals, $itsec_logger; $action = 'report-ip'; /** * Switch types or return false if no valid type * * Valid types: * 1 = invalid/failed login * */ switch ($type) { case 1: $behavior = 'brute-force-login'; break; default: return -1; } //get current IP if needed if ($ip === null) { $ip = ITSEC_Lib::get_ip(); } else { $ip = trim(sanitize_text_field($ip)); } if (ITSEC_Lib::is_ip_whitelisted($ip)) { return 0; } if (ITSEC_Lib_IP_Tools::validate($ip)) { //verify IP address is valid if (!isset($this->settings['api_key']) || !isset($this->settings['api_secret'])) { return -1; //invalid key or secret } $args = json_encode(array('apikey' => $this->settings['api_key'], 'behavior' => $behavior, 'ip' => $ip, 'site' => home_url('', 'http'), 'timestamp' => $itsec_globals['current_time_gmt'])); //Build the request parameters $request = array('body' => array('request' => $args, 'signature' => $this->hmac_SHA1($this->settings['api_secret'], $action . $args))); $response = wp_remote_post($this->endpoint . $action, $request); //Make sure the request was valid and has a valid body if (!is_wp_error($response) && isset($response['body'])) { $response = json_decode($response['body'], true); if (is_array($response) && isset($response['success']) && $response['success'] == true) { if (isset($response['block']) && $response['block'] == true) { $cache = isset($response['cache_ttl']) ? absint($response['cache_ttl']) : 3600; $expiration = date('Y-m-d H:i:s', $itsec_globals['current_time'] + $cache); $expiration_gmt = date('Y-m-d H:i:s', $itsec_globals['current_time_gmt'] + $cache); $itsec_logger->log_event('lockout', 10, array('expires' => $expiration, 'expires_gmt' => $expiration_gmt, 'type' => 'host'), $ip); $this->cache_ip($ip, array('status' => true), $cache); return 1; //ip report success. Just return true for now } else { return 0; } } } } return -1; }
/** * Sanitize and validate input * * @since 4.0 * * @param Array $input array of input fields * * @return Array Sanitized array */ public function sanitize_module_input($input) { global $itsec_globals; $input['did_upgrade'] = isset($this->settings['did_upgrade']) ? $this->settings['did_upgrade'] : false; if (isset($input['backup_email'])) { $bad_emails = array(); $emails_to_save = array(); if (isset($input['backup_email']) && !is_array($input['backup_email'])) { $emails = explode(PHP_EOL, $input['backup_email']); } elseif (isset($input['backup_email'])) { $emails = $input['backup_email']; } foreach ($emails as $email) { $email = sanitize_text_field(trim($email)); if (strlen($email) > 0) { if (is_email($email) === false) { $bad_emails[] = $email; } $emails_to_save[] = $email; } } if (sizeof($bad_emails) > 0) { $bad_addresses = implode(', ', $bad_emails); $type = 'error'; $message = __('The following backup email address(es) do not appear to be valid: ', 'better-wp-security') . $bad_addresses; add_settings_error('itsec', esc_attr('settings_updated'), $message, $type); } $input['backup_email'] = $emails_to_save; } if (isset($input['notification_email'])) { $bad_emails = array(); $emails_to_save = array(); if (isset($input['notification_email']) && !is_array($input['notification_email'])) { $emails = explode(PHP_EOL, $input['notification_email']); } else { $emails = $input['notification_email']; } foreach ($emails as $email) { $email = sanitize_text_field(trim($email)); if (strlen($email) > 0) { if (is_email($email) === false) { $bad_emails[] = $email; } $emails_to_save[] = $email; } } if (sizeof($bad_emails) > 0) { $bad_addresses = implode(', ', $bad_emails); $type = 'error'; $message = __('The following notification email address(es) do not appear to be valid: ', 'better-wp-security') . $bad_addresses; add_settings_error('itsec', esc_attr('settings_updated'), $message, $type); } $input['notification_email'] = $emails_to_save; } $input['lockout_message'] = isset($input['lockout_message']) ? trim(wp_kses($input['lockout_message'], $this->allowed_tags)) : ''; $input['user_lockout_message'] = isset($input['user_lockout_message']) ? trim(wp_kses($input['user_lockout_message'], $this->allowed_tags)) : ''; $input['community_lockout_message'] = isset($input['community_lockout_message']) ? trim(wp_kses($input['community_lockout_message'], $this->allowed_tags)) : ''; $input['blacklist'] = isset($input['blacklist']) && intval($input['blacklist'] == 1) ? true : false; $input['blacklist_count'] = isset($input['blacklist_count']) ? absint($input['blacklist_count']) : 3; $input['blacklist_period'] = isset($input['blacklist_period']) ? absint($input['blacklist_period']) : 7; $input['email_notifications'] = isset($input['email_notifications']) && intval($input['email_notifications'] == 1) ? true : false; $input['lockout_period'] = isset($input['lockout_period']) ? absint($input['lockout_period']) : 15; $input['log_rotation'] = isset($input['log_rotation']) ? absint($input['log_rotation']) : 14; $input['allow_tracking'] = isset($input['allow_tracking']) && intval($input['allow_tracking'] == 1) ? true : false; $input['write_files'] = isset($input['write_files']) && intval($input['write_files'] == 1) ? true : false; $input['nginx_file'] = isset($input['nginx_file']) ? sanitize_text_field($input['nginx_file']) : ABSPATH . 'nginx.conf'; $input['infinitewp_compatibility'] = isset($input['infinitewp_compatibility']) && intval($input['infinitewp_compatibility'] == 1) ? true : false; $input['log_info'] = $itsec_globals['settings']['log_info']; $input['lock_file'] = isset($input['lock_file']) && intval($input['lock_file'] == 1) ? true : false; $input['digest_email'] = isset($input['digest_email']) && intval($input['digest_email'] == 1) ? true : false; $input['proxy_override'] = isset($input['proxy_override']) && intval($input['proxy_override'] == 1) ? true : false; $input['hide_admin_bar'] = isset($input['hide_admin_bar']) && intval($input['hide_admin_bar'] == 1) ? true : false; //Set a fresh message queue if we're just turning on the digest. if ($input['digest_email'] === true && (!isset($this->settings['digest_email']) || $this->settings['digest_email'] === false)) { $digest_queue = array('last_sent' => $itsec_globals['current_time_gmt'], 'messages' => array()); update_site_option('itsec_message_queue', $digest_queue); } $input['log_location'] = isset($input['log_location']) ? sanitize_text_field($input['log_location']) : $itsec_globals['ithemes_log_dir']; //Process white list if (isset($input['lockout_white_list']) && !is_array($input['lockout_white_list'])) { $white_listed_addresses = explode(PHP_EOL, $input['lockout_white_list']); } elseif (isset($input['lockout_white_list'])) { $white_listed_addresses = $input['lockout_white_list']; } else { $white_listed_addresses = array(); } $bad_white_listed_ips = array(); $raw_white_listed_ips = array(); 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'; } foreach ($white_listed_addresses as $index => $address) { // Convert wildcard IPs to CIDR notation $address = ITSEC_Lib_IP_Tools::ip_wild_to_ip_cidr(trim($address)); if (strlen(trim($address)) > 0) { if (ITSEC_Lib_IP_Tools::validate($address) === false) { $bad_white_listed_ips[] = filter_var($address, FILTER_SANITIZE_STRING); } $raw_white_listed_ips[] = filter_var($address, FILTER_SANITIZE_STRING); } else { unset($white_listed_addresses[$index]); } } $raw_white_listed_ips = array_unique($raw_white_listed_ips); if (sizeof($bad_white_listed_ips) > 0) { $type = 'error'; $message = __('There is a problem with an IP address in the white list:', 'better-wp-security') . '<br /><br />'; foreach ($bad_white_listed_ips as $bad_ip) { $message .= sprintf(__('%s is not a valid address in the white list users box.', 'better-wp-security'), $bad_ip) . '<br />'; } add_settings_error('itsec', esc_attr('settings_updated'), $message, $type); } $input['lockout_white_list'] = $raw_white_listed_ips; if ($input['log_location'] != $itsec_globals['ithemes_log_dir']) { $good_path = ITSEC_Lib::validate_path($input['log_location']); } else { $good_path = true; } if ($good_path !== true) { $input['log_location'] = $itsec_globals['ithemes_log_dir']; $type = 'error'; $message = __('The file path entered for the log location does not appear to be valid. it has been reset to: ' . $itsec_globals['ithemes_log_dir'], 'better-wp-security'); add_settings_error('itsec', esc_attr('settings_updated'), $message, $type); } $input['log_type'] = isset($input['log_type']) ? intval($input['log_type']) : 0; if (!isset($type) && $input['write_files'] === true && $this->settings['write_files'] === false) { add_site_option('itsec_rewrites_changed', true); } if (is_multisite()) { if (isset($type)) { $error_handler = new WP_Error(); $error_handler->add($type, $message); $this->core->show_network_admin_notice($error_handler); } else { $this->core->show_network_admin_notice(false); } $this->settings = $input; } return $input; }