/** * Process clearing lockouts on view log page * * @since 4.0 * * @return bool true on success or false */ public function release_lockout($id = NULL) { global $wpdb; if ($id !== NULL && trim($id) !== '') { $sanitized_id = intval($id); $lockout = $wpdb->get_results("SELECT * FROM `" . $wpdb->base_prefix . "itsec_lockouts` WHERE lockout_id = " . $sanitized_id . ";", ARRAY_A); if (is_array($lockout) && sizeof($lockout) >= 1) { return $wpdb->update($wpdb->base_prefix . 'itsec_lockouts', array('lockout_active' => 0), array('lockout_id' => $sanitized_id)); } else { return false; } } elseif (isset($_POST['itsec_release_lockout']) && $_POST['itsec_release_lockout'] == 'true') { if (!wp_verify_nonce($_POST['wp_nonce'], 'itsec_release_lockout')) { die(__('Security error!', 'it-l10n-better-wp-security')); } $type = 'updated'; $message = __('The selected lockouts have been cleared.', 'it-l10n-better-wp-security'); foreach ($_POST as $key => $value) { if (strstr($key, "lo_")) { //see if it's a lockout to avoid processing extra post fields $wpdb->update($wpdb->base_prefix . 'itsec_lockouts', array('lockout_active' => 0), array('lockout_id' => intval($value))); } } ITSEC_Lib::clear_caches(); if (is_multisite()) { $error_handler = new WP_Error(); $error_handler->add($type, $message); $this->core->show_network_admin_notice($error_handler); } else { add_settings_error('itsec', esc_attr('settings_updated'), $message, $type); } } }
/** * Uninstall execution * * @since 4.0 * * @return void * */ private function uninstall_execute() { global $itsec_globals, $itsec_files, $wpdb; $this->deactivate_execute(); $itsec_files->do_deactivate(); delete_site_option('itsec_global'); delete_site_option('itsec_data'); delete_site_option('itsec_initials'); delete_site_option('itsec_jquery_version'); delete_site_option('itsec_message_queue'); $wpdb->query("DROP TABLE IF EXISTS " . $wpdb->base_prefix . "itsec_log;"); $wpdb->query("DROP TABLE IF EXISTS " . $wpdb->base_prefix . "itsec_lockouts;"); $wpdb->query("DROP TABLE IF EXISTS " . $wpdb->base_prefix . "itsec_temp;"); if (is_dir($itsec_globals['ithemes_dir'])) { $this->recursive_delete($itsec_globals['ithemes_dir']); } ITSEC_Lib::clear_caches(); }
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); }
/** * Check if away mode is active * * @since 4.4 * * @param array $input [NULL] Input of options to check if calling from form * @param bool $remaining will return the number of seconds remaining * @param bool $override Whether or not we're calculating override values * * @return mixed true if locked out else false or times until next condition (negative until lockout, positive until release) */ public static function check_away($input = null, $remaining = false, $override = false) { global $itsec_globals; ITSEC_Lib::clear_caches(); //lets try to make sure nothing is storing a bad time $form = true; $has_away_file = @file_exists($itsec_globals['ithemes_dir'] . '/itsec_away.confg'); $status = false; //assume they're not locked out to start //Normal usage check if ($input === null) { //if we didn't provide input to check we need to get it $form = false; $input = get_site_option('itsec_away_mode'); } if ($form === false && !isset($input['enabled']) || !isset($input['type']) || !isset($input['start']) || !isset($input['end']) || !$has_away_file) { return false; //if we don't have complete settings don't lock them out } $current_time = $itsec_globals['current_time']; //use current time $enabled = isset($input['enabled']) ? $input['enabled'] : $form; $test_type = $input['type']; $test_start = $input['start']; $test_end = $input['end']; if ($test_type === 1) { //daily $test_start -= strtotime(date('Y-m-d', $test_start)); $test_end -= strtotime(date('Y-m-d', $test_end)); $day_seconds = $current_time - strtotime(date('Y-m-d', $current_time)); if ($test_start === $test_end) { $status = false; } if ($test_start < $test_end) { //same day if ($test_start <= $day_seconds && $test_end >= $day_seconds && $enabled === true) { $status = $test_end - $day_seconds; } } else { //overnight if (($test_start < $day_seconds || $test_end > $day_seconds) && $enabled === true) { if ($day_seconds >= $test_start) { $status = 86400 - $day_seconds + $test_end; } else { $status = $test_end - $day_seconds; } } } } else { if ($test_start !== $test_end && $test_start <= $current_time && $test_end >= $current_time && $enabled === true) { //one time $status = $test_end - $current_time; } } //they are allowed to log in if ($status === false) { if ($test_type === 1) { if ($day_seconds > $test_start) { //actually starts tomorrow $status = -(86400 + $test_start - $day_seconds); } else { //starts today $status = -($test_start - $day_seconds); } } else { $status = -($test_start - $current_time); if ($status > 0) { if ($form === false && isset($input['enabled']) && $input['enabled'] === true) { //disable away mode if one-time is in the past $input['enabled'] = false; update_site_option('itsec_away_mode', $input); } $status = 0; } } } if ($override === false) { //work in an override from sync $override_option = get_site_option('itsec_away_mode_sync_override'); $override = $override_option['intention']; $expires = $override_option['expires']; if ($expires < $itsec_globals['current_time']) { delete_site_option('itsec_away_mode_sync_override'); } else { if ($override === 'activate') { if ($status <= 0) { //not currently locked out $input['start'] = $current_time - 1; $status = ITSEC_Away_Mode::check_away($input, true, true); } else { delete_site_option('itsec_away_mode_sync_override'); } } elseif ($override === 'deactivate') { if ($status > 0) { //currently locked out $input['end'] = $current_time - 1; $status = ITSEC_Away_Mode::check_away($input, true, true); } else { delete_site_option('itsec_away_mode_sync_override'); } } } } if ($remaining === true) { return $status; } else { if ($status > 0 && $status !== false) { return true; } } return false; //always default to NOT locking folks out }
/** * Uninstall execution * * @since 4.0 * * @return void * */ private function uninstall_execute() { global $itsec_globals, $itsec_files, $wpdb; $this->deactivate_execute(); require_once trailingslashit($itsec_globals['plugin_dir']) . 'core/class-itsec-modules.php'; ITSEC_Modules::run_uninstall(); $itsec_files->do_deactivate(); delete_site_option('itsec_global'); delete_site_option('itsec_data'); delete_site_option('itsec_initials'); delete_site_option('itsec_jquery_version'); delete_site_option('itsec_message_queue'); $wpdb->query("DROP TABLE IF EXISTS " . $wpdb->base_prefix . "itsec_log;"); $wpdb->query("DROP TABLE IF EXISTS " . $wpdb->base_prefix . "itsec_lockouts;"); $wpdb->query("DROP TABLE IF EXISTS " . $wpdb->base_prefix . "itsec_temp;"); if (is_dir($itsec_globals['ithemes_dir'])) { $this->recursive_delete($itsec_globals['ithemes_dir']); } ITSEC_Lib::clear_caches(); }
/** * Uninstall execution * * @since 4.0 * * @return void * */ private function uninstall_execute() { global $itsec_globals, $itsec_files, $wpdb; $this->deactivate_execute(); $itsec_files->do_deactivate(); delete_site_option('itsec_global'); delete_site_option('itsec_data'); delete_site_option('itsec_initials'); delete_site_option('itsec_jquery_version'); delete_site_option('itsec_message_queue'); $wpdb->query("DROP TABLE IF EXISTS " . $wpdb->base_prefix . "itsec_log;"); $wpdb->query("DROP TABLE IF EXISTS " . $wpdb->base_prefix . "itsec_lockouts;"); $wpdb->query("DROP TABLE IF EXISTS " . $wpdb->base_prefix . "itsec_temp;"); if (is_dir($itsec_globals['ithemes_dir'])) { $this->recursive_delete($itsec_globals['ithemes_dir']); } ITSEC_Lib::clear_caches(); // Clean up data from removed malware modules. delete_site_option('itsec_malware'); delete_site_option('itsec_malware_scheduling'); delete_site_option('itsec_malware_scheduling_report_queue'); $wpdb->query("DELETE FROM `" . $wpdb->base_prefix . "options` WHERE `option_name` LIKE ('%itsec_malware_scheduling_last_scans%')"); }
/** * Uninstall execution * * @since 4.0 * * @return void * */ private function uninstall_execute() { global $itsec_globals, $wpdb; $this->deactivate_execute(); require_once $itsec_globals['plugin_dir'] . 'core/class-itsec-modules.php'; ITSEC_Modules::run_uninstall(); $itsec_files = ITSEC_Core::get_itsec_files(); $itsec_files->do_deactivate(); delete_site_option('itsec-storage'); delete_site_option('itsec_global'); delete_site_option('itsec_data'); delete_site_option('itsec_initials'); delete_site_option('itsec_jquery_version'); delete_site_option('itsec_message_queue'); $wpdb->query("DROP TABLE IF EXISTS " . $wpdb->base_prefix . "itsec_log;"); $wpdb->query("DROP TABLE IF EXISTS " . $wpdb->base_prefix . "itsec_lockouts;"); $wpdb->query("DROP TABLE IF EXISTS " . $wpdb->base_prefix . "itsec_temp;"); if (is_dir(ITSEC_Core::get_storage_dir())) { require_once ITSEC_Core::get_core_dir() . '/lib/class-itsec-lib-directory.php'; ITSEC_Lib_Directory::remove(ITSEC_Core::get_storage_dir()); } ITSEC_Lib::clear_caches(); }