Файловый менеджер - Редактировать - /home/tuudkjt/globeasy/wp-includes/ID3/Migrations.zip
Назад
PK </]r<� � DeprecatedOptionsConverter.phpnu ��� <?php namespace EasyWPSMTP\Migrations; use EasyWPSMTP_Utils; use Exception; /** * Class DeprecatedOptionsConverter helps convert deprecated options structure to new one. * * @since 2.0.0 */ class DeprecatedOptionsConverter extends MigrationAbstract { /** * Convert old values. * * @since 2.0.0 * * @return array */ public function get_converted_options() { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.MaxExceeded $old_options = get_option( 'swpsmtp_options', [] ); if ( empty( $old_options ) ) { return []; } $converted = []; if ( isset( $old_options['from_email_field'] ) ) { $converted['mail']['from_email'] = $old_options['from_email_field']; } if ( isset( $old_options['from_name_field'] ) ) { $converted['mail']['from_name'] = $old_options['from_name_field']; } if ( isset( $old_options['force_from_name_replace'] ) ) { $converted['mail']['from_name_force'] = (bool) $old_options['force_from_name_replace']; } if ( isset( $old_options['reply_to_email'] ) ) { $converted['mail']['reply_to_email'] = $old_options['reply_to_email']; } if ( isset( $old_options['sub_mode'] ) ) { $converted['mail']['reply_to_replace_from'] = (bool) $old_options['sub_mode']; } if ( isset( $old_options['bcc_email'] ) ) { $converted['mail']['bcc_emails'] = $old_options['bcc_email']; } if ( isset( $old_options['email_ignore_list'] ) ) { $converted['mail']['from_email_force_exclude_emails'] = $old_options['email_ignore_list']; } if ( isset( $old_options['smtp_settings'] ) ) { $old_smtp_settings = $old_options['smtp_settings']; if ( isset( $old_smtp_settings['host'] ) ) { $converted['smtp']['host'] = $old_smtp_settings['host']; } if ( isset( $old_smtp_settings['type_encryption'] ) ) { $converted['smtp']['encryption'] = $old_smtp_settings['type_encryption']; } if ( isset( $old_smtp_settings['port'] ) ) { $converted['smtp']['port'] = $old_smtp_settings['port']; } if ( isset( $old_smtp_settings['autentication'] ) ) { $converted['smtp']['auth'] = $old_smtp_settings['autentication'] === 'yes'; } if ( isset( $old_smtp_settings['username'] ) ) { $converted['smtp']['user'] = $old_smtp_settings['username']; } $converted['smtp']['pass'] = $this->get_smtp_password(); if ( isset( $old_smtp_settings['insecure_ssl'] ) ) { $converted['general']['allow_smtp_insecure_ssl'] = (bool) $old_smtp_settings['insecure_ssl']; } if ( isset( $old_smtp_settings['enable_debug'] ) ) { $converted['deprecated']['debug_log_enabled'] = (bool) $old_smtp_settings['enable_debug']; } } if ( isset( $old_options['enable_domain_check'] ) ) { $converted['general']['domain_check'] = (bool) $old_options['enable_domain_check']; } if ( isset( $old_options['allowed_domains'] ) ) { $converted['general']['domain_check_allowed_domains'] = EasyWPSMTP_Utils::base64_decode_maybe( $old_options['allowed_domains'] ); } if ( isset( $old_options['block_all_emails'] ) ) { $converted['general']['domain_check_do_not_send'] = (bool) $old_options['block_all_emails']; } if ( empty( $old_options['from_email_field'] ) || empty( $old_options['from_name_field'] ) ) { // Switch to default mailer. $converted['mail']['mailer'] = 'mail'; } else { // Switch to SMTP mailer. $converted['mail']['mailer'] = 'smtp'; } // Force from email, since it's forced in previous version. $converted['mail']['from_email_force'] = true; // Disable auto TLS, since it's disabled in previous version. $converted['smtp']['autotls'] = false; return $converted; } /** * Get SMTP password from deprecated options. * * @since 2.0.0 */ private static function get_smtp_password() { $old_options = get_option( 'swpsmtp_options' ); if ( empty( $old_options['smtp_settings']['password'] ) ) { return ''; } $temp_password = $old_options['smtp_settings']['password']; try { if ( get_option( 'swpsmtp_pass_encrypted' ) ) { // This is encrypted password. $cryptor = EasyWPSMTP_Utils::get_instance(); $decrypted = $cryptor->decrypt_password( $temp_password ); return $decrypted; } } catch ( Exception $e ) { return ''; } // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode $decoded_pass = base64_decode( $temp_password ); // No additional checks for servers that aren't configured with mbstring enabled. if ( ! function_exists( 'mb_detect_encoding' ) ) { return $decoded_pass; } // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode if ( base64_encode( $decoded_pass ) === $temp_password ) { // It might be encoded. if ( mb_detect_encoding( $decoded_pass ) === false ) { // Could not find character encoding. $password = $temp_password; } else { // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode $password = base64_decode( $temp_password ); } } else { // Not encoded. $password = $temp_password; } return stripslashes( $password ); } } PK </]mQ`%$ $ Migrations.phpnu ��� <?php namespace EasyWPSMTP\Migrations; use EasyWPSMTP\Admin\DebugEvents\Migration as DebugEventsMigration; use EasyWPSMTP\Queue\Migration as QueueMigration; use EasyWPSMTP\WP; use WP_Upgrader; /** * Class Migrations. * * @since 2.0.0 */ class Migrations { /** * Register hooks. * * @since 2.0.0 */ public function hooks() { // Initialize migrations during request in the admin panel only. add_action( 'admin_init', [ $this, 'init_migrations_on_request' ] ); // Run deprecated options migration manually via GET param. add_action( 'admin_init', [ $this, 'maybe_run_deprecated_options_migration' ] ); // Initialize migrations after plugin update. add_action( 'upgrader_process_complete', [ $this, 'init_migrations_after_upgrade' ], PHP_INT_MAX, 2 ); add_action( 'wp_ajax_nopriv_easy_wp_smtp_init_migrations', [ $this, 'init_migrations_ajax_handler' ] ); } /** * Initialize DB migrations during request. * * @since 2.3.0 */ public function init_migrations_on_request() { // Do not initialize migrations during AJAX and cron requests. if ( WP::is_doing_ajax() || wp_doing_cron() ) { return; } $this->init_migrations(); } /** * Initialize DB migrations. * * @since 2.3.0 */ private function init_migrations() { $migrations = $this->get_migrations(); foreach ( $migrations as $migration ) { if ( is_subclass_of( $migration, MigrationAbstract::class ) && $migration::is_enabled() ) { ( new $migration() )->init(); } } } /** * Get migrations classes. * * @since 2.3.0 * * @return array Migrations classes. */ private function get_migrations() { $migrations = [ DeprecatedOptionsMigration::class, GeneralMigration::class, DebugEventsMigration::class, QueueMigration::class, ]; /** * Filters DB migrations classes. * * @deprecated 2.3.0 * * @since 2.0.0 * * @param array $migrations Migrations classes. */ $migrations = apply_filters_deprecated( 'easy_wp_smtp_migrations_init', [ $migrations ], '2.3.0', 'easy_wp_smtp_migrations_get_migrations' ); /** * Filters DB migrations classes. * * @since 2.3.0 * * @param array $migrations Migrations classes. */ return apply_filters( 'easy_wp_smtp_migrations_get_migrations', $migrations ); } /** * Initialize DB migrations after plugin update. * Initiate ajax call to perform the migration with the new plugin version code. * * @since 2.3.0 * * @param WP_Upgrader $upgrader WP_Upgrader instance. * @param array $options Array of update data. */ public function init_migrations_after_upgrade( $upgrader, $options ) { if ( // Skip if in admin panel. ( is_admin() && ! wp_doing_ajax() ) || // Skip if it's update from plugins list page. // phpcs:ignore WordPress.Security.NonceVerification.Recommended ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] === 'update-plugin' ) ) { return; } $plugins = []; if ( isset( $options['plugins'] ) && is_array( $options['plugins'] ) ) { $plugins = $options['plugins']; } elseif ( isset( $options['plugin'] ) && is_string( $options['plugin'] ) ) { $plugins = [ $options['plugin'] ]; } if ( ! in_array( 'easy-wp-smtp/easy-wp-smtp.php', $plugins, true ) && ! in_array( 'easy-wp-smtp-pro/easy-wp-smtp.php', $plugins, true ) ) { return; } $url = add_query_arg( [ 'action' => 'easy_wp_smtp_init_migrations', ], admin_url( 'admin-ajax.php' ) ); $timeout = (int) ini_get( 'max_execution_time' ); $args = [ 'sslverify' => false, 'timeout' => $timeout ? $timeout : 30, ]; wp_remote_post( $url, $args ); } /** * Initialize migrations via AJAX request. * * @since 2.3.0 */ public function init_migrations_ajax_handler() { $this->init_migrations(); wp_send_json_success(); } /** * Run deprecated options migration manually via GET parameter. * * @since 2.0.0 */ public function maybe_run_deprecated_options_migration() { if ( current_user_can( easy_wp_smtp()->get_capability_manage_options() ) && isset( $_GET['page'] ) && $_GET['page'] === 'easy-wp-smtp' && isset( $_GET['easy-wp-smtp-migrate-deprecated-options'] ) ) { if ( empty( get_option( 'swpsmtp_options' ) ) ) { WP::add_admin_notice( esc_html__( 'Deprecated options were already removed from DB and can\'t be migrated.', 'easy-wp-smtp' ), WP::ADMIN_NOTICE_ERROR ); return; } ( new DeprecatedOptionsMigration() )->migrate_to_1( true ); wp_safe_redirect( easy_wp_smtp()->get_admin()->get_admin_page_url() ); exit(); } } /** * Initialize DB migrations. * * @deprecated 2.3.0 * * @since 2.0.0 */ public function init() { _deprecated_function( __METHOD__, '2.3.0', self::class . '::init_migrations_on_request' ); $this->init_migrations_on_request(); } } PK </]���� MigrationAbstract.phpnu ��� <?php namespace EasyWPSMTP\Migrations; use EasyWPSMTP\WP; /** * Class MigrationAbstract helps migrate plugin options, DB tables and more. * * @since 2.0.0 */ abstract class MigrationAbstract { /** * Version of the latest migration. * * @since 2.0.0 */ const DB_VERSION = 1; /** * Option key where we save the current migration version. * * @since 2.0.0 */ const OPTION_NAME = 'easy_wp_smtp_migration_version'; /** * Option key where we save any errors while performing migration. * * @since 2.0.0 */ const ERROR_OPTION_NAME = 'easy_wp_smtp_migration_error'; /** * Current migration version, received from static::OPTION_NAME WP option * * @since 2.0.0 * * @var int */ protected $cur_ver; /** * Migration constructor. * * @since 2.0.0 */ public function __construct() { $this->cur_ver = static::get_current_version(); } /** * Initialize migration. * * @since 2.0.0 */ public function init() { $this->validate_db(); } /** * Whether migration is enabled. * * @since 2.0.0 * * @return bool */ public static function is_enabled() { return true; } /** * Static on purpose, to get current DB version without __construct() and validation. * * @since 2.0.0 * * @return int */ public static function get_current_version() { return (int) get_option( static::OPTION_NAME, 0 ); } /** * Check DB version and update to the latest one. * * @since 2.0.0 */ protected function validate_db() { if ( $this->cur_ver < static::DB_VERSION ) { $this->run( static::DB_VERSION ); } } /** * Update DB version in options table. * * @since 2.0.0 * * @param int $version Version number. */ protected function update_db_ver( $version = 0 ) { $version = (int) $version; if ( empty( $version ) ) { $version = static::DB_VERSION; } // Autoload it, because this value is checked all the time // and no need to request it separately from all autoloaded options. update_option( static::OPTION_NAME, $version, true ); } /** * Prevent running the same migration twice. * Run migration only when required. * * @since 2.0.0 * * @param int $version The current migration version. */ protected function maybe_required_older_migrations( $version ) { $version = (int) $version; if ( ( $version - $this->cur_ver ) > 1 ) { $this->run( $version - 1 ); } } /** * Actual migration launcher. * * @since 2.0.0 * * @param int $version The specified migration version to run. */ protected function run( $version ) { $version = (int) $version; if ( method_exists( $this, 'migrate_to_' . $version ) ) { $this->{'migrate_to_' . $version}(); } else { if ( WP::in_wp_admin() ) { $message = sprintf( /* translators: %1$s - the DB option name, %2$s - Easy WP SMTP, %3$s - error message. */ esc_html__( 'There was an error while upgrading the %1$s database. Please contact %2$s support with this information: %3$s.', 'easy-wp-smtp' ), static::OPTION_NAME, '<strong>Easy WP SMTP</strong>', '<code>migration from v' . static::get_current_version() . ' to v' . static::DB_VERSION . ' failed. Plugin version: v' . EasyWPSMTP_PLUGIN_VERSION . '</code>' ); WP::add_admin_notice( $message, WP::ADMIN_NOTICE_ERROR ); } } } } PK </]��4 DeprecatedOptionsMigration.phpnu ��� <?php namespace EasyWPSMTP\Migrations; use EasyWPSMTP\Options; /** * Class Migration helps migrate deprecated plugin options. * * @since 2.0.0 */ class DeprecatedOptionsMigration extends MigrationAbstract { /** * Version of the latest migration. * * @since 2.0.0 */ const DB_VERSION = 1; /** * Option key where we save the current migration version. * * @since 2.0.0 */ const OPTION_NAME = 'easy_wp_smtp_deprecated_options_migration_version'; /** * Option key where we save any errors while performing migration. * * @since 2.0.0 */ const ERROR_OPTION_NAME = 'easy_wp_smtp_deprecated_options_migration_error'; /** * Migration from 1.x to 2.0.0. * * @since 2.0.0 * * @param bool $force Whether to force migration execution even if new options were already saved. */ public function migrate_to_1( $force = false ) { $current_options = get_option( Options::META_KEY, [] ); // Skip migration if new options was already set. if ( ( ! $force && ! empty( $current_options ) ) || empty( get_option( 'swpsmtp_options' ) ) ) { $this->update_db_ver( 1 ); return; } $new_values = ( new DeprecatedOptionsConverter() )->get_converted_options(); Options::init()->set( $new_values ); // Migrate test email saved data to new non auto-loaded option. $test_email = get_option( 'smtp_test_mail' ); if ( ! empty( $test_email ) ) { add_option( 'easy_wp_smtp_test_email', [ 'to' => isset( $test_email['swpsmtp_to'] ) ? $test_email['swpsmtp_to'] : '', 'subject' => isset( $test_email['swpsmtp_subject'] ) ? $test_email['swpsmtp_subject'] : '', 'message' => isset( $test_email['swpsmtp_message'] ) ? $test_email['swpsmtp_message'] : '', ], '', false ); } $this->update_db_ver( 1 ); } } PK </]��P� � GeneralMigration.phpnu ��� <?php namespace EasyWPSMTP\Migrations; use EasyWPSMTP; use EasyWPSMTP\Tasks\Meta; /** * Class Migration helps migrate plugin options, DB tables and more. * * @since 2.0.0 */ class GeneralMigration extends MigrationAbstract { /** * Version of the latest migration. * * @since 2.0.0 */ const DB_VERSION = 1; /** * Option key where we save the current migration version. * * @since 2.0.0 */ const OPTION_NAME = 'easy_wp_smtp_migration_version'; /** * Option key where we save any errors while performing migration. * * @since 2.0.0 */ const ERROR_OPTION_NAME = 'easy_wp_smtp_migration_error'; /** * Migration from 1.x to 2.0.0. * Create Tasks\Meta table, if it does not exist. * * @since 2.0.0 */ protected function migrate_to_1() { $meta = new Meta(); // Create the table if it doesn't exist. if ( $meta && ! $meta->table_exists() ) { $meta->create_table(); } $this->update_db_ver( 1 ); } } PK </]r<� � DeprecatedOptionsConverter.phpnu ��� PK </]mQ`%$ $ 5 Migrations.phpnu ��� PK </]���� �'