.
*
* Attribution: This code is part of the All-in-One WP Migration plugin, developed by
*
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
*/
if ( ! defined( 'ABSPATH' ) ) {
die( 'Kangaroos cannot jump here' );
}
class Ai1wm_Import_Validate {
public static function execute( $params ) {
// Verify file if size > 2GB and PHP = 32-bit
if ( ! ai1wm_is_filesize_supported( ai1wm_archive_path( $params ) ) ) {
throw new Ai1wm_Import_Exception(
wp_kses(
__(
'Your server uses 32-bit PHP and cannot process files larger than 2GB. Please switch to 64-bit PHP and try again.
Technical details',
'all-in-one-wp-migration'
),
ai1wm_allowed_html_tags()
)
);
}
// Verify file name extension
if ( ! ai1wm_is_filename_supported( ai1wm_archive_path( $params ) ) ) {
throw new Ai1wm_Import_Exception(
wp_kses(
__(
'Invalid file type. Please ensure your file is a .wpress backup created with All-in-One WP Migration.
Technical details',
'all-in-one-wp-migration'
),
ai1wm_allowed_html_tags()
)
);
}
// Set progress
Ai1wm_Status::info( __( 'Unpacking configuration...', 'all-in-one-wp-migration' ) );
// Open the archive file for reading
$archive = new Ai1wm_Extractor( ai1wm_archive_path( $params ) );
// Validate the archive file consistency
if ( ! $archive->is_valid() ) {
throw new Ai1wm_Import_Exception(
wp_kses(
__( 'The archive file appears to be corrupted. Follow this article for possible fixes.', 'all-in-one-wp-migration' ),
ai1wm_allowed_html_tags()
)
);
}
// Unpack package.json and multisite.json files
$archive->extract_by_files_array( ai1wm_storage_path( $params ), array( AI1WM_PACKAGE_NAME, AI1WM_MULTISITE_NAME ) );
// Check package.json file
if ( false === is_file( ai1wm_package_path( $params ) ) ) {
throw new Ai1wm_Import_Exception(
wp_kses(
__(
'Please ensure your file was created with the All-in-One WP Migration plugin.
Technical details',
'all-in-one-wp-migration'
),
ai1wm_allowed_html_tags()
)
);
}
// Set archive CRC value
$params['archive_crc_value'] = $archive->get_archive_crc_value();
// Set archive CRC size
$params['archive_crc_size'] = $archive->get_archive_crc_size();
// Close the archive file
$archive->close();
return $params;
}
}