/** * Execute module upgrade * * @return void */ public function execute_upgrade($itsec_old_version) { if ($itsec_old_version < 4000) { global $itsec_bwps_options, $itsec_globals; $current_options = get_site_option('itsec_away_mode'); $current_time = $itsec_globals['current_time']; // Don't do anything if settings haven't already been set, defaults exist in the module system and we prefer to use those if (false !== $current_options) { $current_options['enabled'] = isset($itsec_bwps_options['am_enabled']) && $itsec_bwps_options['am_enabled'] == 1 ? true : false; $current_options['type'] = isset($itsec_bwps_options['am_type']) && $itsec_bwps_options['am_type'] == 1 ? 1 : 2; if (isset($itsec_bwps_options['am_startdate']) && isset($itsec_bwps_options['am_starttime'])) { $current_options['start'] = strtotime(date('Y-m-d', $itsec_bwps_options['am_startdate'])) + intval($itsec_bwps_options['am_starttime']); } elseif (isset($current_options['am_starttime']) && $current_options['type'] == 1) { $current_options['start'] = strtotime(date('Y-m-d', $current_time)) + intval($itsec_bwps_options['am_starttime']); } else { $current_options['enabled'] = false; //didn't have the whole start picture so disable } if (isset($itsec_bwps_options['am_enddate']) && isset($itsec_bwps_options['am_endtime'])) { $current_options['end'] = strtotime(date('Y-m-d', $itsec_bwps_options['am_enddate'])) + intval($itsec_bwps_options['am_endtime']); } elseif (isset($itsec_bwps_options['am_endtime']) && $itsec_bwps_options['type'] == 1) { $current_options['end'] = strtotime(date('Y-m-d', $current_time)) + intval($itsec_bwps_options['am_endtime']); } else { $current_options['enabled'] = false; //didn't have the whole start picture so disable } update_site_option('itsec_away_mode', $current_options); $away_file = ITSEC_Core::get_storage_dir() . '/itsec_away.confg'; //override file if ($current_options['enabled'] === true && !file_exists($away_file)) { @file_put_contents($away_file, 'true'); } else { @unlink($away_file); } } } if ($itsec_old_version < 4041) { $current_options = get_site_option('itsec_away_mode'); $current_override_options = get_site_option('itsec_away_mode_sync_override'); // If there are no current options, go with the new defaults by not saving anything if (is_array($current_options) || is_array($current_override_options)) { $settings = ITSEC_Modules::get_defaults('away-mode'); $original_settings = $settings; if (is_array($current_options)) { $settings['type'] = 1 == $current_options['type'] ? 'daily' : 'one-time'; $settings['start'] = intval($current_options['start'] - ITSEC_Core::get_time_offset()); $settings['start_time'] = $current_options['start'] - strtotime(date('Y-m-d', $current_options['start'])); $settings['end'] = intval($current_options['end'] - ITSEC_Core::get_time_offset()); $settings['end_time'] = $current_options['end'] - strtotime(date('Y-m-d', $current_options['end'])); } if (is_array($current_override_options)) { $settings['override_type'] = $current_override_options['intention']; $settings['override_end'] = $current_override_options['expires']; } ITSEC_Modules::set_settings('away-mode', $settings); if (isset($current_options['enabled']) && $current_options['enabled']) { ITSEC_Modules::activate('away-mode'); } else { ITSEC_Modules::deactivate('away-mode'); } } } }
public function get_defaults() { return array('all_sites' => false, 'method' => 1, 'location' => ITSEC_Core::get_storage_dir('backups'), 'retain' => 0, 'zip' => true, 'exclude' => array('itsec_log', 'itsec_temp', 'itsec_lockouts'), 'enabled' => false, 'interval' => 3, 'last_run' => 0); }
/** * 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; }
public static function get_active_file_name() { global $itsec_globals; $file_name = apply_filters('itsec_filer_away_mode_active_file', ITSEC_Core::get_storage_dir() . '/itsec_away.confg'); return $file_name; }
public function get_defaults() { global $itsec_globals; $email = get_option('admin_email'); return array('notification_email' => array($email), 'backup_email' => array($email), 'lockout_message' => __('error', 'better-wp-security'), 'user_lockout_message' => __('You have been locked out due to too many invalid login attempts.', 'better-wp-security'), 'community_lockout_message' => __('Your IP address has been flagged as a threat by the iThemes Security network.', 'better-wp-security'), 'blacklist' => true, 'blacklist_count' => 3, 'blacklist_period' => 7, 'email_notifications' => true, 'lockout_period' => 15, 'lockout_white_list' => array(), 'log_rotation' => 14, 'log_type' => 'database', 'log_location' => ITSEC_Core::get_storage_dir('logs'), 'log_info' => '', 'allow_tracking' => false, 'write_files' => true, 'nginx_file' => ABSPATH . 'nginx.conf', 'infinitewp_compatibility' => false, 'did_upgrade' => false, 'lock_file' => false, 'digest_email' => false, 'proxy_override' => false, 'hide_admin_bar' => false, 'show_error_codes' => false, 'show_new_dashboard_notice' => true, 'show_security_check' => true); }
/** * 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(); }