Initial commit: WordPress wp-content (themes, plugins, languages)
- Theme: momentry (custom theme with REST API routes) - Plugins: code-snippets (contains all API proxies) - Languages: zh_TW translations - Excludes: cache, backups, uploads, logs
This commit is contained in:
@@ -0,0 +1,444 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Backups_Controller {
|
||||
|
||||
public static function index() {
|
||||
Ai1wm_Template::render(
|
||||
'backups/index',
|
||||
array(
|
||||
'backups' => Ai1wm_Backups::get_files(),
|
||||
'labels' => Ai1wm_Backups::get_labels(),
|
||||
'downloadable' => Ai1wm_Backups::are_downloadable(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function clean( $params = array() ) {
|
||||
ai1wm_setup_environment();
|
||||
|
||||
// Set params
|
||||
if ( empty( $params ) ) {
|
||||
$params = stripslashes_deep( $_POST );
|
||||
}
|
||||
|
||||
// Set secret key
|
||||
$secret_key = null;
|
||||
if ( isset( $params['secret_key'] ) ) {
|
||||
$secret_key = trim( $params['secret_key'] );
|
||||
}
|
||||
|
||||
try {
|
||||
// Ensure that unauthorized people cannot access backups list action
|
||||
ai1wm_verify_secret_key( $secret_key );
|
||||
} catch ( Ai1wm_Not_Valid_Secret_Key_Exception $e ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Delete storage files
|
||||
Ai1wm_Directory::delete( ai1wm_storage_path( $params ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function delete( $params = array() ) {
|
||||
ai1wm_setup_environment();
|
||||
|
||||
// Set params
|
||||
if ( empty( $params ) ) {
|
||||
$params = stripslashes_deep( $_POST );
|
||||
}
|
||||
|
||||
// Set secret key
|
||||
$secret_key = null;
|
||||
if ( isset( $params['secret_key'] ) ) {
|
||||
$secret_key = trim( $params['secret_key'] );
|
||||
}
|
||||
|
||||
// Set archive
|
||||
$archive = null;
|
||||
if ( isset( $params['archive'] ) ) {
|
||||
$archive = trim( $params['archive'] );
|
||||
}
|
||||
|
||||
try {
|
||||
// Ensure that unauthorized people cannot access delete action
|
||||
ai1wm_verify_secret_key( $secret_key );
|
||||
} catch ( Ai1wm_Not_Valid_Secret_Key_Exception $e ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
Ai1wm_Backups::delete_file( $archive );
|
||||
Ai1wm_Backups::delete_label( $archive );
|
||||
} catch ( Ai1wm_Backups_Exception $e ) {
|
||||
ai1wm_json_response( array( 'errors' => array( $e->getMessage() ) ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
ai1wm_json_response( array( 'errors' => array() ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function add_label( $params = array() ) {
|
||||
ai1wm_setup_environment();
|
||||
|
||||
// Set params
|
||||
if ( empty( $params ) ) {
|
||||
$params = stripslashes_deep( $_POST );
|
||||
}
|
||||
|
||||
// Set secret key
|
||||
$secret_key = null;
|
||||
if ( isset( $params['secret_key'] ) ) {
|
||||
$secret_key = trim( $params['secret_key'] );
|
||||
}
|
||||
|
||||
// Set archive
|
||||
$archive = null;
|
||||
if ( isset( $params['archive'] ) ) {
|
||||
$archive = trim( $params['archive'] );
|
||||
}
|
||||
|
||||
// Set backup label
|
||||
$label = null;
|
||||
if ( isset( $params['label'] ) ) {
|
||||
$label = trim( $params['label'] );
|
||||
}
|
||||
|
||||
try {
|
||||
// Ensure that unauthorized people cannot access add label action
|
||||
ai1wm_verify_secret_key( $secret_key );
|
||||
} catch ( Ai1wm_Not_Valid_Secret_Key_Exception $e ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
Ai1wm_Backups::set_label( $archive, $label );
|
||||
} catch ( Ai1wm_Backups_Exception $e ) {
|
||||
ai1wm_json_response( array( 'errors' => array( $e->getMessage() ) ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
ai1wm_json_response( array( 'errors' => array() ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function backup_list( $params = array() ) {
|
||||
ai1wm_setup_environment();
|
||||
|
||||
// Set params
|
||||
if ( empty( $params ) ) {
|
||||
$params = stripslashes_deep( $_GET );
|
||||
}
|
||||
|
||||
// Set secret key
|
||||
$secret_key = null;
|
||||
if ( isset( $params['secret_key'] ) ) {
|
||||
$secret_key = trim( $params['secret_key'] );
|
||||
}
|
||||
|
||||
try {
|
||||
// Ensure that unauthorized people cannot access backups list action
|
||||
ai1wm_verify_secret_key( $secret_key );
|
||||
} catch ( Ai1wm_Not_Valid_Secret_Key_Exception $e ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
Ai1wm_Template::render(
|
||||
'backups/backups-list',
|
||||
array(
|
||||
'backups' => Ai1wm_Backups::get_files(),
|
||||
'labels' => Ai1wm_Backups::get_labels(),
|
||||
'downloadable' => Ai1wm_Backups::are_downloadable(),
|
||||
)
|
||||
);
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function backup_get_config( $params = array() ) {
|
||||
ai1wm_setup_environment();
|
||||
|
||||
// Set params
|
||||
if ( empty( $params ) ) {
|
||||
$params = stripslashes_deep( $_POST );
|
||||
}
|
||||
|
||||
// Set secret key
|
||||
$secret_key = null;
|
||||
if ( isset( $params['secret_key'] ) ) {
|
||||
$secret_key = trim( $params['secret_key'] );
|
||||
}
|
||||
|
||||
try {
|
||||
// Ensure that unauthorized people cannot access backups list action
|
||||
ai1wm_verify_secret_key( $secret_key );
|
||||
} catch ( Ai1wm_Not_Valid_Secret_Key_Exception $e ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
// Open the archive file for reading
|
||||
$archive = new Ai1wm_Extractor( ai1wm_backup_path( $params ) );
|
||||
$archive->extract_by_files_array( ai1wm_storage_path( $params ), array( AI1WM_PACKAGE_NAME ) );
|
||||
$archive->close();
|
||||
} catch ( Exception $e ) {
|
||||
ai1wm_json_response( array( 'errors' => array( $e->getMessage() ) ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
ai1wm_json_response( array( 'errors' => array() ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function backup_check_encryption( $params = array() ) {
|
||||
ai1wm_setup_environment();
|
||||
|
||||
// Set params
|
||||
if ( empty( $params ) ) {
|
||||
$params = stripslashes_deep( $_POST );
|
||||
}
|
||||
|
||||
// Set secret key
|
||||
$secret_key = null;
|
||||
if ( isset( $params['secret_key'] ) ) {
|
||||
$secret_key = trim( $params['secret_key'] );
|
||||
}
|
||||
|
||||
try {
|
||||
// Ensure that unauthorized people cannot access backups list action
|
||||
ai1wm_verify_secret_key( $secret_key );
|
||||
} catch ( Ai1wm_Not_Valid_Secret_Key_Exception $e ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Read package.json file
|
||||
$handle = ai1wm_open( ai1wm_package_path( $params ), 'r' );
|
||||
|
||||
// Parse package.json file
|
||||
$package = ai1wm_read( $handle, filesize( ai1wm_package_path( $params ) ) );
|
||||
$package = json_decode( $package, true );
|
||||
|
||||
// Close handle
|
||||
ai1wm_close( $handle );
|
||||
|
||||
// No encryption provided
|
||||
if ( empty( $package['Encrypted'] ) || empty( $package['EncryptedSignature'] ) ) {
|
||||
ai1wm_json_response( array( 'errors' => array() ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
// Check decryption support
|
||||
if ( ! ai1wm_can_decrypt() ) {
|
||||
ai1wm_json_response( array( 'errors' => array( __( 'Download a file from encrypted backup is not supported on this server. The process cannot continue. <a href="https://help.servmask.com/knowledgebase/unable-to-encrypt-and-decrypt-backups/" target="_blank">Technical details</a>', 'all-in-one-wp-migration' ) ) ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
// Validate decryption password
|
||||
if ( ! empty( $params['decryption_password'] ) ) {
|
||||
if ( ! ai1wm_is_decryption_password_valid( $package['EncryptedSignature'], $params['decryption_password'] ) ) {
|
||||
ai1wm_json_response( array( 'errors' => array( __( 'The decryption password is not valid. The process cannot continue.', 'all-in-one-wp-migration' ) ) ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
ai1wm_json_response( array( 'errors' => array() ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
ai1wm_json_response( array( 'check' => true, 'errors' => array() ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function backup_list_content( $params = array() ) {
|
||||
ai1wm_setup_environment();
|
||||
|
||||
// Set params
|
||||
if ( empty( $params ) ) {
|
||||
$params = stripslashes_deep( $_POST );
|
||||
}
|
||||
|
||||
// Set secret key
|
||||
$secret_key = null;
|
||||
if ( isset( $params['secret_key'] ) ) {
|
||||
$secret_key = trim( $params['secret_key'] );
|
||||
}
|
||||
|
||||
try {
|
||||
// Ensure that unauthorized people cannot access backups list action
|
||||
ai1wm_verify_secret_key( $secret_key );
|
||||
} catch ( Ai1wm_Not_Valid_Secret_Key_Exception $e ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$files = array();
|
||||
|
||||
try {
|
||||
$archive = new Ai1wm_Extractor( ai1wm_backup_path( $params ) );
|
||||
if ( ! $archive->is_valid() ) {
|
||||
throw new Ai1wm_Backups_Exception(
|
||||
__( 'Could not list the backup content. Please ensure the backup file is accessible and not corrupted.', 'all-in-one-wp-migration' )
|
||||
);
|
||||
}
|
||||
|
||||
$files = $archive->list_files();
|
||||
$archive->close();
|
||||
} catch ( Exception $e ) {
|
||||
ai1wm_json_response( array( 'errors' => $e->getMessage() ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
ai1wm_json_response( $files );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function download_file( $params = array() ) {
|
||||
ai1wm_setup_environment();
|
||||
|
||||
// Set params
|
||||
if ( empty( $params ) ) {
|
||||
$params = stripslashes_deep( $_POST );
|
||||
}
|
||||
|
||||
// Set secret key
|
||||
$secret_key = null;
|
||||
if ( isset( $params['secret_key'] ) ) {
|
||||
$secret_key = trim( $params['secret_key'] );
|
||||
}
|
||||
|
||||
// Set decryption password
|
||||
$decryption_password = null;
|
||||
if ( isset( $params['decryption_password'] ) ) {
|
||||
$decryption_password = $params['decryption_password'];
|
||||
}
|
||||
|
||||
// Set file name
|
||||
$file_name = null;
|
||||
if ( isset( $params['file_name'] ) ) {
|
||||
$file_name = trim( $params['file_name'] );
|
||||
}
|
||||
|
||||
// Set file offset
|
||||
if ( isset( $params['file_offset'] ) ) {
|
||||
$file_offset = (int) $params['file_offset'];
|
||||
} else {
|
||||
$file_offset = 0;
|
||||
}
|
||||
|
||||
try {
|
||||
// Ensure that unauthorized people cannot access backups list action
|
||||
ai1wm_verify_secret_key( $secret_key );
|
||||
} catch ( Ai1wm_Not_Valid_Secret_Key_Exception $e ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Read package.json file
|
||||
$handle = ai1wm_open( ai1wm_package_path( $params ), 'r' );
|
||||
|
||||
// Parse package.json file
|
||||
$config = ai1wm_read( $handle, filesize( ai1wm_package_path( $params ) ) );
|
||||
$config = json_decode( $config, true );
|
||||
|
||||
// Close handle
|
||||
ai1wm_close( $handle );
|
||||
|
||||
// Get compression type
|
||||
$compression_type = null;
|
||||
if ( ! empty( $config['Compression']['Enabled'] ) ) {
|
||||
$compression_type = $config['Compression']['Type'];
|
||||
}
|
||||
|
||||
// Open the archive file for reading
|
||||
$archive = new Ai1wm_Extractor( ai1wm_backup_path( $params ), $decryption_password, $compression_type );
|
||||
$archive->set_file_pointer( $file_offset );
|
||||
$archive->extract_one_file_to( ai1wm_storage_path( $params ) );
|
||||
$archive->close();
|
||||
|
||||
try {
|
||||
// Validate file name and file path for directory traversal
|
||||
if ( path_is_absolute( $file_name ) || validate_file( $file_name ) !== 0 ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Download file
|
||||
if ( ( $file_handle = ai1wm_open( ai1wm_storage_path( $params ) . DIRECTORY_SEPARATOR . $file_name, 'rb' ) ) ) {
|
||||
while ( ! feof( $file_handle ) ) {
|
||||
$file_buffer = ai1wm_read( $file_handle, 1024 * 1024 );
|
||||
echo $file_buffer;
|
||||
ob_flush();
|
||||
flush();
|
||||
}
|
||||
|
||||
ai1wm_close( $file_handle );
|
||||
}
|
||||
} catch ( Exception $e ) {
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function download_backup( $params = array() ) {
|
||||
ai1wm_setup_environment();
|
||||
|
||||
// Set params
|
||||
if ( empty( $params ) ) {
|
||||
$params = stripslashes_deep( $_POST );
|
||||
}
|
||||
|
||||
// Set secret key
|
||||
$secret_key = null;
|
||||
if ( isset( $params['secret_key'] ) ) {
|
||||
$secret_key = trim( $params['secret_key'] );
|
||||
}
|
||||
|
||||
try {
|
||||
// Ensure that unauthorized people cannot access backups list action
|
||||
ai1wm_verify_secret_key( $secret_key );
|
||||
} catch ( Ai1wm_Not_Valid_Secret_Key_Exception $e ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
// Download file
|
||||
if ( ( $file_handle = ai1wm_open( ai1wm_backup_path( $params ), 'rb' ) ) ) {
|
||||
while ( ! feof( $file_handle ) ) {
|
||||
$file_buffer = ai1wm_read( $file_handle, 1024 * 1024 );
|
||||
echo $file_buffer;
|
||||
ob_flush();
|
||||
flush();
|
||||
}
|
||||
|
||||
ai1wm_close( $file_handle );
|
||||
}
|
||||
} catch ( Exception $e ) {
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,292 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Export_Controller {
|
||||
|
||||
public static function index() {
|
||||
Ai1wm_Template::render( 'export/index' );
|
||||
}
|
||||
|
||||
public static function export( $params = array() ) {
|
||||
global $ai1wm_params;
|
||||
|
||||
// Set params
|
||||
if ( empty( $params ) ) {
|
||||
$params = stripslashes_deep( array_merge( $_GET, $_POST ) );
|
||||
}
|
||||
|
||||
// Set priority
|
||||
if ( ! isset( $params['priority'] ) ) {
|
||||
$params['priority'] = 5;
|
||||
}
|
||||
|
||||
$ai1wm_params = $params;
|
||||
|
||||
// Set secret key
|
||||
$secret_key = null;
|
||||
if ( isset( $params['secret_key'] ) ) {
|
||||
$secret_key = trim( $params['secret_key'] );
|
||||
}
|
||||
|
||||
ai1wm_setup_environment();
|
||||
ai1wm_setup_errors();
|
||||
|
||||
try {
|
||||
// Ensure that unauthorized people cannot access export action
|
||||
ai1wm_verify_secret_key( $secret_key );
|
||||
} catch ( Ai1wm_Not_Valid_Secret_Key_Exception $e ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Loop over filters
|
||||
if ( ( $filters = ai1wm_get_filters( 'ai1wm_export' ) ) ) {
|
||||
while ( $hooks = current( $filters ) ) {
|
||||
if ( intval( $params['priority'] ) === key( $filters ) ) {
|
||||
foreach ( $hooks as $hook ) {
|
||||
try {
|
||||
|
||||
// Run function hook
|
||||
$params = call_user_func_array( $hook['function'], array( $params ) );
|
||||
|
||||
} catch ( Ai1wm_Database_Exception $e ) {
|
||||
do_action( 'ai1wm_status_export_error', $params, $e );
|
||||
|
||||
if ( defined( 'WP_CLI' ) ) {
|
||||
/* translators: 1: Error code, 2: Error message. */
|
||||
WP_CLI::error( sprintf( __( 'Export failed (database error). Code: %1$s. Message: %2$s', 'all-in-one-wp-migration' ), $e->getCode(), $e->getMessage() ) );
|
||||
}
|
||||
|
||||
status_header( $e->getCode() );
|
||||
ai1wm_json_response( array( 'errors' => array( array( 'code' => $e->getCode(), 'message' => $e->getMessage() ) ) ) );
|
||||
exit;
|
||||
} catch ( Exception $e ) {
|
||||
do_action( 'ai1wm_status_export_error', $params, $e );
|
||||
|
||||
if ( defined( 'WP_CLI' ) ) {
|
||||
/* translators: 1: Error message. */
|
||||
WP_CLI::error( sprintf( __( 'Export failed: %s', 'all-in-one-wp-migration' ), $e->getMessage() ) );
|
||||
}
|
||||
|
||||
Ai1wm_Status::error( __( 'Export failed', 'all-in-one-wp-migration' ), $e->getMessage() );
|
||||
Ai1wm_Notification::error( __( 'Export failed', 'all-in-one-wp-migration' ), $e->getMessage() );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// Set completed
|
||||
$completed = true;
|
||||
if ( isset( $params['completed'] ) ) {
|
||||
$completed = (bool) $params['completed'];
|
||||
}
|
||||
|
||||
// Do request
|
||||
if ( $completed === false || ( $next = next( $filters ) ) && ( $params['priority'] = key( $filters ) ) ) {
|
||||
if ( defined( 'WP_CLI' ) ) {
|
||||
if ( ! defined( 'DOING_CRON' ) ) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $params['ai1wm_manual_export'] ) ) {
|
||||
ai1wm_json_response( $params );
|
||||
exit;
|
||||
}
|
||||
|
||||
wp_remote_request(
|
||||
apply_filters( 'ai1wm_http_export_url', add_query_arg( array( 'ai1wm_import' => 1 ), admin_url( 'admin-ajax.php?action=ai1wm_export' ) ) ),
|
||||
array(
|
||||
'method' => apply_filters( 'ai1wm_http_export_method', 'POST' ),
|
||||
'timeout' => apply_filters( 'ai1wm_http_export_timeout', 10 ),
|
||||
'blocking' => apply_filters( 'ai1wm_http_export_blocking', false ),
|
||||
'sslverify' => apply_filters( 'ai1wm_http_export_sslverify', false ),
|
||||
'headers' => apply_filters( 'ai1wm_http_export_headers', array() ),
|
||||
'body' => apply_filters( 'ai1wm_http_export_body', $params ),
|
||||
)
|
||||
);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
next( $filters );
|
||||
}
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
public static function buttons() {
|
||||
$active_filters = array();
|
||||
$static_filters = array();
|
||||
|
||||
// All-in-One WP Migration
|
||||
if ( defined( 'AI1WM_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_export_file', Ai1wm_Template::get_content( 'export/button-file' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_export_file', Ai1wm_Template::get_content( 'export/button-file' ) );
|
||||
}
|
||||
|
||||
// Add Google Drive Extension
|
||||
if ( defined( 'AI1WMGE_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_export_gdrive', Ai1wm_Template::get_content( 'export/button-gdrive' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_export_gdrive', Ai1wm_Template::get_content( 'export/button-gdrive' ) );
|
||||
}
|
||||
|
||||
// Add FTP Extension
|
||||
if ( defined( 'AI1WMFE_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_export_ftp', Ai1wm_Template::get_content( 'export/button-ftp' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_export_ftp', Ai1wm_Template::get_content( 'export/button-ftp' ) );
|
||||
}
|
||||
|
||||
// Add Dropbox Extension
|
||||
if ( defined( 'AI1WMDE_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_export_dropbox', Ai1wm_Template::get_content( 'export/button-dropbox' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_export_dropbox', Ai1wm_Template::get_content( 'export/button-dropbox' ) );
|
||||
}
|
||||
|
||||
// Add Amazon S3 Extension
|
||||
if ( defined( 'AI1WMSE_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_export_s3', Ai1wm_Template::get_content( 'export/button-s3' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_export_s3', Ai1wm_Template::get_content( 'export/button-s3' ) );
|
||||
}
|
||||
|
||||
// Add OneDrive Extension
|
||||
if ( defined( 'AI1WMOE_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_export_onedrive', Ai1wm_Template::get_content( 'export/button-onedrive' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_export_onedrive', Ai1wm_Template::get_content( 'export/button-onedrive' ) );
|
||||
}
|
||||
|
||||
// Add pCloud Extension
|
||||
if ( defined( 'AI1WMPE_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_export_pcloud', Ai1wm_Template::get_content( 'export/button-pcloud' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_export_pcloud', Ai1wm_Template::get_content( 'export/button-pcloud' ) );
|
||||
}
|
||||
|
||||
// Add S3 Client Extension
|
||||
if ( defined( 'AI1WMNE_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_export_s3_client', Ai1wm_Template::get_content( 'export/button-s3-client' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_export_s3_client', Ai1wm_Template::get_content( 'export/button-s3-client' ) );
|
||||
}
|
||||
|
||||
// Add Google Cloud Storage Extension
|
||||
if ( defined( 'AI1WMCE_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_export_gcloud_storage', Ai1wm_Template::get_content( 'export/button-gcloud-storage' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_export_gcloud_storage', Ai1wm_Template::get_content( 'export/button-gcloud-storage' ) );
|
||||
}
|
||||
|
||||
// Add DigitalOcean Spaces Extension
|
||||
if ( defined( 'AI1WMIE_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_export_digitalocean', Ai1wm_Template::get_content( 'export/button-digitalocean' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_export_digitalocean', Ai1wm_Template::get_content( 'export/button-digitalocean' ) );
|
||||
}
|
||||
|
||||
// Add Mega Extension
|
||||
if ( defined( 'AI1WMEE_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_export_mega', Ai1wm_Template::get_content( 'export/button-mega' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_export_mega', Ai1wm_Template::get_content( 'export/button-mega' ) );
|
||||
}
|
||||
|
||||
// Add Backblaze B2 Extension
|
||||
if ( defined( 'AI1WMAE_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_export_b2', Ai1wm_Template::get_content( 'export/button-b2' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_export_b2', Ai1wm_Template::get_content( 'export/button-b2' ) );
|
||||
}
|
||||
|
||||
// Add Box Extension
|
||||
if ( defined( 'AI1WMBE_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_export_box', Ai1wm_Template::get_content( 'export/button-box' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_export_box', Ai1wm_Template::get_content( 'export/button-box' ) );
|
||||
}
|
||||
|
||||
// Add Microsoft Azure Extension
|
||||
if ( defined( 'AI1WMZE_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_export_azure_storage', Ai1wm_Template::get_content( 'export/button-azure-storage' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_export_azure_storage', Ai1wm_Template::get_content( 'export/button-azure-storage' ) );
|
||||
}
|
||||
|
||||
// Add WebDAV Extension
|
||||
if ( defined( 'AI1WMWE_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_export_webdav', Ai1wm_Template::get_content( 'export/button-webdav' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_export_webdav', Ai1wm_Template::get_content( 'export/button-webdav' ) );
|
||||
}
|
||||
|
||||
// Add Amazon Glacier Extension
|
||||
if ( defined( 'AI1WMRE_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_export_glacier', Ai1wm_Template::get_content( 'export/button-glacier' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_export_glacier', Ai1wm_Template::get_content( 'export/button-glacier' ) );
|
||||
}
|
||||
|
||||
return array_merge( $active_filters, $static_filters );
|
||||
}
|
||||
|
||||
public static function cleanup() {
|
||||
try {
|
||||
// Iterate over storage directory
|
||||
$iterator = new Ai1wm_Recursive_Directory_Iterator( AI1WM_STORAGE_PATH );
|
||||
|
||||
// Exclude index.php
|
||||
$iterator = new Ai1wm_Recursive_Exclude_Filter( $iterator, array( 'index.php', 'index.html' ) );
|
||||
|
||||
// Loop over folders and files
|
||||
foreach ( $iterator as $item ) {
|
||||
try {
|
||||
if ( $item->isFile() && $item->getExtension() === 'log' ) {
|
||||
if ( $item->getMTime() < ( time() - AI1WM_MAX_LOG_CLEANUP ) ) {
|
||||
Ai1wm_File::delete( $item->getPathname() );
|
||||
}
|
||||
} elseif ( $item->getMTime() < ( time() - AI1WM_MAX_STORAGE_CLEANUP ) ) {
|
||||
if ( $item->isDir() ) {
|
||||
Ai1wm_Directory::delete( $item->getPathname() );
|
||||
} else {
|
||||
Ai1wm_File::delete( $item->getPathname() );
|
||||
}
|
||||
}
|
||||
} catch ( Exception $e ) {
|
||||
}
|
||||
}
|
||||
} catch ( Exception $e ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Feedback_Controller {
|
||||
|
||||
public static function feedback( $params = array() ) {
|
||||
ai1wm_setup_environment();
|
||||
|
||||
// Set params
|
||||
if ( empty( $params ) ) {
|
||||
$params = stripslashes_deep( $_POST );
|
||||
}
|
||||
|
||||
// Set secret key
|
||||
$secret_key = null;
|
||||
if ( isset( $params['secret_key'] ) ) {
|
||||
$secret_key = trim( $params['secret_key'] );
|
||||
}
|
||||
|
||||
// Set type
|
||||
$type = null;
|
||||
if ( isset( $params['ai1wm_type'] ) ) {
|
||||
$type = trim( $params['ai1wm_type'] );
|
||||
}
|
||||
|
||||
// Set e-mail
|
||||
$email = null;
|
||||
if ( isset( $params['ai1wm_email'] ) ) {
|
||||
$email = trim( $params['ai1wm_email'] );
|
||||
}
|
||||
|
||||
// Set message
|
||||
$message = null;
|
||||
if ( isset( $params['ai1wm_message'] ) ) {
|
||||
$message = trim( $params['ai1wm_message'] );
|
||||
}
|
||||
|
||||
// Set terms
|
||||
$terms = false;
|
||||
if ( isset( $params['ai1wm_terms'] ) ) {
|
||||
$terms = (bool) $params['ai1wm_terms'];
|
||||
}
|
||||
|
||||
try {
|
||||
// Ensure that unauthorized people cannot access feedback action
|
||||
ai1wm_verify_secret_key( $secret_key );
|
||||
} catch ( Ai1wm_Not_Valid_Secret_Key_Exception $e ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$extensions = Ai1wm_Extensions::get();
|
||||
|
||||
// Exclude File Extension
|
||||
if ( defined( 'AI1WMTE_PLUGIN_NAME' ) ) {
|
||||
unset( $extensions[ AI1WMTE_PLUGIN_NAME ] );
|
||||
}
|
||||
|
||||
$purchases = array();
|
||||
foreach ( $extensions as $extension ) {
|
||||
$purchases[] = $extension['key'];
|
||||
}
|
||||
|
||||
try {
|
||||
Ai1wm_Feedback::add( $type, $email, $message, $terms, implode( PHP_EOL, $purchases ) );
|
||||
} catch ( Ai1wm_Feedback_Exception $e ) {
|
||||
ai1wm_json_response( array( 'errors' => array( $e->getMessage() ) ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
ai1wm_json_response( array( 'errors' => array() ) );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,298 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Controller {
|
||||
|
||||
public static function index() {
|
||||
Ai1wm_Template::render( 'import/index' );
|
||||
}
|
||||
|
||||
public static function import( $params = array() ) {
|
||||
global $ai1wm_params;
|
||||
|
||||
// Set params
|
||||
if ( empty( $params ) ) {
|
||||
$params = stripslashes_deep( array_merge( $_GET, $_POST ) );
|
||||
}
|
||||
|
||||
// Set priority
|
||||
if ( ! isset( $params['priority'] ) ) {
|
||||
$params['priority'] = 10;
|
||||
}
|
||||
|
||||
$ai1wm_params = $params;
|
||||
|
||||
// Set secret key
|
||||
$secret_key = null;
|
||||
if ( isset( $params['secret_key'] ) ) {
|
||||
$secret_key = trim( $params['secret_key'] );
|
||||
}
|
||||
|
||||
ai1wm_setup_environment();
|
||||
ai1wm_setup_errors();
|
||||
|
||||
try {
|
||||
// Ensure that unauthorized people cannot access import action
|
||||
ai1wm_verify_secret_key( $secret_key );
|
||||
} catch ( Ai1wm_Not_Valid_Secret_Key_Exception $e ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Loop over filters
|
||||
if ( ( $filters = ai1wm_get_filters( 'ai1wm_import' ) ) ) {
|
||||
while ( $hooks = current( $filters ) ) {
|
||||
if ( intval( $params['priority'] ) === key( $filters ) ) {
|
||||
foreach ( $hooks as $hook ) {
|
||||
try {
|
||||
|
||||
// Run function hook
|
||||
$params = call_user_func_array( $hook['function'], array( $params ) );
|
||||
|
||||
} catch ( Ai1wm_Upload_Exception $e ) {
|
||||
do_action( 'ai1wm_status_upload_error', $params, $e );
|
||||
|
||||
if ( defined( 'WP_CLI' ) ) {
|
||||
/* translators: 1: Error code, 2: Error message. */
|
||||
WP_CLI::error( sprintf( __( 'Import failed. Code: %1$s. %2$s', 'all-in-one-wp-migration' ), $e->getCode(), $e->getMessage() ) );
|
||||
}
|
||||
|
||||
status_header( $e->getCode() );
|
||||
ai1wm_json_response( array( 'errors' => array( array( 'code' => $e->getCode(), 'message' => $e->getMessage() ) ) ) );
|
||||
exit;
|
||||
} catch ( Ai1wm_Database_Exception $e ) {
|
||||
do_action( 'ai1wm_status_import_error', $params, $e );
|
||||
|
||||
if ( defined( 'WP_CLI' ) ) {
|
||||
/* translators: 1: Error code, 2: Error message. */
|
||||
WP_CLI::error( sprintf( __( 'Import failed (database error). Code: %1$s. %2$s', 'all-in-one-wp-migration' ), $e->getCode(), $e->getMessage() ) );
|
||||
}
|
||||
|
||||
status_header( $e->getCode() );
|
||||
ai1wm_json_response( array( 'errors' => array( array( 'code' => $e->getCode(), 'message' => $e->getMessage() ) ) ) );
|
||||
exit;
|
||||
} catch ( Exception $e ) {
|
||||
do_action( 'ai1wm_status_import_error', $params, $e );
|
||||
|
||||
if ( defined( 'WP_CLI' ) ) {
|
||||
/* translators: Error message. */
|
||||
WP_CLI::error( sprintf( __( 'Import failed: %s', 'all-in-one-wp-migration' ), $e->getMessage() ) );
|
||||
}
|
||||
|
||||
if ( $e instanceof Ai1wm_CRC_Exception ) {
|
||||
Ai1wm_Status::left_error( __( 'Import failed', 'all-in-one-wp-migration' ), $e->getMessage() );
|
||||
} else {
|
||||
Ai1wm_Status::error( __( 'Import failed', 'all-in-one-wp-migration' ), $e->getMessage() );
|
||||
}
|
||||
|
||||
Ai1wm_Notification::error( __( 'Import failed', 'all-in-one-wp-migration' ), $e->getMessage() );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// Set completed
|
||||
$completed = true;
|
||||
if ( isset( $params['completed'] ) ) {
|
||||
$completed = (bool) $params['completed'];
|
||||
}
|
||||
|
||||
// Do request
|
||||
if ( $completed === false || ( $next = next( $filters ) ) && ( $params['priority'] = key( $filters ) ) ) {
|
||||
if ( defined( 'WP_CLI' ) ) {
|
||||
if ( ! defined( 'DOING_CRON' ) ) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $params['ai1wm_manual_import'] ) || isset( $params['ai1wm_manual_restore'] ) ) {
|
||||
ai1wm_json_response( $params );
|
||||
exit;
|
||||
}
|
||||
|
||||
wp_remote_request(
|
||||
apply_filters( 'ai1wm_http_import_url', add_query_arg( array( 'ai1wm_import' => 1 ), admin_url( 'admin-ajax.php?action=ai1wm_import' ) ) ),
|
||||
array(
|
||||
'method' => apply_filters( 'ai1wm_http_import_method', 'POST' ),
|
||||
'timeout' => apply_filters( 'ai1wm_http_import_timeout', 10 ),
|
||||
'blocking' => apply_filters( 'ai1wm_http_import_blocking', false ),
|
||||
'sslverify' => apply_filters( 'ai1wm_http_import_sslverify', false ),
|
||||
'headers' => apply_filters( 'ai1wm_http_import_headers', array() ),
|
||||
'body' => apply_filters( 'ai1wm_http_import_body', $params ),
|
||||
)
|
||||
);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
next( $filters );
|
||||
}
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
public static function buttons() {
|
||||
$active_filters = array();
|
||||
$static_filters = array();
|
||||
|
||||
// All-in-One WP Migration
|
||||
if ( defined( 'AI1WM_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_import_file', Ai1wm_Template::get_content( 'import/button-file' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_import_file', Ai1wm_Template::get_content( 'import/button-file' ) );
|
||||
}
|
||||
|
||||
// Add Google Drive Extension
|
||||
if ( defined( 'AI1WMGE_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_import_gdrive', Ai1wm_Template::get_content( 'import/button-gdrive' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_import_gdrive', Ai1wm_Template::get_content( 'import/button-gdrive' ) );
|
||||
}
|
||||
|
||||
// Add FTP Extension
|
||||
if ( defined( 'AI1WMFE_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_import_ftp', Ai1wm_Template::get_content( 'import/button-ftp' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_import_ftp', Ai1wm_Template::get_content( 'import/button-ftp' ) );
|
||||
}
|
||||
|
||||
// Add Dropbox Extension
|
||||
if ( defined( 'AI1WMDE_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_import_dropbox', Ai1wm_Template::get_content( 'import/button-dropbox' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_import_dropbox', Ai1wm_Template::get_content( 'import/button-dropbox' ) );
|
||||
}
|
||||
|
||||
// Add URL Extension
|
||||
if ( defined( 'AI1WMLE_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_import_url', Ai1wm_Template::get_content( 'import/button-url' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_import_url', Ai1wm_Template::get_content( 'import/button-url' ) );
|
||||
}
|
||||
|
||||
// Add Amazon S3 Extension
|
||||
if ( defined( 'AI1WMSE_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_import_s3', Ai1wm_Template::get_content( 'import/button-s3' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_import_s3', Ai1wm_Template::get_content( 'import/button-s3' ) );
|
||||
}
|
||||
|
||||
// Add OneDrive Extension
|
||||
if ( defined( 'AI1WMOE_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_import_onedrive', Ai1wm_Template::get_content( 'import/button-onedrive' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_import_onedrive', Ai1wm_Template::get_content( 'import/button-onedrive' ) );
|
||||
}
|
||||
|
||||
// Add pCloud Extension
|
||||
if ( defined( 'AI1WMPE_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_import_pcloud', Ai1wm_Template::get_content( 'import/button-pcloud' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_import_pcloud', Ai1wm_Template::get_content( 'import/button-pcloud' ) );
|
||||
}
|
||||
|
||||
// Add S3 Client Extension
|
||||
if ( defined( 'AI1WMNE_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_import_s3_client', Ai1wm_Template::get_content( 'import/button-s3-client' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_import_s3_client', Ai1wm_Template::get_content( 'import/button-s3-client' ) );
|
||||
}
|
||||
|
||||
// Add Google Cloud Storage Extension
|
||||
if ( defined( 'AI1WMCE_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_import_gcloud_storage', Ai1wm_Template::get_content( 'import/button-gcloud-storage' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_import_gcloud_storage', Ai1wm_Template::get_content( 'import/button-gcloud-storage' ) );
|
||||
}
|
||||
|
||||
// Add DigitalOcean Spaces Extension
|
||||
if ( defined( 'AI1WMIE_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_import_digitalocean', Ai1wm_Template::get_content( 'import/button-digitalocean' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_import_digitalocean', Ai1wm_Template::get_content( 'import/button-digitalocean' ) );
|
||||
}
|
||||
|
||||
// Add Mega Extension
|
||||
if ( defined( 'AI1WMEE_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_import_mega', Ai1wm_Template::get_content( 'import/button-mega' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_import_mega', Ai1wm_Template::get_content( 'import/button-mega' ) );
|
||||
}
|
||||
|
||||
// Add Backblaze B2 Extension
|
||||
if ( defined( 'AI1WMAE_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_import_b2', Ai1wm_Template::get_content( 'import/button-b2' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_import_b2', Ai1wm_Template::get_content( 'import/button-b2' ) );
|
||||
}
|
||||
|
||||
// Add Box Extension
|
||||
if ( defined( 'AI1WMBE_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_import_box', Ai1wm_Template::get_content( 'import/button-box' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_import_box', Ai1wm_Template::get_content( 'import/button-box' ) );
|
||||
}
|
||||
|
||||
// Add Microsoft Azure Extension
|
||||
if ( defined( 'AI1WMZE_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_import_azure_storage', Ai1wm_Template::get_content( 'import/button-azure-storage' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_import_azure_storage', Ai1wm_Template::get_content( 'import/button-azure-storage' ) );
|
||||
}
|
||||
|
||||
// Add WebDAV Extension
|
||||
if ( defined( 'AI1WMWE_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_import_webdav', Ai1wm_Template::get_content( 'import/button-webdav' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_import_webdav', Ai1wm_Template::get_content( 'import/button-webdav' ) );
|
||||
}
|
||||
|
||||
// Add Amazon Glacier Extension
|
||||
if ( defined( 'AI1WMRE_PLUGIN_NAME' ) ) {
|
||||
$active_filters[] = apply_filters( 'ai1wm_import_glacier', Ai1wm_Template::get_content( 'import/button-glacier' ) );
|
||||
} else {
|
||||
$static_filters[] = apply_filters( 'ai1wm_import_glacier', Ai1wm_Template::get_content( 'import/button-glacier' ) );
|
||||
}
|
||||
|
||||
return array_merge( $active_filters, $static_filters );
|
||||
}
|
||||
|
||||
public static function pro() {
|
||||
return Ai1wm_Template::get_content( 'import/pro' );
|
||||
}
|
||||
|
||||
public static function max_chunk_size() {
|
||||
return min(
|
||||
ai1wm_parse_size( ini_get( 'post_max_size' ), AI1WM_MAX_CHUNK_SIZE ),
|
||||
ai1wm_parse_size( ini_get( 'upload_max_filesize' ), AI1WM_MAX_CHUNK_SIZE ),
|
||||
ai1wm_parse_size( AI1WM_MAX_CHUNK_SIZE )
|
||||
);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Reset_Controller {
|
||||
public static function index() {
|
||||
Ai1wm_Template::render( 'reset/index' );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Schedules_Controller {
|
||||
public static function index() {
|
||||
Ai1wm_Template::render( 'schedules/index' );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Status_Controller {
|
||||
|
||||
public static function status( $params = array() ) {
|
||||
ai1wm_setup_environment();
|
||||
|
||||
// Set params
|
||||
if ( empty( $params ) ) {
|
||||
$params = stripslashes_deep( $_GET );
|
||||
}
|
||||
|
||||
// Set secret key
|
||||
$secret_key = null;
|
||||
if ( isset( $params['secret_key'] ) ) {
|
||||
$secret_key = trim( $params['secret_key'] );
|
||||
}
|
||||
|
||||
try {
|
||||
// Ensure that unauthorized people cannot access status action
|
||||
ai1wm_verify_secret_key( $secret_key );
|
||||
} catch ( Ai1wm_Not_Valid_Secret_Key_Exception $e ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
ai1wm_json_response( get_option( AI1WM_STATUS, array() ) );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Updater_Controller {
|
||||
|
||||
public static function plugins_api( $result, $action = null, $args = null ) {
|
||||
return Ai1wm_Updater::plugins_api( $result, $action, $args );
|
||||
}
|
||||
|
||||
public static function pre_update_plugins( $transient ) {
|
||||
if ( empty( $transient->checked ) ) {
|
||||
return $transient;
|
||||
}
|
||||
|
||||
// Check for updates every 11 hours
|
||||
if ( ( $last_check_for_updates = get_site_transient( AI1WM_LAST_CHECK_FOR_UPDATES ) ) ) {
|
||||
if ( ( time() - $last_check_for_updates ) < 11 * HOUR_IN_SECONDS ) {
|
||||
return $transient;
|
||||
}
|
||||
}
|
||||
|
||||
// Set last check for updates
|
||||
set_site_transient( AI1WM_LAST_CHECK_FOR_UPDATES, time() );
|
||||
|
||||
// Check for updates
|
||||
Ai1wm_Updater::check_for_updates();
|
||||
|
||||
return $transient;
|
||||
}
|
||||
|
||||
public static function update_plugins( $transient ) {
|
||||
return Ai1wm_Updater::update_plugins( $transient );
|
||||
}
|
||||
|
||||
public static function check_for_updates() {
|
||||
return Ai1wm_Updater::check_for_updates();
|
||||
}
|
||||
|
||||
public static function plugin_row_meta( $plugin_meta, $plugin_file ) {
|
||||
return Ai1wm_Updater::plugin_row_meta( $plugin_meta, $plugin_file );
|
||||
}
|
||||
|
||||
public static function in_plugin_update_message( $plugin_data, $response ) {
|
||||
$updater = get_option( AI1WM_UPDATER, array() );
|
||||
|
||||
// Get updater details
|
||||
if ( isset( $updater[ $plugin_data['slug'] ]['update_message'] ) ) {
|
||||
Ai1wm_Template::render( 'updater/update', array( 'message' => $updater[ $plugin_data['slug'] ]['update_message'] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Backups {
|
||||
|
||||
/**
|
||||
* Get all backup files
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_files() {
|
||||
$backups = array();
|
||||
|
||||
try {
|
||||
|
||||
// Iterate over directory
|
||||
$iterator = new Ai1wm_Recursive_Directory_Iterator( AI1WM_BACKUPS_PATH );
|
||||
|
||||
// Filter by extensions
|
||||
$iterator = new Ai1wm_Recursive_Extension_Filter( $iterator, array( 'wpress' ) );
|
||||
|
||||
// Recursively iterate over directory
|
||||
$iterator = new Ai1wm_Recursive_Iterator_Iterator( $iterator, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD );
|
||||
|
||||
// Get backup files
|
||||
foreach ( $iterator as $item ) {
|
||||
try {
|
||||
if ( ai1wm_is_filesize_supported( $item->getPathname() ) ) {
|
||||
$backups[] = array(
|
||||
'path' => $iterator->getSubPath(),
|
||||
'filename' => $iterator->getSubPathname(),
|
||||
'mtime' => $iterator->getMTime(),
|
||||
'size' => $iterator->getSize(),
|
||||
);
|
||||
} else {
|
||||
$backups[] = array(
|
||||
'path' => $iterator->getSubPath(),
|
||||
'filename' => $iterator->getSubPathname(),
|
||||
'mtime' => $iterator->getMTime(),
|
||||
'size' => null,
|
||||
);
|
||||
}
|
||||
} catch ( Exception $e ) {
|
||||
$backups[] = array(
|
||||
'path' => $iterator->getSubPath(),
|
||||
'filename' => $iterator->getSubPathname(),
|
||||
'mtime' => null,
|
||||
'size' => null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Sort backups modified date
|
||||
usort( $backups, 'Ai1wm_Backups::compare' );
|
||||
|
||||
} catch ( Exception $e ) {
|
||||
}
|
||||
|
||||
return $backups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count all backup files
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public static function count_files() {
|
||||
return count( Ai1wm_Backups::get_files() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete backup file
|
||||
*
|
||||
* @param string $file File name
|
||||
* @return boolean
|
||||
*/
|
||||
public static function delete_file( $file ) {
|
||||
if ( ai1wm_is_filename_supported( $file ) ) {
|
||||
if ( $deleted = @unlink( ai1wm_backup_path( array( 'archive' => $file ) ) ) ) {
|
||||
do_action( 'ai1wm_status_backup_deleted', $file );
|
||||
}
|
||||
|
||||
return $deleted;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all backup labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_labels() {
|
||||
return get_option( AI1WM_BACKUPS_LABELS, array() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set backup label
|
||||
*
|
||||
* @param string $file File name
|
||||
* @param string $label File label
|
||||
* @return boolean
|
||||
*/
|
||||
public static function set_label( $file, $label ) {
|
||||
if ( ( $labels = get_option( AI1WM_BACKUPS_LABELS, array() ) ) !== false ) {
|
||||
$labels[ $file ] = $label;
|
||||
}
|
||||
|
||||
return update_option( AI1WM_BACKUPS_LABELS, $labels );
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete backup label
|
||||
*
|
||||
* @param string $file File name
|
||||
* @return boolean
|
||||
*/
|
||||
public static function delete_label( $file ) {
|
||||
if ( ( $labels = get_option( AI1WM_BACKUPS_LABELS, array() ) ) !== false ) {
|
||||
unset( $labels[ $file ] );
|
||||
}
|
||||
|
||||
return update_option( AI1WM_BACKUPS_LABELS, $labels );
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare backup files by modified time
|
||||
*
|
||||
* @param array $a File item A
|
||||
* @param array $b File item B
|
||||
* @return integer
|
||||
*/
|
||||
public static function compare( $a, $b ) {
|
||||
if ( $a['mtime'] === $b['mtime'] ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ( $a['mtime'] > $b['mtime'] ) ? - 1 : 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if backups are downloadable
|
||||
*/
|
||||
public static function are_downloadable() {
|
||||
static $downloadable = null;
|
||||
if ( is_null( $downloadable ) ) {
|
||||
$downloadable = Ai1wm_Backups::are_in_wp_content_folder() || strpos( AI1WM_BACKUPS_PATH, untrailingslashit( ABSPATH ) ) === 0;
|
||||
}
|
||||
|
||||
return $downloadable;
|
||||
}
|
||||
|
||||
public static function are_in_wp_content_folder() {
|
||||
static $in_wp_content = null;
|
||||
if ( is_null( $in_wp_content ) ) {
|
||||
$in_wp_content = strpos( AI1WM_BACKUPS_PATH, untrailingslashit( WP_CONTENT_DIR ) ) === 0;
|
||||
}
|
||||
|
||||
return $in_wp_content;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Compatibility {
|
||||
|
||||
public static function get( $params ) {
|
||||
$extensions = Ai1wm_Extensions::get();
|
||||
|
||||
foreach ( $extensions as $extension_name => $extension_data ) {
|
||||
if ( ! isset( $params[ $extension_data['short'] ] ) ) {
|
||||
unset( $extensions[ $extension_name ] );
|
||||
}
|
||||
}
|
||||
|
||||
// If no extension is used, update everything that is available
|
||||
if ( empty( $extensions ) ) {
|
||||
$extensions = Ai1wm_Extensions::get();
|
||||
}
|
||||
|
||||
$messages = array();
|
||||
foreach ( $extensions as $extension_name => $extension_data ) {
|
||||
if ( ! Ai1wm_Compatibility::check( $extension_data ) ) {
|
||||
if ( defined( 'WP_CLI' ) ) {
|
||||
/* translators: Extension name. */
|
||||
$messages[] = sprintf( __( '%s is out of date. Please update this extension before using it.', 'all-in-one-wp-migration' ), $extension_data['title'] );
|
||||
} else {
|
||||
/* translators: 1: Extension name, 2: Plugins update page. */
|
||||
$messages[] = sprintf( __( '<strong>%1$s</strong> is out of date. You must <a href="%2$s">update this extension</a> before using it.<br />', 'all-in-one-wp-migration' ), $extension_data['title'], network_admin_url( 'plugins.php' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $messages;
|
||||
}
|
||||
|
||||
public static function check( $extension ) {
|
||||
if ( $extension['version'] !== 'develop' ) {
|
||||
if ( version_compare( $extension['version'], $extension['requires'], '<' ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Export_Abstract {}
|
||||
class Ai1wm_Import_Abstract {}
|
||||
class Ai1wm_Config {}
|
||||
@@ -0,0 +1,352 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Extensions {
|
||||
|
||||
/**
|
||||
* Get active extensions
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get() {
|
||||
$extensions = array();
|
||||
|
||||
// Add Microsoft Azure Extension
|
||||
if ( defined( 'AI1WMZE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMZE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMZE_PURCHASE_ID,
|
||||
'title' => AI1WMZE_PLUGIN_TITLE,
|
||||
'about' => AI1WMZE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMZE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMZE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMZE_VERSION,
|
||||
'requires' => '1.53',
|
||||
'short' => AI1WMZE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add Backblaze B2 Extension
|
||||
if ( defined( 'AI1WMAE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMAE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMAE_PURCHASE_ID,
|
||||
'title' => AI1WMAE_PLUGIN_TITLE,
|
||||
'about' => AI1WMAE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMAE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMAE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMAE_VERSION,
|
||||
'requires' => '1.59',
|
||||
'short' => AI1WMAE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add Backup Plugin
|
||||
if ( defined( 'AI1WMVE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMVE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMVE_PURCHASE_ID,
|
||||
'title' => AI1WMVE_PLUGIN_TITLE,
|
||||
'about' => AI1WMVE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMVE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMVE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMVE_VERSION,
|
||||
'requires' => '1.0',
|
||||
'short' => AI1WMVE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add Box Extension
|
||||
if ( defined( 'AI1WMBE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMBE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMBE_PURCHASE_ID,
|
||||
'title' => AI1WMBE_PLUGIN_TITLE,
|
||||
'about' => AI1WMBE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMBE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMBE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMBE_VERSION,
|
||||
'requires' => '1.69',
|
||||
'short' => AI1WMBE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add DigitalOcean Spaces Extension
|
||||
if ( defined( 'AI1WMIE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMIE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMIE_PURCHASE_ID,
|
||||
'title' => AI1WMIE_PLUGIN_TITLE,
|
||||
'about' => AI1WMIE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMIE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMIE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMIE_VERSION,
|
||||
'requires' => '1.69',
|
||||
'short' => AI1WMIE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add Direct Extension
|
||||
if ( defined( 'AI1WMXE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMXE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMXE_PURCHASE_ID,
|
||||
'title' => AI1WMXE_PLUGIN_TITLE,
|
||||
'about' => AI1WMXE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMXE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMXE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMXE_VERSION,
|
||||
'requires' => '1.38',
|
||||
'short' => AI1WMXE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add Dropbox Extension
|
||||
if ( defined( 'AI1WMDE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMDE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMDE_PURCHASE_ID,
|
||||
'title' => AI1WMDE_PLUGIN_TITLE,
|
||||
'about' => AI1WMDE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMDE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMDE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMDE_VERSION,
|
||||
'requires' => '3.94',
|
||||
'short' => AI1WMDE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add File Extension
|
||||
if ( defined( 'AI1WMTE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMTE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMTE_PURCHASE_ID,
|
||||
'title' => AI1WMTE_PLUGIN_TITLE,
|
||||
'about' => AI1WMTE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMTE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMTE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMTE_VERSION,
|
||||
'requires' => '1.5',
|
||||
'short' => AI1WMTE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add FTP Extension
|
||||
if ( defined( 'AI1WMFE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMFE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMFE_PURCHASE_ID,
|
||||
'title' => AI1WMFE_PLUGIN_TITLE,
|
||||
'about' => AI1WMFE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMFE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMFE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMFE_VERSION,
|
||||
'requires' => '2.93',
|
||||
'short' => AI1WMFE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add Google Cloud Storage Extension
|
||||
if ( defined( 'AI1WMCE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMCE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMCE_PURCHASE_ID,
|
||||
'title' => AI1WMCE_PLUGIN_TITLE,
|
||||
'about' => AI1WMCE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMCE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMCE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMCE_VERSION,
|
||||
'requires' => '1.62',
|
||||
'short' => AI1WMCE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add Google Drive Extension
|
||||
if ( defined( 'AI1WMGE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMGE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMGE_PURCHASE_ID,
|
||||
'title' => AI1WMGE_PLUGIN_TITLE,
|
||||
'about' => AI1WMGE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMGE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMGE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMGE_VERSION,
|
||||
'requires' => '2.100',
|
||||
'short' => AI1WMGE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add Amazon Glacier Extension
|
||||
if ( defined( 'AI1WMRE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMRE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMRE_PURCHASE_ID,
|
||||
'title' => AI1WMRE_PLUGIN_TITLE,
|
||||
'about' => AI1WMRE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMRE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMRE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMRE_VERSION,
|
||||
'requires' => '1.55',
|
||||
'short' => AI1WMRE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add Mega Extension
|
||||
if ( defined( 'AI1WMEE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMEE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMEE_PURCHASE_ID,
|
||||
'title' => AI1WMEE_PLUGIN_TITLE,
|
||||
'about' => AI1WMEE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMEE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMEE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMEE_VERSION,
|
||||
'requires' => '1.64',
|
||||
'short' => AI1WMEE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add Multisite Extension
|
||||
if ( defined( 'AI1WMME_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMME_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMME_PURCHASE_ID,
|
||||
'title' => AI1WMME_PLUGIN_TITLE,
|
||||
'about' => AI1WMME_PLUGIN_ABOUT,
|
||||
'check' => AI1WMME_PLUGIN_CHECK,
|
||||
'basename' => AI1WMME_PLUGIN_BASENAME,
|
||||
'version' => AI1WMME_VERSION,
|
||||
'requires' => '4.62',
|
||||
'short' => AI1WMME_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add OneDrive Extension
|
||||
if ( defined( 'AI1WMOE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMOE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMOE_PURCHASE_ID,
|
||||
'title' => AI1WMOE_PLUGIN_TITLE,
|
||||
'about' => AI1WMOE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMOE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMOE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMOE_VERSION,
|
||||
'requires' => '1.84',
|
||||
'short' => AI1WMOE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add pCloud Extension
|
||||
if ( defined( 'AI1WMPE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMPE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMPE_PURCHASE_ID,
|
||||
'title' => AI1WMPE_PLUGIN_TITLE,
|
||||
'about' => AI1WMPE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMPE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMPE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMPE_VERSION,
|
||||
'requires' => '1.56',
|
||||
'short' => AI1WMPE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add Pro Plugin
|
||||
if ( defined( 'AI1WMKE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMKE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMKE_PURCHASE_ID,
|
||||
'title' => AI1WMKE_PLUGIN_TITLE,
|
||||
'about' => AI1WMKE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMKE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMKE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMKE_VERSION,
|
||||
'requires' => '1.37',
|
||||
'short' => AI1WMKE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add S3 Client Extension
|
||||
if ( defined( 'AI1WMNE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMNE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMNE_PURCHASE_ID,
|
||||
'title' => AI1WMNE_PLUGIN_TITLE,
|
||||
'about' => AI1WMNE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMNE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMNE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMNE_VERSION,
|
||||
'requires' => '1.56',
|
||||
'short' => AI1WMNE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add Amazon S3 Extension
|
||||
if ( defined( 'AI1WMSE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMSE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMSE_PURCHASE_ID,
|
||||
'title' => AI1WMSE_PLUGIN_TITLE,
|
||||
'about' => AI1WMSE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMSE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMSE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMSE_VERSION,
|
||||
'requires' => '3.95',
|
||||
'short' => AI1WMSE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add Unlimited Extension
|
||||
if ( defined( 'AI1WMUE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMUE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMUE_PURCHASE_ID,
|
||||
'title' => AI1WMUE_PLUGIN_TITLE,
|
||||
'about' => AI1WMUE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMUE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMUE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMUE_VERSION,
|
||||
'requires' => '2.83',
|
||||
'short' => AI1WMUE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add URL Extension
|
||||
if ( defined( 'AI1WMLE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMLE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMLE_PURCHASE_ID,
|
||||
'title' => AI1WMLE_PLUGIN_TITLE,
|
||||
'about' => AI1WMLE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMLE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMLE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMLE_VERSION,
|
||||
'requires' => '2.79',
|
||||
'short' => AI1WMLE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add WebDAV Extension
|
||||
if ( defined( 'AI1WMWE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMWE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMWE_PURCHASE_ID,
|
||||
'title' => AI1WMWE_PLUGIN_TITLE,
|
||||
'about' => AI1WMWE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMWE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMWE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMWE_VERSION,
|
||||
'requires' => '1.50',
|
||||
'short' => AI1WMWE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
return $extensions;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Feedback {
|
||||
|
||||
/**
|
||||
* Submit customer feedback to servmask.com
|
||||
*
|
||||
* @param string $type Feedback type
|
||||
* @param string $email User e-mail
|
||||
* @param string $message User message
|
||||
* @param integer $terms User accept terms
|
||||
* @param string $purchases Purchases IDs
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function add( $type, $email, $message, $terms, $purchases ) {
|
||||
// Validate email
|
||||
if ( filter_var( $email, FILTER_VALIDATE_EMAIL ) === false ) {
|
||||
throw new Ai1wm_Feedback_Exception( esc_html__( 'Please enter a valid email address.', 'all-in-one-wp-migration' ) );
|
||||
}
|
||||
|
||||
// Validate type
|
||||
if ( empty( $type ) ) {
|
||||
throw new Ai1wm_Feedback_Exception( esc_html__( 'Please select a feedback type.', 'all-in-one-wp-migration' ) );
|
||||
}
|
||||
|
||||
// Validate message
|
||||
if ( empty( $message ) ) {
|
||||
throw new Ai1wm_Feedback_Exception( esc_html__( 'Please describe your issue or feedback.', 'all-in-one-wp-migration' ) );
|
||||
}
|
||||
|
||||
// Validate terms
|
||||
if ( empty( $terms ) ) {
|
||||
throw new Ai1wm_Feedback_Exception( esc_html__( 'Please check the consent box so we can use your email to respond to you.', 'all-in-one-wp-migration' ) );
|
||||
}
|
||||
|
||||
$response = wp_remote_post(
|
||||
AI1WM_FEEDBACK_URL,
|
||||
array(
|
||||
'timeout' => 15,
|
||||
'body' => array(
|
||||
'type' => $type,
|
||||
'email' => $email,
|
||||
'message' => $message,
|
||||
'purchases' => $purchases,
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
if ( is_wp_error( $response ) ) {
|
||||
/* translators: Error message. */
|
||||
throw new Ai1wm_Feedback_Exception( esc_html( sprintf( __( 'An error occurred while submitting your request: %s', 'all-in-one-wp-migration' ), $response->get_error_message() ) ) );
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Handler {
|
||||
|
||||
/**
|
||||
* Error handler
|
||||
*
|
||||
* @param integer $errno Error level
|
||||
* @param string $errstr Error message
|
||||
* @param string $errfile Error file
|
||||
* @param integer $errline Error line
|
||||
* @return void
|
||||
*/
|
||||
public static function error( $errno, $errstr, $errfile, $errline ) {
|
||||
global $ai1wm_params;
|
||||
if ( ! empty( $ai1wm_params['storage'] ) ) {
|
||||
Ai1wm_Log::error( $ai1wm_params['storage'], array( 'Number' => $errno, 'Message' => $errstr, 'File' => $errfile, 'Line' => $errline ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shutdown handler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function shutdown() {
|
||||
global $ai1wm_params;
|
||||
if ( ! empty( $ai1wm_params['storage'] ) ) {
|
||||
if ( ( $error = error_get_last() ) ) {
|
||||
Ai1wm_Log::error( $ai1wm_params['storage'], $error );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Log {
|
||||
|
||||
public static function error( $nonce, $params ) {
|
||||
$data = array();
|
||||
|
||||
// Add date
|
||||
$data[] = gmdate( 'M d Y H:i:s', time() );
|
||||
|
||||
// Add params
|
||||
$data[] = json_encode( $params );
|
||||
|
||||
// Add empty line
|
||||
$data[] = PHP_EOL;
|
||||
|
||||
// Write log data
|
||||
if ( $handle = ai1wm_open( ai1wm_error_path( $nonce ), 'a' ) ) {
|
||||
ai1wm_write( $handle, implode( PHP_EOL, $data ) );
|
||||
ai1wm_close( $handle );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Message {
|
||||
|
||||
public static function flash( $type, $message ) {
|
||||
if ( ( $messages = get_option( AI1WM_MESSAGES, array() ) ) !== false ) {
|
||||
return update_option( AI1WM_MESSAGES, array_merge( $messages, array( $type => $message ) ) );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function has( $type ) {
|
||||
if ( ( $messages = get_option( AI1WM_MESSAGES, array() ) ) ) {
|
||||
if ( isset( $messages[ $type ] ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function get( $type ) {
|
||||
$message = null;
|
||||
if ( ( $messages = get_option( AI1WM_MESSAGES, array() ) ) ) {
|
||||
if ( isset( $messages[ $type ] ) && ( $message = $messages[ $type ] ) ) {
|
||||
unset( $messages[ $type ] );
|
||||
}
|
||||
|
||||
// Set messages
|
||||
update_option( AI1WM_MESSAGES, $messages );
|
||||
}
|
||||
|
||||
return $message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Notification {
|
||||
|
||||
public static function ok( $subject, $message ) {
|
||||
// Enable notifications
|
||||
if ( ! apply_filters( 'ai1wm_notification_ok_toggle', false ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Set email
|
||||
if ( ! ( $email = apply_filters( 'ai1wm_notification_ok_email', get_option( 'admin_email', false ) ) ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Set subject
|
||||
if ( ! ( $subject = apply_filters( 'ai1wm_notification_ok_subject', $subject ) ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Set message
|
||||
if ( ! ( $message = apply_filters( 'ai1wm_notification_ok_message', $message ) ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Send email
|
||||
if ( ai1wm_is_scheduled_backup() ) {
|
||||
wp_mail( $email, $subject, $message, array( 'Content-Type: text/html; charset=UTF-8' ) );
|
||||
}
|
||||
}
|
||||
|
||||
public static function error( $subject, $message ) {
|
||||
// Enable notifications
|
||||
if ( ! apply_filters( 'ai1wm_notification_error_toggle', false ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Set email
|
||||
if ( ! ( $email = apply_filters( 'ai1wm_notification_error_email', get_option( 'admin_email', false ) ) ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Set subject
|
||||
if ( ! ( $subject = apply_filters( 'ai1wm_notification_error_subject', $subject ) ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Set message
|
||||
if ( ! ( $message = apply_filters( 'ai1wm_notification_error_message', $message ) ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Send email
|
||||
if ( ai1wm_is_scheduled_backup() ) {
|
||||
wp_mail( $email, $subject, $message, array( 'Content-Type: text/html; charset=UTF-8' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Status {
|
||||
|
||||
public static function error( $title, $message ) {
|
||||
self::log( array( 'type' => 'error', 'title' => $title, 'message' => $message ) );
|
||||
}
|
||||
|
||||
public static function left_error( $title, $message ) {
|
||||
self::log( array( 'type' => 'error', 'title' => $title, 'message' => $message, 'leftAligned' => true ) );
|
||||
}
|
||||
|
||||
public static function info( $message ) {
|
||||
self::log( array( 'type' => 'info', 'message' => $message ) );
|
||||
}
|
||||
|
||||
public static function download( $message ) {
|
||||
self::log( array( 'type' => 'download', 'message' => $message ) );
|
||||
}
|
||||
|
||||
public static function disk_space_confirm( $message ) {
|
||||
self::log( array( 'type' => 'disk_space_confirm', 'message' => $message ) );
|
||||
}
|
||||
|
||||
public static function confirm( $message ) {
|
||||
self::log( array( 'type' => 'confirm', 'message' => $message ) );
|
||||
}
|
||||
|
||||
public static function done( $title, $message = null ) {
|
||||
self::log( array( 'type' => 'done', 'title' => $title, 'message' => $message ) );
|
||||
}
|
||||
|
||||
public static function blogs( $title, $message ) {
|
||||
self::log( array( 'type' => 'blogs', 'title' => $title, 'message' => $message ) );
|
||||
}
|
||||
|
||||
public static function progress( $percent ) {
|
||||
self::log( array( 'type' => 'progress', 'percent' => $percent ) );
|
||||
}
|
||||
|
||||
public static function backup_is_encrypted( $error ) {
|
||||
self::log( array( 'type' => 'backup_is_encrypted', 'error' => $error ) );
|
||||
}
|
||||
|
||||
public static function server_cannot_decrypt( $message ) {
|
||||
self::log( array( 'type' => 'server_cannot_decrypt', 'message' => $message ) );
|
||||
}
|
||||
|
||||
public static function log( $data ) {
|
||||
if ( ! ai1wm_is_scheduled_backup() ) {
|
||||
update_option( AI1WM_STATUS, $data );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Template extends Bandar {
|
||||
|
||||
/**
|
||||
* Renders a file and returns its contents
|
||||
*
|
||||
* @param string $view View to render
|
||||
* @param array $args Set of arguments
|
||||
* @param string|bool $path Path to template
|
||||
* @return string Rendered view
|
||||
*/
|
||||
public static function render( $view, $args = array(), $path = false ) {
|
||||
parent::render( $view, $args, $path );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns link to an asset file
|
||||
*
|
||||
* @param string $asset Asset file
|
||||
* @param string $prefix Asset prefix
|
||||
* @return string Asset URL
|
||||
*/
|
||||
public static function asset_link( $asset, $prefix = 'AI1WM' ) {
|
||||
return constant( $prefix . '_URL' ) . '/lib/view/assets/' . $asset . '?v=' . constant( $prefix . '_VERSION' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a file and gets its contents
|
||||
*
|
||||
* @param string $view View to render
|
||||
* @param array $args Set of arguments
|
||||
* @param string|bool $path Path to template
|
||||
* @return string Rendered view
|
||||
*/
|
||||
public static function get_content( $view, $args = array(), $path = false ) {
|
||||
return parent::getTemplateContent( $view, $args, $path );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Updater {
|
||||
|
||||
/**
|
||||
* Retrieve plugin installer pages from WordPress Plugins API.
|
||||
*
|
||||
* @param mixed $result
|
||||
* @param string $action
|
||||
* @param array|object $args
|
||||
* @return mixed
|
||||
*/
|
||||
public static function plugins_api( $result, $action = null, $args = null ) {
|
||||
if ( empty( $args->slug ) ) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
// Get extensions
|
||||
$extensions = Ai1wm_Extensions::get();
|
||||
|
||||
// View details page
|
||||
if ( isset( $extensions[ $args->slug ] ) && $action === 'plugin_information' ) {
|
||||
$updater = get_option( AI1WM_UPDATER, array() );
|
||||
|
||||
// Plugin details
|
||||
if ( isset( $updater[ $args->slug ] ) ) {
|
||||
return (object) $updater[ $args->slug ];
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update WordPress plugin list page.
|
||||
*
|
||||
* @param object $transient
|
||||
* @return object
|
||||
*/
|
||||
public static function update_plugins( $transient ) {
|
||||
global $wp_version;
|
||||
|
||||
// Creating default object from empty value
|
||||
if ( ! is_object( $transient ) ) {
|
||||
$transient = (object) array();
|
||||
}
|
||||
|
||||
// Get extensions
|
||||
$extensions = Ai1wm_Extensions::get();
|
||||
|
||||
// Get current updates
|
||||
$updater = get_option( AI1WM_UPDATER, array() );
|
||||
|
||||
// Get extension updates
|
||||
foreach ( $updater as $slug => $update ) {
|
||||
if ( isset( $extensions[ $slug ], $update['version'], $update['homepage'], $update['download_link'], $update['icons'] ) ) {
|
||||
|
||||
// Get download URL
|
||||
$download_url = add_query_arg( array( 'siteurl' => get_site_url() ), sprintf( '%s/%s', $update['download_link'], $extensions[ $slug ]['key'] ) );
|
||||
|
||||
// Set plugin details
|
||||
$plugin_details = (object) array(
|
||||
'slug' => $slug,
|
||||
'new_version' => $update['version'],
|
||||
'url' => $update['homepage'],
|
||||
'plugin' => $extensions[ $slug ]['basename'],
|
||||
'package' => $download_url,
|
||||
'tested' => $wp_version,
|
||||
'icons' => $update['icons'],
|
||||
);
|
||||
|
||||
// Enable auto updates
|
||||
if ( version_compare( $extensions[ $slug ]['version'], $update['version'], '<' ) ) {
|
||||
$transient->response[ $extensions[ $slug ]['basename'] ] = $plugin_details;
|
||||
} else {
|
||||
$transient->no_update[ $extensions[ $slug ]['basename'] ] = $plugin_details;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $transient;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for extension updates
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function check_for_updates() {
|
||||
$updater = get_option( AI1WM_UPDATER, array() );
|
||||
|
||||
// Get extension updates
|
||||
foreach ( Ai1wm_Extensions::get() as $slug => $extension ) {
|
||||
$about = wp_remote_get(
|
||||
$extension['about'],
|
||||
array(
|
||||
'timeout' => 15,
|
||||
'headers' => array( 'Accept' => 'application/json' ),
|
||||
)
|
||||
);
|
||||
|
||||
// Add plugin updates
|
||||
if ( is_wp_error( $about ) ) {
|
||||
$updater[ $slug ]['error_message'] = $about->get_error_message();
|
||||
} else {
|
||||
$body = wp_remote_retrieve_body( $about );
|
||||
if ( ( $data = json_decode( $body, true ) ) ) {
|
||||
if ( isset( $data['slug'], $data['version'], $data['homepage'], $data['download_link'], $data['icons'] ) ) {
|
||||
$updater[ $slug ] = $data;
|
||||
}
|
||||
}
|
||||
|
||||
// Add plugin messages
|
||||
$check = wp_remote_get(
|
||||
add_query_arg( array( 'site_url' => get_site_url(), 'admin_email' => get_option( 'admin_email' ) ), sprintf( '%s/%s', $extension['check'], $extension['key'] ) ),
|
||||
array(
|
||||
'timeout' => 15,
|
||||
'headers' => array( 'Accept' => 'application/json' ),
|
||||
)
|
||||
);
|
||||
|
||||
// Add plugin checks
|
||||
if ( is_wp_error( $check ) ) {
|
||||
$updater[ $slug ]['error_message'] = $check->get_error_message();
|
||||
} else {
|
||||
$body = wp_remote_retrieve_body( $check );
|
||||
if ( ( $data = json_decode( $body, true ) ) ) {
|
||||
if ( isset( $updater[ $slug ], $data['message'] ) ) {
|
||||
$updater[ $slug ]['update_message'] = $data['message'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return update_option( AI1WM_UPDATER, $updater );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add "Check for updates" link
|
||||
*
|
||||
* @param array $plugin_meta An array of the plugin's metadata, including the version, author, author URI, and plugin URI
|
||||
* @param string $plugin_file Path to the plugin file relative to the plugins directory
|
||||
* @return array
|
||||
*/
|
||||
public static function plugin_row_meta( $plugin_meta, $plugin_file ) {
|
||||
$updater = get_option( AI1WM_UPDATER, array() );
|
||||
|
||||
// Add link for each extension
|
||||
foreach ( Ai1wm_Extensions::get() as $slug => $extension ) {
|
||||
if ( $plugin_file === $extension['basename'] ) {
|
||||
|
||||
// Get updater URL
|
||||
$updater_url = add_query_arg( array( 'ai1wm_check_for_updates' => 1, 'ai1wm_nonce' => wp_create_nonce( 'ai1wm_check_for_updates' ) ), network_admin_url( 'plugins.php' ) );
|
||||
|
||||
// Check for updates
|
||||
$plugin_meta[] = Ai1wm_Template::get_content( 'updater/check', array( 'url' => $updater_url ) );
|
||||
|
||||
// Check error message
|
||||
if ( isset( $updater[ $slug ]['error_message'] ) ) {
|
||||
$plugin_meta[] = Ai1wm_Template::get_content( 'updater/error', array( 'message' => $updater[ $slug ]['error_message'] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $plugin_meta;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Export_Archive_Crc {
|
||||
|
||||
public static function execute( $params ) {
|
||||
$archive_bytes_read = 0;
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Calculating archive checksum...', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Set archive bytes remaining
|
||||
if ( isset( $params['archive_bytes_remaining'] ) ) {
|
||||
$archive_bytes_remaining = (int) $params['archive_bytes_remaining'];
|
||||
} else {
|
||||
$archive_bytes_remaining = ai1wm_archive_bytes( $params );
|
||||
}
|
||||
|
||||
// Set archive bytes offset
|
||||
if ( isset( $params['archive_bytes_offset'] ) ) {
|
||||
$archive_bytes_offset = (int) $params['archive_bytes_offset'];
|
||||
} else {
|
||||
$archive_bytes_offset = 0;
|
||||
}
|
||||
|
||||
// Set archive CRC value
|
||||
$archive_crc_value = null;
|
||||
if ( isset( $params['archive_crc_value'] ) ) {
|
||||
$archive_crc_value = $params['archive_crc_value'];
|
||||
}
|
||||
|
||||
// Flag to hold if file data has been processed
|
||||
$completed = true;
|
||||
|
||||
// Start time
|
||||
$start = microtime( true );
|
||||
|
||||
// Initialize CRC context for this chunk
|
||||
$hash_ctx = Ai1wm_Crc::init_crc32();
|
||||
|
||||
// Open archive for reading
|
||||
if ( ( $file_handle = ai1wm_open( ai1wm_archive_path( $params ), 'rb' ) ) ) {
|
||||
if ( fseek( $file_handle, $archive_bytes_offset, SEEK_SET ) !== -1 ) {
|
||||
|
||||
// Process file in chunks
|
||||
while ( $archive_bytes_remaining > 0 ) {
|
||||
if ( ( $file_content = ai1wm_read( $file_handle, min( Ai1wm_Archiver::READ_CHUNK_SIZE, $archive_bytes_remaining ) ) ) !== false ) {
|
||||
|
||||
// Empty read indicates EOF
|
||||
if ( strlen( $file_content ) === 0 ) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Add the amount of bytes we read
|
||||
$archive_bytes_read += strlen( $file_content );
|
||||
|
||||
// Subtract the amount of bytes we read
|
||||
$archive_bytes_remaining -= strlen( $file_content );
|
||||
|
||||
// Update CRC with original content
|
||||
Ai1wm_Crc::update_crc32( $hash_ctx, $file_content );
|
||||
}
|
||||
|
||||
// Time elapsed
|
||||
if ( ( $timeout = apply_filters( 'ai1wm_completed_timeout', 10 ) ) ) {
|
||||
if ( ( microtime( true ) - $start ) > $timeout ) {
|
||||
$completed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get archive bytes offset
|
||||
$archive_bytes_offset += $archive_bytes_read;
|
||||
}
|
||||
|
||||
ai1wm_close( $file_handle );
|
||||
}
|
||||
|
||||
// Combine and finalize CRC
|
||||
if ( empty( $archive_crc_value ) ) {
|
||||
$params['archive_crc_value'] = Ai1wm_Crc::finalize_crc32( $hash_ctx );
|
||||
} else {
|
||||
$params['archive_crc_value'] = Ai1wm_Crc::combine_crc32( $archive_crc_value, Ai1wm_Crc::finalize_crc32( $hash_ctx ), $archive_bytes_read );
|
||||
}
|
||||
|
||||
// End of the archive file?
|
||||
if ( $completed ) {
|
||||
|
||||
// St archive bytes remaining
|
||||
unset( $params['archive_bytes_remaining'] );
|
||||
|
||||
// Unset archive offset
|
||||
unset( $params['archive_bytes_offset'] );
|
||||
|
||||
// Unset completed flag
|
||||
unset( $params['completed'] );
|
||||
|
||||
} else {
|
||||
|
||||
// St archive bytes remaining
|
||||
$params['archive_bytes_remaining'] = $archive_bytes_remaining;
|
||||
|
||||
// Set archive offset
|
||||
$params['archive_bytes_offset'] = $archive_bytes_offset;
|
||||
|
||||
// Set completed flag
|
||||
$params['completed'] = $completed;
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Export_Archive {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
do_action( 'ai1wm_status_export_start', $params );
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Creating export file...', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Create empty archive file
|
||||
$archive = new Ai1wm_Compressor( ai1wm_archive_path( $params ) );
|
||||
$archive->close();
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Export file created.', 'all-in-one-wp-migration' ) );
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Export_Clean {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
// Delete storage files
|
||||
Ai1wm_Directory::delete( ai1wm_storage_path( $params ) );
|
||||
|
||||
if ( isset( $params['ai1wm_export_cancel'] ) ) {
|
||||
do_action( 'ai1wm_status_export_canceled', $params );
|
||||
}
|
||||
|
||||
// Exit in console
|
||||
if ( defined( 'WP_CLI' ) ) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Export_Compatibility {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Checking for compatibility...', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Get messages
|
||||
$messages = Ai1wm_Compatibility::get( $params );
|
||||
|
||||
// Set messages
|
||||
if ( empty( $messages ) ) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
// Error message
|
||||
throw new Ai1wm_Compatibility_Exception( wp_kses( implode( $messages ), ai1wm_allowed_html_tags() ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Export_Config_File {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Archiving configuration...', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Open the archive file for writing
|
||||
$archive = new Ai1wm_Compressor( ai1wm_archive_path( $params ) );
|
||||
|
||||
// Add package.json to archive
|
||||
$archive->add_file( ai1wm_package_path( $params ), AI1WM_PACKAGE_NAME );
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Configuration archived.', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Truncate the archive file
|
||||
$archive->truncate();
|
||||
|
||||
// Close the archive file
|
||||
$archive->close();
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Export_Config {
|
||||
|
||||
public static function execute( $params ) {
|
||||
global $table_prefix, $wp_version;
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Preparing configuration...', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Get options
|
||||
$options = wp_load_alloptions();
|
||||
|
||||
// Get database client
|
||||
$db_client = Ai1wm_Database_Utility::get_client();
|
||||
|
||||
$config = array();
|
||||
|
||||
// Set site URL
|
||||
$config['SiteURL'] = site_url();
|
||||
|
||||
// Set home URL
|
||||
$config['HomeURL'] = home_url();
|
||||
|
||||
// Set internal site URL
|
||||
if ( isset( $options['siteurl'] ) ) {
|
||||
$config['InternalSiteURL'] = $options['siteurl'];
|
||||
}
|
||||
|
||||
// Set internal home URL
|
||||
if ( isset( $options['home'] ) ) {
|
||||
$config['InternalHomeURL'] = $options['home'];
|
||||
}
|
||||
|
||||
// Set replace old and new values
|
||||
if ( isset( $params['options']['replace'] ) && ( $replace = $params['options']['replace'] ) ) {
|
||||
for ( $i = 0; $i < count( $replace['old_value'] ); $i++ ) {
|
||||
if ( ! empty( $replace['old_value'][ $i ] ) && ! empty( $replace['new_value'][ $i ] ) ) {
|
||||
$config['Replace']['OldValues'][] = $replace['old_value'][ $i ];
|
||||
$config['Replace']['NewValues'][] = $replace['new_value'][ $i ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set no spam comments
|
||||
if ( isset( $params['options']['no_spam_comments'] ) ) {
|
||||
$config['NoSpamComments'] = true;
|
||||
}
|
||||
|
||||
// Set no post revisions
|
||||
if ( isset( $params['options']['no_post_revisions'] ) ) {
|
||||
$config['NoPostRevisions'] = true;
|
||||
}
|
||||
|
||||
// Set no media
|
||||
if ( isset( $params['options']['no_media'] ) ) {
|
||||
$config['NoMedia'] = true;
|
||||
}
|
||||
|
||||
// Set no themes
|
||||
if ( isset( $params['options']['no_themes'] ) ) {
|
||||
$config['NoThemes'] = true;
|
||||
}
|
||||
|
||||
// Set no inactive themes
|
||||
if ( isset( $params['options']['no_inactive_themes'] ) ) {
|
||||
$config['NoInactiveThemes'] = true;
|
||||
}
|
||||
|
||||
// Set no must-use plugins
|
||||
if ( isset( $params['options']['no_muplugins'] ) ) {
|
||||
$config['NoMustUsePlugins'] = true;
|
||||
}
|
||||
|
||||
// Set no plugins
|
||||
if ( isset( $params['options']['no_plugins'] ) ) {
|
||||
$config['NoPlugins'] = true;
|
||||
}
|
||||
|
||||
// Set no inactive plugins
|
||||
if ( isset( $params['options']['no_inactive_plugins'] ) ) {
|
||||
$config['NoInactivePlugins'] = true;
|
||||
}
|
||||
|
||||
// Set no cache
|
||||
if ( isset( $params['options']['no_cache'] ) ) {
|
||||
$config['NoCache'] = true;
|
||||
}
|
||||
|
||||
// Set no database
|
||||
if ( isset( $params['options']['no_database'] ) ) {
|
||||
$config['NoDatabase'] = true;
|
||||
}
|
||||
|
||||
// Set no email replace
|
||||
if ( isset( $params['options']['no_email_replace'] ) ) {
|
||||
$config['NoEmailReplace'] = true;
|
||||
}
|
||||
|
||||
// Set plugin version
|
||||
$config['Plugin'] = array( 'Version' => AI1WM_VERSION );
|
||||
|
||||
// Set WordPress version and content
|
||||
$config['WordPress'] = array( 'Version' => $wp_version, 'Absolute' => ABSPATH, 'Content' => WP_CONTENT_DIR, 'Plugins' => ai1wm_get_plugins_dir(), 'Themes' => ai1wm_get_themes_dirs(), 'Uploads' => ai1wm_get_uploads_dir(), 'UploadsURL' => ai1wm_get_uploads_url() );
|
||||
|
||||
// Set database version
|
||||
$config['Database'] = array(
|
||||
'Version' => $db_client->server_info(),
|
||||
'Charset' => defined( 'DB_CHARSET' ) ? DB_CHARSET : 'undefined',
|
||||
'Collate' => defined( 'DB_COLLATE' ) ? DB_COLLATE : 'undefined',
|
||||
'Prefix' => $table_prefix,
|
||||
);
|
||||
|
||||
// Exclude selected db tables
|
||||
if ( isset( $params['options']['exclude_db_tables'], $params['excluded_db_tables'] ) ) {
|
||||
if ( ( $excluded_db_tables = explode( ',', $params['excluded_db_tables'] ) ) ) {
|
||||
$config['Database']['ExcludedTables'] = $excluded_db_tables;
|
||||
}
|
||||
}
|
||||
|
||||
// Include selected db tables
|
||||
if ( isset( $params['options']['include_db_tables'], $params['included_db_tables'] ) ) {
|
||||
if ( ( $included_db_tables = explode( ',', $params['included_db_tables'] ) ) ) {
|
||||
$config['Database']['IncludedTables'] = $included_db_tables;
|
||||
}
|
||||
}
|
||||
|
||||
// Set PHP version
|
||||
$config['PHP'] = array( 'Version' => PHP_VERSION, 'System' => PHP_OS, 'Integer' => PHP_INT_SIZE );
|
||||
|
||||
// Set active plugins
|
||||
$config['Plugins'] = array_values( array_diff( ai1wm_active_plugins(), ai1wm_active_servmask_plugins() ) );
|
||||
|
||||
// Set active template
|
||||
$config['Template'] = ai1wm_active_template();
|
||||
|
||||
// Set active stylesheet
|
||||
$config['Stylesheet'] = ai1wm_active_stylesheet();
|
||||
|
||||
// Set upload path
|
||||
$config['Uploads'] = get_option( 'upload_path' );
|
||||
|
||||
// Set upload URL path
|
||||
$config['UploadsURL'] = get_option( 'upload_url_path' );
|
||||
|
||||
// Set server info
|
||||
$config['Server'] = array( '.htaccess' => base64_encode( ai1wm_get_htaccess() ), 'web.config' => base64_encode( ai1wm_get_webconfig() ) );
|
||||
|
||||
// Set encrypt backups
|
||||
if ( isset( $params['options']['encrypt_backups'] ) ) {
|
||||
$config['Encrypted'] = true;
|
||||
}
|
||||
|
||||
// Set encrypt password
|
||||
if ( isset( $params['options']['encrypt_password'] ) ) {
|
||||
$config['EncryptedSignature'] = base64_encode( ai1wm_encrypt_string( AI1WM_SIGN_TEXT, $params['options']['encrypt_password'] ) );
|
||||
}
|
||||
|
||||
// Set compression type
|
||||
if ( ! empty( $params['options']['compression_type'] ) ) {
|
||||
$config['Compression'] = array( 'Enabled' => true, 'Type' => $params['options']['compression_type'] );
|
||||
}
|
||||
|
||||
// Save package.json file
|
||||
$handle = ai1wm_open( ai1wm_package_path( $params ), 'w' );
|
||||
ai1wm_write( $handle, json_encode( $config ) );
|
||||
ai1wm_close( $handle );
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Configuration prepared.', 'all-in-one-wp-migration' ) );
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Export_Content {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
// Set encrypt password
|
||||
$encrypt_password = null;
|
||||
if ( isset( $params['options']['encrypt_backups'], $params['options']['encrypt_password'] ) ) {
|
||||
$encrypt_password = $params['options']['encrypt_password'];
|
||||
}
|
||||
|
||||
// Set compression type
|
||||
$compression_type = null;
|
||||
if ( isset( $params['options']['compression_type'] ) ) {
|
||||
$compression_type = $params['options']['compression_type'];
|
||||
}
|
||||
|
||||
// Set archive bytes offset
|
||||
if ( isset( $params['archive_bytes_offset'] ) ) {
|
||||
$archive_bytes_offset = (int) $params['archive_bytes_offset'];
|
||||
} else {
|
||||
$archive_bytes_offset = ai1wm_archive_bytes( $params );
|
||||
}
|
||||
|
||||
// Set file bytes offset
|
||||
if ( isset( $params['file_bytes_offset'] ) ) {
|
||||
$file_bytes_offset = (int) $params['file_bytes_offset'];
|
||||
} else {
|
||||
$file_bytes_offset = 0;
|
||||
}
|
||||
|
||||
// Set file bytes written
|
||||
if ( isset( $params['file_bytes_written'] ) ) {
|
||||
$file_bytes_written = (int) $params['file_bytes_written'];
|
||||
} else {
|
||||
$file_bytes_written = 0;
|
||||
}
|
||||
|
||||
// Set content bytes offset
|
||||
if ( isset( $params['content_bytes_offset'] ) ) {
|
||||
$content_bytes_offset = (int) $params['content_bytes_offset'];
|
||||
} else {
|
||||
$content_bytes_offset = 0;
|
||||
}
|
||||
|
||||
// Get processed files size
|
||||
if ( isset( $params['processed_files_size'] ) ) {
|
||||
$processed_files_size = (int) $params['processed_files_size'];
|
||||
} else {
|
||||
$processed_files_size = 0;
|
||||
}
|
||||
|
||||
// Get total content files size
|
||||
if ( isset( $params['total_content_files_size'] ) ) {
|
||||
$total_content_files_size = (int) $params['total_content_files_size'];
|
||||
} else {
|
||||
$total_content_files_size = 1;
|
||||
}
|
||||
|
||||
// Get total content files count
|
||||
if ( isset( $params['total_content_files_count'] ) ) {
|
||||
$total_content_files_count = (int) $params['total_content_files_count'];
|
||||
} else {
|
||||
$total_content_files_count = 1;
|
||||
}
|
||||
|
||||
// Set file CRC
|
||||
if ( isset( $params['file_crc'] ) ) {
|
||||
$file_crc = $params['file_crc'];
|
||||
} else {
|
||||
$file_crc = null;
|
||||
}
|
||||
|
||||
// What percent of files have we processed?
|
||||
$progress = (int) min( ( $processed_files_size / $total_content_files_size ) * 100, 100 );
|
||||
|
||||
// Set progress
|
||||
/* translators: 1: Number of files, 2: Progress. */
|
||||
Ai1wm_Status::info( sprintf( __( 'Archiving %1$d content files...<br />%2$d%% complete', 'all-in-one-wp-migration' ), $total_content_files_count, $progress ) );
|
||||
|
||||
// Flag to hold if file data has been processed
|
||||
$completed = true;
|
||||
|
||||
// Start time
|
||||
$start = microtime( true );
|
||||
|
||||
// Get content list file
|
||||
$content_list = ai1wm_open( ai1wm_content_list_path( $params ), 'r' );
|
||||
|
||||
// Set the file pointer at the current index
|
||||
if ( fseek( $content_list, $content_bytes_offset ) !== -1 ) {
|
||||
|
||||
// Open the archive file for writing
|
||||
$archive = new Ai1wm_Compressor( ai1wm_archive_path( $params ), $encrypt_password, $compression_type );
|
||||
|
||||
// Set the file pointer to the one that we have saved
|
||||
$archive->set_file_pointer( $archive_bytes_offset );
|
||||
|
||||
// Loop over files
|
||||
while ( ( $row = ai1wm_getcsv( $content_list ) ) !== false ) {
|
||||
list( $file_abspath, $file_relpath, $file_size, $file_mtime ) = $row;
|
||||
$file_bytes_read = 0;
|
||||
|
||||
// Add file to archive
|
||||
if ( ( $completed = $archive->add_file( $file_abspath, $file_relpath, $file_bytes_read, $file_bytes_offset, $file_bytes_written, $file_crc ) ) ) {
|
||||
$file_crc = null;
|
||||
|
||||
// Reset file bytes
|
||||
$file_bytes_offset = $file_bytes_written = 0;
|
||||
|
||||
// Get content bytes offset
|
||||
$content_bytes_offset = ftell( $content_list );
|
||||
}
|
||||
|
||||
// Increment processed files size
|
||||
$processed_files_size += $file_bytes_read;
|
||||
|
||||
// What percent of files have we processed?
|
||||
$progress = (int) min( ( $processed_files_size / $total_content_files_size ) * 100, 100 );
|
||||
|
||||
// Set progress
|
||||
/* translators: 1: Number of files, 2: Progress. */
|
||||
Ai1wm_Status::info( sprintf( __( 'Archiving %1$d content files...<br />%2$d%% complete', 'all-in-one-wp-migration' ), $total_content_files_count, $progress ) );
|
||||
|
||||
// More than 10 seconds have passed, break and do another request
|
||||
if ( ( $timeout = apply_filters( 'ai1wm_completed_timeout', 10 ) ) ) {
|
||||
if ( ( microtime( true ) - $start ) > $timeout ) {
|
||||
$completed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get archive bytes offset
|
||||
$archive_bytes_offset = $archive->get_file_pointer();
|
||||
|
||||
// Truncate the archive file
|
||||
$archive->truncate();
|
||||
|
||||
// Close the archive file
|
||||
$archive->close();
|
||||
}
|
||||
|
||||
// End of the content list?
|
||||
if ( feof( $content_list ) ) {
|
||||
|
||||
// Unset archive bytes offset
|
||||
unset( $params['archive_bytes_offset'] );
|
||||
|
||||
// Unset file bytes offset
|
||||
unset( $params['file_bytes_offset'] );
|
||||
|
||||
// Unset file bytes written
|
||||
unset( $params['file_bytes_written'] );
|
||||
|
||||
// Unset content bytes offset
|
||||
unset( $params['content_bytes_offset'] );
|
||||
|
||||
// Unset processed files size
|
||||
unset( $params['processed_files_size'] );
|
||||
|
||||
// Unset total content files size
|
||||
unset( $params['total_content_files_size'] );
|
||||
|
||||
// Unset total content files count
|
||||
unset( $params['total_content_files_count'] );
|
||||
|
||||
// Unset file CRC
|
||||
unset( $params['file_crc'] );
|
||||
|
||||
// Unset completed flag
|
||||
unset( $params['completed'] );
|
||||
|
||||
} else {
|
||||
|
||||
// Set archive bytes offset
|
||||
$params['archive_bytes_offset'] = $archive_bytes_offset;
|
||||
|
||||
// Set file bytes offset
|
||||
$params['file_bytes_offset'] = $file_bytes_offset;
|
||||
|
||||
// Set file bytes written
|
||||
$params['file_bytes_written'] = $file_bytes_written;
|
||||
|
||||
// Set content bytes offset
|
||||
$params['content_bytes_offset'] = $content_bytes_offset;
|
||||
|
||||
// Set processed files size
|
||||
$params['processed_files_size'] = $processed_files_size;
|
||||
|
||||
// Set total content files size
|
||||
$params['total_content_files_size'] = $total_content_files_size;
|
||||
|
||||
// Set total content files count
|
||||
$params['total_content_files_count'] = $total_content_files_count;
|
||||
|
||||
// Set file CRC
|
||||
$params['file_crc'] = $file_crc;
|
||||
|
||||
// Set completed flag
|
||||
$params['completed'] = $completed;
|
||||
}
|
||||
|
||||
// Close the content list file
|
||||
ai1wm_close( $content_list );
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Export_Database_File {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
// Set exclude database
|
||||
if ( isset( $params['options']['no_database'] ) ) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
$database_bytes_read = 0;
|
||||
|
||||
// Set encrypt password
|
||||
$encrypt_password = null;
|
||||
if ( isset( $params['options']['encrypt_backups'], $params['options']['encrypt_password'] ) ) {
|
||||
$encrypt_password = $params['options']['encrypt_password'];
|
||||
}
|
||||
|
||||
// Set compression type
|
||||
$compression_type = null;
|
||||
if ( isset( $params['options']['compression_type'] ) ) {
|
||||
$compression_type = $params['options']['compression_type'];
|
||||
}
|
||||
|
||||
// Set archive bytes offset
|
||||
if ( isset( $params['archive_bytes_offset'] ) ) {
|
||||
$archive_bytes_offset = (int) $params['archive_bytes_offset'];
|
||||
} else {
|
||||
$archive_bytes_offset = ai1wm_archive_bytes( $params );
|
||||
}
|
||||
|
||||
// Set database bytes offset
|
||||
if ( isset( $params['database_bytes_offset'] ) ) {
|
||||
$database_bytes_offset = (int) $params['database_bytes_offset'];
|
||||
} else {
|
||||
$database_bytes_offset = 0;
|
||||
}
|
||||
|
||||
// Set database bytes written
|
||||
if ( isset( $params['database_bytes_written'] ) ) {
|
||||
$database_bytes_written = (int) $params['database_bytes_written'];
|
||||
} else {
|
||||
$database_bytes_written = 0;
|
||||
}
|
||||
|
||||
// Set database CRC
|
||||
if ( isset( $params['database_crc'] ) ) {
|
||||
$database_crc = $params['database_crc'];
|
||||
} else {
|
||||
$database_crc = null;
|
||||
}
|
||||
|
||||
// Get total database size
|
||||
if ( isset( $params['total_database_size'] ) ) {
|
||||
$total_database_size = (int) $params['total_database_size'];
|
||||
} else {
|
||||
$total_database_size = ai1wm_database_bytes( $params );
|
||||
}
|
||||
|
||||
// What percent of database have we processed?
|
||||
$progress = (int) min( ( $database_bytes_offset / $total_database_size ) * 100, 100 );
|
||||
|
||||
// Set progress
|
||||
/* translators: Progress. */
|
||||
Ai1wm_Status::info( sprintf( __( 'Archiving database...<br />%d%% complete', 'all-in-one-wp-migration' ), $progress ) );
|
||||
|
||||
// Open the archive file for writing
|
||||
$archive = new Ai1wm_Compressor( ai1wm_archive_path( $params ), $encrypt_password, $compression_type );
|
||||
|
||||
// Set the file pointer to the one that we have saved
|
||||
$archive->set_file_pointer( $archive_bytes_offset );
|
||||
|
||||
// Add database.sql to archive
|
||||
if ( $archive->add_file( ai1wm_database_path( $params ), AI1WM_DATABASE_NAME, $database_bytes_read, $database_bytes_offset, $database_bytes_written, $database_crc ) ) {
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Database archived.', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Unset archive bytes offset
|
||||
unset( $params['archive_bytes_offset'] );
|
||||
|
||||
// Unset database bytes offset
|
||||
unset( $params['database_bytes_offset'] );
|
||||
|
||||
// Unset database bytes written
|
||||
unset( $params['database_bytes_written'] );
|
||||
|
||||
// Unset database CRC
|
||||
unset( $params['database_crc'] );
|
||||
|
||||
// Unset total database size
|
||||
unset( $params['total_database_size'] );
|
||||
|
||||
// Unset completed flag
|
||||
unset( $params['completed'] );
|
||||
|
||||
} else {
|
||||
|
||||
// Get archive bytes offset
|
||||
$archive_bytes_offset = $archive->get_file_pointer();
|
||||
|
||||
// What percent of database have we processed?
|
||||
$progress = (int) min( ( $database_bytes_offset / $total_database_size ) * 100, 100 );
|
||||
|
||||
// Set progress
|
||||
/* translators: Progress. */
|
||||
Ai1wm_Status::info( sprintf( __( 'Archiving database...<br />%d%% complete', 'all-in-one-wp-migration' ), $progress ) );
|
||||
|
||||
// Set archive bytes offset
|
||||
$params['archive_bytes_offset'] = $archive_bytes_offset;
|
||||
|
||||
// Set database bytes offset
|
||||
$params['database_bytes_offset'] = $database_bytes_offset;
|
||||
|
||||
// Set database bytes written
|
||||
$params['database_bytes_written'] = $database_bytes_written;
|
||||
|
||||
// Set database CRC
|
||||
$params['database_crc'] = $database_crc;
|
||||
|
||||
// Set total database size
|
||||
$params['total_database_size'] = $total_database_size;
|
||||
|
||||
// Set completed flag
|
||||
$params['completed'] = false;
|
||||
}
|
||||
|
||||
// Truncate the archive file
|
||||
$archive->truncate();
|
||||
|
||||
// Close the archive file
|
||||
$archive->close();
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Export_Database {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
// Set exclude database
|
||||
if ( isset( $params['options']['no_database'] ) ) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
// Set query offset
|
||||
if ( isset( $params['query_offset'] ) ) {
|
||||
$query_offset = (int) $params['query_offset'];
|
||||
} else {
|
||||
$query_offset = 0;
|
||||
}
|
||||
|
||||
// Set table index
|
||||
if ( isset( $params['table_index'] ) ) {
|
||||
$table_index = (int) $params['table_index'];
|
||||
} else {
|
||||
$table_index = 0;
|
||||
}
|
||||
|
||||
// Set table offset
|
||||
if ( isset( $params['table_offset'] ) ) {
|
||||
$table_offset = (int) $params['table_offset'];
|
||||
} else {
|
||||
$table_offset = 0;
|
||||
}
|
||||
|
||||
// Set table rows
|
||||
if ( isset( $params['table_rows'] ) ) {
|
||||
$table_rows = (int) $params['table_rows'];
|
||||
} else {
|
||||
$table_rows = 0;
|
||||
}
|
||||
|
||||
// Set total tables count
|
||||
if ( isset( $params['total_tables_count'] ) ) {
|
||||
$total_tables_count = (int) $params['total_tables_count'];
|
||||
} else {
|
||||
$total_tables_count = 1;
|
||||
}
|
||||
|
||||
// What percent of tables have we processed?
|
||||
$progress = (int) ( ( $table_index / $total_tables_count ) * 100 );
|
||||
|
||||
// Set progress
|
||||
/* translators: 1: Progress, 2: Number of records. */
|
||||
Ai1wm_Status::info( sprintf( __( 'Exporting database...<br />%1$d%% complete<br />%2$s records saved', 'all-in-one-wp-migration' ), $progress, number_format_i18n( $table_rows ) ) );
|
||||
|
||||
// Get tables list file
|
||||
$tables_list = ai1wm_open( ai1wm_tables_list_path( $params ), 'r' );
|
||||
|
||||
// Loop over tables
|
||||
$tables = array();
|
||||
while ( ( $row = ai1wm_getcsv( $tables_list ) ) !== false ) {
|
||||
list( $table_name ) = $row;
|
||||
$tables[] = $table_name; // phpcs:ignore Generic.Formatting.MultipleStatementAlignment.NotSameWarning
|
||||
}
|
||||
|
||||
// Close the tables list file
|
||||
ai1wm_close( $tables_list );
|
||||
|
||||
// Get database client
|
||||
$db_client = Ai1wm_Database_Utility::get_client();
|
||||
|
||||
// Exclude spam comments
|
||||
if ( isset( $params['options']['no_spam_comments'] ) ) {
|
||||
$db_client->set_table_where_query( ai1wm_table_prefix() . 'comments', "`comment_approved` != 'spam'" )
|
||||
->set_table_where_query( ai1wm_table_prefix() . 'commentmeta', sprintf( "`comment_ID` IN ( SELECT `comment_ID` FROM `%s` WHERE `comment_approved` != 'spam' )", ai1wm_table_prefix() . 'comments' ) );
|
||||
}
|
||||
|
||||
// Exclude post revisions
|
||||
if ( isset( $params['options']['no_post_revisions'] ) ) {
|
||||
$db_client->set_table_where_query( ai1wm_table_prefix() . 'posts', "`post_type` != 'revision'" )
|
||||
->set_table_where_query( ai1wm_table_prefix() . 'postmeta', sprintf( "`post_id` IN ( SELECT `ID` FROM `%s` WHERE `post_type` != 'revision' )", ai1wm_table_prefix() . 'posts' ) );
|
||||
}
|
||||
|
||||
$old_table_prefixes = $old_column_prefixes = array();
|
||||
$new_table_prefixes = $new_column_prefixes = array();
|
||||
|
||||
// Set table prefixes
|
||||
if ( ai1wm_table_prefix() ) {
|
||||
$old_table_prefixes[] = ai1wm_table_prefix();
|
||||
$new_table_prefixes[] = ai1wm_servmask_prefix();
|
||||
} else {
|
||||
foreach ( $tables as $table_name ) {
|
||||
$old_table_prefixes[] = $table_name;
|
||||
$new_table_prefixes[] = ai1wm_servmask_prefix() . $table_name;
|
||||
}
|
||||
}
|
||||
|
||||
// Set column prefixes
|
||||
if ( strlen( ai1wm_table_prefix() ) > 1 ) {
|
||||
$old_column_prefixes[] = ai1wm_table_prefix();
|
||||
$new_column_prefixes[] = ai1wm_servmask_prefix();
|
||||
} else {
|
||||
foreach ( array( 'user_roles', 'capabilities', 'user_level', 'dashboard_quick_press_last_post_id', 'user-settings', 'user-settings-time' ) as $column_prefix ) {
|
||||
$old_column_prefixes[] = ai1wm_table_prefix() . $column_prefix;
|
||||
$new_column_prefixes[] = ai1wm_servmask_prefix() . $column_prefix;
|
||||
}
|
||||
}
|
||||
|
||||
$db_client->set_tables( $tables )
|
||||
->set_old_table_prefixes( $old_table_prefixes )
|
||||
->set_new_table_prefixes( $new_table_prefixes )
|
||||
->set_old_column_prefixes( $old_column_prefixes )
|
||||
->set_new_column_prefixes( $new_column_prefixes );
|
||||
|
||||
// Exclude column prefixes
|
||||
$db_client->set_reserved_column_prefixes( array( 'wp_force_deactivated_plugins', 'wp_page_for_privacy_policy', 'wp_rocket_settings', 'wp_rocket_dismiss_imagify_notice', 'wp_rocket_no_licence', 'wp_rocket_rocketcdn_old_url', 'wp_rocket_hide_deactivation_form' ) );
|
||||
|
||||
// Exclude site options
|
||||
$db_client->set_table_where_query( ai1wm_table_prefix() . 'options', sprintf( "`option_name` NOT IN ('%s', '%s', '%s', '%s', '%s', '%s', '%s')", AI1WM_STATUS, AI1WM_SECRET_KEY, AI1WM_AUTH_USER, AI1WM_AUTH_PASSWORD, AI1WM_AUTH_HEADER, AI1WM_BACKUPS_LABELS, AI1WM_SITES_LINKS ) );
|
||||
|
||||
// Set table select columns
|
||||
if ( ( $column_names = $db_client->get_column_names( ai1wm_table_prefix() . 'options' ) ) ) {
|
||||
if ( isset( $column_names['option_name'], $column_names['option_value'] ) ) {
|
||||
$column_names['option_value'] = sprintf( "(CASE WHEN option_name = '%s' THEN 'a:0:{}' WHEN (option_name = '%s' OR option_name = '%s') THEN '' ELSE option_value END) AS option_value", AI1WM_ACTIVE_PLUGINS, AI1WM_ACTIVE_TEMPLATE, AI1WM_ACTIVE_STYLESHEET );
|
||||
}
|
||||
|
||||
$db_client->set_table_select_columns( ai1wm_table_prefix() . 'options', $column_names );
|
||||
}
|
||||
|
||||
// Set table prefix columns
|
||||
$db_client->set_table_prefix_columns( ai1wm_table_prefix() . 'options', array( 'option_name' ) )
|
||||
->set_table_prefix_columns( ai1wm_table_prefix() . 'usermeta', array( 'meta_key' ) );
|
||||
|
||||
// Export database
|
||||
if ( $db_client->export( ai1wm_database_path( $params ), $query_offset, $table_index, $table_offset, $table_rows ) ) {
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Database exported.', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Unset query offset
|
||||
unset( $params['query_offset'] );
|
||||
|
||||
// Unset table index
|
||||
unset( $params['table_index'] );
|
||||
|
||||
// Unset table offset
|
||||
unset( $params['table_offset'] );
|
||||
|
||||
// Unset table rows
|
||||
unset( $params['table_rows'] );
|
||||
|
||||
// Unset total tables count
|
||||
unset( $params['total_tables_count'] );
|
||||
|
||||
// Unset completed flag
|
||||
unset( $params['completed'] );
|
||||
|
||||
} else {
|
||||
|
||||
// What percent of tables have we processed?
|
||||
$progress = (int) ( ( $table_index / $total_tables_count ) * 100 );
|
||||
|
||||
// Set progress
|
||||
/* translators: 1: Progress, 2: Number of records. */
|
||||
Ai1wm_Status::info( sprintf( __( 'Exporting database...<br />%1$d%% complete<br />%2$s records saved', 'all-in-one-wp-migration' ), $progress, number_format_i18n( $table_rows ) ) );
|
||||
|
||||
// Set query offset
|
||||
$params['query_offset'] = $query_offset;
|
||||
|
||||
// Set table index
|
||||
$params['table_index'] = $table_index;
|
||||
|
||||
// Set table offset
|
||||
$params['table_offset'] = $table_offset;
|
||||
|
||||
// Set table rows
|
||||
$params['table_rows'] = $table_rows;
|
||||
|
||||
// Set total tables count
|
||||
$params['total_tables_count'] = $total_tables_count;
|
||||
|
||||
// Set completed flag
|
||||
$params['completed'] = false;
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Export_Download {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
// Get archive CRC value
|
||||
$archive_crc_value = null;
|
||||
if ( isset( $params['archive_crc_value'] ) ) {
|
||||
$archive_crc_value = $params['archive_crc_value'];
|
||||
}
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Renaming export file...', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Open the archive file for writing
|
||||
$archive = new Ai1wm_Compressor( ai1wm_archive_path( $params ) );
|
||||
|
||||
// Append EOF block
|
||||
$archive->close( true, $archive_crc_value );
|
||||
|
||||
// Rename archive file
|
||||
if ( rename( ai1wm_archive_path( $params ), ai1wm_backup_path( $params ) ) ) {
|
||||
$blog_id = null;
|
||||
|
||||
// Get subsite Blog ID
|
||||
if ( isset( $params['options']['sites'] ) && ( $sites = $params['options']['sites'] ) ) {
|
||||
if ( count( $sites ) === 1 ) {
|
||||
$blog_id = array_shift( $sites );
|
||||
}
|
||||
}
|
||||
|
||||
// Set archive details
|
||||
$file = ai1wm_archive_name( $params );
|
||||
$link = ai1wm_backup_url( $params );
|
||||
$size = ai1wm_backup_size( $params );
|
||||
$name = ai1wm_site_name( $blog_id );
|
||||
|
||||
// Set progress
|
||||
if ( ai1wm_direct_download_supported() ) {
|
||||
Ai1wm_Status::download(
|
||||
sprintf(
|
||||
/* translators: 1: Link to archive, 2: Archive title, 3: File name, 4: Archive title, 5: File size. */
|
||||
__(
|
||||
'<a href="%1$s" class="ai1wm-button-green ai1wm-emphasize ai1wm-button-download" title="%2$s" download="%3$s">
|
||||
<span>Download %2$s</span>
|
||||
<em>Size: %4$s</em>
|
||||
</a>',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
$link,
|
||||
$name,
|
||||
$file,
|
||||
$size
|
||||
)
|
||||
);
|
||||
} else {
|
||||
Ai1wm_Status::download(
|
||||
sprintf(
|
||||
/* translators: 1: Archive title, 2: File name, 3: Archive title, 4: File size. */
|
||||
__(
|
||||
'<a href="#" class="ai1wm-button-green ai1wm-emphasize ai1wm-direct-download" title="%1$s" download="%2$s">
|
||||
<span>Download %3$s</span>
|
||||
<em>Size: %4$s</em>
|
||||
</a>',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
$name,
|
||||
$file,
|
||||
$name,
|
||||
$size
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
do_action( 'ai1wm_status_export_done', $params );
|
||||
|
||||
// Run manual on backup created hook
|
||||
if ( isset( $params['ai1wm_manual_backup'] ) ) {
|
||||
do_action( 'ai1wm_status_backup_created', $params );
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Export_Enumerate_Content {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
$exclude_filters = array_merge( array( ai1wm_get_uploads_dir(), ai1wm_get_plugins_dir() ), ai1wm_get_themes_dirs() );
|
||||
|
||||
// Get total content files count
|
||||
if ( isset( $params['total_content_files_count'] ) ) {
|
||||
$total_content_files_count = (int) $params['total_content_files_count'];
|
||||
} else {
|
||||
$total_content_files_count = 1;
|
||||
}
|
||||
|
||||
// Get total content files size
|
||||
if ( isset( $params['total_content_files_size'] ) ) {
|
||||
$total_content_files_size = (int) $params['total_content_files_size'];
|
||||
} else {
|
||||
$total_content_files_size = 1;
|
||||
}
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Gathering content files...', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Exclude cache
|
||||
if ( isset( $params['options']['no_cache'] ) ) {
|
||||
$exclude_filters[] = 'cache';
|
||||
}
|
||||
|
||||
// Exclude must-use plugins
|
||||
if ( isset( $params['options']['no_muplugins'] ) ) {
|
||||
$exclude_filters[] = 'mu-plugins';
|
||||
}
|
||||
|
||||
// Exclude media
|
||||
if ( isset( $params['options']['no_media'] ) ) {
|
||||
$exclude_filters[] = 'blogs.dir';
|
||||
}
|
||||
|
||||
// Exclude SQLite file
|
||||
if ( defined( 'FQDB' ) ) {
|
||||
$exclude_filters[] = FQDB;
|
||||
}
|
||||
|
||||
// Exclude selected files
|
||||
if ( isset( $params['options']['exclude_files'], $params['excluded_files'] ) ) {
|
||||
if ( ( $excluded_files = explode( ',', $params['excluded_files'] ) ) ) {
|
||||
foreach ( $excluded_files as $excluded_path ) {
|
||||
$exclude_filters[] = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . untrailingslashit( $excluded_path );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create content list file
|
||||
$content_list = ai1wm_open( ai1wm_content_list_path( $params ), 'w' );
|
||||
|
||||
// Enumerate over content directory
|
||||
if ( isset( $params['options']['no_themes'], $params['options']['no_muplugins'], $params['options']['no_plugins'] ) === false ) {
|
||||
|
||||
// Iterate over content directory
|
||||
$iterator = new Ai1wm_Recursive_Directory_Iterator( WP_CONTENT_DIR );
|
||||
|
||||
// Exclude content files
|
||||
$iterator = new Ai1wm_Recursive_Exclude_Filter( $iterator, apply_filters( 'ai1wm_exclude_content_from_export', ai1wm_content_filters( $exclude_filters ) ) );
|
||||
|
||||
// Recursively iterate over content directory
|
||||
$iterator = new Ai1wm_Recursive_Iterator_Iterator( $iterator, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD );
|
||||
|
||||
// Write path line
|
||||
foreach ( $iterator as $item ) {
|
||||
if ( $item->isFile() ) {
|
||||
if ( ai1wm_putcsv( $content_list, array( $iterator->getPathname(), $iterator->getSubPathname(), $iterator->getSize(), $iterator->getMTime() ) ) ) {
|
||||
$total_content_files_count++;
|
||||
|
||||
// Add current file size
|
||||
$total_content_files_size += $iterator->getSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Content files gathered.', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Set total content files count
|
||||
$params['total_content_files_count'] = $total_content_files_count;
|
||||
|
||||
// Set total content files size
|
||||
$params['total_content_files_size'] = $total_content_files_size;
|
||||
|
||||
// Close the content list file
|
||||
ai1wm_close( $content_list );
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Export_Enumerate_Media {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
$exclude_filters = array();
|
||||
|
||||
// Get total media files count
|
||||
if ( isset( $params['total_media_files_count'] ) ) {
|
||||
$total_media_files_count = (int) $params['total_media_files_count'];
|
||||
} else {
|
||||
$total_media_files_count = 1;
|
||||
}
|
||||
|
||||
// Get total media files size
|
||||
if ( isset( $params['total_media_files_size'] ) ) {
|
||||
$total_media_files_size = (int) $params['total_media_files_size'];
|
||||
} else {
|
||||
$total_media_files_size = 1;
|
||||
}
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Gathering media files...', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Exclude selected files
|
||||
if ( isset( $params['options']['exclude_files'], $params['excluded_files'] ) ) {
|
||||
if ( ( $excluded_files = explode( ',', $params['excluded_files'] ) ) ) {
|
||||
foreach ( $excluded_files as $excluded_path ) {
|
||||
$exclude_filters[] = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . untrailingslashit( $excluded_path );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create media list file
|
||||
$media_list = ai1wm_open( ai1wm_media_list_path( $params ), 'w' );
|
||||
|
||||
// Enumerate over media directory
|
||||
if ( isset( $params['options']['no_media'] ) === false ) {
|
||||
if ( is_dir( ai1wm_get_uploads_dir() ) ) {
|
||||
|
||||
// Iterate over media directory
|
||||
$iterator = new Ai1wm_Recursive_Directory_Iterator( ai1wm_get_uploads_dir() );
|
||||
|
||||
// Exclude media files
|
||||
$iterator = new Ai1wm_Recursive_Exclude_Filter( $iterator, apply_filters( 'ai1wm_exclude_media_from_export', ai1wm_media_filters( $exclude_filters ) ) );
|
||||
|
||||
// Recursively iterate over content directory
|
||||
$iterator = new Ai1wm_Recursive_Iterator_Iterator( $iterator, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD );
|
||||
|
||||
// Write path line
|
||||
foreach ( $iterator as $item ) {
|
||||
if ( $item->isFile() ) {
|
||||
if ( ai1wm_putcsv( $media_list, array( $iterator->getPathname(), $iterator->getSubPathname(), $iterator->getSize(), $iterator->getMTime() ) ) ) {
|
||||
$total_media_files_count++;
|
||||
|
||||
// Add current file size
|
||||
$total_media_files_size += $iterator->getSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Media files gathered.', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Set total media files count
|
||||
$params['total_media_files_count'] = $total_media_files_count;
|
||||
|
||||
// Set total media files size
|
||||
$params['total_media_files_size'] = $total_media_files_size;
|
||||
|
||||
// Close the media list file
|
||||
ai1wm_close( $media_list );
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Export_Enumerate_Plugins {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
$exclude_filters = array( AI1WM_SQLITE_DATABASE_INTEGRATION_NAME );
|
||||
|
||||
// Get total plugins files count
|
||||
if ( isset( $params['total_plugins_files_count'] ) ) {
|
||||
$total_plugins_files_count = (int) $params['total_plugins_files_count'];
|
||||
} else {
|
||||
$total_plugins_files_count = 1;
|
||||
}
|
||||
|
||||
// Get total plugins files size
|
||||
if ( isset( $params['total_plugins_files_size'] ) ) {
|
||||
$total_plugins_files_size = (int) $params['total_plugins_files_size'];
|
||||
} else {
|
||||
$total_plugins_files_size = 1;
|
||||
}
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Gathering plugin files...', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Exclude inactive plugins
|
||||
if ( isset( $params['options']['no_inactive_plugins'] ) ) {
|
||||
foreach ( get_plugins() as $plugin_name => $plugin_info ) {
|
||||
if ( is_plugin_inactive( $plugin_name ) ) {
|
||||
$exclude_filters[] = ( dirname( $plugin_name ) === '.' ? basename( $plugin_name ) : dirname( $plugin_name ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Exclude selected files
|
||||
if ( isset( $params['options']['exclude_files'], $params['excluded_files'] ) ) {
|
||||
if ( ( $excluded_files = explode( ',', $params['excluded_files'] ) ) ) {
|
||||
foreach ( $excluded_files as $excluded_path ) {
|
||||
$exclude_filters[] = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . untrailingslashit( $excluded_path );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create plugins list file
|
||||
$plugins_list = ai1wm_open( ai1wm_plugins_list_path( $params ), 'w' );
|
||||
|
||||
// Enumerate over plugins directory
|
||||
if ( isset( $params['options']['no_plugins'] ) === false ) {
|
||||
|
||||
// Iterate over plugins directory
|
||||
$iterator = new Ai1wm_Recursive_Directory_Iterator( ai1wm_get_plugins_dir() );
|
||||
|
||||
// Exclude plugins files
|
||||
$iterator = new Ai1wm_Recursive_Exclude_Filter( $iterator, apply_filters( 'ai1wm_exclude_plugins_from_export', ai1wm_plugin_filters( $exclude_filters ) ) );
|
||||
|
||||
// Recursively iterate over plugins directory
|
||||
$iterator = new Ai1wm_Recursive_Iterator_Iterator( $iterator, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD );
|
||||
|
||||
// Write path line
|
||||
foreach ( $iterator as $item ) {
|
||||
if ( $item->isFile() ) {
|
||||
if ( ai1wm_putcsv( $plugins_list, array( $iterator->getPathname(), $iterator->getSubPathname(), $iterator->getSize(), $iterator->getMTime() ) ) ) {
|
||||
$total_plugins_files_count++;
|
||||
|
||||
// Add current file size
|
||||
$total_plugins_files_size += $iterator->getSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Plugin files gathered.', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Set total plugins files count
|
||||
$params['total_plugins_files_count'] = $total_plugins_files_count;
|
||||
|
||||
// Set total plugins files size
|
||||
$params['total_plugins_files_size'] = $total_plugins_files_size;
|
||||
|
||||
// Close the plugins list file
|
||||
ai1wm_close( $plugins_list );
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Export_Enumerate_Tables {
|
||||
|
||||
public static function execute( $params ) {
|
||||
// Set exclude database
|
||||
if ( isset( $params['options']['no_database'] ) ) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
// Get total tables count
|
||||
if ( isset( $params['total_tables_count'] ) ) {
|
||||
$total_tables_count = (int) $params['total_tables_count'];
|
||||
} else {
|
||||
$total_tables_count = 1;
|
||||
}
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Gathering database tables...', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Get database client
|
||||
$db_client = Ai1wm_Database_Utility::get_client();
|
||||
|
||||
// Include table prefixes
|
||||
if ( ai1wm_table_prefix() ) {
|
||||
$db_client->add_table_prefix_filter( ai1wm_table_prefix() );
|
||||
|
||||
// Include table prefixes (Webba Booking and CiviCRM)
|
||||
foreach ( array( 'wbk_', 'civicrm_' ) as $table_name ) {
|
||||
$db_client->add_table_prefix_filter( $table_name );
|
||||
}
|
||||
}
|
||||
|
||||
// Create tables list file
|
||||
$tables_list = ai1wm_open( ai1wm_tables_list_path( $params ), 'w' );
|
||||
|
||||
// Exclude selected db tables
|
||||
$excluded_db_tables = array();
|
||||
if ( isset( $params['options']['exclude_db_tables'], $params['excluded_db_tables'] ) ) {
|
||||
$excluded_db_tables = explode( ',', $params['excluded_db_tables'] );
|
||||
}
|
||||
|
||||
// Write table line
|
||||
foreach ( $db_client->get_tables() as $table_name ) {
|
||||
if ( ! in_array( $table_name, $excluded_db_tables ) && ai1wm_putcsv( $tables_list, array( $table_name ) ) ) {
|
||||
$total_tables_count++;
|
||||
}
|
||||
}
|
||||
|
||||
// Include selected db tables
|
||||
if ( isset( $params['options']['include_db_tables'] ) && ! empty( $params['included_db_tables'] ) ) {
|
||||
foreach ( explode( ',', $params['included_db_tables'] ) as $table_name ) {
|
||||
if ( ai1wm_putcsv( $tables_list, array( $table_name ) ) ) {
|
||||
$total_tables_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Database tables gathered.', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Set total tables count
|
||||
$params['total_tables_count'] = $total_tables_count;
|
||||
|
||||
// Close the tables list file
|
||||
ai1wm_close( $tables_list );
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Export_Enumerate_Themes {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
$exclude_filters = array();
|
||||
|
||||
// Get total themes files count
|
||||
if ( isset( $params['total_themes_files_count'] ) ) {
|
||||
$total_themes_files_count = (int) $params['total_themes_files_count'];
|
||||
} else {
|
||||
$total_themes_files_count = 1;
|
||||
}
|
||||
|
||||
// Get total themes files size
|
||||
if ( isset( $params['total_themes_files_size'] ) ) {
|
||||
$total_themes_files_size = (int) $params['total_themes_files_size'];
|
||||
} else {
|
||||
$total_themes_files_size = 1;
|
||||
}
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Gathering theme files...', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Exclude inactive themes
|
||||
if ( isset( $params['options']['no_inactive_themes'] ) ) {
|
||||
foreach ( search_theme_directories() as $theme_name => $theme_info ) {
|
||||
if ( ! in_array( $theme_name, array( get_template(), get_stylesheet() ) ) ) {
|
||||
if ( isset( $theme_info['theme_root'] ) ) {
|
||||
$exclude_filters[] = $theme_info['theme_root'] . DIRECTORY_SEPARATOR . $theme_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Exclude selected files
|
||||
if ( isset( $params['options']['exclude_files'], $params['excluded_files'] ) ) {
|
||||
if ( ( $excluded_files = explode( ',', $params['excluded_files'] ) ) ) {
|
||||
foreach ( $excluded_files as $excluded_path ) {
|
||||
$exclude_filters[] = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . untrailingslashit( $excluded_path );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create themes list file
|
||||
$themes_list = ai1wm_open( ai1wm_themes_list_path( $params ), 'w' );
|
||||
|
||||
// Enumerate over themes directory
|
||||
if ( isset( $params['options']['no_themes'] ) === false ) {
|
||||
foreach ( ai1wm_get_themes_dirs() as $theme_dir ) {
|
||||
if ( is_dir( $theme_dir ) ) {
|
||||
|
||||
// Iterate over themes directory
|
||||
$iterator = new Ai1wm_Recursive_Directory_Iterator( $theme_dir );
|
||||
|
||||
// Exclude themes files
|
||||
$iterator = new Ai1wm_Recursive_Exclude_Filter( $iterator, apply_filters( 'ai1wm_exclude_themes_from_export', ai1wm_theme_filters( $exclude_filters ) ) );
|
||||
|
||||
// Recursively iterate over themes directory
|
||||
$iterator = new Ai1wm_Recursive_Iterator_Iterator( $iterator, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD );
|
||||
|
||||
// Write path line
|
||||
foreach ( $iterator as $item ) {
|
||||
if ( $item->isFile() ) {
|
||||
if ( ai1wm_putcsv( $themes_list, array( $iterator->getPathname(), $iterator->getSubPathname(), $iterator->getSize(), $iterator->getMTime() ) ) ) {
|
||||
$total_themes_files_count++;
|
||||
|
||||
// Add current file size
|
||||
$total_themes_files_size += $iterator->getSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Theme files gathered.', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Set total themes files count
|
||||
$params['total_themes_files_count'] = $total_themes_files_count;
|
||||
|
||||
// Set total themes files size
|
||||
$params['total_themes_files_size'] = $total_themes_files_size;
|
||||
|
||||
// Close the themes list file
|
||||
ai1wm_close( $themes_list );
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Export_Init {
|
||||
|
||||
public static function execute( $params ) {
|
||||
$blog_id = null;
|
||||
|
||||
// Get subsite Blog ID
|
||||
if ( isset( $params['options']['sites'] ) && ( $sites = $params['options']['sites'] ) ) {
|
||||
if ( count( $sites ) === 1 ) {
|
||||
$blog_id = array_shift( $sites );
|
||||
}
|
||||
}
|
||||
|
||||
do_action( 'ai1wm_status_export_init', $params );
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Preparing to export...', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Set archive
|
||||
if ( empty( $params['archive'] ) ) {
|
||||
$params['archive'] = ai1wm_archive_file( $blog_id );
|
||||
}
|
||||
|
||||
// Set storage
|
||||
if ( empty( $params['storage'] ) ) {
|
||||
$params['storage'] = ai1wm_storage_folder();
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Export_Media {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
// Set encrypt password
|
||||
$encrypt_password = null;
|
||||
if ( isset( $params['options']['encrypt_backups'], $params['options']['encrypt_password'] ) ) {
|
||||
$encrypt_password = $params['options']['encrypt_password'];
|
||||
}
|
||||
|
||||
// Set compression type
|
||||
$compression_type = null;
|
||||
if ( isset( $params['options']['compression_type'] ) ) {
|
||||
$compression_type = $params['options']['compression_type'];
|
||||
}
|
||||
|
||||
// Set archive bytes offset
|
||||
if ( isset( $params['archive_bytes_offset'] ) ) {
|
||||
$archive_bytes_offset = (int) $params['archive_bytes_offset'];
|
||||
} else {
|
||||
$archive_bytes_offset = ai1wm_archive_bytes( $params );
|
||||
}
|
||||
|
||||
// Set file bytes offset
|
||||
if ( isset( $params['file_bytes_offset'] ) ) {
|
||||
$file_bytes_offset = (int) $params['file_bytes_offset'];
|
||||
} else {
|
||||
$file_bytes_offset = 0;
|
||||
}
|
||||
|
||||
// Set file bytes written
|
||||
if ( isset( $params['file_bytes_written'] ) ) {
|
||||
$file_bytes_written = (int) $params['file_bytes_written'];
|
||||
} else {
|
||||
$file_bytes_written = 0;
|
||||
}
|
||||
|
||||
// Set media bytes offset
|
||||
if ( isset( $params['media_bytes_offset'] ) ) {
|
||||
$media_bytes_offset = (int) $params['media_bytes_offset'];
|
||||
} else {
|
||||
$media_bytes_offset = 0;
|
||||
}
|
||||
|
||||
// Get processed files size
|
||||
if ( isset( $params['processed_files_size'] ) ) {
|
||||
$processed_files_size = (int) $params['processed_files_size'];
|
||||
} else {
|
||||
$processed_files_size = 0;
|
||||
}
|
||||
|
||||
// Get total media files size
|
||||
if ( isset( $params['total_media_files_size'] ) ) {
|
||||
$total_media_files_size = (int) $params['total_media_files_size'];
|
||||
} else {
|
||||
$total_media_files_size = 1;
|
||||
}
|
||||
|
||||
// Get total media files count
|
||||
if ( isset( $params['total_media_files_count'] ) ) {
|
||||
$total_media_files_count = (int) $params['total_media_files_count'];
|
||||
} else {
|
||||
$total_media_files_count = 1;
|
||||
}
|
||||
|
||||
// Set file CRC
|
||||
if ( isset( $params['file_crc'] ) ) {
|
||||
$file_crc = $params['file_crc'];
|
||||
} else {
|
||||
$file_crc = null;
|
||||
}
|
||||
|
||||
// What percent of files have we processed?
|
||||
$progress = (int) min( ( $processed_files_size / $total_media_files_size ) * 100, 100 );
|
||||
|
||||
// Set progress
|
||||
/* translators: 1: Number of files, 2: Progress. */
|
||||
Ai1wm_Status::info( sprintf( __( 'Archiving %1$d media files...<br />%2$d%% complete', 'all-in-one-wp-migration' ), $total_media_files_count, $progress ) );
|
||||
|
||||
// Flag to hold if file data has been processed
|
||||
$completed = true;
|
||||
|
||||
// Start time
|
||||
$start = microtime( true );
|
||||
|
||||
// Get media list file
|
||||
$media_list = ai1wm_open( ai1wm_media_list_path( $params ), 'r' );
|
||||
|
||||
// Set the file pointer at the current index
|
||||
if ( fseek( $media_list, $media_bytes_offset ) !== -1 ) {
|
||||
|
||||
// Open the archive file for writing
|
||||
$archive = new Ai1wm_Compressor( ai1wm_archive_path( $params ), $encrypt_password, $compression_type );
|
||||
|
||||
// Set the file pointer to the one that we have saved
|
||||
$archive->set_file_pointer( $archive_bytes_offset );
|
||||
|
||||
// Loop over files
|
||||
while ( ( $row = ai1wm_getcsv( $media_list ) ) !== false ) {
|
||||
list( $file_abspath, $file_relpath, $file_size, $file_mtime ) = $row;
|
||||
$file_bytes_read = 0;
|
||||
|
||||
// Add file to archive
|
||||
if ( ( $completed = $archive->add_file( $file_abspath, 'uploads' . DIRECTORY_SEPARATOR . $file_relpath, $file_bytes_read, $file_bytes_offset, $file_bytes_written, $file_crc ) ) ) {
|
||||
$file_crc = null;
|
||||
|
||||
// Reset file bytes
|
||||
$file_bytes_offset = $file_bytes_written = 0;
|
||||
|
||||
// Get media bytes offset
|
||||
$media_bytes_offset = ftell( $media_list );
|
||||
}
|
||||
|
||||
// Increment processed files size
|
||||
$processed_files_size += $file_bytes_read;
|
||||
|
||||
// What percent of files have we processed?
|
||||
$progress = (int) min( ( $processed_files_size / $total_media_files_size ) * 100, 100 );
|
||||
|
||||
// Set progress
|
||||
/* translators: 1: Number of files, 2: Progress. */
|
||||
Ai1wm_Status::info( sprintf( __( 'Archiving %1$d media files...<br />%2$d%% complete', 'all-in-one-wp-migration' ), $total_media_files_count, $progress ) );
|
||||
|
||||
// More than 10 seconds have passed, break and do another request
|
||||
if ( ( $timeout = apply_filters( 'ai1wm_completed_timeout', 10 ) ) ) {
|
||||
if ( ( microtime( true ) - $start ) > $timeout ) {
|
||||
$completed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get archive bytes offset
|
||||
$archive_bytes_offset = $archive->get_file_pointer();
|
||||
|
||||
// Truncate the archive file
|
||||
$archive->truncate();
|
||||
|
||||
// Close the archive file
|
||||
$archive->close();
|
||||
}
|
||||
|
||||
// End of the media list?
|
||||
if ( feof( $media_list ) ) {
|
||||
|
||||
// Unset archive bytes offset
|
||||
unset( $params['archive_bytes_offset'] );
|
||||
|
||||
// Unset file bytes offset
|
||||
unset( $params['file_bytes_offset'] );
|
||||
|
||||
// Unset file bytes written
|
||||
unset( $params['file_bytes_written'] );
|
||||
|
||||
// Unset media bytes offset
|
||||
unset( $params['media_bytes_offset'] );
|
||||
|
||||
// Unset processed files size
|
||||
unset( $params['processed_files_size'] );
|
||||
|
||||
// Unset total media files size
|
||||
unset( $params['total_media_files_size'] );
|
||||
|
||||
// Unset total media files count
|
||||
unset( $params['total_media_files_count'] );
|
||||
|
||||
// Unset file CRC
|
||||
unset( $params['file_crc'] );
|
||||
|
||||
// Unset completed flag
|
||||
unset( $params['completed'] );
|
||||
|
||||
} else {
|
||||
|
||||
// Set archive bytes offset
|
||||
$params['archive_bytes_offset'] = $archive_bytes_offset;
|
||||
|
||||
// Set file bytes offset
|
||||
$params['file_bytes_offset'] = $file_bytes_offset;
|
||||
|
||||
// Set file bytes written
|
||||
$params['file_bytes_written'] = $file_bytes_written;
|
||||
|
||||
// Set media bytes offset
|
||||
$params['media_bytes_offset'] = $media_bytes_offset;
|
||||
|
||||
// Set processed files size
|
||||
$params['processed_files_size'] = $processed_files_size;
|
||||
|
||||
// Set total media files size
|
||||
$params['total_media_files_size'] = $total_media_files_size;
|
||||
|
||||
// Set total media files count
|
||||
$params['total_media_files_count'] = $total_media_files_count;
|
||||
|
||||
// Set file CRC
|
||||
$params['file_crc'] = $file_crc;
|
||||
|
||||
// Set completed flag
|
||||
$params['completed'] = $completed;
|
||||
}
|
||||
|
||||
// Close the media list file
|
||||
ai1wm_close( $media_list );
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Export_Plugins {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
// Set encrypt password
|
||||
$encrypt_password = null;
|
||||
if ( isset( $params['options']['encrypt_backups'], $params['options']['encrypt_password'] ) ) {
|
||||
$encrypt_password = $params['options']['encrypt_password'];
|
||||
}
|
||||
|
||||
// Set compression type
|
||||
$compression_type = null;
|
||||
if ( isset( $params['options']['compression_type'] ) ) {
|
||||
$compression_type = $params['options']['compression_type'];
|
||||
}
|
||||
|
||||
// Set archive bytes offset
|
||||
if ( isset( $params['archive_bytes_offset'] ) ) {
|
||||
$archive_bytes_offset = (int) $params['archive_bytes_offset'];
|
||||
} else {
|
||||
$archive_bytes_offset = ai1wm_archive_bytes( $params );
|
||||
}
|
||||
|
||||
// Set file bytes offset
|
||||
if ( isset( $params['file_bytes_offset'] ) ) {
|
||||
$file_bytes_offset = (int) $params['file_bytes_offset'];
|
||||
} else {
|
||||
$file_bytes_offset = 0;
|
||||
}
|
||||
|
||||
// Set file bytes written
|
||||
if ( isset( $params['file_bytes_written'] ) ) {
|
||||
$file_bytes_written = (int) $params['file_bytes_written'];
|
||||
} else {
|
||||
$file_bytes_written = 0;
|
||||
}
|
||||
|
||||
// Set plugins bytes offset
|
||||
if ( isset( $params['plugins_bytes_offset'] ) ) {
|
||||
$plugins_bytes_offset = (int) $params['plugins_bytes_offset'];
|
||||
} else {
|
||||
$plugins_bytes_offset = 0;
|
||||
}
|
||||
|
||||
// Get processed files size
|
||||
if ( isset( $params['processed_files_size'] ) ) {
|
||||
$processed_files_size = (int) $params['processed_files_size'];
|
||||
} else {
|
||||
$processed_files_size = 0;
|
||||
}
|
||||
|
||||
// Get total plugins files size
|
||||
if ( isset( $params['total_plugins_files_size'] ) ) {
|
||||
$total_plugins_files_size = (int) $params['total_plugins_files_size'];
|
||||
} else {
|
||||
$total_plugins_files_size = 1;
|
||||
}
|
||||
|
||||
// Get total plugins files count
|
||||
if ( isset( $params['total_plugins_files_count'] ) ) {
|
||||
$total_plugins_files_count = (int) $params['total_plugins_files_count'];
|
||||
} else {
|
||||
$total_plugins_files_count = 1;
|
||||
}
|
||||
|
||||
// Set file CRC
|
||||
if ( isset( $params['file_crc'] ) ) {
|
||||
$file_crc = $params['file_crc'];
|
||||
} else {
|
||||
$file_crc = null;
|
||||
}
|
||||
|
||||
// What percent of files have we processed?
|
||||
$progress = (int) min( ( $processed_files_size / $total_plugins_files_size ) * 100, 100 );
|
||||
|
||||
// Set progress
|
||||
/* translators: 1: Number of files, 2: Progress. */
|
||||
Ai1wm_Status::info( sprintf( __( 'Archiving %1$d plugin files...<br />%2$d%% complete', 'all-in-one-wp-migration' ), $total_plugins_files_count, $progress ) );
|
||||
|
||||
// Flag to hold if file data has been processed
|
||||
$completed = true;
|
||||
|
||||
// Start time
|
||||
$start = microtime( true );
|
||||
|
||||
// Get plugins list file
|
||||
$plugins_list = ai1wm_open( ai1wm_plugins_list_path( $params ), 'r' );
|
||||
|
||||
// Set the file pointer at the current index
|
||||
if ( fseek( $plugins_list, $plugins_bytes_offset ) !== -1 ) {
|
||||
|
||||
// Open the archive file for writing
|
||||
$archive = new Ai1wm_Compressor( ai1wm_archive_path( $params ), $encrypt_password, $compression_type );
|
||||
|
||||
// Set the file pointer to the one that we have saved
|
||||
$archive->set_file_pointer( $archive_bytes_offset );
|
||||
|
||||
// Loop over files
|
||||
while ( ( $row = ai1wm_getcsv( $plugins_list ) ) !== false ) {
|
||||
list( $file_abspath, $file_relpath, $file_size, $file_mtime ) = $row;
|
||||
$file_bytes_read = 0;
|
||||
|
||||
// Add file to archive
|
||||
if ( ( $completed = $archive->add_file( $file_abspath, 'plugins' . DIRECTORY_SEPARATOR . $file_relpath, $file_bytes_read, $file_bytes_offset, $file_bytes_written, $file_crc ) ) ) {
|
||||
$file_crc = null;
|
||||
|
||||
// Reset file bytes
|
||||
$file_bytes_offset = $file_bytes_written = 0;
|
||||
|
||||
// Get plugins bytes offset
|
||||
$plugins_bytes_offset = ftell( $plugins_list );
|
||||
}
|
||||
|
||||
// Increment processed files size
|
||||
$processed_files_size += $file_bytes_read;
|
||||
|
||||
// What percent of files have we processed?
|
||||
$progress = (int) min( ( $processed_files_size / $total_plugins_files_size ) * 100, 100 );
|
||||
|
||||
// Set progress
|
||||
/* translators: 1: Number of files, 2: Progress. */
|
||||
Ai1wm_Status::info( sprintf( __( 'Archiving %1$d plugin files...<br />%2$d%% complete', 'all-in-one-wp-migration' ), $total_plugins_files_count, $progress ) );
|
||||
|
||||
// More than 10 seconds have passed, break and do another request
|
||||
if ( ( $timeout = apply_filters( 'ai1wm_completed_timeout', 10 ) ) ) {
|
||||
if ( ( microtime( true ) - $start ) > $timeout ) {
|
||||
$completed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get archive bytes offset
|
||||
$archive_bytes_offset = $archive->get_file_pointer();
|
||||
|
||||
// Truncate the archive file
|
||||
$archive->truncate();
|
||||
|
||||
// Close the archive file
|
||||
$archive->close();
|
||||
}
|
||||
|
||||
// End of the plugins list?
|
||||
if ( feof( $plugins_list ) ) {
|
||||
|
||||
// Unset archive bytes offset
|
||||
unset( $params['archive_bytes_offset'] );
|
||||
|
||||
// Unset file bytes offset
|
||||
unset( $params['file_bytes_offset'] );
|
||||
|
||||
// Unset file bytes written
|
||||
unset( $params['file_bytes_written'] );
|
||||
|
||||
// Unset plugins bytes offset
|
||||
unset( $params['plugins_bytes_offset'] );
|
||||
|
||||
// Unset processed files size
|
||||
unset( $params['processed_files_size'] );
|
||||
|
||||
// Unset total plugins files size
|
||||
unset( $params['total_plugins_files_size'] );
|
||||
|
||||
// Unset total plugins files count
|
||||
unset( $params['total_plugins_files_count'] );
|
||||
|
||||
// Unset file CRC
|
||||
unset( $params['file_crc'] );
|
||||
|
||||
// Unset completed flag
|
||||
unset( $params['completed'] );
|
||||
|
||||
} else {
|
||||
|
||||
// Set archive bytes offset
|
||||
$params['archive_bytes_offset'] = $archive_bytes_offset;
|
||||
|
||||
// Set file bytes offset
|
||||
$params['file_bytes_offset'] = $file_bytes_offset;
|
||||
|
||||
// Set file bytes written
|
||||
$params['file_bytes_written'] = $file_bytes_written;
|
||||
|
||||
// Set plugins bytes offset
|
||||
$params['plugins_bytes_offset'] = $plugins_bytes_offset;
|
||||
|
||||
// Set processed files size
|
||||
$params['processed_files_size'] = $processed_files_size;
|
||||
|
||||
// Set total plugins files size
|
||||
$params['total_plugins_files_size'] = $total_plugins_files_size;
|
||||
|
||||
// Set total plugins files count
|
||||
$params['total_plugins_files_count'] = $total_plugins_files_count;
|
||||
|
||||
// Set file CRC
|
||||
$params['file_crc'] = $file_crc;
|
||||
|
||||
// Set completed flag
|
||||
$params['completed'] = $completed;
|
||||
}
|
||||
|
||||
// Close the plugins list file
|
||||
ai1wm_close( $plugins_list );
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Export_Themes {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
// Set encrypt password
|
||||
$encrypt_password = null;
|
||||
if ( isset( $params['options']['encrypt_backups'], $params['options']['encrypt_password'] ) ) {
|
||||
$encrypt_password = $params['options']['encrypt_password'];
|
||||
}
|
||||
|
||||
// Set compression type
|
||||
$compression_type = null;
|
||||
if ( isset( $params['options']['compression_type'] ) ) {
|
||||
$compression_type = $params['options']['compression_type'];
|
||||
}
|
||||
|
||||
// Set archive bytes offset
|
||||
if ( isset( $params['archive_bytes_offset'] ) ) {
|
||||
$archive_bytes_offset = (int) $params['archive_bytes_offset'];
|
||||
} else {
|
||||
$archive_bytes_offset = ai1wm_archive_bytes( $params );
|
||||
}
|
||||
|
||||
// Set file bytes offset
|
||||
if ( isset( $params['file_bytes_offset'] ) ) {
|
||||
$file_bytes_offset = (int) $params['file_bytes_offset'];
|
||||
} else {
|
||||
$file_bytes_offset = 0;
|
||||
}
|
||||
|
||||
// Set file bytes written
|
||||
if ( isset( $params['file_bytes_written'] ) ) {
|
||||
$file_bytes_written = (int) $params['file_bytes_written'];
|
||||
} else {
|
||||
$file_bytes_written = 0;
|
||||
}
|
||||
|
||||
// Set themes bytes offset
|
||||
if ( isset( $params['themes_bytes_offset'] ) ) {
|
||||
$themes_bytes_offset = (int) $params['themes_bytes_offset'];
|
||||
} else {
|
||||
$themes_bytes_offset = 0;
|
||||
}
|
||||
|
||||
// Get processed files size
|
||||
if ( isset( $params['processed_files_size'] ) ) {
|
||||
$processed_files_size = (int) $params['processed_files_size'];
|
||||
} else {
|
||||
$processed_files_size = 0;
|
||||
}
|
||||
|
||||
// Get total themes files size
|
||||
if ( isset( $params['total_themes_files_size'] ) ) {
|
||||
$total_themes_files_size = (int) $params['total_themes_files_size'];
|
||||
} else {
|
||||
$total_themes_files_size = 1;
|
||||
}
|
||||
|
||||
// Get total themes files count
|
||||
if ( isset( $params['total_themes_files_count'] ) ) {
|
||||
$total_themes_files_count = (int) $params['total_themes_files_count'];
|
||||
} else {
|
||||
$total_themes_files_count = 1;
|
||||
}
|
||||
|
||||
// Set file CRC
|
||||
if ( isset( $params['file_crc'] ) ) {
|
||||
$file_crc = $params['file_crc'];
|
||||
} else {
|
||||
$file_crc = null;
|
||||
}
|
||||
|
||||
// What percent of files have we processed?
|
||||
$progress = (int) min( ( $processed_files_size / $total_themes_files_size ) * 100, 100 );
|
||||
|
||||
// Set progress
|
||||
/* translators: 1: Number of files, 2: Progress. */
|
||||
Ai1wm_Status::info( sprintf( __( 'Archiving %1$d theme files...<br />%2$d%% complete', 'all-in-one-wp-migration' ), $total_themes_files_count, $progress ) );
|
||||
|
||||
// Flag to hold if file data has been processed
|
||||
$completed = true;
|
||||
|
||||
// Start time
|
||||
$start = microtime( true );
|
||||
|
||||
// Get themes list file
|
||||
$themes_list = ai1wm_open( ai1wm_themes_list_path( $params ), 'r' );
|
||||
|
||||
// Set the file pointer at the current index
|
||||
if ( fseek( $themes_list, $themes_bytes_offset ) !== -1 ) {
|
||||
|
||||
// Open the archive file for writing
|
||||
$archive = new Ai1wm_Compressor( ai1wm_archive_path( $params ), $encrypt_password, $compression_type );
|
||||
|
||||
// Set the file pointer to the one that we have saved
|
||||
$archive->set_file_pointer( $archive_bytes_offset );
|
||||
|
||||
// Loop over files
|
||||
while ( ( $row = ai1wm_getcsv( $themes_list ) ) !== false ) {
|
||||
list( $file_abspath, $file_relpath, $file_size, $file_mtime ) = $row;
|
||||
$file_bytes_read = 0;
|
||||
|
||||
// Add file to archive
|
||||
if ( ( $completed = $archive->add_file( $file_abspath, 'themes' . DIRECTORY_SEPARATOR . $file_relpath, $file_bytes_read, $file_bytes_offset, $file_bytes_written, $file_crc ) ) ) {
|
||||
$file_crc = null;
|
||||
|
||||
// Reset file bytes
|
||||
$file_bytes_offset = $file_bytes_written = 0;
|
||||
|
||||
// Get themes bytes offset
|
||||
$themes_bytes_offset = ftell( $themes_list );
|
||||
}
|
||||
|
||||
// Increment processed files size
|
||||
$processed_files_size += $file_bytes_read;
|
||||
|
||||
// What percent of files have we processed?
|
||||
$progress = (int) min( ( $processed_files_size / $total_themes_files_size ) * 100, 100 );
|
||||
|
||||
// Set progress
|
||||
/* translators: 1: Number of files, 2: Progress. */
|
||||
Ai1wm_Status::info( sprintf( __( 'Archiving %1$d theme files...<br />%2$d%% complete', 'all-in-one-wp-migration' ), $total_themes_files_count, $progress ) );
|
||||
|
||||
// More than 10 seconds have passed, break and do another request
|
||||
if ( ( $timeout = apply_filters( 'ai1wm_completed_timeout', 10 ) ) ) {
|
||||
if ( ( microtime( true ) - $start ) > $timeout ) {
|
||||
$completed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get archive bytes offset
|
||||
$archive_bytes_offset = $archive->get_file_pointer();
|
||||
|
||||
// Truncate the archive file
|
||||
$archive->truncate();
|
||||
|
||||
// Close the archive file
|
||||
$archive->close();
|
||||
}
|
||||
|
||||
// End of the themes list?
|
||||
if ( feof( $themes_list ) ) {
|
||||
|
||||
// Unset archive bytes offset
|
||||
unset( $params['archive_bytes_offset'] );
|
||||
|
||||
// Unset file bytes offset
|
||||
unset( $params['file_bytes_offset'] );
|
||||
|
||||
// Unset file bytes written
|
||||
unset( $params['file_bytes_written'] );
|
||||
|
||||
// Unset themes bytes offset
|
||||
unset( $params['themes_bytes_offset'] );
|
||||
|
||||
// Unset processed files size
|
||||
unset( $params['processed_files_size'] );
|
||||
|
||||
// Unset total themes files size
|
||||
unset( $params['total_themes_files_size'] );
|
||||
|
||||
// Unset total themes files count
|
||||
unset( $params['total_themes_files_count'] );
|
||||
|
||||
// Unset file CRC
|
||||
unset( $params['file_crc'] );
|
||||
|
||||
// Unset completed flag
|
||||
unset( $params['completed'] );
|
||||
|
||||
} else {
|
||||
|
||||
// Set archive bytes offset
|
||||
$params['archive_bytes_offset'] = $archive_bytes_offset;
|
||||
|
||||
// Set file bytes offset
|
||||
$params['file_bytes_offset'] = $file_bytes_offset;
|
||||
|
||||
// Set file bytes written
|
||||
$params['file_bytes_written'] = $file_bytes_written;
|
||||
|
||||
// Set themes bytes offset
|
||||
$params['themes_bytes_offset'] = $themes_bytes_offset;
|
||||
|
||||
// Set processed files size
|
||||
$params['processed_files_size'] = $processed_files_size;
|
||||
|
||||
// Set total themes files size
|
||||
$params['total_themes_files_size'] = $total_themes_files_size;
|
||||
|
||||
// Set total themes files count
|
||||
$params['total_themes_files_count'] = $total_themes_files_count;
|
||||
|
||||
// Set file CRC
|
||||
$params['file_crc'] = $file_crc;
|
||||
|
||||
// Set completed flag
|
||||
$params['completed'] = $completed;
|
||||
}
|
||||
|
||||
// Close the themes list file
|
||||
ai1wm_close( $themes_list );
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Blogs {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Preparing blogs...', 'all-in-one-wp-migration' ) );
|
||||
|
||||
$blogs = array();
|
||||
|
||||
// Check multisite.json file
|
||||
if ( true === is_file( ai1wm_multisite_path( $params ) ) ) {
|
||||
|
||||
// Read multisite.json file
|
||||
$handle = ai1wm_open( ai1wm_multisite_path( $params ), 'r' );
|
||||
|
||||
// Parse multisite.json file
|
||||
$multisite = ai1wm_read( $handle, filesize( ai1wm_multisite_path( $params ) ) );
|
||||
$multisite = json_decode( $multisite, true );
|
||||
|
||||
// Close handle
|
||||
ai1wm_close( $handle );
|
||||
|
||||
// Validate
|
||||
if ( empty( $multisite['Network'] ) ) {
|
||||
if ( isset( $multisite['Sites'] ) && ( $sites = $multisite['Sites'] ) ) {
|
||||
if ( count( $sites ) === 1 && ( $subsite = current( $sites ) ) ) {
|
||||
|
||||
// Set internal Site URL (backward compatibility)
|
||||
if ( empty( $subsite['InternalSiteURL'] ) ) {
|
||||
$subsite['InternalSiteURL'] = null;
|
||||
}
|
||||
|
||||
// Set internal Home URL (backward compatibility)
|
||||
if ( empty( $subsite['InternalHomeURL'] ) ) {
|
||||
$subsite['InternalHomeURL'] = null;
|
||||
}
|
||||
|
||||
// Set active plugins (backward compatibility)
|
||||
if ( empty( $subsite['Plugins'] ) ) {
|
||||
$subsite['Plugins'] = array();
|
||||
}
|
||||
|
||||
// Set active template (backward compatibility)
|
||||
if ( empty( $subsite['Template'] ) ) {
|
||||
$subsite['Template'] = null;
|
||||
}
|
||||
|
||||
// Set active stylesheet (backward compatibility)
|
||||
if ( empty( $subsite['Stylesheet'] ) ) {
|
||||
$subsite['Stylesheet'] = null;
|
||||
}
|
||||
|
||||
// Set uploads path (backward compatibility)
|
||||
if ( empty( $subsite['Uploads'] ) ) {
|
||||
$subsite['Uploads'] = null;
|
||||
}
|
||||
|
||||
// Set uploads URL path (backward compatibility)
|
||||
if ( empty( $subsite['UploadsURL'] ) ) {
|
||||
$subsite['UploadsURL'] = null;
|
||||
}
|
||||
|
||||
// Set uploads path (backward compatibility)
|
||||
if ( empty( $subsite['WordPress']['Uploads'] ) ) {
|
||||
$subsite['WordPress']['Uploads'] = null;
|
||||
}
|
||||
|
||||
// Set uploads URL path (backward compatibility)
|
||||
if ( empty( $subsite['WordPress']['UploadsURL'] ) ) {
|
||||
$subsite['WordPress']['UploadsURL'] = null;
|
||||
}
|
||||
|
||||
// Set blog items
|
||||
$blogs[] = array(
|
||||
'Old' => array(
|
||||
'BlogID' => $subsite['BlogID'],
|
||||
'SiteURL' => $subsite['SiteURL'],
|
||||
'HomeURL' => $subsite['HomeURL'],
|
||||
'InternalSiteURL' => $subsite['InternalSiteURL'],
|
||||
'InternalHomeURL' => $subsite['InternalHomeURL'],
|
||||
'Plugins' => $subsite['Plugins'],
|
||||
'Template' => $subsite['Template'],
|
||||
'Stylesheet' => $subsite['Stylesheet'],
|
||||
'Uploads' => $subsite['Uploads'],
|
||||
'UploadsURL' => $subsite['UploadsURL'],
|
||||
'WordPress' => $subsite['WordPress'],
|
||||
),
|
||||
'New' => array(
|
||||
'BlogID' => null,
|
||||
'SiteURL' => site_url(),
|
||||
'HomeURL' => home_url(),
|
||||
'InternalSiteURL' => site_url(),
|
||||
'InternalHomeURL' => home_url(),
|
||||
'Plugins' => $subsite['Plugins'],
|
||||
'Template' => $subsite['Template'],
|
||||
'Stylesheet' => $subsite['Stylesheet'],
|
||||
'Uploads' => get_option( 'upload_path' ),
|
||||
'UploadsURL' => get_option( 'upload_url_path' ),
|
||||
'WordPress' => array(
|
||||
'UploadsURL' => ai1wm_get_uploads_url(),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
throw new Ai1wm_Import_Exception( esc_html__( 'The archive must contain only a single WordPress site. The process cannot continue. Please revisit your export settings.', 'all-in-one-wp-migration' ) );
|
||||
}
|
||||
} else {
|
||||
throw new Ai1wm_Import_Exception( esc_html__( 'The archive must contain at least one WordPress site. The process cannot continue. Please check your export settings.', 'all-in-one-wp-migration' ) );
|
||||
}
|
||||
} else {
|
||||
throw new Ai1wm_Import_Exception( esc_html__( 'Could not import a WordPress Network into a single WordPress site. The process cannot continue. Please check your import settings.', 'all-in-one-wp-migration' ) );
|
||||
}
|
||||
}
|
||||
|
||||
// Write blogs.json file
|
||||
$handle = ai1wm_open( ai1wm_blogs_path( $params ), 'w' );
|
||||
ai1wm_write( $handle, json_encode( $blogs ) );
|
||||
ai1wm_close( $handle );
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Blogs prepared.', 'all-in-one-wp-migration' ) );
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Check_Compression {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
// Read package.json file
|
||||
$handle = ai1wm_open( ai1wm_package_path( $params ), 'r' );
|
||||
|
||||
// Parse package.json file
|
||||
$package = ai1wm_read( $handle, filesize( ai1wm_package_path( $params ) ) );
|
||||
$package = json_decode( $package, true );
|
||||
|
||||
// Close handle
|
||||
ai1wm_close( $handle );
|
||||
|
||||
// No compression provided
|
||||
if ( empty( $package['Compression']['Enabled'] ) || empty( $package['Compression']['Type'] ) ) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
// Check if server supports decompression
|
||||
if ( ! ai1wm_has_compression_type( $package['Compression']['Type'] ) ) {
|
||||
throw new Ai1wm_Import_Exception(
|
||||
wp_kses(
|
||||
sprintf(
|
||||
__(
|
||||
'Importing a compressed backup is not supported on this server.
|
||||
Please ensure <strong>%s</strong> extension is enabled. <a href="https://help.servmask.com/knowledgebase/compressed-backups/" target="_blank">Technical details</a>',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
$package['Compression']['Type']
|
||||
),
|
||||
ai1wm_allowed_html_tags()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Set progres
|
||||
Ai1wm_Status::info( __( 'Compressed backup detected. Compression will be handled automatically.', 'all-in-one-wp-migration' ) );
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Check_Encryption {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
// Read package.json file
|
||||
$handle = ai1wm_open( ai1wm_package_path( $params ), 'r' );
|
||||
|
||||
// Parse package.json file
|
||||
$package = ai1wm_read( $handle, filesize( ai1wm_package_path( $params ) ) );
|
||||
$package = json_decode( $package, true );
|
||||
|
||||
// Close handle
|
||||
ai1wm_close( $handle );
|
||||
|
||||
// No encryption provided
|
||||
if ( empty( $package['Encrypted'] ) || empty( $package['EncryptedSignature'] ) ) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
// Check decryption support
|
||||
if ( ! ai1wm_can_decrypt() ) {
|
||||
if ( defined( 'WP_CLI' ) ) {
|
||||
WP_CLI::error( __( 'Importing an encrypted backup is not supported on this server. The process cannot continue. Technical details: https://help.servmask.com/knowledgebase/unable-to-encrypt-and-decrypt-backups/', 'all-in-one-wp-migration' ) );
|
||||
} else {
|
||||
Ai1wm_Status::server_cannot_decrypt( __( 'Importing an encrypted backup is not supported on this server. The process cannot continue. <a href="https://help.servmask.com/knowledgebase/unable-to-encrypt-and-decrypt-backups/" target="_blank">Technical details</a>', 'all-in-one-wp-migration' ) );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// Get WP CLI decryption password
|
||||
if ( defined( 'WP_CLI' ) ) {
|
||||
$params['decryption_password'] = readline( __( 'Backup is encrypted. Please provide decryption password: ', 'all-in-one-wp-migration' ) );
|
||||
}
|
||||
|
||||
// Validate decryption password
|
||||
if ( ! empty( $params['decryption_password'] ) ) {
|
||||
if ( ai1wm_is_decryption_password_valid( $package['EncryptedSignature'], $params['decryption_password'] ) ) {
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Decryption password validated.', 'all-in-one-wp-migration' ) );
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
$decryption_password_error = __( 'The decryption password is not valid. The process cannot continue.', 'all-in-one-wp-migration' );
|
||||
|
||||
if ( defined( 'WP_CLI' ) ) {
|
||||
WP_CLI::error( $decryption_password_error );
|
||||
} else {
|
||||
Ai1wm_Status::backup_is_encrypted( $decryption_password_error );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
Ai1wm_Status::backup_is_encrypted( null );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Clean {
|
||||
|
||||
public static function execute( $params ) {
|
||||
// Get database client
|
||||
$db_client = Ai1wm_Database_Utility::get_client();
|
||||
|
||||
// Flush mainsite tables
|
||||
$db_client->add_table_prefix_filter( ai1wm_table_prefix( 'mainsite' ) );
|
||||
$db_client->flush();
|
||||
|
||||
// Trigger import cancel action
|
||||
if ( isset( $params['ai1wm_import_cancel'] ) ) {
|
||||
do_action( 'ai1wm_status_import_canceled', $params );
|
||||
} else {
|
||||
do_action( 'ai1wm_status_import_done', $params );
|
||||
}
|
||||
|
||||
// Delete storage files
|
||||
Ai1wm_Directory::delete( ai1wm_storage_path( $params ) );
|
||||
|
||||
// Exit in console
|
||||
if ( defined( 'WP_CLI' ) ) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Compatibility {
|
||||
|
||||
public static function execute( $params ) {
|
||||
do_action( 'ai1wm_status_import_start', $params );
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Checking for compatibility...', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Get messages
|
||||
$messages = Ai1wm_Compatibility::get( $params );
|
||||
|
||||
// Set messages
|
||||
if ( empty( $messages ) ) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
// Error message
|
||||
throw new Ai1wm_Compatibility_Exception( wp_kses( implode( $messages ), ai1wm_allowed_html_tags() ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Confirm {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
$messages = array();
|
||||
|
||||
// Read package.json file
|
||||
$handle = ai1wm_open( ai1wm_package_path( $params ), 'r' );
|
||||
|
||||
// Parse package.json file
|
||||
$package = ai1wm_read( $handle, filesize( ai1wm_package_path( $params ) ) );
|
||||
$package = json_decode( $package, true );
|
||||
|
||||
// Close handle
|
||||
ai1wm_close( $handle );
|
||||
|
||||
// Confirm message
|
||||
if ( defined( 'WP_CLI' ) ) {
|
||||
$messages[] = sprintf(
|
||||
/* translators: Link to Unlimited Extension */
|
||||
__(
|
||||
'Importing this file will only replace matching content. Other items stay unchanged.
|
||||
Need a full reset first? Try Reset Hub in our Unlimited Extension (%s).
|
||||
Ensure you have a current backup. Proceed?',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
'https://servmask.com/products/unlimited-extension'
|
||||
);
|
||||
} else {
|
||||
$messages[] = sprintf(
|
||||
/* translators: Link to Unlimited Extension */
|
||||
__(
|
||||
'Importing this file will only replace matching content. Other items stay unchanged.
|
||||
Need a full reset first? Try Reset Hub in our <a href="%s" target="_blank">Unlimited Extension</a>.<br />
|
||||
Ensure you have a current backup. Proceed?',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
'https://servmask.com/products/unlimited-extension?utm_source=import-confirm&utm_medium=plugin&utm_campaign=ai1wm'
|
||||
);
|
||||
}
|
||||
|
||||
// Check compatibility of PHP versions
|
||||
if ( isset( $package['PHP']['Version'] ) ) {
|
||||
// Extract major and minor version numbers
|
||||
$source_versions = explode( '.', $package['PHP']['Version'] );
|
||||
$target_versions = explode( '.', PHP_VERSION );
|
||||
|
||||
$source_major_version = intval( $source_versions[0] );
|
||||
$source_minor_version = intval( isset( $source_versions[1] ) ? $source_versions[1] : 0 );
|
||||
|
||||
$target_major_version = intval( $target_versions[0] );
|
||||
$target_minor_version = intval( isset( $target_versions[1] ) ? $target_versions[1] : 0 );
|
||||
|
||||
if ( $source_major_version !== $target_major_version ) {
|
||||
$from_php = $source_major_version;
|
||||
$to_php = $target_major_version;
|
||||
} elseif ( $source_minor_version !== $target_minor_version ) {
|
||||
$from_php = sprintf( '%s.%s', $source_major_version, $source_minor_version );
|
||||
$to_php = sprintf( '%s.%s', $target_major_version, $target_minor_version );
|
||||
}
|
||||
|
||||
if ( isset( $from_php, $to_php ) ) {
|
||||
if ( defined( 'WP_CLI' ) ) {
|
||||
$messages[] = sprintf(
|
||||
/* translators: 1: Source PHP version, 2: Target PHP version. */
|
||||
__(
|
||||
'Your backup is from a PHP %1$s but the site that you are importing to is PHP %2$s.
|
||||
This could cause the import to fail. Technical details: https://help.servmask.com/knowledgebase/migrate-wordpress-from-php-5-to-php-7/',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
$from_php,
|
||||
$to_php
|
||||
);
|
||||
} else {
|
||||
$messages[] = sprintf(
|
||||
'<i class="ai1wm-import-info">' .
|
||||
/* translators: 1: Source PHP version, 2: Target PHP version. */
|
||||
__(
|
||||
'Your backup is from a PHP %1$s but the site that you are importing to is PHP %2$s. This could cause the import to fail. <a href="https://help.servmask.com/knowledgebase/migrate-wordpress-from-php-5-to-php-7/" target="_blank">Technical details</a>',
|
||||
'all-in-one-wp-migration'
|
||||
) . '</i>',
|
||||
$from_php,
|
||||
$to_php
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( defined( 'WP_CLI' ) ) {
|
||||
$assoc_args = array();
|
||||
if ( isset( $params['cli_args'] ) ) {
|
||||
$assoc_args = $params['cli_args'];
|
||||
}
|
||||
|
||||
WP_CLI::confirm( implode( PHP_EOL, $messages ), $assoc_args );
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::confirm( implode( $messages ) );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,306 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Content {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
// Set decryption password
|
||||
$decryption_password = null;
|
||||
if ( isset( $params['decryption_password'] ) ) {
|
||||
$decryption_password = $params['decryption_password'];
|
||||
}
|
||||
|
||||
// Set archive bytes offset
|
||||
if ( isset( $params['archive_bytes_offset'] ) ) {
|
||||
$archive_bytes_offset = (int) $params['archive_bytes_offset'];
|
||||
} else {
|
||||
$archive_bytes_offset = 0;
|
||||
}
|
||||
|
||||
// Set file bytes offset
|
||||
if ( isset( $params['file_bytes_offset'] ) ) {
|
||||
$file_bytes_offset = (int) $params['file_bytes_offset'];
|
||||
} else {
|
||||
$file_bytes_offset = 0;
|
||||
}
|
||||
|
||||
// Set file bytes written
|
||||
if ( isset( $params['file_bytes_written'] ) ) {
|
||||
$file_bytes_written = (int) $params['file_bytes_written'];
|
||||
} else {
|
||||
$file_bytes_written = 0;
|
||||
}
|
||||
|
||||
// Get processed files size
|
||||
if ( isset( $params['processed_files_size'] ) ) {
|
||||
$processed_files_size = (int) $params['processed_files_size'];
|
||||
} else {
|
||||
$processed_files_size = 0;
|
||||
}
|
||||
|
||||
// Get total files size
|
||||
if ( isset( $params['total_files_size'] ) ) {
|
||||
$total_files_size = (int) $params['total_files_size'];
|
||||
} else {
|
||||
$total_files_size = 1;
|
||||
}
|
||||
|
||||
// Get total files count
|
||||
if ( isset( $params['total_files_count'] ) ) {
|
||||
$total_files_count = (int) $params['total_files_count'];
|
||||
} else {
|
||||
$total_files_count = 1;
|
||||
}
|
||||
|
||||
// Read blogs.json file
|
||||
$handle = ai1wm_open( ai1wm_blogs_path( $params ), 'r' );
|
||||
|
||||
// Parse blogs.json file
|
||||
$blogs = ai1wm_read( $handle, filesize( ai1wm_blogs_path( $params ) ) );
|
||||
$blogs = json_decode( $blogs, true );
|
||||
|
||||
// Close handle
|
||||
ai1wm_close( $handle );
|
||||
|
||||
// Read package.json file
|
||||
$handle = ai1wm_open( ai1wm_package_path( $params ), 'r' );
|
||||
|
||||
// Parse package.json file
|
||||
$config = ai1wm_read( $handle, filesize( ai1wm_package_path( $params ) ) );
|
||||
$config = json_decode( $config, true );
|
||||
|
||||
// Close handle
|
||||
ai1wm_close( $handle );
|
||||
|
||||
// What percent of files have we processed?
|
||||
$progress = (int) min( ( $processed_files_size / $total_files_size ) * 100, 100 );
|
||||
|
||||
// Set progress
|
||||
/* translators: 1: Number of files, 2: Progress. */
|
||||
Ai1wm_Status::info( sprintf( __( 'Restoring %1$d files...<br />%2$d%% complete', 'all-in-one-wp-migration' ), $total_files_count, $progress ) );
|
||||
|
||||
// Flag to hold if file data has been processed
|
||||
$completed = true;
|
||||
|
||||
// Start time
|
||||
$start = microtime( true );
|
||||
|
||||
// Get compression type
|
||||
$compression_type = null;
|
||||
if ( ! empty( $config['Compression']['Enabled'] ) ) {
|
||||
$compression_type = $config['Compression']['Type'];
|
||||
}
|
||||
|
||||
// Open the archive file for reading
|
||||
$archive = new Ai1wm_Extractor( ai1wm_archive_path( $params ), $decryption_password, $compression_type );
|
||||
|
||||
// Set the file pointer to the one that we have saved
|
||||
$archive->set_file_pointer( $archive_bytes_offset );
|
||||
|
||||
$old_paths = array( 'plugins', 'themes' );
|
||||
$new_paths = array( ai1wm_get_plugins_dir(), get_theme_root() );
|
||||
|
||||
// Set extract paths
|
||||
foreach ( $blogs as $blog ) {
|
||||
if ( ai1wm_is_mainsite( $blog['Old']['BlogID'] ) === false ) {
|
||||
if ( defined( 'UPLOADBLOGSDIR' ) ) {
|
||||
// Old files dir style
|
||||
$old_paths[] = ai1wm_blog_files_relpath( $blog['Old']['BlogID'] );
|
||||
$new_paths[] = ai1wm_blog_files_abspath( $blog['New']['BlogID'] );
|
||||
|
||||
// Old blogs.dir style
|
||||
$old_paths[] = ai1wm_blog_blogsdir_relpath( $blog['Old']['BlogID'] );
|
||||
$new_paths[] = ai1wm_blog_blogsdir_abspath( $blog['New']['BlogID'] );
|
||||
|
||||
// New sites dir style
|
||||
$old_paths[] = ai1wm_blog_sites_relpath( $blog['Old']['BlogID'] );
|
||||
$new_paths[] = ai1wm_blog_files_abspath( $blog['New']['BlogID'] );
|
||||
} else {
|
||||
// Old files dir style
|
||||
$old_paths[] = ai1wm_blog_files_relpath( $blog['Old']['BlogID'] );
|
||||
$new_paths[] = ai1wm_blog_sites_abspath( $blog['New']['BlogID'] );
|
||||
|
||||
// Old blogs.dir style
|
||||
$old_paths[] = ai1wm_blog_blogsdir_relpath( $blog['Old']['BlogID'] );
|
||||
$new_paths[] = ai1wm_blog_sites_abspath( $blog['New']['BlogID'] );
|
||||
|
||||
// New sites dir style
|
||||
$old_paths[] = ai1wm_blog_sites_relpath( $blog['Old']['BlogID'] );
|
||||
$new_paths[] = ai1wm_blog_sites_abspath( $blog['New']['BlogID'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set base site extract paths (should be added at the end of arrays)
|
||||
foreach ( $blogs as $blog ) {
|
||||
if ( ai1wm_is_mainsite( $blog['Old']['BlogID'] ) === true ) {
|
||||
if ( defined( 'UPLOADBLOGSDIR' ) ) {
|
||||
// Old files dir style
|
||||
$old_paths[] = ai1wm_blog_files_relpath( $blog['Old']['BlogID'] );
|
||||
$new_paths[] = ai1wm_blog_files_abspath( $blog['New']['BlogID'] );
|
||||
|
||||
// Old blogs.dir style
|
||||
$old_paths[] = ai1wm_blog_blogsdir_relpath( $blog['Old']['BlogID'] );
|
||||
$new_paths[] = ai1wm_blog_blogsdir_abspath( $blog['New']['BlogID'] );
|
||||
|
||||
// New sites dir style
|
||||
$old_paths[] = ai1wm_blog_sites_relpath( $blog['Old']['BlogID'] );
|
||||
$new_paths[] = ai1wm_blog_files_abspath( $blog['New']['BlogID'] );
|
||||
} else {
|
||||
// Old files dir style
|
||||
$old_paths[] = ai1wm_blog_files_relpath( $blog['Old']['BlogID'] );
|
||||
$new_paths[] = ai1wm_blog_sites_abspath( $blog['New']['BlogID'] );
|
||||
|
||||
// Old blogs.dir style
|
||||
$old_paths[] = ai1wm_blog_blogsdir_relpath( $blog['Old']['BlogID'] );
|
||||
$new_paths[] = ai1wm_blog_sites_abspath( $blog['New']['BlogID'] );
|
||||
|
||||
// New sites dir style
|
||||
$old_paths[] = ai1wm_blog_sites_relpath( $blog['Old']['BlogID'] );
|
||||
$new_paths[] = ai1wm_blog_sites_abspath( $blog['New']['BlogID'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$old_paths[] = ai1wm_blog_sites_relpath();
|
||||
$new_paths[] = ai1wm_blog_sites_abspath();
|
||||
|
||||
while ( $archive->has_not_reached_eof() ) {
|
||||
$file_bytes_read = 0;
|
||||
|
||||
// Exclude WordPress files
|
||||
$exclude_files = array_keys( _get_dropins() );
|
||||
|
||||
// Exclude plugin files
|
||||
$exclude_files = array_merge(
|
||||
$exclude_files,
|
||||
array(
|
||||
AI1WM_PACKAGE_NAME,
|
||||
AI1WM_MULTISITE_NAME,
|
||||
AI1WM_DATABASE_NAME,
|
||||
AI1WM_MUPLUGINS_NAME,
|
||||
)
|
||||
);
|
||||
|
||||
// Exclude theme files
|
||||
$exclude_files = array_merge( $exclude_files, array( AI1WM_THEMES_FUNCTIONS_NAME ) );
|
||||
|
||||
// Exclude Elementor files
|
||||
$exclude_files = array_merge( $exclude_files, array( AI1WM_ELEMENTOR_CSS_NAME ) );
|
||||
|
||||
// Exclude CiviCRM files
|
||||
$exclude_files = array_merge( $exclude_files, array( AI1WM_CIVICRM_UPLOADS_NAME ) );
|
||||
|
||||
// Exclude content extensions
|
||||
$exclude_extensions = array( AI1WM_LESS_CACHE_EXTENSION, AI1WM_SQLITE_DATABASE_EXTENSION );
|
||||
|
||||
// Extract a file from archive to WP_CONTENT_DIR
|
||||
if ( ( $completed = $archive->extract_one_file_to( WP_CONTENT_DIR, $exclude_files, $exclude_extensions, $old_paths, $new_paths, $file_bytes_read, $file_bytes_offset, $file_bytes_written ) ) ) {
|
||||
$file_bytes_offset = $file_bytes_written = 0;
|
||||
}
|
||||
|
||||
// Get archive bytes offset
|
||||
$archive_bytes_offset = $archive->get_file_pointer();
|
||||
|
||||
// Increment processed files size
|
||||
$processed_files_size += $file_bytes_read;
|
||||
|
||||
// What percent of files have we processed?
|
||||
$progress = (int) min( ( $processed_files_size / $total_files_size ) * 100, 100 );
|
||||
|
||||
// Set progress
|
||||
/* translators: 1: Number of files, 2: Progress. */
|
||||
Ai1wm_Status::info( sprintf( __( 'Restoring %1$d files...<br />%2$d%% complete', 'all-in-one-wp-migration' ), $total_files_count, $progress ) );
|
||||
|
||||
// More than 10 seconds have passed, break and do another request
|
||||
if ( ( $timeout = apply_filters( 'ai1wm_completed_timeout', 10 ) ) ) {
|
||||
if ( ( microtime( true ) - $start ) > $timeout ) {
|
||||
$completed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// End of the archive?
|
||||
if ( $archive->has_reached_eof() ) {
|
||||
|
||||
// Unset archive bytes offset
|
||||
unset( $params['archive_bytes_offset'] );
|
||||
|
||||
// Unset file bytes offset
|
||||
unset( $params['file_bytes_offset'] );
|
||||
|
||||
// Unset file bytes written
|
||||
unset( $params['file_bytes_written'] );
|
||||
|
||||
// Unset processed files size
|
||||
unset( $params['processed_files_size'] );
|
||||
|
||||
// Unset total files size
|
||||
unset( $params['total_files_size'] );
|
||||
|
||||
// Unset total files count
|
||||
unset( $params['total_files_count'] );
|
||||
|
||||
// Unset completed flag
|
||||
unset( $params['completed'] );
|
||||
|
||||
} else {
|
||||
|
||||
// Set archive bytes offset
|
||||
$params['archive_bytes_offset'] = $archive_bytes_offset;
|
||||
|
||||
// Set file bytes offset
|
||||
$params['file_bytes_offset'] = $file_bytes_offset;
|
||||
|
||||
// Set file bytes written
|
||||
$params['file_bytes_written'] = $file_bytes_written;
|
||||
|
||||
// Set processed files size
|
||||
$params['processed_files_size'] = $processed_files_size;
|
||||
|
||||
// Set total files size
|
||||
$params['total_files_size'] = $total_files_size;
|
||||
|
||||
// Set total files count
|
||||
$params['total_files_count'] = $total_files_count;
|
||||
|
||||
// Set completed flag
|
||||
$params['completed'] = $completed;
|
||||
}
|
||||
|
||||
// Close the archive file
|
||||
$archive->close();
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Database_File {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
// Set decryption password
|
||||
$decryption_password = null;
|
||||
if ( isset( $params['decryption_password'] ) ) {
|
||||
$decryption_password = $params['decryption_password'];
|
||||
}
|
||||
|
||||
// Set archive bytes offset
|
||||
if ( isset( $params['archive_bytes_offset'] ) ) {
|
||||
$archive_bytes_offset = (int) $params['archive_bytes_offset'];
|
||||
} else {
|
||||
$archive_bytes_offset = 0;
|
||||
}
|
||||
|
||||
// Set file bytes offset
|
||||
if ( isset( $params['file_bytes_offset'] ) ) {
|
||||
$file_bytes_offset = (int) $params['file_bytes_offset'];
|
||||
} else {
|
||||
$file_bytes_offset = 0;
|
||||
}
|
||||
|
||||
// Set file bytes written
|
||||
if ( isset( $params['file_bytes_written'] ) ) {
|
||||
$file_bytes_written = (int) $params['file_bytes_written'];
|
||||
} else {
|
||||
$file_bytes_written = 0;
|
||||
}
|
||||
|
||||
// Get total archive size
|
||||
if ( isset( $params['total_archive_size'] ) ) {
|
||||
$total_archive_size = (int) $params['total_archive_size'];
|
||||
} else {
|
||||
$total_archive_size = ai1wm_archive_bytes( $params );
|
||||
}
|
||||
|
||||
// Read package.json file
|
||||
$handle = ai1wm_open( ai1wm_package_path( $params ), 'r' );
|
||||
|
||||
// Parse package.json file
|
||||
$config = ai1wm_read( $handle, filesize( ai1wm_package_path( $params ) ) );
|
||||
$config = json_decode( $config, true );
|
||||
|
||||
// Close handle
|
||||
ai1wm_close( $handle );
|
||||
|
||||
// What percent of archive have we processed?
|
||||
$progress = (int) min( ( $archive_bytes_offset / $total_archive_size ) * 100, 100 );
|
||||
|
||||
// Set progress
|
||||
/* translators: Progress. */
|
||||
Ai1wm_Status::info( sprintf( __( 'Unpacking database...<br />%d%% complete', 'all-in-one-wp-migration' ), $progress ) );
|
||||
|
||||
// Get compression type
|
||||
$compression_type = null;
|
||||
if ( ! empty( $config['Compression']['Enabled'] ) ) {
|
||||
$compression_type = $config['Compression']['Type'];
|
||||
}
|
||||
|
||||
// Open the archive file for reading
|
||||
$archive = new Ai1wm_Extractor( ai1wm_archive_path( $params ), $decryption_password, $compression_type );
|
||||
|
||||
// Set the file pointer to the one that we have saved
|
||||
$archive->set_file_pointer( $archive_bytes_offset );
|
||||
|
||||
// Flag to hold if file data has been processed
|
||||
$completed = true;
|
||||
|
||||
if ( $archive->has_not_reached_eof() ) {
|
||||
$file_bytes_read = 0;
|
||||
|
||||
// Unpack database.sql file
|
||||
if ( ( $completed = $archive->extract_by_files_array( ai1wm_storage_path( $params ), array( AI1WM_DATABASE_NAME ), array(), array(), $file_bytes_read, $file_bytes_offset, $file_bytes_written ) ) ) {
|
||||
$file_bytes_offset = $file_bytes_written = 0;
|
||||
}
|
||||
|
||||
// Get archive bytes offset
|
||||
$archive_bytes_offset = $archive->get_file_pointer();
|
||||
}
|
||||
|
||||
// End of the archive?
|
||||
if ( $archive->has_reached_eof() ) {
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Database unpacked.', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Unset archive bytes offset
|
||||
unset( $params['archive_bytes_offset'] );
|
||||
|
||||
// Unset file bytes offset
|
||||
unset( $params['file_bytes_offset'] );
|
||||
|
||||
// Unset file bytes written
|
||||
unset( $params['file_bytes_written'] );
|
||||
|
||||
// Unset total archive size
|
||||
unset( $params['total_archive_size'] );
|
||||
|
||||
// Unset completed flag
|
||||
unset( $params['completed'] );
|
||||
|
||||
} else {
|
||||
|
||||
// What percent of archive have we processed?
|
||||
$progress = (int) min( ( $archive_bytes_offset / $total_archive_size ) * 100, 100 );
|
||||
|
||||
// Set progress
|
||||
/* translators: Progress. */
|
||||
Ai1wm_Status::info( sprintf( __( 'Unpacking database...<br />%d%% complete', 'all-in-one-wp-migration' ), $progress ) );
|
||||
|
||||
// Set archive bytes offset
|
||||
$params['archive_bytes_offset'] = $archive_bytes_offset;
|
||||
|
||||
// Set file bytes offset
|
||||
$params['file_bytes_offset'] = $file_bytes_offset;
|
||||
|
||||
// Set file bytes written
|
||||
$params['file_bytes_written'] = $file_bytes_written;
|
||||
|
||||
// Set total archive size
|
||||
$params['total_archive_size'] = $total_archive_size;
|
||||
|
||||
// Set completed flag
|
||||
$params['completed'] = $completed;
|
||||
}
|
||||
|
||||
// Close the archive file
|
||||
$archive->close();
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,376 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Done {
|
||||
|
||||
public static function execute( $params ) {
|
||||
global $wp_rewrite;
|
||||
|
||||
// Check multisite.json file
|
||||
if ( is_file( ai1wm_multisite_path( $params ) ) ) {
|
||||
|
||||
// Read multisite.json file
|
||||
$handle = ai1wm_open( ai1wm_multisite_path( $params ), 'r' );
|
||||
|
||||
// Parse multisite.json file
|
||||
$multisite = ai1wm_read( $handle, filesize( ai1wm_multisite_path( $params ) ) );
|
||||
$multisite = json_decode( $multisite, true );
|
||||
|
||||
// Close handle
|
||||
ai1wm_close( $handle );
|
||||
|
||||
// Activate WordPress plugins
|
||||
if ( isset( $multisite['Plugins'] ) && ( $plugins = $multisite['Plugins'] ) ) {
|
||||
ai1wm_activate_plugins( $plugins );
|
||||
}
|
||||
|
||||
// Deactivate WordPress SSL plugins
|
||||
if ( ! is_ssl() ) {
|
||||
ai1wm_deactivate_plugins(
|
||||
array(
|
||||
ai1wm_discover_plugin_basename( 'really-simple-ssl/rlrsssl-really-simple-ssl.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wordpress-https/wordpress-https.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wp-force-ssl/wp-force-ssl.php' ),
|
||||
ai1wm_discover_plugin_basename( 'force-https-littlebizzy/force-https.php' ),
|
||||
)
|
||||
);
|
||||
|
||||
ai1wm_woocommerce_force_ssl( false );
|
||||
}
|
||||
|
||||
// Deactivate WordPress plugins
|
||||
ai1wm_deactivate_plugins(
|
||||
array(
|
||||
ai1wm_discover_plugin_basename( 'invisible-recaptcha/invisible-recaptcha.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wps-hide-login/wps-hide-login.php' ),
|
||||
ai1wm_discover_plugin_basename( 'hide-my-wp/index.php' ),
|
||||
ai1wm_discover_plugin_basename( 'hide-my-wordpress/index.php' ),
|
||||
ai1wm_discover_plugin_basename( 'mycustomwidget/my_custom_widget.php' ),
|
||||
ai1wm_discover_plugin_basename( 'lockdown-wp-admin/lockdown-wp-admin.php' ),
|
||||
ai1wm_discover_plugin_basename( 'rename-wp-login/rename-wp-login.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wp-simple-firewall/icwp-wpsf.php' ),
|
||||
ai1wm_discover_plugin_basename( 'join-my-multisite/joinmymultisite.php' ),
|
||||
ai1wm_discover_plugin_basename( 'multisite-clone-duplicator/multisite-clone-duplicator.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wordpress-mu-domain-mapping/domain_mapping.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wordpress-starter/siteground-wizard.php' ),
|
||||
ai1wm_discover_plugin_basename( 'pro-sites/pro-sites.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wpide/WPide.php' ),
|
||||
ai1wm_discover_plugin_basename( 'page-optimize/page-optimize.php' ),
|
||||
ai1wm_discover_plugin_basename( 'update-services/update-services.php' ),
|
||||
)
|
||||
);
|
||||
|
||||
// Deactivate Swift Optimizer rules
|
||||
ai1wm_deactivate_swift_optimizer_rules(
|
||||
array(
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration/all-in-one-wp-migration.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-azure-storage-extension/all-in-one-wp-migration-azure-storage-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-b2-extension/all-in-one-wp-migration-b2-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-backup/all-in-one-wp-migration-backup.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-box-extension/all-in-one-wp-migration-box-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-digitalocean-extension/all-in-one-wp-migration-digitalocean-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-direct-extension/all-in-one-wp-migration-direct-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-dropbox-extension/all-in-one-wp-migration-dropbox-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-file-extension/all-in-one-wp-migration-file-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-ftp-extension/all-in-one-wp-migration-ftp-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-gcloud-storage-extension/all-in-one-wp-migration-gcloud-storage-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-gdrive-extension/all-in-one-wp-migration-gdrive-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-glacier-extension/all-in-one-wp-migration-glacier-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-mega-extension/all-in-one-wp-migration-mega-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-multisite-extension/all-in-one-wp-migration-multisite-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-onedrive-extension/all-in-one-wp-migration-onedrive-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-pcloud-extension/all-in-one-wp-migration-pcloud-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-pro/all-in-one-wp-migration-pro.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-s3-client-extension/all-in-one-wp-migration-s3-client-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-s3-extension/all-in-one-wp-migration-s3-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-unlimited-extension/all-in-one-wp-migration-unlimited-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-url-extension/all-in-one-wp-migration-url-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-webdav-extension/all-in-one-wp-migration-webdav-extension.php' ),
|
||||
)
|
||||
);
|
||||
|
||||
// Deactivate Revolution Slider
|
||||
ai1wm_deactivate_revolution_slider( ai1wm_discover_plugin_basename( 'revslider/revslider.php' ) );
|
||||
|
||||
// Deactivate Jetpack modules
|
||||
ai1wm_deactivate_jetpack_modules( array( 'photon', 'sso' ) );
|
||||
|
||||
// Flush Elementor cache
|
||||
ai1wm_elementor_cache_flush();
|
||||
|
||||
// Initial DB version
|
||||
ai1wm_initial_db_version();
|
||||
|
||||
} else {
|
||||
|
||||
// Check package.json file
|
||||
if ( is_file( ai1wm_package_path( $params ) ) ) {
|
||||
|
||||
// Read package.json file
|
||||
$handle = ai1wm_open( ai1wm_package_path( $params ), 'r' );
|
||||
|
||||
// Parse package.json file
|
||||
$package = ai1wm_read( $handle, filesize( ai1wm_package_path( $params ) ) );
|
||||
$package = json_decode( $package, true );
|
||||
|
||||
// Close handle
|
||||
ai1wm_close( $handle );
|
||||
|
||||
// Activate WordPress plugins
|
||||
if ( isset( $package['Plugins'] ) && ( $plugins = $package['Plugins'] ) ) {
|
||||
ai1wm_activate_plugins( $plugins );
|
||||
}
|
||||
|
||||
// Activate WordPress template
|
||||
if ( isset( $package['Template'] ) && ( $template = $package['Template'] ) ) {
|
||||
ai1wm_activate_template( $template );
|
||||
}
|
||||
|
||||
// Activate WordPress stylesheet
|
||||
if ( isset( $package['Stylesheet'] ) && ( $stylesheet = $package['Stylesheet'] ) ) {
|
||||
ai1wm_activate_stylesheet( $stylesheet );
|
||||
}
|
||||
|
||||
// Deactivate WordPress SSL plugins
|
||||
if ( ! is_ssl() ) {
|
||||
ai1wm_deactivate_plugins(
|
||||
array(
|
||||
ai1wm_discover_plugin_basename( 'really-simple-ssl/rlrsssl-really-simple-ssl.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wordpress-https/wordpress-https.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wp-force-ssl/wp-force-ssl.php' ),
|
||||
ai1wm_discover_plugin_basename( 'force-https-littlebizzy/force-https.php' ),
|
||||
)
|
||||
);
|
||||
|
||||
ai1wm_woocommerce_force_ssl( false );
|
||||
}
|
||||
|
||||
// Deactivate WordPress plugins
|
||||
ai1wm_deactivate_plugins(
|
||||
array(
|
||||
ai1wm_discover_plugin_basename( 'invisible-recaptcha/invisible-recaptcha.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wps-hide-login/wps-hide-login.php' ),
|
||||
ai1wm_discover_plugin_basename( 'hide-my-wp/index.php' ),
|
||||
ai1wm_discover_plugin_basename( 'hide-my-wordpress/index.php' ),
|
||||
ai1wm_discover_plugin_basename( 'mycustomwidget/my_custom_widget.php' ),
|
||||
ai1wm_discover_plugin_basename( 'lockdown-wp-admin/lockdown-wp-admin.php' ),
|
||||
ai1wm_discover_plugin_basename( 'rename-wp-login/rename-wp-login.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wp-simple-firewall/icwp-wpsf.php' ),
|
||||
ai1wm_discover_plugin_basename( 'join-my-multisite/joinmymultisite.php' ),
|
||||
ai1wm_discover_plugin_basename( 'multisite-clone-duplicator/multisite-clone-duplicator.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wordpress-mu-domain-mapping/domain_mapping.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wordpress-starter/siteground-wizard.php' ),
|
||||
ai1wm_discover_plugin_basename( 'pro-sites/pro-sites.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wpide/WPide.php' ),
|
||||
ai1wm_discover_plugin_basename( 'page-optimize/page-optimize.php' ),
|
||||
ai1wm_discover_plugin_basename( 'update-services/update-services.php' ),
|
||||
)
|
||||
);
|
||||
|
||||
// Deactivate Swift Optimizer rules
|
||||
ai1wm_deactivate_swift_optimizer_rules(
|
||||
array(
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration/all-in-one-wp-migration.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-azure-storage-extension/all-in-one-wp-migration-azure-storage-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-b2-extension/all-in-one-wp-migration-b2-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-backup/all-in-one-wp-migration-backup.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-box-extension/all-in-one-wp-migration-box-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-digitalocean-extension/all-in-one-wp-migration-digitalocean-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-direct-extension/all-in-one-wp-migration-direct-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-dropbox-extension/all-in-one-wp-migration-dropbox-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-file-extension/all-in-one-wp-migration-file-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-ftp-extension/all-in-one-wp-migration-ftp-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-gcloud-storage-extension/all-in-one-wp-migration-gcloud-storage-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-gdrive-extension/all-in-one-wp-migration-gdrive-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-glacier-extension/all-in-one-wp-migration-glacier-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-mega-extension/all-in-one-wp-migration-mega-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-multisite-extension/all-in-one-wp-migration-multisite-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-onedrive-extension/all-in-one-wp-migration-onedrive-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-pcloud-extension/all-in-one-wp-migration-pcloud-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-pro/all-in-one-wp-migration-pro.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-s3-client-extension/all-in-one-wp-migration-s3-client-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-s3-extension/all-in-one-wp-migration-s3-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-unlimited-extension/all-in-one-wp-migration-unlimited-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-url-extension/all-in-one-wp-migration-url-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-webdav-extension/all-in-one-wp-migration-webdav-extension.php' ),
|
||||
)
|
||||
);
|
||||
|
||||
// Deactivate Revolution Slider
|
||||
ai1wm_deactivate_revolution_slider( ai1wm_discover_plugin_basename( 'revslider/revslider.php' ) );
|
||||
|
||||
// Deactivate Jetpack modules
|
||||
ai1wm_deactivate_jetpack_modules( array( 'photon', 'sso' ) );
|
||||
|
||||
// Flush Elementor cache
|
||||
ai1wm_elementor_cache_flush();
|
||||
|
||||
// Initial DB version
|
||||
ai1wm_initial_db_version();
|
||||
}
|
||||
}
|
||||
|
||||
// Check blogs.json file
|
||||
if ( is_file( ai1wm_blogs_path( $params ) ) ) {
|
||||
|
||||
// Read blogs.json file
|
||||
$handle = ai1wm_open( ai1wm_blogs_path( $params ), 'r' );
|
||||
|
||||
// Parse blogs.json file
|
||||
$blogs = ai1wm_read( $handle, filesize( ai1wm_blogs_path( $params ) ) );
|
||||
$blogs = json_decode( $blogs, true );
|
||||
|
||||
// Close handle
|
||||
ai1wm_close( $handle );
|
||||
|
||||
// Loop over blogs
|
||||
foreach ( $blogs as $blog ) {
|
||||
|
||||
// Activate WordPress plugins
|
||||
if ( isset( $blog['New']['Plugins'] ) && ( $plugins = $blog['New']['Plugins'] ) ) {
|
||||
ai1wm_activate_plugins( $plugins );
|
||||
}
|
||||
|
||||
// Activate WordPress template
|
||||
if ( isset( $blog['New']['Template'] ) && ( $template = $blog['New']['Template'] ) ) {
|
||||
ai1wm_activate_template( $template );
|
||||
}
|
||||
|
||||
// Activate WordPress stylesheet
|
||||
if ( isset( $blog['New']['Stylesheet'] ) && ( $stylesheet = $blog['New']['Stylesheet'] ) ) {
|
||||
ai1wm_activate_stylesheet( $stylesheet );
|
||||
}
|
||||
|
||||
// Deactivate WordPress SSL plugins
|
||||
if ( ! is_ssl() ) {
|
||||
ai1wm_deactivate_plugins(
|
||||
array(
|
||||
ai1wm_discover_plugin_basename( 'really-simple-ssl/rlrsssl-really-simple-ssl.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wordpress-https/wordpress-https.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wp-force-ssl/wp-force-ssl.php' ),
|
||||
ai1wm_discover_plugin_basename( 'force-https-littlebizzy/force-https.php' ),
|
||||
)
|
||||
);
|
||||
|
||||
ai1wm_woocommerce_force_ssl( false );
|
||||
}
|
||||
|
||||
// Deactivate WordPress plugins
|
||||
ai1wm_deactivate_plugins(
|
||||
array(
|
||||
ai1wm_discover_plugin_basename( 'invisible-recaptcha/invisible-recaptcha.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wps-hide-login/wps-hide-login.php' ),
|
||||
ai1wm_discover_plugin_basename( 'hide-my-wp/index.php' ),
|
||||
ai1wm_discover_plugin_basename( 'hide-my-wordpress/index.php' ),
|
||||
ai1wm_discover_plugin_basename( 'mycustomwidget/my_custom_widget.php' ),
|
||||
ai1wm_discover_plugin_basename( 'lockdown-wp-admin/lockdown-wp-admin.php' ),
|
||||
ai1wm_discover_plugin_basename( 'rename-wp-login/rename-wp-login.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wp-simple-firewall/icwp-wpsf.php' ),
|
||||
ai1wm_discover_plugin_basename( 'join-my-multisite/joinmymultisite.php' ),
|
||||
ai1wm_discover_plugin_basename( 'multisite-clone-duplicator/multisite-clone-duplicator.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wordpress-mu-domain-mapping/domain_mapping.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wordpress-starter/siteground-wizard.php' ),
|
||||
ai1wm_discover_plugin_basename( 'pro-sites/pro-sites.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wpide/WPide.php' ),
|
||||
ai1wm_discover_plugin_basename( 'page-optimize/page-optimize.php' ),
|
||||
ai1wm_discover_plugin_basename( 'update-services/update-services.php' ),
|
||||
)
|
||||
);
|
||||
|
||||
// Deactivate Swift Optimizer rules
|
||||
ai1wm_deactivate_swift_optimizer_rules(
|
||||
array(
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration/all-in-one-wp-migration.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-azure-storage-extension/all-in-one-wp-migration-azure-storage-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-b2-extension/all-in-one-wp-migration-b2-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-backup/all-in-one-wp-migration-backup.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-box-extension/all-in-one-wp-migration-box-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-digitalocean-extension/all-in-one-wp-migration-digitalocean-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-direct-extension/all-in-one-wp-migration-direct-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-dropbox-extension/all-in-one-wp-migration-dropbox-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-file-extension/all-in-one-wp-migration-file-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-ftp-extension/all-in-one-wp-migration-ftp-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-gcloud-storage-extension/all-in-one-wp-migration-gcloud-storage-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-gdrive-extension/all-in-one-wp-migration-gdrive-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-glacier-extension/all-in-one-wp-migration-glacier-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-mega-extension/all-in-one-wp-migration-mega-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-multisite-extension/all-in-one-wp-migration-multisite-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-onedrive-extension/all-in-one-wp-migration-onedrive-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-pcloud-extension/all-in-one-wp-migration-pcloud-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-pro/all-in-one-wp-migration-pro.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-s3-client-extension/all-in-one-wp-migration-s3-client-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-s3-extension/all-in-one-wp-migration-s3-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-unlimited-extension/all-in-one-wp-migration-unlimited-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-url-extension/all-in-one-wp-migration-url-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-webdav-extension/all-in-one-wp-migration-webdav-extension.php' ),
|
||||
)
|
||||
);
|
||||
|
||||
// Deactivate Revolution Slider
|
||||
ai1wm_deactivate_revolution_slider( ai1wm_discover_plugin_basename( 'revslider/revslider.php' ) );
|
||||
|
||||
// Deactivate Jetpack modules
|
||||
ai1wm_deactivate_jetpack_modules( array( 'photon', 'sso' ) );
|
||||
|
||||
// Flush Elementor cache
|
||||
ai1wm_elementor_cache_flush();
|
||||
|
||||
// Initial DB version
|
||||
ai1wm_initial_db_version();
|
||||
}
|
||||
}
|
||||
|
||||
// Clear auth cookie (WP Cerber)
|
||||
if ( ai1wm_validate_plugin_basename( 'wp-cerber/wp-cerber.php' ) ) {
|
||||
wp_clear_auth_cookie();
|
||||
}
|
||||
|
||||
$should_reset_permalinks = false;
|
||||
|
||||
// Switch to default permalink structure
|
||||
if ( ( $should_reset_permalinks = ai1wm_should_reset_permalinks( $params ) ) ) {
|
||||
$wp_rewrite->set_permalink_structure( '' );
|
||||
}
|
||||
|
||||
// Set progress
|
||||
if ( ai1wm_validate_plugin_basename( 'fusion-builder/fusion-builder.php' ) ) {
|
||||
Ai1wm_Status::done( __( 'Your site has been imported successfully!', 'all-in-one-wp-migration' ), Ai1wm_Template::get_content( 'import/avada', array( 'should_reset_permalinks' => $should_reset_permalinks ) ) );
|
||||
} elseif ( ai1wm_validate_plugin_basename( 'oxygen/functions.php' ) ) {
|
||||
Ai1wm_Status::done( __( 'Your site has been imported successfully!', 'all-in-one-wp-migration' ), Ai1wm_Template::get_content( 'import/oxygen', array( 'should_reset_permalinks' => $should_reset_permalinks ) ) );
|
||||
} else {
|
||||
Ai1wm_Status::done( __( 'Your site has been imported successfully!', 'all-in-one-wp-migration' ), Ai1wm_Template::get_content( 'import/done', array( 'should_reset_permalinks' => $should_reset_permalinks ) ) );
|
||||
}
|
||||
|
||||
do_action( 'ai1wm_status_import_done', $params );
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Enumerate {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Gathering WordPress files...', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Open the archive file for reading
|
||||
$archive = new Ai1wm_Extractor( ai1wm_archive_path( $params ) );
|
||||
|
||||
// Get total files count
|
||||
$params['total_files_count'] = $archive->get_total_files_count();
|
||||
|
||||
// Get total files size
|
||||
$params['total_files_size'] = $archive->get_total_files_size();
|
||||
|
||||
// Close the archive file
|
||||
$archive->close();
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'WordPress files gathered.', 'all-in-one-wp-migration' ) );
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Mu_Plugins {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Activating mu-plugins...', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Set decryption password
|
||||
$decryption_password = null;
|
||||
if ( isset( $params['decryption_password'] ) ) {
|
||||
$decryption_password = $params['decryption_password'];
|
||||
}
|
||||
|
||||
// Read package.json file
|
||||
$handle = ai1wm_open( ai1wm_package_path( $params ), 'r' );
|
||||
|
||||
// Parse package.json file
|
||||
$config = ai1wm_read( $handle, filesize( ai1wm_package_path( $params ) ) );
|
||||
$config = json_decode( $config, true );
|
||||
|
||||
// Close handle
|
||||
ai1wm_close( $handle );
|
||||
|
||||
// Get compression type
|
||||
$compression_type = null;
|
||||
if ( ! empty( $config['Compression']['Enabled'] ) ) {
|
||||
$compression_type = $config['Compression']['Type'];
|
||||
}
|
||||
|
||||
// List of must-use plugins
|
||||
$exclude_files = array(
|
||||
AI1WM_MUPLUGINS_NAME . DIRECTORY_SEPARATOR . AI1WM_ENDURANCE_PAGE_CACHE_NAME,
|
||||
AI1WM_MUPLUGINS_NAME . DIRECTORY_SEPARATOR . AI1WM_ENDURANCE_PHP_EDGE_NAME,
|
||||
AI1WM_MUPLUGINS_NAME . DIRECTORY_SEPARATOR . AI1WM_ENDURANCE_BROWSER_CACHE_NAME,
|
||||
AI1WM_MUPLUGINS_NAME . DIRECTORY_SEPARATOR . AI1WM_GD_SYSTEM_PLUGIN_NAME,
|
||||
AI1WM_MUPLUGINS_NAME . DIRECTORY_SEPARATOR . AI1WM_WP_STACK_CACHE_NAME,
|
||||
AI1WM_MUPLUGINS_NAME . DIRECTORY_SEPARATOR . AI1WM_WP_COMSH_LOADER_NAME,
|
||||
AI1WM_MUPLUGINS_NAME . DIRECTORY_SEPARATOR . AI1WM_WP_COMSH_HELPER_NAME,
|
||||
AI1WM_MUPLUGINS_NAME . DIRECTORY_SEPARATOR . AI1WM_WP_ENGINE_SYSTEM_PLUGIN_NAME,
|
||||
AI1WM_MUPLUGINS_NAME . DIRECTORY_SEPARATOR . AI1WM_WPE_SIGN_ON_PLUGIN_NAME,
|
||||
AI1WM_MUPLUGINS_NAME . DIRECTORY_SEPARATOR . AI1WM_WP_ENGINE_SECURITY_AUDITOR_NAME,
|
||||
AI1WM_MUPLUGINS_NAME . DIRECTORY_SEPARATOR . AI1WM_WP_CERBER_SECURITY_NAME,
|
||||
AI1WM_MUPLUGINS_NAME . DIRECTORY_SEPARATOR . AI1WM_SQLITE_DATABASE_INTEGRATION_NAME,
|
||||
AI1WM_MUPLUGINS_NAME . DIRECTORY_SEPARATOR . AI1WM_SQLITE_DATABASE_ZERO_NAME,
|
||||
AI1WM_MUPLUGINS_NAME . DIRECTORY_SEPARATOR . AI1WM_EOS_DEACTIVATE_PLUGINS_NAME,
|
||||
);
|
||||
|
||||
// Open the archive file for reading
|
||||
$archive = new Ai1wm_Extractor( ai1wm_archive_path( $params ), $decryption_password, $compression_type );
|
||||
|
||||
// Unpack mu-plugins files
|
||||
$archive->extract_by_files_array( WP_CONTENT_DIR, array( AI1WM_MUPLUGINS_NAME ), $exclude_files );
|
||||
|
||||
// Close the archive file
|
||||
$archive->close();
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Mu-plugins activated.', 'all-in-one-wp-migration' ) );
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Options {
|
||||
|
||||
public static function execute( $params ) {
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Preparing WordPress options...', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Get database client
|
||||
$db_client = Ai1wm_Database_Utility::get_client();
|
||||
|
||||
$tables = $db_client->get_tables();
|
||||
|
||||
// Get base prefix
|
||||
$base_prefix = ai1wm_table_prefix();
|
||||
|
||||
// Get mainsite prefix
|
||||
$mainsite_prefix = ai1wm_table_prefix( 'mainsite' );
|
||||
|
||||
// Check WP sitemeta table exists
|
||||
if ( in_array( "{$mainsite_prefix}sitemeta", $tables ) ) {
|
||||
|
||||
// Get fs_accounts option value (Freemius)
|
||||
$result = $db_client->query( "SELECT meta_value FROM `{$mainsite_prefix}sitemeta` WHERE meta_key = 'fs_accounts'" );
|
||||
if ( ( $row = $db_client->fetch_assoc( $result ) ) ) {
|
||||
$fs_accounts = get_option( 'fs_accounts', array() );
|
||||
$meta_value = maybe_unserialize( $row['meta_value'] );
|
||||
|
||||
// Update fs_accounts option value (Freemius)
|
||||
if ( ( $fs_accounts = array_merge( $fs_accounts, $meta_value ) ) ) {
|
||||
if ( isset( $fs_accounts['users'], $fs_accounts['sites'] ) ) {
|
||||
update_option( 'fs_accounts', $fs_accounts );
|
||||
} else {
|
||||
delete_option( 'fs_accounts' );
|
||||
delete_option( 'fs_dbg_accounts' );
|
||||
delete_option( 'fs_active_plugins' );
|
||||
delete_option( 'fs_api_cache' );
|
||||
delete_option( 'fs_dbg_api_cache' );
|
||||
delete_option( 'fs_debug_mode' );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'WordPress options prepared.', 'all-in-one-wp-migration' ) );
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Permalinks {
|
||||
|
||||
public static function execute( $params ) {
|
||||
global $wp_rewrite;
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Retrieving WordPress permalinks settings...', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Get using permalinks
|
||||
$params['using_permalinks'] = (int) $wp_rewrite->using_permalinks();
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'WordPress permalinks settings retrieved.', 'all-in-one-wp-migration' ) );
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Upload {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
// Get upload tmp name
|
||||
if ( isset( $_FILES['upload_file']['tmp_name'] ) ) {
|
||||
$upload_tmp_name = $_FILES['upload_file']['tmp_name'];
|
||||
} else {
|
||||
throw new Ai1wm_Upload_Exception(
|
||||
wp_kses(
|
||||
__(
|
||||
'The uploaded file is missing a temporary path. The process cannot continue.
|
||||
<a href="https://help.servmask.com/knowledgebase/upload-file-error/" target="_blank">Technical details</a>',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
ai1wm_allowed_html_tags()
|
||||
),
|
||||
400
|
||||
);
|
||||
}
|
||||
|
||||
// Get upload error
|
||||
if ( isset( $_FILES['upload_file']['error'] ) ) {
|
||||
$upload_error = $_FILES['upload_file']['error'];
|
||||
} else {
|
||||
throw new Ai1wm_Upload_Exception(
|
||||
wp_kses(
|
||||
__(
|
||||
'The uploaded file is missing an error code. The process cannot continue.
|
||||
<a href="https://help.servmask.com/knowledgebase/upload-file-error/" target="_blank">Technical details</a>',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
ai1wm_allowed_html_tags()
|
||||
),
|
||||
400
|
||||
);
|
||||
}
|
||||
|
||||
// Verify file extension
|
||||
if ( ! ai1wm_is_filename_supported( ai1wm_archive_path( $params ) ) ) {
|
||||
throw new Ai1wm_Upload_Exception(
|
||||
wp_kses(
|
||||
__(
|
||||
'Invalid file type. Please ensure your file is a <strong>.wpress</strong> backup created with All-in-One WP Migration.
|
||||
<a href="https://help.servmask.com/knowledgebase/invalid-backup-file/" target="_blank">Technical details</a>',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
ai1wm_allowed_html_tags()
|
||||
),
|
||||
415
|
||||
);
|
||||
}
|
||||
|
||||
// Verify file data
|
||||
if ( ! ai1wm_is_filedata_supported( $upload_tmp_name ) ) {
|
||||
throw new Ai1wm_Upload_Exception(
|
||||
wp_kses(
|
||||
__(
|
||||
'Invalid file data. Please ensure your file is a <strong>.wpress</strong> backup created with All-in-One WP Migration.
|
||||
<a href="https://help.servmask.com/knowledgebase/invalid-backup-file/" target="_blank">Technical details</a>',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
ai1wm_allowed_html_tags()
|
||||
),
|
||||
415
|
||||
);
|
||||
}
|
||||
|
||||
// Upload file data
|
||||
switch ( $upload_error ) {
|
||||
case UPLOAD_ERR_OK:
|
||||
try {
|
||||
ai1wm_copy( $upload_tmp_name, ai1wm_archive_path( $params ) );
|
||||
ai1wm_unlink( $upload_tmp_name );
|
||||
} catch ( Exception $e ) {
|
||||
/* translators: Error message. */
|
||||
throw new Ai1wm_Upload_Exception(
|
||||
wp_kses(
|
||||
sprintf(
|
||||
__(
|
||||
'Could not upload the file because %s. The process cannot continue.
|
||||
<a href="https://help.servmask.com/knowledgebase/upload-file-error/" target="_blank">Technical details</a>',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
$e->getMessage()
|
||||
),
|
||||
ai1wm_allowed_html_tags()
|
||||
),
|
||||
400
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case UPLOAD_ERR_INI_SIZE:
|
||||
case UPLOAD_ERR_FORM_SIZE:
|
||||
case UPLOAD_ERR_PARTIAL:
|
||||
case UPLOAD_ERR_NO_FILE:
|
||||
throw new Ai1wm_Upload_Exception(
|
||||
wp_kses(
|
||||
__(
|
||||
'The uploaded file is too large for this server. The process cannot continue.
|
||||
<a href="https://help.servmask.com/knowledgebase/upload-file-error/" target="_blank">Technical details</a>',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
ai1wm_allowed_html_tags()
|
||||
),
|
||||
413
|
||||
);
|
||||
|
||||
case UPLOAD_ERR_NO_TMP_DIR:
|
||||
throw new Ai1wm_Upload_Exception(
|
||||
wp_kses(
|
||||
__(
|
||||
'No temporary folder is available on the server. The process cannot continue.
|
||||
<a href="https://help.servmask.com/knowledgebase/upload-file-error/" target="_blank">Technical details</a>',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
ai1wm_allowed_html_tags()
|
||||
),
|
||||
400
|
||||
);
|
||||
|
||||
case UPLOAD_ERR_CANT_WRITE:
|
||||
throw new Ai1wm_Upload_Exception(
|
||||
wp_kses(
|
||||
__(
|
||||
'Could not save the uploaded file. Please check file permissions and try again.
|
||||
<a href="https://help.servmask.com/knowledgebase/upload-file-error/" target="_blank">Technical details</a>',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
ai1wm_allowed_html_tags()
|
||||
),
|
||||
400
|
||||
);
|
||||
|
||||
case UPLOAD_ERR_EXTENSION:
|
||||
throw new Ai1wm_Upload_Exception(
|
||||
wp_kses(
|
||||
__(
|
||||
'A PHP extension blocked this file upload. The process cannot continue.
|
||||
<a href="https://help.servmask.com/knowledgebase/upload-file-error/" target="_blank">Technical details</a>',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
ai1wm_allowed_html_tags()
|
||||
),
|
||||
400
|
||||
);
|
||||
|
||||
default:
|
||||
/* translators: Error code. */
|
||||
throw new Ai1wm_Upload_Exception(
|
||||
wp_kses(
|
||||
sprintf(
|
||||
__(
|
||||
'An unknown error (code: %s) occurred during the file upload. The process cannot continue.
|
||||
<a href="https://help.servmask.com/knowledgebase/upload-file-error/" target="_blank">Technical details</a>',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
$upload_error
|
||||
),
|
||||
ai1wm_allowed_html_tags()
|
||||
),
|
||||
400
|
||||
);
|
||||
}
|
||||
|
||||
ai1wm_json_response( array( 'errors' => array() ) );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Users {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
// Check multisite.json file
|
||||
if ( is_file( ai1wm_multisite_path( $params ) ) ) {
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Preparing WordPress users...', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Read multisite.json file
|
||||
$handle = ai1wm_open( ai1wm_multisite_path( $params ), 'r' );
|
||||
|
||||
// Parse multisite.json file
|
||||
$multisite = ai1wm_read( $handle, filesize( ai1wm_multisite_path( $params ) ) );
|
||||
$multisite = json_decode( $multisite, true );
|
||||
|
||||
// Close handle
|
||||
ai1wm_close( $handle );
|
||||
|
||||
ai1wm_populate_roles();
|
||||
|
||||
// Set WordPress super admins
|
||||
if ( isset( $multisite['Admins'] ) && ( $admins = $multisite['Admins'] ) ) {
|
||||
foreach ( $admins as $username ) {
|
||||
if ( ( $user = get_user_by( 'login', $username ) ) ) {
|
||||
if ( $user->exists() ) {
|
||||
$user->set_role( 'administrator' );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'WordPress users prepared.', 'all-in-one-wp-migration' ) );
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Crc {
|
||||
|
||||
public static function execute( $params ) {
|
||||
$archive_bytes_read = 0;
|
||||
|
||||
// Skip validation for v1 archives (no CRC available)
|
||||
if ( empty( $params['archive_crc_value'] ) ) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Validating archive checksum...', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Set archive bytes remaining
|
||||
if ( isset( $params['archive_bytes_remaining'] ) ) {
|
||||
$archive_bytes_remaining = (int) $params['archive_bytes_remaining'];
|
||||
} elseif ( isset( $params['archive_crc_size'] ) ) {
|
||||
$archive_bytes_remaining = (int) $params['archive_crc_size'];
|
||||
} else {
|
||||
$archive_bytes_remaining = 0;
|
||||
}
|
||||
|
||||
// Set archive bytes offset
|
||||
if ( isset( $params['archive_bytes_offset'] ) ) {
|
||||
$archive_bytes_offset = (int) $params['archive_bytes_offset'];
|
||||
} else {
|
||||
$archive_bytes_offset = 0;
|
||||
}
|
||||
|
||||
// Set file CRC
|
||||
$file_crc = null;
|
||||
if ( isset( $params['file_crc'] ) ) {
|
||||
$file_crc = $params['file_crc'];
|
||||
}
|
||||
|
||||
// Flag to hold if file data has been processed
|
||||
$completed = true;
|
||||
|
||||
// Start time
|
||||
$start = microtime( true );
|
||||
|
||||
// Initialize CRC context
|
||||
$hash_ctx = Ai1wm_Crc::init_crc32();
|
||||
|
||||
// Open archive for reading
|
||||
if ( ( $file_handle = ai1wm_open( ai1wm_archive_path( $params ), 'rb' ) ) ) {
|
||||
if ( fseek( $file_handle, $archive_bytes_offset, SEEK_SET ) !== -1 ) {
|
||||
|
||||
// Process file in chunks
|
||||
while ( $archive_bytes_remaining > 0 ) {
|
||||
if ( ( $file_content = ai1wm_read( $file_handle, min( Ai1wm_Archiver::READ_CHUNK_SIZE, $archive_bytes_remaining ) ) ) !== false ) {
|
||||
|
||||
// Empty read indicates EOF
|
||||
if ( strlen( $file_content ) === 0 ) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Add the amount of bytes we read
|
||||
$archive_bytes_read += strlen( $file_content );
|
||||
|
||||
// Subtract the amount of bytes we read
|
||||
$archive_bytes_remaining -= strlen( $file_content );
|
||||
|
||||
// Update CRC with original content
|
||||
Ai1wm_Crc::update_crc32( $hash_ctx, $file_content );
|
||||
}
|
||||
|
||||
// Time elapsed
|
||||
if ( ( $timeout = apply_filters( 'ai1wm_completed_timeout', 10 ) ) ) {
|
||||
if ( ( microtime( true ) - $start ) > $timeout ) {
|
||||
$completed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get archive bytes offset
|
||||
$archive_bytes_offset += $archive_bytes_read;
|
||||
}
|
||||
|
||||
ai1wm_close( $file_handle );
|
||||
}
|
||||
|
||||
// Combine and finalize CRC
|
||||
if ( empty( $file_crc ) ) {
|
||||
$params['file_crc'] = Ai1wm_Crc::finalize_crc32( $hash_ctx );
|
||||
} else {
|
||||
$params['file_crc'] = Ai1wm_Crc::combine_crc32( $file_crc, Ai1wm_Crc::finalize_crc32( $hash_ctx ), $archive_bytes_read );
|
||||
}
|
||||
|
||||
// End of the archive file?
|
||||
if ( $completed ) {
|
||||
|
||||
// Validate CRC value
|
||||
if ( $params['archive_crc_value'] !== $params['file_crc'] ) {
|
||||
throw new Ai1wm_CRC_Exception(
|
||||
wp_kses(
|
||||
__(
|
||||
'This backup file is damaged and can\'t be imported.<br />' .
|
||||
'Try downloading or transferring the file again.<br /><br />' .
|
||||
'<strong>Reason:</strong> File integrity check failed (CRC mismatch). <a href="https://help.servmask.com/knowledgebase/import-failed-crc-mismatch/" target="_blank">Technical details</a>',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
ai1wm_allowed_html_tags()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Unset file CRC
|
||||
unset( $params['file_crc'] );
|
||||
|
||||
// Unset archive bytes remaining
|
||||
unset( $params['archive_bytes_remaining'] );
|
||||
|
||||
// Unset archive bytes offset
|
||||
unset( $params['archive_bytes_offset'] );
|
||||
|
||||
// Unset completed flag
|
||||
unset( $params['completed'] );
|
||||
|
||||
} else {
|
||||
|
||||
// St archive bytes remaining
|
||||
$params['archive_bytes_remaining'] = $archive_bytes_remaining;
|
||||
|
||||
// Set archive bytes offset
|
||||
$params['archive_bytes_offset'] = $archive_bytes_offset;
|
||||
|
||||
// Set completed flag
|
||||
$params['completed'] = $completed;
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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.
|
||||
<a href="https://help.servmask.com/knowledgebase/php-32bit/" target="_blank">Technical details</a>',
|
||||
'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 <strong>.wpress</strong> backup created with All-in-One WP Migration.
|
||||
<a href="https://help.servmask.com/knowledgebase/invalid-backup-file/" target="_blank">Technical details</a>',
|
||||
'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 <a href="https://help.servmask.com/knowledgebase/corrupted-archive/" target="_blank">this article</a> 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.
|
||||
<a href="https://help.servmask.com/knowledgebase/invalid-backup-file/" target="_blank">Technical details</a>',
|
||||
'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;
|
||||
}
|
||||
}
|
||||
20
plugins/all-in-one-wp-migration/lib/vendor/bandar/bandar/LICENSE
vendored
Normal file
20
plugins/all-in-one-wp-migration/lib/vendor/bandar/bandar/LICENSE
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 Yani Iliev
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
233
plugins/all-in-one-wp-migration/lib/vendor/bandar/bandar/lib/Bandar.php
vendored
Normal file
233
plugins/all-in-one-wp-migration/lib/vendor/bandar/bandar/lib/Bandar.php
vendored
Normal file
@@ -0,0 +1,233 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Main template engine file
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE: Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* @category Templates
|
||||
* @package Bandar
|
||||
* @author Yani Iliev <yani@iliev.me>
|
||||
* @copyright 2013 Yani Iliev
|
||||
* @license https://raw.github.com/yani-/bandar/master/LICENSE The MIT License (MIT)
|
||||
* @version GIT: 3.0.0
|
||||
* @link https://github.com/yani-/bandar/
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( 'Kangaroos cannot jump here' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define EOL for CLI and Web
|
||||
*/
|
||||
if (!defined('BANDAR_EOL')) {
|
||||
define('BANDAR_EOL', php_sapi_name() === 'cli' ? PHP_EOL : '<br />');
|
||||
}
|
||||
|
||||
/**
|
||||
* Include exceptions
|
||||
*/
|
||||
require_once
|
||||
dirname(__FILE__) .
|
||||
DIRECTORY_SEPARATOR .
|
||||
'Exceptions' .
|
||||
DIRECTORY_SEPARATOR .
|
||||
'TemplateDoesNotExistException.php';
|
||||
|
||||
/**
|
||||
* Bandar Main class
|
||||
*
|
||||
* @category Templates
|
||||
* @package Bandar
|
||||
* @author Yani Iliev <yani@iliev.me>
|
||||
* @copyright 2013 Yani Iliev
|
||||
* @license https://raw.github.com/yani-/bandar/master/LICENSE The MIT License (MIT)
|
||||
* @version Release: 2.0.1
|
||||
* @link https://github.com/yani-/bandar/
|
||||
*/
|
||||
class Bandar
|
||||
{
|
||||
/**
|
||||
* Path to template files
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public static $templatesPath = null;
|
||||
|
||||
/**
|
||||
* Template file to output
|
||||
* @var string|null
|
||||
*/
|
||||
public static $template = null;
|
||||
|
||||
/**
|
||||
* Outputs the passed string if Bandar is in debug mode
|
||||
*
|
||||
* @param string $str Debug string to output
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function debug($str)
|
||||
{
|
||||
/**
|
||||
* if debug flag is on, output the string
|
||||
*/
|
||||
if (defined('BANDAR_DEBUG') && BANDAR_DEBUG) {
|
||||
echo $str;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves templatesPath from BANDAR_TEMPLATES_PATH constant
|
||||
*
|
||||
* @throws TemplatesPathNotSetException If BANDAR_TEMPLATES_PATH is not defined
|
||||
*
|
||||
* @return string|null Templates path
|
||||
*/
|
||||
public static function getTemplatesPathFromConstant()
|
||||
{
|
||||
self::debug(
|
||||
'Calling getTemplatesPathFromConstant' . BANDAR_EOL
|
||||
);
|
||||
if (defined('BANDAR_TEMPLATES_PATH')) {
|
||||
return realpath(BANDAR_TEMPLATES_PATH) . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for template
|
||||
*
|
||||
* @param string $template Template file
|
||||
*
|
||||
* @throws TemplateDoesNotExistException If template file is not found
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public static function setTemplate($template, $path = false)
|
||||
{
|
||||
self::debug(
|
||||
'Calling setTemplate with' . BANDAR_EOL .
|
||||
'$template = ' . $template . BANDAR_EOL .
|
||||
'type of $template is ' . gettype($template) . BANDAR_EOL
|
||||
);
|
||||
|
||||
if ($path) {
|
||||
$template = realpath($path) . DIRECTORY_SEPARATOR . $template;
|
||||
} else {
|
||||
$template = self::getTemplatesPathFromConstant() . $template;
|
||||
}
|
||||
|
||||
$template = realpath($template . '.php');
|
||||
/**
|
||||
* Check if passed template exist
|
||||
*/
|
||||
if (self::templateExists($template)) {
|
||||
self::$template = $template;
|
||||
} else {
|
||||
throw new TemplateDoesNotExistException;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if template exists by using file_exists
|
||||
*
|
||||
* @param string $template Template file
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function templateExists($template)
|
||||
{
|
||||
self::debug(
|
||||
'Calling templateExists with ' . BANDAR_EOL .
|
||||
'$template = ' . $template . BANDAR_EOL .
|
||||
'type of $template is ' . gettype($template) . BANDAR_EOL
|
||||
);
|
||||
return (!is_dir($template) && is_readable($template));
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a passed template
|
||||
*
|
||||
* @param string $template Template name
|
||||
* @param array $args Variables to pass to the template file
|
||||
*
|
||||
* @return string Contents of the template
|
||||
*/
|
||||
public static function render($template, $args=array(), $path = false)
|
||||
{
|
||||
self::debug(
|
||||
'Calling render with' .
|
||||
'$template = ' . $template . BANDAR_EOL .
|
||||
'type of $template is ' . gettype($template) . BANDAR_EOL .
|
||||
'$args = ' . print_r($args, true) . BANDAR_EOL .
|
||||
'type of $args is ' . gettype($args) . BANDAR_EOL
|
||||
);
|
||||
self::setTemplate($template, $path);
|
||||
/**
|
||||
* Extracting passed aguments
|
||||
*/
|
||||
extract($args);
|
||||
ob_start();
|
||||
/**
|
||||
* Including the view
|
||||
*/
|
||||
include self::$template;
|
||||
|
||||
return ob_get_flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the content of a passed template
|
||||
*
|
||||
* @param string $template Template name
|
||||
* @param array $args Variables to pass to the template file
|
||||
*
|
||||
* @return string Contents of the template
|
||||
*/
|
||||
public static function getTemplateContent($template, $args=array(), $path = false)
|
||||
{
|
||||
self::debug(
|
||||
'Calling render with' .
|
||||
'$template = ' . $template . BANDAR_EOL .
|
||||
'type of $template is ' . gettype($template) . BANDAR_EOL .
|
||||
'$args = ' . print_r($args, true) . BANDAR_EOL .
|
||||
'type of $args is ' . gettype($args) . BANDAR_EOL
|
||||
);
|
||||
self::setTemplate($template, $path);
|
||||
/**
|
||||
* Extracting passed aguments
|
||||
*/
|
||||
extract($args);
|
||||
ob_start();
|
||||
/**
|
||||
* Including the view
|
||||
*/
|
||||
include self::$template;
|
||||
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Contains TemplateDoesNotExistException class to be used in main Bandar class
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE: Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* @category Exceptions
|
||||
* @package Bandar
|
||||
* @author Yani Iliev <yani@iliev.me>
|
||||
* @copyright 2013 Yani Iliev
|
||||
* @license https://raw.github.com/yani-/bandar/master/LICENSE The MIT License (MIT)
|
||||
* @version GIT: 3.0.0
|
||||
* @link https://github.com/yani-/bandar/
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( 'Kangaroos cannot jump here' );
|
||||
}
|
||||
|
||||
/**
|
||||
* TemplateDoesNotExistException
|
||||
*
|
||||
* @category Exceptions
|
||||
* @package Bandar
|
||||
* @author Yani Iliev <yani@iliev.me>
|
||||
* @copyright 2013 Yani Iliev
|
||||
* @license https://raw.github.com/yani-/bandar/master/LICENSE The MIT License (MIT)
|
||||
* @version Release: 2.0.1
|
||||
* @link https://github.com/yani-/bandar/
|
||||
*/
|
||||
class TemplateDoesNotExistException extends Exception
|
||||
{
|
||||
|
||||
}
|
||||
432
plugins/all-in-one-wp-migration/lib/vendor/servmask/archiver/class-ai1wm-archiver.php
vendored
Normal file
432
plugins/all-in-one-wp-migration/lib/vendor/servmask/archiver/class-ai1wm-archiver.php
vendored
Normal file
@@ -0,0 +1,432 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Attribution: This code is part of the All-in-One WP Migration plugin, developed by
|
||||
*
|
||||
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
|
||||
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
|
||||
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
|
||||
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
|
||||
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
||||
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( 'Kangaroos cannot jump here' );
|
||||
}
|
||||
|
||||
abstract class Ai1wm_Archiver {
|
||||
|
||||
const HEADER_SIZE = 4377;
|
||||
|
||||
const READ_CHUNK_SIZE = 512000;
|
||||
|
||||
/**
|
||||
* File name including path to the file
|
||||
*
|
||||
* @type string
|
||||
*/
|
||||
protected $file_name = null;
|
||||
|
||||
/**
|
||||
* File password string
|
||||
*
|
||||
* @type string
|
||||
*/
|
||||
protected $file_password = null;
|
||||
|
||||
/**
|
||||
* File compression type
|
||||
*
|
||||
* @type string
|
||||
*/
|
||||
protected $file_compression = null;
|
||||
|
||||
/**
|
||||
* Handle to the file
|
||||
*
|
||||
* @type resource
|
||||
*/
|
||||
protected $file_handle = null;
|
||||
|
||||
/**
|
||||
* Header block format of a file
|
||||
*
|
||||
* Field Name Offset Length Contents
|
||||
* name 0 255 filename (no path, no slash)
|
||||
* size 255 14 size of file contents
|
||||
* mtime 269 12 last modification time
|
||||
* prefix 281 4088 path name, no trailing slashes
|
||||
* crc32 4369 8 CRC32 checksum (hex string, optional)
|
||||
*
|
||||
* @type array
|
||||
*/
|
||||
protected $block_format = array(
|
||||
'a255', // filename
|
||||
'a14', // size of file contents
|
||||
'a12', // last time modified
|
||||
'a4088', // path
|
||||
'a8', // crc32
|
||||
);
|
||||
|
||||
/**
|
||||
* Archive CRC value from the v2 EOF block
|
||||
*
|
||||
* @type string
|
||||
*/
|
||||
protected $archive_crc_value = null;
|
||||
|
||||
/**
|
||||
* Archive CRC size from the v2 EOF block
|
||||
*
|
||||
* @type string
|
||||
*/
|
||||
protected $archive_crc_size = null;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*
|
||||
* Initializes filename and end of file block
|
||||
*
|
||||
* @param string $file_name File to use as archive
|
||||
* @param string $file_password File password string
|
||||
* @param string $file_compression File compression type
|
||||
* @param bool $file_write File Read/write mode
|
||||
*
|
||||
* @throws Ai1wm_Not_Accessible_Exception
|
||||
* @throws Ai1wm_Not_Seekable_Exception
|
||||
*/
|
||||
public function __construct( $file_name, $file_password = null, $file_compression = null, $file_write = false ) {
|
||||
$this->file_name = $file_name;
|
||||
$this->file_password = $file_password;
|
||||
$this->file_compression = $file_compression;
|
||||
|
||||
// Open archive file
|
||||
if ( $file_write ) {
|
||||
// Open archive file for writing
|
||||
if ( ( $this->file_handle = @fopen( $file_name, 'cb' ) ) === false ) {
|
||||
throw new Ai1wm_Not_Accessible_Exception( sprintf( __( 'Could not open file for writing. File: %s', 'all-in-one-wp-migration' ), $this->file_name ) );
|
||||
}
|
||||
|
||||
// Seek to end of archive file
|
||||
if ( @fseek( $this->file_handle, 0, SEEK_END ) === -1 ) {
|
||||
throw new Ai1wm_Not_Seekable_Exception( sprintf( __( 'Could not seek to end of file. File: %s', 'all-in-one-wp-migration' ), $this->file_name ) );
|
||||
}
|
||||
} else {
|
||||
// Open archive file for reading
|
||||
if ( ( $this->file_handle = @fopen( $file_name, 'rb' ) ) === false ) {
|
||||
throw new Ai1wm_Not_Accessible_Exception( sprintf( __( 'Could not open file for reading. File: %s', 'all-in-one-wp-migration' ), $this->file_name ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set current file pointer
|
||||
*
|
||||
* @param int $offset Archive offset
|
||||
*
|
||||
* @throws \Ai1wm_Not_Seekable_Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set_file_pointer( $offset ) {
|
||||
if ( @fseek( $this->file_handle, $offset, SEEK_SET ) === -1 ) {
|
||||
throw new Ai1wm_Not_Seekable_Exception( sprintf( __( 'Could not seek to offset of file. File: %s Offset: %d', 'all-in-one-wp-migration' ), $this->file_name, $offset ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current file pointer
|
||||
*
|
||||
* @throws \Ai1wm_Not_Tellable_Exception
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_file_pointer() {
|
||||
if ( ( $offset = @ftell( $this->file_handle ) ) === false ) {
|
||||
throw new Ai1wm_Not_Tellable_Exception( sprintf( __( 'Could not tell offset of file. File: %s', 'all-in-one-wp-migration' ), $this->file_name ) );
|
||||
}
|
||||
|
||||
return $offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends end of file block to the archive file
|
||||
*
|
||||
* @param string|null $archive_crc_value Pre-calculated archive CRC32 (optional)
|
||||
*
|
||||
* @throws \Ai1wm_Not_Seekable_Exception
|
||||
* @throws \Ai1wm_Not_Writable_Exception
|
||||
* @throws \Ai1wm_Quota_Exceeded_Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function append_eof( $archive_crc_value = null ) {
|
||||
// Seek to end of archive file
|
||||
if ( @fseek( $this->file_handle, 0, SEEK_END ) === -1 ) {
|
||||
throw new Ai1wm_Not_Seekable_Exception( sprintf( __( 'Could not seek to end of file. File: %s', 'all-in-one-wp-migration' ), $this->file_name ) );
|
||||
}
|
||||
|
||||
// Use pre-calculated CRC if provided, otherwise calculate (fallback)
|
||||
if ( empty( $archive_crc_value ) ) {
|
||||
$archive_crc_value = Ai1wm_Crc::calculate_file_crc32( $this->file_name );
|
||||
}
|
||||
|
||||
// Get archive size (before EOF block)
|
||||
if ( ( $archive_crc_size = @ftell( $this->file_handle ) ) === false ) {
|
||||
throw new Ai1wm_Not_Tellable_Exception( sprintf( __( 'Could not tell offset of file. File: %s', 'all-in-one-wp-migration' ), $this->file_name ) );
|
||||
}
|
||||
|
||||
// Write end of file block
|
||||
if ( ( $eof_block = $this->get_eof_block( $archive_crc_size, $archive_crc_value ) ) ) {
|
||||
if ( ( $file_bytes = @fwrite( $this->file_handle, $eof_block ) ) !== false ) {
|
||||
if ( strlen( $eof_block ) !== $file_bytes ) {
|
||||
throw new Ai1wm_Quota_Exceeded_Exception( sprintf( __( 'Out of disk space. Could not write end of block to file. File: %s', 'all-in-one-wp-migration' ), $this->file_name ) );
|
||||
}
|
||||
} else {
|
||||
throw new Ai1wm_Not_Writable_Exception( sprintf( __( 'Could not write end of block to file. File: %s', 'all-in-one-wp-migration' ), $this->file_name ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace forward slash with current directory separator
|
||||
*
|
||||
* @param string $path Path
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function replace_forward_slash_with_directory_separator( $path ) {
|
||||
return str_replace( '/', DIRECTORY_SEPARATOR, $path );
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace current directory separator with forward slash
|
||||
*
|
||||
* @param string $path Path
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function replace_directory_separator_with_forward_slash( $path ) {
|
||||
return str_replace( DIRECTORY_SEPARATOR, '/', $path );
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape Windows directory separator
|
||||
*
|
||||
* @param string $path Path
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function escape_windows_directory_separator( $path ) {
|
||||
return preg_replace( '/[\\\\]+/', '\\\\\\\\', $path );
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate archive file
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_valid() {
|
||||
// Failed detecting the current file pointer offset
|
||||
if ( ( $offset = @ftell( $this->file_handle ) ) === false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Failed seeking the beginning of EOL block
|
||||
if ( @fseek( $this->file_handle, -static::HEADER_SIZE, SEEK_END ) === -1 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get end of file block
|
||||
if ( ( $block = @fread( $this->file_handle, static::HEADER_SIZE ) ) === false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Failed returning to original offset
|
||||
if ( @fseek( $this->file_handle, $offset, SEEK_SET ) === -1 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Trailing block does not match EOL
|
||||
if ( $this->is_eof_block( $block ) === false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncates the archive file
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function truncate() {
|
||||
if ( ( $offset = @ftell( $this->file_handle ) ) === false ) {
|
||||
throw new Ai1wm_Not_Tellable_Exception( sprintf( __( 'Could not tell offset of file. File: %s', 'all-in-one-wp-migration' ), $this->file_name ) );
|
||||
}
|
||||
|
||||
if ( @filesize( $this->file_name ) > $offset ) {
|
||||
if ( @ftruncate( $this->file_handle, $offset ) === false ) {
|
||||
throw new Ai1wm_Not_Truncatable_Exception( sprintf( __( 'Could not truncate file. File: %s', 'all-in-one-wp-migration' ), $this->file_name ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the archive file
|
||||
*
|
||||
* We either close the file or append the end of file block if complete argument is set to true
|
||||
*
|
||||
* @param bool $complete Flag to append end of file block
|
||||
* @param string|null $archive_crc_value Pre-calculated archive CRC32 (optional)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function close( $complete = false, $archive_crc_value = null ) {
|
||||
// Are we done appending to the file?
|
||||
if ( true === $complete ) {
|
||||
$this->append_eof( $archive_crc_value );
|
||||
}
|
||||
|
||||
if ( @fclose( $this->file_handle ) === false ) {
|
||||
throw new Ai1wm_Not_Closable_Exception( sprintf( __( 'Could not close file. File: %s', 'all-in-one-wp-migration' ), $this->file_name ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate end of file block
|
||||
*
|
||||
* @param string $archive_crc_value Archive CRC
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function get_eof_block( $archive_crc_size = null, $archive_crc_value = null ) {
|
||||
return pack( 'a255a14a4100a8', '', $archive_crc_size, '', $archive_crc_value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a block is an end of file block (v1 or v2)
|
||||
*
|
||||
* @param string $block The block to check
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function is_eof_block( $block ) {
|
||||
return $this->is_v1_eof( $block ) || $this->is_v2_eof( $block );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a block is a v1 end of file block (all null bytes)
|
||||
*
|
||||
* @param string $block The block to check
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function is_v1_eof( $block ) {
|
||||
return $this->get_eof_block() === $block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a block is a v2 end of file block
|
||||
*
|
||||
* @param string $block The block to check
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function is_v2_eof( $block ) {
|
||||
// Unpack end of file data
|
||||
if ( ( $data = unpack( 'a255/a14size/a4100/a8crc32', $block ) ) ) {
|
||||
if ( isset( $data['size'], $data['crc32'] ) ) {
|
||||
if ( preg_match( '/^[0-9a-f]{8}$/i', $data['crc32'] ) ) {
|
||||
return $this->get_eof_block( $data['size'], $data['crc32'] ) === $block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get archive CRC from EOF block (v2 only)
|
||||
*
|
||||
* @return string|null CRC32 hex string or null if v1 archive
|
||||
*/
|
||||
public function get_archive_crc_value() {
|
||||
if ( is_null( $this->archive_crc_value ) ) {
|
||||
$this->set_archive_crc_data();
|
||||
}
|
||||
|
||||
return $this->archive_crc_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get archive CRC size from EOF block (v2 only)
|
||||
*
|
||||
* @return int|null Size hex string or null if v1 archive
|
||||
*/
|
||||
public function get_archive_crc_size() {
|
||||
if ( is_null( $this->archive_crc_size ) ) {
|
||||
$this->set_archive_crc_data();
|
||||
}
|
||||
|
||||
return $this->archive_crc_size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set archive CRC value and size from the v2 EOF block
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function set_archive_crc_data() {
|
||||
// Failed detecting the current file pointer offset
|
||||
if ( ( $offset = @ftell( $this->file_handle ) ) === false ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Failed seeking the beginning of EOL block
|
||||
if ( @fseek( $this->file_handle, -static::HEADER_SIZE, SEEK_END ) === -1 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get end of file block
|
||||
if ( ( $block = @fread( $this->file_handle, static::HEADER_SIZE ) ) === false ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Failed returning to original offset
|
||||
if ( @fseek( $this->file_handle, $offset, SEEK_SET ) === -1 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if v2 EOF
|
||||
if ( $this->is_v2_eof( $block ) === false ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Unpack end of file data
|
||||
if ( ( $data = unpack( 'a255/a14size/a4100/a8crc32', $block ) ) ) {
|
||||
if ( isset( $data['crc32'] ) ) {
|
||||
$this->archive_crc_value = trim( $data['crc32'] );
|
||||
}
|
||||
|
||||
if ( isset( $data['size'] ) ) {
|
||||
$this->archive_crc_size = (int) trim( $data['size'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
306
plugins/all-in-one-wp-migration/lib/vendor/servmask/archiver/class-ai1wm-compressor.php
vendored
Normal file
306
plugins/all-in-one-wp-migration/lib/vendor/servmask/archiver/class-ai1wm-compressor.php
vendored
Normal file
@@ -0,0 +1,306 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Compressor extends Ai1wm_Archiver {
|
||||
|
||||
/**
|
||||
* Overloaded constructor that opens the passed file for writing
|
||||
*
|
||||
* @param string $file_name File to use as archive
|
||||
* @param string $file_password File password string
|
||||
* @param string $file_compression File compression type
|
||||
*/
|
||||
public function __construct( $file_name, $file_password = null, $file_compression = null ) {
|
||||
// Call parent, to initialize variables
|
||||
parent::__construct( $file_name, $file_password, $file_compression, true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a file to the archive
|
||||
*
|
||||
* @param string $file_name File to add to the archive
|
||||
* @param string $new_file_name Write the file with a different name
|
||||
* @param int $file_bytes_read Amount of the bytes we read
|
||||
* @param int $file_bytes_offset File bytes offset
|
||||
* @param int $file_bytes_written Amount of the bytes we wrote
|
||||
* @param string|null $file_crc File CRC32 checksum (passed by reference, optional)
|
||||
*
|
||||
* @throws \Ai1wm_Not_Seekable_Exception
|
||||
* @throws \Ai1wm_Not_Writable_Exception
|
||||
* @throws \Ai1wm_Quota_Exceeded_Exception
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function add_file( $file_name, $new_file_name = '', &$file_bytes_read = 0, &$file_bytes_offset = 0, &$file_bytes_written = 0, &$file_crc = null ) {
|
||||
// Replace forward slash with current directory separator in file name
|
||||
$file_name = ai1wm_replace_forward_slash_with_directory_separator( $file_name );
|
||||
|
||||
// Escape Windows directory separator in file name
|
||||
$file_name = ai1wm_escape_windows_directory_separator( $file_name );
|
||||
|
||||
// Flag to hold if file data has been processed
|
||||
$completed = true;
|
||||
|
||||
// Start time
|
||||
$start = microtime( true );
|
||||
|
||||
// Open the file for reading in binary mode (fopen may return null for quarantined files)
|
||||
if ( ( $file_handle = @fopen( $file_name, 'rb' ) ) ) {
|
||||
|
||||
// Start native hash for current chunk
|
||||
$hash_ctx = Ai1wm_Crc::init_crc32();
|
||||
|
||||
// Get header block with empty CRC placeholder
|
||||
if ( ( $block = $this->get_file_block( $file_name, $new_file_name, '' ) ) ) {
|
||||
|
||||
// Write header block
|
||||
if ( $file_bytes_offset === 0 ) {
|
||||
if ( ( $file_bytes = @fwrite( $this->file_handle, $block ) ) !== false ) {
|
||||
if ( strlen( $block ) !== $file_bytes ) {
|
||||
throw new Ai1wm_Quota_Exceeded_Exception( sprintf( __( 'Out of disk space. Could not write header to file. File: %s', 'all-in-one-wp-migration' ), $this->file_name ) );
|
||||
}
|
||||
} else {
|
||||
throw new Ai1wm_Not_Writable_Exception( sprintf( __( 'Could not write header to file. File: %s', 'all-in-one-wp-migration' ), $this->file_name ) );
|
||||
}
|
||||
}
|
||||
|
||||
// Set file offset
|
||||
if ( @fseek( $file_handle, $file_bytes_offset, SEEK_SET ) !== -1 ) {
|
||||
$file_bytes_read = 0;
|
||||
|
||||
// Cache config file check outside the loop
|
||||
$should_process_file = ! in_array( $new_file_name, ai1wm_config_filters() );
|
||||
|
||||
// Read the file in 512KB chunks
|
||||
while ( false === @feof( $file_handle ) ) {
|
||||
if ( ( $file_content = @fread( $file_handle, static::READ_CHUNK_SIZE ) ) !== false ) {
|
||||
|
||||
// Empty read indicates EOF
|
||||
if ( strlen( $file_content ) === 0 ) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Add the amount of bytes we read
|
||||
$file_bytes_read += strlen( $file_content );
|
||||
|
||||
// Update CRC with original content (BEFORE compression/encryption)
|
||||
Ai1wm_Crc::update_crc32( $hash_ctx, $file_content );
|
||||
|
||||
// Do not encrypt or compress config files
|
||||
if ( $should_process_file === true ) {
|
||||
|
||||
// Add chunk data compression
|
||||
if ( ! empty( $this->file_compression ) ) {
|
||||
switch ( $this->file_compression ) {
|
||||
case 'gzip':
|
||||
$file_content = gzcompress( $file_content, 9 );
|
||||
break;
|
||||
|
||||
case 'bzip2':
|
||||
$file_content = bzcompress( $file_content, 9 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Add chunk data encryption
|
||||
if ( ! empty( $this->file_password ) ) {
|
||||
$file_content = ai1wm_encrypt_string( $file_content, $this->file_password );
|
||||
}
|
||||
|
||||
// Add variable length chunk size before chunk data
|
||||
if ( ! empty( $this->file_compression ) ) {
|
||||
$file_content = pack( 'N', strlen( $file_content ) ) . $file_content;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( $file_bytes = @fwrite( $this->file_handle, $file_content ) ) !== false ) {
|
||||
if ( strlen( $file_content ) !== $file_bytes ) {
|
||||
throw new Ai1wm_Quota_Exceeded_Exception( sprintf( __( 'Out of disk space. Could not write content to file. File: %s', 'all-in-one-wp-migration' ), $this->file_name ) );
|
||||
}
|
||||
} else {
|
||||
throw new Ai1wm_Not_Writable_Exception( sprintf( __( 'Could not write content to file. File: %s', 'all-in-one-wp-migration' ), $this->file_name ) );
|
||||
}
|
||||
|
||||
// Add the amount of bytes we wrote
|
||||
$file_bytes_written += $file_bytes;
|
||||
}
|
||||
|
||||
// Time elapsed
|
||||
if ( ( $timeout = apply_filters( 'ai1wm_completed_timeout', 10 ) ) ) {
|
||||
if ( ( microtime( true ) - $start ) > $timeout ) {
|
||||
$completed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add the amount of bytes we read
|
||||
$file_bytes_offset += $file_bytes_read;
|
||||
}
|
||||
|
||||
// Combine and finalize CRC
|
||||
if ( empty( $file_crc ) ) {
|
||||
$file_crc = Ai1wm_Crc::finalize_crc32( $hash_ctx );
|
||||
} else {
|
||||
$file_crc = Ai1wm_Crc::combine_crc32( $file_crc, Ai1wm_Crc::finalize_crc32( $hash_ctx ), $file_bytes_read );
|
||||
}
|
||||
|
||||
// Write file size to file header
|
||||
if ( ( $file_size_block = $this->get_file_size_block( $file_bytes_written ) ) ) {
|
||||
|
||||
// Seek to beginning of file size (back over: content + crc32(8) + path(4088) + mtime(12) + size(14))
|
||||
if ( @fseek( $this->file_handle, - $file_bytes_written - 8 - 4088 - 12 - 14, SEEK_CUR ) === -1 ) {
|
||||
throw new Ai1wm_Not_Seekable_Exception( __( 'Your PHP is 32-bit. In order to export your file, please change your PHP version to 64-bit and try again. <a href="https://help.servmask.com/knowledgebase/php-32bit/" target="_blank">Technical details</a>', 'all-in-one-wp-migration' ) );
|
||||
}
|
||||
|
||||
// Write file size to file header
|
||||
if ( ( $file_bytes = @fwrite( $this->file_handle, $file_size_block ) ) !== false ) {
|
||||
if ( strlen( $file_size_block ) !== $file_bytes ) {
|
||||
throw new Ai1wm_Quota_Exceeded_Exception( sprintf( __( 'Out of disk space. Could not write size to file. File: %s', 'all-in-one-wp-migration' ), $this->file_name ) );
|
||||
}
|
||||
} else {
|
||||
throw new Ai1wm_Not_Writable_Exception( sprintf( __( 'Could not write size to file. File: %s', 'all-in-one-wp-migration' ), $this->file_name ) );
|
||||
}
|
||||
|
||||
// Seek to beginning of file CRC (forward over: mtime(12) + path(4088))
|
||||
if ( @fseek( $this->file_handle, + 12 + 4088, SEEK_CUR ) === -1 ) {
|
||||
throw new Ai1wm_Not_Seekable_Exception( __( 'Your PHP is 32-bit. In order to export your file, please change your PHP version to 64-bit and try again. <a href="https://help.servmask.com/knowledgebase/php-32bit/" target="_blank">Technical details</a>', 'all-in-one-wp-migration' ) );
|
||||
}
|
||||
|
||||
// Write file CRC to file header
|
||||
if ( ( $file_crc_block = $this->get_file_crc_block( $file_crc ) ) ) {
|
||||
if ( ( $file_bytes = @fwrite( $this->file_handle, $file_crc_block ) ) !== false ) {
|
||||
if ( strlen( $file_crc_block ) !== $file_bytes ) {
|
||||
throw new Ai1wm_Quota_Exceeded_Exception( sprintf( __( 'Out of disk space. Could not write CRC to file. File: %s', 'all-in-one-wp-migration' ), $this->file_name ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Seek to end of file content (forward over: content)
|
||||
if ( @fseek( $this->file_handle, + $file_bytes_written, SEEK_CUR ) === -1 ) {
|
||||
throw new Ai1wm_Not_Seekable_Exception( __( 'Your PHP is 32-bit. In order to export your file, please change your PHP version to 64-bit and try again. <a href="https://help.servmask.com/knowledgebase/php-32bit/" target="_blank">Technical details</a>', 'all-in-one-wp-migration' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Close the handle
|
||||
@fclose( $file_handle );
|
||||
}
|
||||
|
||||
return $completed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate binary block header for a file
|
||||
*
|
||||
* @param string $file_name Filename to generate block header for
|
||||
* @param string $new_file_name Write the file with a different name
|
||||
* @param string|null $crc32 CRC32 checksum (optional)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function get_file_block( $file_name, $new_file_name = '', $crc32 = null ) {
|
||||
$block = '';
|
||||
|
||||
// Get stats about the file
|
||||
if ( ( $stat = @stat( $file_name ) ) !== false ) {
|
||||
|
||||
// Filename of the file we are accessing
|
||||
if ( empty( $new_file_name ) ) {
|
||||
$name = ai1wm_basename( $file_name );
|
||||
} else {
|
||||
$name = ai1wm_basename( $new_file_name );
|
||||
}
|
||||
|
||||
// Size in bytes of the file
|
||||
$size = $stat['size'];
|
||||
|
||||
// Last time the file was modified
|
||||
$date = $stat['mtime'];
|
||||
|
||||
// Replace current directory separator with backward slash in file path
|
||||
if ( empty( $new_file_name ) ) {
|
||||
$path = ai1wm_replace_directory_separator_with_forward_slash( ai1wm_dirname( $file_name ) );
|
||||
} else {
|
||||
$path = ai1wm_replace_directory_separator_with_forward_slash( ai1wm_dirname( $new_file_name ) );
|
||||
}
|
||||
|
||||
// Only calculate CRC if not provided
|
||||
if ( empty( $crc32 ) ) {
|
||||
$crc32 = Ai1wm_Crc::calculate_file_crc32( $file_name );
|
||||
}
|
||||
|
||||
// Concatenate block format parts
|
||||
$format = implode( '', $this->block_format );
|
||||
|
||||
// Pack file data into binary string
|
||||
$block = pack( $format, $name, $size, $date, $path, $crc32 );
|
||||
}
|
||||
|
||||
return $block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate file size binary block header for a file
|
||||
*
|
||||
* @param int $file_size File size
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_file_size_block( $file_size ) {
|
||||
$block = '';
|
||||
|
||||
// Pack file data into binary string
|
||||
if ( isset( $this->block_format[1] ) ) {
|
||||
$block = pack( $this->block_format[1], $file_size );
|
||||
}
|
||||
|
||||
return $block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate file CRC binary block header for a file
|
||||
*
|
||||
* @param int $file_crc File CRC
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_file_crc_block( $file_crc ) {
|
||||
$block = '';
|
||||
|
||||
// Pack file data into binary string
|
||||
if ( isset( $this->block_format[4] ) ) {
|
||||
$block = pack( $this->block_format[4], $file_crc );
|
||||
}
|
||||
|
||||
return $block;
|
||||
}
|
||||
}
|
||||
717
plugins/all-in-one-wp-migration/lib/vendor/servmask/archiver/class-ai1wm-extractor.php
vendored
Normal file
717
plugins/all-in-one-wp-migration/lib/vendor/servmask/archiver/class-ai1wm-extractor.php
vendored
Normal file
@@ -0,0 +1,717 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Extractor extends Ai1wm_Archiver {
|
||||
|
||||
/**
|
||||
* Total files count
|
||||
*
|
||||
* @type int
|
||||
*/
|
||||
protected $total_files_count = null;
|
||||
|
||||
/**
|
||||
* Total files size
|
||||
*
|
||||
* @type int
|
||||
*/
|
||||
protected $total_files_size = null;
|
||||
|
||||
/**
|
||||
* Overloaded constructor that opens the passed file for reading
|
||||
*
|
||||
* @param string $file_name File to use as archive
|
||||
* @param string $file_password File password string
|
||||
* @param string $file_compression File compression type
|
||||
*/
|
||||
public function __construct( $file_name, $file_password = null, $file_compression = null ) {
|
||||
// Call parent, to initialize variables
|
||||
parent::__construct( $file_name, $file_password, $file_compression, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* List all files in the archive
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function list_files() {
|
||||
$files = array();
|
||||
|
||||
// Seek to beginning of archive file
|
||||
if ( @fseek( $this->file_handle, 0, SEEK_SET ) === -1 ) {
|
||||
throw new Ai1wm_Not_Seekable_Exception( sprintf( __( 'Could not seek to beginning of file. File: %s', 'all-in-one-wp-migration' ), $this->file_name ) );
|
||||
}
|
||||
|
||||
$offset = 0;
|
||||
|
||||
// Loop over files
|
||||
while ( ( $block = @fread( $this->file_handle, static::HEADER_SIZE ) ) ) {
|
||||
|
||||
// End block has been reached
|
||||
if ( $this->is_eof_block( $block ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get file data from the block
|
||||
if ( ( $data = $this->get_data_from_block( $block ) ) ) {
|
||||
// Store the position where the file begins - used for downloading from archive directly
|
||||
$data['offset'] = $offset;
|
||||
|
||||
// Skip file content, so we can move forward to the next file
|
||||
if ( @fseek( $this->file_handle, $data['size'], SEEK_CUR ) === -1 ) {
|
||||
throw new Ai1wm_Not_Seekable_Exception( sprintf( __( 'Could not seek to offset of file. File: %s Offset: %d', 'all-in-one-wp-migration' ), $this->file_name, $data['size'] ) );
|
||||
}
|
||||
|
||||
$files[] = $data;
|
||||
}
|
||||
|
||||
$offset = @ftell( $this->file_handle );
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total files count in an archive
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_total_files_count() {
|
||||
if ( is_null( $this->total_files_count ) ) {
|
||||
$this->set_files_totals();
|
||||
}
|
||||
|
||||
return $this->total_files_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total files size in an archive
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_total_files_size() {
|
||||
if ( is_null( $this->total_files_size ) ) {
|
||||
$this->set_files_totals();
|
||||
}
|
||||
|
||||
return $this->total_files_size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the total files count and size in the archive
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function set_files_totals() {
|
||||
// Total files count
|
||||
$this->total_files_count = 0;
|
||||
|
||||
// Total files size
|
||||
$this->total_files_size = 0;
|
||||
|
||||
// Seek to beginning of archive file
|
||||
if ( @fseek( $this->file_handle, 0, SEEK_SET ) === -1 ) {
|
||||
throw new Ai1wm_Not_Seekable_Exception( sprintf( __( 'Could not seek to beginning of file. File: %s', 'all-in-one-wp-migration' ), $this->file_name ) );
|
||||
}
|
||||
|
||||
// Loop over files
|
||||
while ( ( $block = @fread( $this->file_handle, static::HEADER_SIZE ) ) ) {
|
||||
|
||||
// End block has been reached
|
||||
if ( $this->is_eof_block( $block ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get file data from the block
|
||||
if ( ( $data = $this->get_data_from_block( $block ) ) ) {
|
||||
|
||||
// We have a file, increment the count
|
||||
$this->total_files_count += 1;
|
||||
|
||||
// We have a file, increment the size
|
||||
$this->total_files_size += $data['size'];
|
||||
|
||||
// Skip file content so we can move forward to the next file
|
||||
if ( @fseek( $this->file_handle, $data['size'], SEEK_CUR ) === -1 ) {
|
||||
throw new Ai1wm_Not_Seekable_Exception( sprintf( __( 'Could not seek to offset of file. File: %s Offset: %d', 'all-in-one-wp-migration' ), $this->file_name, $data['size'] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract one file to location
|
||||
*
|
||||
* @param string $location Destination path
|
||||
* @param array $exclude_files Exclude files by name
|
||||
* @param array $exclude_extensions Exclude files by extension
|
||||
* @param array $old_paths Old replace paths
|
||||
* @param array $new_paths New replace paths
|
||||
* @param int $file_bytes_read Amount of the bytes we read
|
||||
* @param int $file_bytes_offset File bytes offset
|
||||
* @param int $file_bytes_written Amount of the bytes we wrote
|
||||
*
|
||||
* @throws \Ai1wm_Not_Directory_Exception
|
||||
* @throws \Ai1wm_Not_Seekable_Exception
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function extract_one_file_to( $location, $exclude_files = array(), $exclude_extensions = array(), $old_paths = array(), $new_paths = array(), &$file_bytes_read = 0, &$file_bytes_offset = 0, &$file_bytes_written = 0 ) {
|
||||
if ( false === is_dir( $location ) ) {
|
||||
throw new Ai1wm_Not_Directory_Exception( sprintf( __( 'Location is not a directory: %s', 'all-in-one-wp-migration' ), $location ) );
|
||||
}
|
||||
|
||||
// Replace forward slash with current directory separator in location
|
||||
$location = ai1wm_replace_forward_slash_with_directory_separator( $location );
|
||||
|
||||
// Flag to hold if file data has been processed
|
||||
$completed = true;
|
||||
|
||||
// Seek to file offset to archive file
|
||||
if ( $file_bytes_offset > 0 ) {
|
||||
if ( @fseek( $this->file_handle, - $file_bytes_offset - static::HEADER_SIZE, SEEK_CUR ) === -1 ) {
|
||||
throw new Ai1wm_Not_Seekable_Exception( sprintf( __( 'Could not seek to offset of file. File: %s Offset: %d', 'all-in-one-wp-migration' ), $this->file_name, - $file_bytes_offset - static::HEADER_SIZE ) );
|
||||
}
|
||||
}
|
||||
|
||||
// Read file header block
|
||||
if ( ( $block = @fread( $this->file_handle, static::HEADER_SIZE ) ) ) {
|
||||
|
||||
// We reached end of file, set the pointer to the end of the file so that feof returns true
|
||||
if ( $this->is_eof_block( $block ) ) {
|
||||
|
||||
// Seek to end of archive file minus 1 byte
|
||||
@fseek( $this->file_handle, 1, SEEK_END );
|
||||
|
||||
// Read 1 character
|
||||
@fgetc( $this->file_handle );
|
||||
|
||||
} else {
|
||||
|
||||
// Get file header data from the block
|
||||
if ( ( $data = $this->get_data_from_block( $block ) ) ) {
|
||||
|
||||
// Set file name
|
||||
$file_name = $data['filename'];
|
||||
|
||||
// Set file size
|
||||
$file_size = $data['size'];
|
||||
|
||||
// Set file mtime
|
||||
$file_mtime = $data['mtime'];
|
||||
|
||||
// Set file path
|
||||
$file_path = $data['path'];
|
||||
|
||||
// Set file crc
|
||||
$file_crc32 = $data['crc32'];
|
||||
|
||||
// Should we skip this file by name?
|
||||
$should_exclude_file = false;
|
||||
for ( $i = 0; $i < count( $exclude_files ); $i++ ) {
|
||||
if ( strpos( $file_name . DIRECTORY_SEPARATOR, ai1wm_replace_forward_slash_with_directory_separator( $exclude_files[ $i ] ) . DIRECTORY_SEPARATOR ) === 0 ) {
|
||||
$should_exclude_file = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Should we skip this file by extension?
|
||||
for ( $i = 0; $i < count( $exclude_extensions ); $i++ ) {
|
||||
if ( strrpos( $file_name, $exclude_extensions[ $i ] ) === strlen( $file_name ) - strlen( $exclude_extensions[ $i ] ) ) {
|
||||
$should_exclude_file = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Validate file name and file path for directory traversal
|
||||
if ( path_is_absolute( $file_name ) || validate_file( $file_name ) !== 0 ) {
|
||||
$should_exclude_file = true;
|
||||
}
|
||||
|
||||
// Do we have a match?
|
||||
if ( $should_exclude_file === false ) {
|
||||
|
||||
// Replace extract paths
|
||||
for ( $i = 0; $i < count( $old_paths ); $i++ ) {
|
||||
if ( strpos( $file_path . DIRECTORY_SEPARATOR, ai1wm_replace_forward_slash_with_directory_separator( $old_paths[ $i ] ) . DIRECTORY_SEPARATOR ) === 0 ) {
|
||||
$file_name = substr_replace( $file_name, ai1wm_replace_forward_slash_with_directory_separator( $new_paths[ $i ] ), 0, strlen( ai1wm_replace_forward_slash_with_directory_separator( $old_paths[ $i ] ) ) );
|
||||
$file_path = substr_replace( $file_path, ai1wm_replace_forward_slash_with_directory_separator( $new_paths[ $i ] ), 0, strlen( ai1wm_replace_forward_slash_with_directory_separator( $old_paths[ $i ] ) ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Escape Windows directory separator in file path
|
||||
if ( path_is_absolute( $file_path ) ) {
|
||||
$location_file_path = ai1wm_escape_windows_directory_separator( $file_path );
|
||||
} else {
|
||||
$location_file_path = ai1wm_escape_windows_directory_separator( $location . DIRECTORY_SEPARATOR . $file_path );
|
||||
}
|
||||
|
||||
// Escape Windows directory separator in file name
|
||||
if ( path_is_absolute( $file_name ) ) {
|
||||
$location_file_name = ai1wm_escape_windows_directory_separator( $file_name );
|
||||
} else {
|
||||
$location_file_name = ai1wm_escape_windows_directory_separator( $location . DIRECTORY_SEPARATOR . $file_name );
|
||||
}
|
||||
|
||||
// Check if location doesn't exist, then create it
|
||||
if ( false === is_dir( $location_file_path ) ) {
|
||||
@mkdir( $location_file_path, $this->get_permissions_for_directory(), true );
|
||||
}
|
||||
|
||||
$file_bytes_read = 0;
|
||||
|
||||
// We have a match, let's extract the file
|
||||
if ( ( $completed = $this->extract_to( $location_file_name, $file_name, $file_size, $file_mtime, $file_bytes_read, $file_bytes_offset, $file_bytes_written ) ) ) {
|
||||
$file_bytes_offset = $file_bytes_written = 0;
|
||||
|
||||
// Verify CRC32 if present (not empty means version 2 archive with CRC32)
|
||||
if ( ! empty( $file_crc32 ) ) {
|
||||
do_action( 'ai1wm_check_file_integrity', $file_name, $file_crc32 );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
// We don't have a match, skip file content
|
||||
if ( @fseek( $this->file_handle, $file_size, SEEK_CUR ) === -1 ) {
|
||||
throw new Ai1wm_Not_Seekable_Exception( sprintf( __( 'Could not seek to offset of file. File: %s Offset: %d', 'all-in-one-wp-migration' ), $this->file_name, $file_size ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $completed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract specific files from archive
|
||||
*
|
||||
* @param string $location Location where to extract files
|
||||
* @param array $include_files Include files by name
|
||||
* @param array $exclude_files Exclude files by name
|
||||
* @param array $exclude_extensions Exclude files by extension
|
||||
* @param int $file_bytes_read Amount of the bytes we read
|
||||
* @param int $file_bytes_offset File bytes offset
|
||||
* @param int $file_bytes_written Amount of the bytes we wrote
|
||||
*
|
||||
* @throws \Ai1wm_Not_Directory_Exception
|
||||
* @throws \Ai1wm_Not_Seekable_Exception
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function extract_by_files_array( $location, $include_files = array(), $exclude_files = array(), $exclude_extensions = array(), &$file_bytes_read = 0, &$file_bytes_offset = 0, &$file_bytes_written = 0 ) {
|
||||
if ( false === is_dir( $location ) ) {
|
||||
throw new Ai1wm_Not_Directory_Exception( sprintf( __( 'Location is not a directory: %s', 'all-in-one-wp-migration' ), $location ) );
|
||||
}
|
||||
|
||||
// Replace forward slash with current directory separator in location
|
||||
$location = ai1wm_replace_forward_slash_with_directory_separator( $location );
|
||||
|
||||
// Flag to hold if file data has been processed
|
||||
$completed = true;
|
||||
|
||||
// Start time
|
||||
$start = microtime( true );
|
||||
|
||||
// Seek to file offset to archive file
|
||||
if ( $file_bytes_offset > 0 ) {
|
||||
if ( @fseek( $this->file_handle, - $file_bytes_offset - static::HEADER_SIZE, SEEK_CUR ) === -1 ) {
|
||||
throw new Ai1wm_Not_Seekable_Exception( sprintf( __( 'Could not seek to offset of file. File: %s Offset: %d', 'all-in-one-wp-migration' ), $this->file_name, - $file_bytes_offset - static::HEADER_SIZE ) );
|
||||
}
|
||||
}
|
||||
|
||||
// We read until we reached the end of the file, or the files we were looking for were found
|
||||
while ( ( $block = @fread( $this->file_handle, static::HEADER_SIZE ) ) ) {
|
||||
|
||||
// We reached end of file, set the pointer to the end of the file so that feof returns true
|
||||
if ( $this->is_eof_block( $block ) ) {
|
||||
|
||||
// Seek to end of archive file minus 1 byte
|
||||
@fseek( $this->file_handle, 1, SEEK_END );
|
||||
|
||||
// Read 1 character
|
||||
@fgetc( $this->file_handle );
|
||||
|
||||
} else {
|
||||
|
||||
// Get file header data from the block
|
||||
if ( ( $data = $this->get_data_from_block( $block ) ) ) {
|
||||
|
||||
// Set file name
|
||||
$file_name = $data['filename'];
|
||||
|
||||
// Set file size
|
||||
$file_size = $data['size'];
|
||||
|
||||
// Set file mtime
|
||||
$file_mtime = $data['mtime'];
|
||||
|
||||
// Set file path
|
||||
$file_path = $data['path'];
|
||||
|
||||
// Set file crc
|
||||
$file_crc32 = $data['crc32'];
|
||||
|
||||
// Should we extract this file by name?
|
||||
$should_include_file = false;
|
||||
for ( $i = 0; $i < count( $include_files ); $i++ ) {
|
||||
if ( strpos( $file_name . DIRECTORY_SEPARATOR, ai1wm_replace_forward_slash_with_directory_separator( $include_files[ $i ] ) . DIRECTORY_SEPARATOR ) === 0 ) {
|
||||
$should_include_file = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Should we skip this file name?
|
||||
for ( $i = 0; $i < count( $exclude_files ); $i++ ) {
|
||||
if ( strpos( $file_name . DIRECTORY_SEPARATOR, ai1wm_replace_forward_slash_with_directory_separator( $exclude_files[ $i ] ) . DIRECTORY_SEPARATOR ) === 0 ) {
|
||||
$should_include_file = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Should we skip this file by extension?
|
||||
for ( $i = 0; $i < count( $exclude_extensions ); $i++ ) {
|
||||
if ( strrpos( $file_name, $exclude_extensions[ $i ] ) === strlen( $file_name ) - strlen( $exclude_extensions[ $i ] ) ) {
|
||||
$should_include_file = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Validate file name and file path for directory traversal
|
||||
if ( path_is_absolute( $file_name ) || validate_file( $file_name ) !== 0 ) {
|
||||
$should_include_file = false;
|
||||
}
|
||||
|
||||
// Do we have a match?
|
||||
if ( $should_include_file === true ) {
|
||||
|
||||
// Escape Windows directory separator in file path
|
||||
$location_file_path = ai1wm_escape_windows_directory_separator( $location . DIRECTORY_SEPARATOR . $file_path );
|
||||
|
||||
// Escape Windows directory separator in file name
|
||||
$location_file_name = ai1wm_escape_windows_directory_separator( $location . DIRECTORY_SEPARATOR . $file_name );
|
||||
|
||||
// Check if location doesn't exist, then create it
|
||||
if ( false === is_dir( $location_file_path ) ) {
|
||||
@mkdir( $location_file_path, $this->get_permissions_for_directory(), true );
|
||||
}
|
||||
|
||||
$file_bytes_read = 0;
|
||||
|
||||
// We have a match, let's extract the file
|
||||
if ( ( $completed = $this->extract_to( $location_file_name, $file_name, $file_size, $file_mtime, $file_bytes_read, $file_bytes_offset, $file_bytes_written ) ) ) {
|
||||
$file_bytes_offset = $file_bytes_written = 0;
|
||||
|
||||
// Verify CRC32 if present (not empty means version 2 archive with CRC32)
|
||||
if ( ! empty( $file_crc32 ) ) {
|
||||
do_action( 'ai1wm_check_file_integrity', $file_name, $file_crc32 );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
// We don't have a match, skip file content
|
||||
if ( @fseek( $this->file_handle, $file_size, SEEK_CUR ) === -1 ) {
|
||||
throw new Ai1wm_Not_Seekable_Exception( sprintf( __( 'Could not seek to offset of file. File: %s Offset: %d', 'all-in-one-wp-migration' ), $this->file_name, $file_size ) );
|
||||
}
|
||||
}
|
||||
|
||||
// Time elapsed
|
||||
if ( ( $timeout = apply_filters( 'ai1wm_completed_timeout', 10 ) ) ) {
|
||||
if ( ( microtime( true ) - $start ) > $timeout ) {
|
||||
$completed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $completed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract file to
|
||||
*
|
||||
* @param string $location_file_name Location file name
|
||||
* @param string $file_name File name
|
||||
* @param array $file_size File size (in bytes)
|
||||
* @param array $file_mtime File modified time (in seconds)
|
||||
* @param int $file_bytes_read Amount of the bytes we read
|
||||
* @param int $file_bytes_offset File bytes offset
|
||||
* @param int $file_bytes_written Amount of the bytes we wrote
|
||||
*
|
||||
* @throws \Ai1wm_Not_Seekable_Exception
|
||||
* @throws \Ai1wm_Not_Readable_Exception
|
||||
* @throws \Ai1wm_Quota_Exceeded_Exception
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function extract_to( $location_file_name, $file_name, $file_size, $file_mtime, &$file_bytes_read = 0, &$file_bytes_offset = 0, &$file_bytes_written = 0 ) {
|
||||
// Flag to hold if file data has been processed
|
||||
$completed = true;
|
||||
|
||||
// Start time
|
||||
$start = microtime( true );
|
||||
|
||||
// Seek to file offset to archive file
|
||||
if ( $file_bytes_offset > 0 ) {
|
||||
if ( @fseek( $this->file_handle, $file_bytes_offset, SEEK_CUR ) === -1 ) {
|
||||
throw new Ai1wm_Not_Seekable_Exception( sprintf( __( 'Could not seek to offset of file. File: %s Offset: %d', 'all-in-one-wp-migration' ), $this->file_name, $file_size ) );
|
||||
}
|
||||
}
|
||||
|
||||
// Set file size
|
||||
$file_size -= $file_bytes_offset;
|
||||
|
||||
// Should the extract overwrite the file if it exists? (fopen may return null for quarantined files)
|
||||
if ( ( $file_handle = @fopen( $location_file_name, ( $file_bytes_offset === 0 ? 'wb' : 'cb' ) ) ) ) {
|
||||
|
||||
// Set file offset
|
||||
if ( @fseek( $file_handle, $file_bytes_written, SEEK_SET ) !== -1 ) {
|
||||
$file_bytes_read = 0;
|
||||
|
||||
// Cache config file check outside the loop
|
||||
$should_process_file = ! in_array( $file_name, ai1wm_config_filters() );
|
||||
|
||||
// Is the filesize more than 0 bytes?
|
||||
while ( $file_size > 0 ) {
|
||||
|
||||
// Read the file in chunks of 512KB
|
||||
$chunk_size = min( $file_size, static::READ_CHUNK_SIZE );
|
||||
|
||||
// Do not decrypt or decompress config files
|
||||
if ( $should_process_file === true ) {
|
||||
|
||||
// Get decryption chunk size
|
||||
if ( ! empty( $this->file_password ) ) {
|
||||
if ( $file_size > static::READ_CHUNK_SIZE ) {
|
||||
$chunk_size += ai1wm_crypt_iv_length() * 2;
|
||||
$chunk_size = min( $chunk_size, $file_size );
|
||||
}
|
||||
}
|
||||
|
||||
// Read chunk header data
|
||||
if ( ! empty( $this->file_compression ) ) {
|
||||
$chunk_header_size = 4;
|
||||
|
||||
// Get chunk header block
|
||||
if ( ( $chunk_header_block = fread( $this->file_handle, $chunk_header_size ) ) === false ) {
|
||||
throw new Ai1wm_Not_Readable_Exception( sprintf( __( 'Could not read content from file. File: %s', 'all-in-one-wp-migration' ), $this->file_name ) );
|
||||
}
|
||||
|
||||
// Get chunk header data
|
||||
if ( ( $chunk_header_data = unpack( 'Nsize', $chunk_header_block ) ) ) {
|
||||
if ( isset( $chunk_header_data['size'] ) ) {
|
||||
$chunk_size = $chunk_header_data['size'];
|
||||
}
|
||||
}
|
||||
|
||||
// Add the amount of bytes we read
|
||||
$file_bytes_read += $chunk_header_size;
|
||||
|
||||
// Remove the amout of bytes we read
|
||||
$file_size -= $chunk_header_size;
|
||||
}
|
||||
}
|
||||
|
||||
// Read data chunk by chunk from archive file
|
||||
if ( $chunk_size > 0 ) {
|
||||
|
||||
// Read the file in chunks of 512KB from archiver
|
||||
if ( ( $file_content = @fread( $this->file_handle, $chunk_size ) ) === false ) {
|
||||
throw new Ai1wm_Not_Readable_Exception( sprintf( __( 'Could not read content from file. File: %s', 'all-in-one-wp-migration' ), $this->file_name ) );
|
||||
}
|
||||
|
||||
// Add the amount of bytes we read
|
||||
$file_bytes_read += $chunk_size;
|
||||
|
||||
// Remove the amout of bytes we read
|
||||
$file_size -= $chunk_size;
|
||||
|
||||
// Do not decrypt or decompress config files
|
||||
if ( $should_process_file === true ) {
|
||||
|
||||
// Add chunk data decryption
|
||||
if ( ! empty( $this->file_password ) ) {
|
||||
$file_content = ai1wm_decrypt_string( $file_content, $this->file_password );
|
||||
}
|
||||
|
||||
// Add chunk data decompression
|
||||
if ( ! empty( $this->file_compression ) ) {
|
||||
switch ( $this->file_compression ) {
|
||||
case 'gzip':
|
||||
$file_content = gzuncompress( $file_content );
|
||||
break;
|
||||
|
||||
case 'bzip2':
|
||||
$file_content = bzdecompress( $file_content );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Write file contents
|
||||
if ( ( $file_bytes = @fwrite( $file_handle, $file_content ) ) !== false ) {
|
||||
if ( strlen( $file_content ) !== $file_bytes ) {
|
||||
throw new Ai1wm_Quota_Exceeded_Exception( sprintf( __( 'Out of disk space. Could not write content to file. File: %s', 'all-in-one-wp-migration' ), $location_file_name ) );
|
||||
}
|
||||
}
|
||||
|
||||
// Add the amount of bytes we wrote
|
||||
$file_bytes_written += $file_bytes;
|
||||
}
|
||||
|
||||
// Time elapsed
|
||||
if ( ( $timeout = apply_filters( 'ai1wm_completed_timeout', 10 ) ) ) {
|
||||
if ( ( microtime( true ) - $start ) > $timeout ) {
|
||||
$completed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add the amount of bytes we read
|
||||
$file_bytes_offset += $file_bytes_read;
|
||||
}
|
||||
|
||||
// Close the handle
|
||||
@fclose( $file_handle );
|
||||
|
||||
// Let's apply last modified date
|
||||
@touch( $location_file_name, $file_mtime );
|
||||
|
||||
// All files should chmoded to 644
|
||||
@chmod( $location_file_name, $this->get_permissions_for_file() );
|
||||
|
||||
} else {
|
||||
|
||||
// We don't have file permissions, skip file content
|
||||
if ( @fseek( $this->file_handle, $file_size, SEEK_CUR ) === -1 ) {
|
||||
throw new Ai1wm_Not_Seekable_Exception( sprintf( __( 'Could not seek to offset of file. File: %s Offset: %d', 'all-in-one-wp-migration' ), $this->file_name, $file_size ) );
|
||||
}
|
||||
}
|
||||
|
||||
return $completed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file header data from the block
|
||||
*
|
||||
* @param string $block Binary file header
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function get_data_from_block( $block ) {
|
||||
$data = false;
|
||||
|
||||
// Prepare our array keys to unpack
|
||||
$format = array(
|
||||
$this->block_format[0] . 'filename/',
|
||||
$this->block_format[1] . 'size/',
|
||||
$this->block_format[2] . 'mtime/',
|
||||
$this->block_format[3] . 'path/',
|
||||
$this->block_format[4] . 'crc32',
|
||||
);
|
||||
$format = implode( '', $format );
|
||||
|
||||
// Unpack file header data
|
||||
if ( ( $data = unpack( $format, $block ) ) ) {
|
||||
|
||||
// Set file details
|
||||
$data['filename'] = trim( $data['filename'] );
|
||||
$data['size'] = (int) trim( $data['size'] );
|
||||
$data['mtime'] = (int) trim( $data['mtime'] );
|
||||
$data['path'] = trim( $data['path'] );
|
||||
$data['crc32'] = trim( $data['crc32'] );
|
||||
|
||||
// Set file name
|
||||
$data['filename'] = ( $data['path'] === '.' ? $data['filename'] : $data['path'] . DIRECTORY_SEPARATOR . $data['filename'] );
|
||||
|
||||
// Set file path
|
||||
$data['path'] = ( $data['path'] === '.' ? '' : $data['path'] );
|
||||
|
||||
// Replace forward slash with current directory separator in file name
|
||||
$data['filename'] = ai1wm_replace_forward_slash_with_directory_separator( $data['filename'] );
|
||||
|
||||
// Replace forward slash with current directory separator in file path
|
||||
$data['path'] = ai1wm_replace_forward_slash_with_directory_separator( $data['path'] );
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if file has reached end of file
|
||||
* Returns true if file has reached eof, false otherwise
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has_reached_eof() {
|
||||
return @feof( $this->file_handle );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if file has reached end of file
|
||||
* Returns true if file has NOT reached eof, false otherwise
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has_not_reached_eof() {
|
||||
return ! @feof( $this->file_handle );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get directory permissions
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_permissions_for_directory() {
|
||||
if ( defined( 'FS_CHMOD_DIR' ) ) {
|
||||
return FS_CHMOD_DIR;
|
||||
}
|
||||
|
||||
return 0755;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file permissions
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_permissions_for_file() {
|
||||
if ( defined( 'FS_CHMOD_FILE' ) ) {
|
||||
return FS_CHMOD_FILE;
|
||||
}
|
||||
|
||||
return 0644;
|
||||
}
|
||||
}
|
||||
202
plugins/all-in-one-wp-migration/lib/vendor/servmask/checksum/class-ai1wm-crc.php
vendored
Normal file
202
plugins/all-in-one-wp-migration/lib/vendor/servmask/checksum/class-ai1wm-crc.php
vendored
Normal file
@@ -0,0 +1,202 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Crc {
|
||||
|
||||
/**
|
||||
* Calculate CRC32 checksum for a file
|
||||
*
|
||||
* @param string $file_path Path to the file
|
||||
* @return string|null CRC32 checksum as hexadecimal string or null on error
|
||||
*/
|
||||
public static function calculate_file_crc32( $file_path ) {
|
||||
if ( ! file_exists( $file_path ) || ! is_readable( $file_path ) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Use hash_file for CRC32b (CRC32 with reversed bit order, more standard)
|
||||
$crc = hash_file( 'crc32b', $file_path );
|
||||
|
||||
return $crc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify file CRC32 checksum
|
||||
*
|
||||
* @param string $file_path Path to the file
|
||||
* @param string $expected_crc Expected CRC32 checksum
|
||||
* @return bool True if CRC matches, false otherwise
|
||||
*/
|
||||
public static function verify_file_crc32( $file_path, $expected_crc ) {
|
||||
$calculated_crc = self::calculate_file_crc32( $file_path );
|
||||
|
||||
if ( $calculated_crc === null ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return strcasecmp( $calculated_crc, $expected_crc ) === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize CRC32 hash context for incremental calculation
|
||||
*
|
||||
* @return resource|\HashContext Hash context
|
||||
*/
|
||||
public static function init_crc32() {
|
||||
return hash_init( 'crc32b' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Update CRC32 hash with a data chunk
|
||||
*
|
||||
* @param resource|\HashContext $context Hash context
|
||||
* @param string $data Data chunk to add
|
||||
* @return void
|
||||
*/
|
||||
public static function update_crc32( $context, $data ) {
|
||||
hash_update( $context, $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Finalize CRC32 calculation and return result
|
||||
*
|
||||
* @param resource|\HashContext $context Hash context
|
||||
* @return string CRC32 checksum as hexadecimal string
|
||||
*/
|
||||
public static function finalize_crc32( $context ) {
|
||||
return hash_final( $context );
|
||||
}
|
||||
|
||||
/**
|
||||
* Combine two CRC32 checksums
|
||||
*
|
||||
* This method mathematically combines two CRC32 values, allowing resumable
|
||||
* CRC calculation across multiple processing cycles (e.g., handling timeouts).
|
||||
*
|
||||
* Based on zlib's crc32_combine algorithm using GF(2) polynomial arithmetic.
|
||||
*
|
||||
* @param string $crc1_hex CRC32 of first data block (hex string)
|
||||
* @param string $crc2_hex CRC32 of second data block (hex string)
|
||||
* @param int $len2 Length of second data block in bytes
|
||||
* @return string Combined CRC32 checksum as hexadecimal string
|
||||
*/
|
||||
public static function combine_crc32( $crc1_hex, $crc2_hex, $len2 ) {
|
||||
// CRC32 polynomial (reversed)
|
||||
$poly = 0xEDB88320;
|
||||
|
||||
// Convert hex strings to integers
|
||||
$crc1 = hexdec( $crc1_hex );
|
||||
$crc2 = hexdec( $crc2_hex );
|
||||
|
||||
// If second block is empty, return first CRC unchanged
|
||||
if ( $len2 === 0 ) {
|
||||
return sprintf( '%08x', $crc1 );
|
||||
}
|
||||
|
||||
// Build operator matrix for x^n where n = len2 * 8
|
||||
// This represents multiplication by x^(8*len2) mod poly
|
||||
$even = array_fill( 0, 32, 0 );
|
||||
$even[0] = $poly;
|
||||
$row = 1;
|
||||
for ( $n = 1; $n < 32; $n++ ) {
|
||||
$even[ $n ] = $row;
|
||||
$row = $row << 1;
|
||||
}
|
||||
|
||||
// Square to get x^2, x^4, x^8, etc.
|
||||
$odd = array_fill( 0, 32, 0 );
|
||||
self::gf2_matrix_square( $odd, $even );
|
||||
self::gf2_matrix_square( $even, $odd );
|
||||
|
||||
// Apply len2 zeros to crc1 by repeatedly squaring and applying
|
||||
do {
|
||||
// Apply zeros operator for this bit of len2
|
||||
self::gf2_matrix_square( $odd, $even );
|
||||
if ( $len2 & 1 ) {
|
||||
$crc1 = self::gf2_matrix_times( $odd, $crc1 );
|
||||
}
|
||||
$len2 >>= 1;
|
||||
|
||||
// If no more bits, we're done
|
||||
if ( $len2 === 0 ) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Square again for next bit
|
||||
self::gf2_matrix_square( $even, $odd );
|
||||
if ( $len2 & 1 ) {
|
||||
$crc1 = self::gf2_matrix_times( $even, $crc1 );
|
||||
}
|
||||
$len2 >>= 1;
|
||||
|
||||
} while ( $len2 !== 0 );
|
||||
|
||||
// Combine the two CRCs
|
||||
$crc1 ^= $crc2;
|
||||
|
||||
return sprintf( '%08x', $crc1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Matrix multiplication in GF(2)
|
||||
*
|
||||
* @param array $mat Matrix
|
||||
* @param int $vec Vector
|
||||
* @return int Result
|
||||
*/
|
||||
private static function gf2_matrix_times( $mat, $vec ) {
|
||||
$sum = 0;
|
||||
$mat_index = 0;
|
||||
|
||||
while ( $vec ) {
|
||||
if ( $vec & 1 ) {
|
||||
$sum ^= $mat[ $mat_index ];
|
||||
}
|
||||
$vec = ( $vec >> 1 ) & 0x7FFFFFFF;
|
||||
$mat_index++;
|
||||
}
|
||||
|
||||
return $sum;
|
||||
}
|
||||
|
||||
/**
|
||||
* Square a matrix in GF(2)
|
||||
*
|
||||
* @param array $square Result matrix (passed by reference)
|
||||
* @param array $mat Input matrix
|
||||
* @return void
|
||||
*/
|
||||
private static function gf2_matrix_square( &$square, $mat ) {
|
||||
for ( $n = 0; $n < 32; $n++ ) {
|
||||
$square[ $n ] = self::gf2_matrix_times( $mat, $mat[ $n ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
119
plugins/all-in-one-wp-migration/lib/vendor/servmask/command/class-ai1wm-wp-cli-command.php
vendored
Normal file
119
plugins/all-in-one-wp-migration/lib/vendor/servmask/command/class-ai1wm-wp-cli-command.php
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Attribution: This code is part of the All-in-One WP Migration plugin, developed by
|
||||
*
|
||||
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
|
||||
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
|
||||
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
|
||||
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
|
||||
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
||||
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( 'Kangaroos cannot jump here' );
|
||||
}
|
||||
|
||||
if ( defined( 'WP_CLI' ) ) {
|
||||
class Ai1wm_WP_CLI_Command extends WP_CLI_Command {
|
||||
|
||||
/**
|
||||
* Creates a new backup.
|
||||
*
|
||||
* ## EXAMPLES
|
||||
*
|
||||
* $ wp ai1wm export
|
||||
*
|
||||
* @subcommand export
|
||||
*/
|
||||
public function export( $args = array(), $assoc_args = array() ) {
|
||||
$this->info();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new backup.
|
||||
*
|
||||
* ## EXAMPLES
|
||||
*
|
||||
* $ wp ai1wm backup
|
||||
*
|
||||
* @subcommand backup
|
||||
*/
|
||||
public function backup( $args = array(), $assoc_args = array() ) {
|
||||
$this->info();
|
||||
}
|
||||
|
||||
/**
|
||||
* Imports a backup.
|
||||
*
|
||||
* ## EXAMPLES
|
||||
*
|
||||
* $ wp ai1wm import
|
||||
*
|
||||
* @subcommand import
|
||||
*/
|
||||
public function import( $args = array(), $assoc_args = array() ) {
|
||||
$this->info();
|
||||
}
|
||||
|
||||
/**
|
||||
* Restores a backup.
|
||||
*
|
||||
* ## EXAMPLES
|
||||
*
|
||||
* $ wp ai1wm restore
|
||||
*
|
||||
* @subcommand restore
|
||||
*/
|
||||
public function restore( $args = array(), $assoc_args = array() ) {
|
||||
$this->info();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets site to default WordPress installation.
|
||||
*
|
||||
* ## EXAMPLES
|
||||
*
|
||||
* $ wp ai1wm reset
|
||||
*
|
||||
* @subcommand reset
|
||||
*/
|
||||
public function reset( $args = array(), $assoc_args = array() ) {
|
||||
$this->info();
|
||||
}
|
||||
|
||||
protected function info() {
|
||||
if ( is_multisite() ) {
|
||||
WP_CLI::error_multi_line(
|
||||
array(
|
||||
__( 'This feature is available in Multisite Extension.', 'all-in-one-wp-migration' ),
|
||||
__( 'You can purchase it from this address: https://servmask.com/products/multisite-extension', 'all-in-one-wp-migration' ),
|
||||
)
|
||||
);
|
||||
exit;
|
||||
}
|
||||
|
||||
WP_CLI::error_multi_line(
|
||||
array(
|
||||
__( 'This feature is available in Unlimited Extension.', 'all-in-one-wp-migration' ),
|
||||
__( 'You can purchase it from this address: https://servmask.com/products/unlimited-extension', 'all-in-one-wp-migration' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
142
plugins/all-in-one-wp-migration/lib/vendor/servmask/cron/class-ai1wm-cron.php
vendored
Normal file
142
plugins/all-in-one-wp-migration/lib/vendor/servmask/cron/class-ai1wm-cron.php
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Cron {
|
||||
|
||||
/**
|
||||
* Schedules a hook which will be executed by the WordPress
|
||||
* actions core on a specific interval
|
||||
*
|
||||
* @param string $hook Event hook
|
||||
* @param string $recurrence How often the event should reoccur
|
||||
* @param integer $timestamp Preferred timestamp (when the event shall be run)
|
||||
* @param array $args Arguments to pass to the hook function(s)
|
||||
* @return mixed
|
||||
*/
|
||||
public static function add( $hook, $recurrence, $timestamp, $args = array() ) {
|
||||
$schedules = wp_get_schedules();
|
||||
|
||||
// Schedule event
|
||||
if ( isset( $schedules[ $recurrence ] ) && ( $current = $schedules[ $recurrence ] ) ) {
|
||||
if ( $timestamp <= ( $current_timestamp = time() ) ) {
|
||||
while ( $timestamp <= $current_timestamp ) {
|
||||
$timestamp += $current['interval'];
|
||||
}
|
||||
}
|
||||
|
||||
return wp_schedule_event( $timestamp, $recurrence, $hook, $args );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Un-schedules all previously-scheduled cron jobs using a particular
|
||||
* hook name or a specific combination of hook name and arguments.
|
||||
*
|
||||
* @param string $hook Event hook
|
||||
* @return boolean
|
||||
*/
|
||||
public static function clear( $hook ) {
|
||||
$cron = get_option( AI1WM_CRON, array() );
|
||||
if ( empty( $cron ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ( $cron as $timestamp => $hooks ) {
|
||||
if ( isset( $hooks[ $hook ] ) ) {
|
||||
unset( $cron[ $timestamp ][ $hook ] );
|
||||
|
||||
// Unset empty timestamps
|
||||
if ( empty( $cron[ $timestamp ] ) ) {
|
||||
unset( $cron[ $timestamp ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return update_option( AI1WM_CRON, $cron );
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether cronjob already exists
|
||||
*
|
||||
* @param string $hook Event hook
|
||||
* @param array $args Event callback arguments
|
||||
* @return boolean
|
||||
*/
|
||||
public static function exists( $hook, $args = array() ) {
|
||||
$cron = get_option( AI1WM_CRON, array() );
|
||||
if ( empty( $cron ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ( $cron as $timestamp => $hooks ) {
|
||||
if ( empty( $args ) ) {
|
||||
if ( isset( $hooks[ $hook ] ) ) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if ( isset( $hooks[ $hook ][ md5( serialize( $args ) ) ] ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes cron event(s) if it exists
|
||||
*
|
||||
* @param string $hook Event hook
|
||||
* @param array $args Event callback arguments
|
||||
* @return boolean
|
||||
*/
|
||||
public static function delete( $hook, $args = array() ) {
|
||||
$cron = get_option( AI1WM_CRON, array() );
|
||||
if ( empty( $cron ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$key = md5( serialize( $args ) );
|
||||
foreach ( $cron as $timestamp => $hooks ) {
|
||||
if ( isset( $cron[ $timestamp ][ $hook ][ $key ] ) ) {
|
||||
unset( $cron[ $timestamp ][ $hook ][ $key ] );
|
||||
}
|
||||
if ( isset( $cron[ $timestamp ][ $hook ] ) && empty( $cron[ $timestamp ][ $hook ] ) ) {
|
||||
unset( $cron[ $timestamp ][ $hook ] );
|
||||
}
|
||||
if ( empty( $cron[ $timestamp ] ) ) {
|
||||
unset( $cron[ $timestamp ] );
|
||||
}
|
||||
}
|
||||
|
||||
return update_option( AI1WM_CRON, $cron );
|
||||
}
|
||||
}
|
||||
82
plugins/all-in-one-wp-migration/lib/vendor/servmask/database/class-ai1wm-database-mariadb.php
vendored
Normal file
82
plugins/all-in-one-wp-migration/lib/vendor/servmask/database/class-ai1wm-database-mariadb.php
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Database_Mariadb extends Ai1wm_Database_Mysqli {
|
||||
|
||||
/**
|
||||
* Replace column types
|
||||
*
|
||||
* @param string $input Column value
|
||||
* @return string
|
||||
*/
|
||||
protected function replace_column_types( $input ) {
|
||||
static $search = null;
|
||||
static $replace = null;
|
||||
|
||||
// Cache column types on first call
|
||||
if ( is_null( $search ) || is_null( $replace ) ) {
|
||||
$search = array();
|
||||
$replace = array();
|
||||
|
||||
// Convert INET4 column type (10.10.0)
|
||||
if ( version_compare( $this->server_version(), '10.10.0', '<' ) ) {
|
||||
$search[] = '/(?<!`)\bINET4\b(?!\s*\()/i';
|
||||
$replace[] = 'VARCHAR(15)';
|
||||
}
|
||||
|
||||
// Convert INET6 column type (10.5.0)
|
||||
if ( version_compare( $this->server_version(), '10.5.0', '<' ) ) {
|
||||
$search[] = '/(?<!`)\bINET6\b(?!\s*\()/i';
|
||||
$replace[] = 'VARCHAR(45)';
|
||||
}
|
||||
|
||||
// Convert UUID column type (10.7.0)
|
||||
if ( version_compare( $this->server_version(), '10.7.0', '<' ) ) {
|
||||
$search[] = '/(?<!`)\bUUID\b(?!\s*\()/i';
|
||||
$replace[] = 'CHAR(36)';
|
||||
}
|
||||
|
||||
// Convert XMLTYPE column type (12.3.0)
|
||||
if ( version_compare( $this->server_version(), '12.3.0', '<' ) ) {
|
||||
$search[] = '/(?<!`)\bXMLTYPE\b(?!\s*\()/i';
|
||||
$replace[] = 'LONGTEXT';
|
||||
}
|
||||
|
||||
// Convert VECTOR(N) column type (11.7.1)
|
||||
if ( version_compare( $this->server_version(), '11.7.1', '<' ) ) {
|
||||
$search[] = '/(?<!`)\bVECTOR\s*\(\s*\d+\s*\)/i';
|
||||
$replace[] = 'BLOB';
|
||||
}
|
||||
}
|
||||
|
||||
return preg_replace( $search, $replace, $input );
|
||||
}
|
||||
}
|
||||
159
plugins/all-in-one-wp-migration/lib/vendor/servmask/database/class-ai1wm-database-mysql.php
vendored
Normal file
159
plugins/all-in-one-wp-migration/lib/vendor/servmask/database/class-ai1wm-database-mysql.php
vendored
Normal file
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Database_Mysql extends Ai1wm_Database {
|
||||
|
||||
/**
|
||||
* Check whether table has auto increment attribute
|
||||
*
|
||||
* @param string $table_name Table name
|
||||
* @return boolean
|
||||
*/
|
||||
public function has_auto_increment( $table_name ) {
|
||||
return stripos( $this->get_create_table( $table_name ), 'AUTO_INCREMENT' ) !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run MySQL query
|
||||
*
|
||||
* @param string $input SQL query
|
||||
* @return mixed
|
||||
*/
|
||||
public function query( $input ) {
|
||||
if ( ! ( $result = mysql_query( $input, $this->wpdb->dbh ) ) ) {
|
||||
$mysql_errno = 0;
|
||||
|
||||
// Get MySQL error code
|
||||
if ( ! empty( $this->wpdb->dbh ) ) {
|
||||
if ( is_resource( $this->wpdb->dbh ) ) {
|
||||
$mysql_errno = mysql_errno( $this->wpdb->dbh );
|
||||
} else {
|
||||
$mysql_errno = 2006;
|
||||
}
|
||||
}
|
||||
|
||||
// MySQL server has gone away, try to reconnect
|
||||
if ( empty( $this->wpdb->dbh ) || 2006 === $mysql_errno ) {
|
||||
if ( ! $this->wpdb->check_connection( false ) ) {
|
||||
throw new Ai1wm_Database_Exception( __( 'Error reconnecting to the database. <a href="https://help.servmask.com/knowledgebase/mysql-error-reconnecting/" target="_blank">Technical details</a>', 'all-in-one-wp-migration' ), 503 );
|
||||
}
|
||||
|
||||
$result = mysql_query( $input, $this->wpdb->dbh );
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape string input for MySQL query
|
||||
*
|
||||
* @param string $input String to escape
|
||||
* @return string
|
||||
*/
|
||||
public function escape( $input ) {
|
||||
return mysql_real_escape_string( $input, $this->wpdb->dbh );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the error code for the most recent function call
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function errno() {
|
||||
return mysql_errno( $this->wpdb->dbh );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string description of the last error
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function error() {
|
||||
return mysql_error( $this->wpdb->dbh );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return server info
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function server_info() {
|
||||
static $cached_result = null;
|
||||
|
||||
// Cache server info on first call
|
||||
if ( $cached_result === null ) {
|
||||
$cached_result = mysql_get_server_info( $this->wpdb->dbh );
|
||||
}
|
||||
|
||||
return $cached_result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the result from MySQL query as associative array
|
||||
*
|
||||
* @param mixed $result MySQL resource
|
||||
* @return array
|
||||
*/
|
||||
public function fetch_assoc( &$result ) {
|
||||
return mysql_fetch_assoc( $result );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the result from MySQL query as row
|
||||
*
|
||||
* @param mixed $result MySQL resource
|
||||
* @return array
|
||||
*/
|
||||
public function fetch_row( &$result ) {
|
||||
return mysql_fetch_row( $result );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number for rows from MySQL results
|
||||
*
|
||||
* @param mixed $result MySQL resource
|
||||
* @return integer
|
||||
*/
|
||||
public function num_rows( &$result ) {
|
||||
return mysql_num_rows( $result );
|
||||
}
|
||||
|
||||
/**
|
||||
* Free MySQL result memory
|
||||
*
|
||||
* @param mixed $result MySQL resource
|
||||
* @return boolean
|
||||
*/
|
||||
public function free_result( &$result ) {
|
||||
return mysql_free_result( $result );
|
||||
}
|
||||
}
|
||||
181
plugins/all-in-one-wp-migration/lib/vendor/servmask/database/class-ai1wm-database-mysqli.php
vendored
Normal file
181
plugins/all-in-one-wp-migration/lib/vendor/servmask/database/class-ai1wm-database-mysqli.php
vendored
Normal file
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Database_Mysqli extends Ai1wm_Database {
|
||||
|
||||
/**
|
||||
* Check whether table has auto increment attribute
|
||||
*
|
||||
* @param string $table_name Table name
|
||||
* @return boolean
|
||||
*/
|
||||
public function has_auto_increment( $table_name ) {
|
||||
return stripos( $this->get_create_table( $table_name ), 'AUTO_INCREMENT' ) !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run MySQL query
|
||||
*
|
||||
* @param string $input SQL query
|
||||
* @return mixed
|
||||
*/
|
||||
public function query( $input ) {
|
||||
if ( ! mysqli_real_query( $this->wpdb->dbh, $input ) ) {
|
||||
$mysqli_errno = 0;
|
||||
|
||||
// Get MySQL error code
|
||||
if ( ! empty( $this->wpdb->dbh ) ) {
|
||||
if ( $this->wpdb->dbh instanceof mysqli ) {
|
||||
$mysqli_errno = mysqli_errno( $this->wpdb->dbh );
|
||||
} else {
|
||||
$mysqli_errno = 2006;
|
||||
}
|
||||
}
|
||||
|
||||
// MySQL server has gone away, try to reconnect
|
||||
if ( empty( $this->wpdb->dbh ) || 2006 === $mysqli_errno ) {
|
||||
if ( ! $this->wpdb->check_connection( false ) ) {
|
||||
throw new Ai1wm_Database_Exception( __( 'Error reconnecting to the database. <a href="https://help.servmask.com/knowledgebase/mysql-error-reconnecting/" target="_blank">Technical details</a>', 'all-in-one-wp-migration' ), 503 );
|
||||
}
|
||||
|
||||
mysqli_real_query( $this->wpdb->dbh, $input );
|
||||
}
|
||||
}
|
||||
|
||||
// The parameter $mode has had no effect as of PHP 8.1.0.
|
||||
if ( ( PHP_MAJOR_VERSION >= 8 && PHP_MINOR_VERSION >= 1 ) || ! defined( 'MYSQLI_STORE_RESULT_COPY_DATA' ) ) {
|
||||
return mysqli_store_result( $this->wpdb->dbh );
|
||||
}
|
||||
|
||||
// Copy results from the internal mysqlnd buffer into the PHP variables fetched
|
||||
return mysqli_store_result( $this->wpdb->dbh, MYSQLI_STORE_RESULT_COPY_DATA );
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape string input for MySQL query
|
||||
*
|
||||
* @param string $input String to escape
|
||||
* @return string
|
||||
*/
|
||||
public function escape( $input ) {
|
||||
return mysqli_real_escape_string( $this->wpdb->dbh, $input );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the error code for the most recent function call
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function errno() {
|
||||
return mysqli_errno( $this->wpdb->dbh );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string description of the last error
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function error() {
|
||||
return mysqli_error( $this->wpdb->dbh );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return server info
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function server_info() {
|
||||
static $cached_result = null;
|
||||
|
||||
// Cache server info on first call
|
||||
if ( $cached_result === null ) {
|
||||
$cached_result = mysqli_get_server_info( $this->wpdb->dbh );
|
||||
}
|
||||
|
||||
return $cached_result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the result from MySQL query as associative array
|
||||
*
|
||||
* @param mixed $result MySQL resource
|
||||
* @return array
|
||||
*/
|
||||
public function fetch_assoc( &$result ) {
|
||||
if ( $result === false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return mysqli_fetch_assoc( $result );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the result from MySQL query as row
|
||||
*
|
||||
* @param mixed $result MySQL resource
|
||||
* @return array
|
||||
*/
|
||||
public function fetch_row( &$result ) {
|
||||
if ( $result === false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return mysqli_fetch_row( $result );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number for rows from MySQL results
|
||||
*
|
||||
* @param mixed $result MySQL resource
|
||||
* @return integer
|
||||
*/
|
||||
public function num_rows( &$result ) {
|
||||
if ( $result === false ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return mysqli_num_rows( $result );
|
||||
}
|
||||
|
||||
/**
|
||||
* Free MySQL result memory
|
||||
*
|
||||
* @param mixed $result MySQL resource
|
||||
* @return boolean
|
||||
*/
|
||||
public function free_result( &$result ) {
|
||||
if ( $result === false ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return mysqli_free_result( $result );
|
||||
}
|
||||
}
|
||||
377
plugins/all-in-one-wp-migration/lib/vendor/servmask/database/class-ai1wm-database-sqlite.php
vendored
Normal file
377
plugins/all-in-one-wp-migration/lib/vendor/servmask/database/class-ai1wm-database-sqlite.php
vendored
Normal file
@@ -0,0 +1,377 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Database_Sqlite extends Ai1wm_Database {
|
||||
|
||||
/**
|
||||
* Check whether table has auto increment attribute
|
||||
*
|
||||
* @param string $table_name Table name
|
||||
* @return boolean
|
||||
*/
|
||||
public function has_auto_increment( $table_name ) {
|
||||
return stripos( $this->get_create_table( $table_name ), 'AUTOINCREMENT' ) !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get views
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_views() {
|
||||
if ( is_null( $this->views ) ) {
|
||||
$where_query = array();
|
||||
|
||||
// Loop over table prefixes
|
||||
if ( $this->get_table_prefix_filters() ) {
|
||||
foreach ( $this->get_table_prefix_filters() as $prefix_filter ) {
|
||||
if ( isset( $prefix_filter[0], $prefix_filter[1] ) ) {
|
||||
$where_query[] = sprintf( "(`name` REGEXP '^%s' AND `name` NOT REGEXP '^%s')", $prefix_filter[0], $prefix_filter[1] );
|
||||
} else {
|
||||
$where_query[] = sprintf( "`name` REGEXP '^%s'", $prefix_filter[0] );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$where_query[] = 1;
|
||||
}
|
||||
|
||||
$this->views = array();
|
||||
|
||||
// Loop over views
|
||||
$result = $this->query( sprintf( "SELECT `name` FROM `sqlite_master` WHERE `type`='view' AND (%s)", implode( ' OR ', $where_query ) ) );
|
||||
while ( $row = $this->fetch_row( $result ) ) {
|
||||
if ( isset( $row[0] ) ) {
|
||||
$this->views[] = $row[0];
|
||||
}
|
||||
}
|
||||
|
||||
$this->free_result( $result );
|
||||
}
|
||||
|
||||
return $this->views;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get base tables
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_base_tables() {
|
||||
if ( is_null( $this->base_tables ) ) {
|
||||
$where_query = array();
|
||||
|
||||
// Loop over table prefixes
|
||||
if ( $this->get_table_prefix_filters() ) {
|
||||
foreach ( $this->get_table_prefix_filters() as $prefix_filter ) {
|
||||
if ( isset( $prefix_filter[0], $prefix_filter[1] ) ) {
|
||||
$where_query[] = sprintf( "(`name` REGEXP '^%s' AND `name` NOT REGEXP '^%s')", $prefix_filter[0], $prefix_filter[1] );
|
||||
} else {
|
||||
$where_query[] = sprintf( "`name` REGEXP '^%s'", $prefix_filter[0] );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$where_query[] = 1;
|
||||
}
|
||||
|
||||
$this->base_tables = array();
|
||||
|
||||
// Loop over base tables
|
||||
$result = $this->query( sprintf( "SELECT `name` FROM `sqlite_master` WHERE `type`='table' AND (%s)", implode( ' OR ', $where_query ) ) );
|
||||
while ( $row = $this->fetch_row( $result ) ) {
|
||||
if ( isset( $row[0] ) ) {
|
||||
$this->base_tables[] = $row[0];
|
||||
}
|
||||
}
|
||||
|
||||
$this->free_result( $result );
|
||||
}
|
||||
|
||||
return $this->base_tables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run SQLite query
|
||||
*
|
||||
* @param string $input SQL query
|
||||
* @return mixed
|
||||
*/
|
||||
public function query( $input ) {
|
||||
return $this->wpdb->get_results( $input, ARRAY_A );
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape string input for SQLite query
|
||||
*
|
||||
* @param string $input String to escape
|
||||
* @return string
|
||||
*/
|
||||
public function escape( $input ) {
|
||||
return $this->wpdb->_real_escape( $input );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the error code for the most recent function call
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function errno() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string description of the last error
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function error() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return server info
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function server_info() {
|
||||
return $this->wpdb->db_server_info();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return result as associative array
|
||||
*
|
||||
* @param mixed $result SQLite resource
|
||||
* @return array
|
||||
*/
|
||||
public function fetch_assoc( &$result ) {
|
||||
if ( key( $result ) === null ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$current = current( $result );
|
||||
next( $result );
|
||||
|
||||
return $current;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the result from SQLite query as row
|
||||
*
|
||||
* @param mixed $result SQLite resource
|
||||
* @return array
|
||||
*/
|
||||
public function fetch_row( &$result ) {
|
||||
$current = $this->fetch_assoc( $result );
|
||||
if ( $current === false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return array_values( $current );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number for rows from SQLite results
|
||||
*
|
||||
* @param mixed $result SQLite resource
|
||||
* @return integer
|
||||
*/
|
||||
public function num_rows( &$result ) {
|
||||
return count( $result );
|
||||
}
|
||||
|
||||
/**
|
||||
* Stub for free SQLite result memory
|
||||
*
|
||||
* @param mixed $result SQLite resource
|
||||
* @return void
|
||||
*/
|
||||
public function free_result( &$result ) {
|
||||
unset( $result );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get SQLite create view
|
||||
*
|
||||
* @param string $table_name View name
|
||||
* @return string
|
||||
*/
|
||||
protected function get_create_view( $table_name ) {
|
||||
$result = $this->query( "SELECT `sql` FROM `sqlite_master` WHERE `name` = '{$table_name}'" );
|
||||
$row = $this->fetch_assoc( $result );
|
||||
|
||||
// Close result cursor
|
||||
$this->free_result( $result );
|
||||
|
||||
// Get create table
|
||||
if ( isset( $row['sql'] ) ) {
|
||||
return $row['sql'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get SQLite create table
|
||||
*
|
||||
* @param string $table_name Table name
|
||||
* @return string
|
||||
*/
|
||||
protected function get_create_table( $table_name ) {
|
||||
$result = $this->query( "SELECT `sql` FROM `sqlite_master` WHERE `name` = '{$table_name}'" );
|
||||
$row = $this->fetch_assoc( $result );
|
||||
|
||||
// Close result cursor
|
||||
$this->free_result( $result );
|
||||
|
||||
// Get create table
|
||||
if ( isset( $row['sql'] ) ) {
|
||||
return $row['sql'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace table defaults
|
||||
*
|
||||
* @param string $input SQL statement
|
||||
* @return string
|
||||
*/
|
||||
protected function replace_table_defaults( $input ) {
|
||||
$pattern = array(
|
||||
'/DEFAULT(\s+)(\d+)/i',
|
||||
"/DEFAULT(\s+)'(.*?)'/i",
|
||||
);
|
||||
|
||||
return preg_replace( $pattern, '', $input );
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace view quotes
|
||||
*
|
||||
* @param string $input View value
|
||||
* @return string
|
||||
*/
|
||||
protected function replace_view_quotes( $input ) {
|
||||
return str_replace( '"', '`', $input );
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace table quotes
|
||||
*
|
||||
* @param string $input Table value
|
||||
* @return string
|
||||
*/
|
||||
protected function replace_table_quotes( $input ) {
|
||||
return str_replace( '"', '`', $input );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get SQLite primary keys
|
||||
*
|
||||
* @param string $table_name Table name
|
||||
* @return array
|
||||
*/
|
||||
protected function get_primary_keys( $table_name ) {
|
||||
$primary_keys = array();
|
||||
|
||||
// Get primary keys
|
||||
$result = $this->query( "SELECT `table_info`.`name` FROM PRAGMA_TABLE_INFO('{$table_name}') AS table_info WHERE `table_info`.`pk` != 0" );
|
||||
while ( $row = $this->fetch_assoc( $result ) ) {
|
||||
if ( isset( $row['name'] ) ) {
|
||||
$primary_keys[] = $row['name'];
|
||||
}
|
||||
}
|
||||
|
||||
// Close result cursor
|
||||
$this->free_result( $result );
|
||||
|
||||
return $primary_keys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get SQLite column types
|
||||
*
|
||||
* @param string $table_name Table name
|
||||
* @return array
|
||||
*/
|
||||
protected function get_column_types( $table_name ) {
|
||||
$column_types = array();
|
||||
|
||||
// Get column types
|
||||
$result = $this->query( "SELECT `name`, `type` FROM PRAGMA_TABLE_INFO('{$table_name}')" );
|
||||
while ( $row = $this->fetch_assoc( $result ) ) {
|
||||
if ( isset( $row['name'] ) ) {
|
||||
$column_types[ strtolower( $row['name'] ) ] = $row['type'];
|
||||
}
|
||||
}
|
||||
|
||||
// Close result cursor
|
||||
$this->free_result( $result );
|
||||
|
||||
return $column_types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get SQLite column names
|
||||
*
|
||||
* @param string $table_name Table name
|
||||
* @return array
|
||||
*/
|
||||
public function get_column_names( $table_name ) {
|
||||
$column_names = array();
|
||||
|
||||
// Get column names
|
||||
$result = $this->query( "SELECT `name` FROM PRAGMA_TABLE_INFO('{$table_name}')" );
|
||||
while ( $row = $this->fetch_assoc( $result ) ) {
|
||||
if ( isset( $row['name'] ) ) {
|
||||
$column_names[ strtolower( $row['name'] ) ] = $row['name'];
|
||||
}
|
||||
}
|
||||
|
||||
// Close result cursor
|
||||
$this->free_result( $result );
|
||||
|
||||
return $column_names;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get SQLite max allowed packet
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
protected function get_max_allowed_packet() {
|
||||
return PHP_INT_MAX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use SQLite transactions
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
protected function use_transactions() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
457
plugins/all-in-one-wp-migration/lib/vendor/servmask/database/class-ai1wm-database-utility.php
vendored
Normal file
457
plugins/all-in-one-wp-migration/lib/vendor/servmask/database/class-ai1wm-database-utility.php
vendored
Normal file
@@ -0,0 +1,457 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Database_Utility {
|
||||
|
||||
protected static $db_client = null;
|
||||
|
||||
/**
|
||||
* Set the database client instance for injection
|
||||
*
|
||||
* @param Ai1wm_Database $db_client Database client instance.
|
||||
* @return void
|
||||
*/
|
||||
public static function set_client( $db_client ) {
|
||||
self::$db_client = $db_client;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the database client instance, creating it if not set
|
||||
*
|
||||
* @return Ai1wm_Database
|
||||
*/
|
||||
public static function get_client() {
|
||||
if ( self::$db_client === null ) {
|
||||
return self::create_client();
|
||||
}
|
||||
|
||||
return self::$db_client;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create DB client to be used for DB manipulation
|
||||
*
|
||||
* @return Ai1wm_Database
|
||||
*/
|
||||
private static function create_client() {
|
||||
global $wpdb;
|
||||
|
||||
// SQLite
|
||||
if ( $wpdb instanceof WP_SQLite_DB || $wpdb instanceof WP_SQLite_DB\wpsqlitedb ) {
|
||||
return new Ai1wm_Database_Sqlite( $wpdb );
|
||||
}
|
||||
|
||||
// MariaDB
|
||||
if ( ( $server_version = $wpdb->get_var( 'SELECT VERSION()' ) ) ) {
|
||||
if ( stripos( $server_version, 'MariaDB' ) !== false ) {
|
||||
return new Ai1wm_Database_Mariadb( $wpdb );
|
||||
}
|
||||
}
|
||||
|
||||
// MySQLi
|
||||
if ( PHP_MAJOR_VERSION >= 7 ) {
|
||||
return new Ai1wm_Database_Mysqli( $wpdb );
|
||||
}
|
||||
|
||||
// MySQL
|
||||
if ( empty( $wpdb->use_mysqli ) ) {
|
||||
return new Ai1wm_Database_Mysql( $wpdb );
|
||||
}
|
||||
|
||||
return new Ai1wm_Database_Mysqli( $wpdb );
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace all occurrences of the search string with the replacement string.
|
||||
* This function is case-sensitive.
|
||||
*
|
||||
* @param string $data Data to replace
|
||||
* @param array $search List of string we're looking to replace
|
||||
* @param array $replace What we want it to be replaced with
|
||||
* @return string The original string with all elements replaced as needed
|
||||
*/
|
||||
public static function replace_values( $data, $search = array(), $replace = array() ) {
|
||||
return strtr( $data, array_combine( $search, $replace ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace serialized occurrences of the search string with the replacement string.
|
||||
* This function is case-sensitive.
|
||||
*
|
||||
* @param string $data Data to replace
|
||||
* @param array $search List of string we're looking to replace
|
||||
* @param array $replace What we want it to be replaced with
|
||||
* @return string The original array with all elements replaced as needed
|
||||
*/
|
||||
public static function replace_serialized_values( $data, $search = array(), $replace = array() ) {
|
||||
$pos = 0;
|
||||
|
||||
$result = self::parse_serialized_values( $data, $pos, $search, $replace );
|
||||
if ( $pos !== strlen( $data ) ) {
|
||||
// Failed to parse entire data
|
||||
return strtr( $data, array_combine( $search, $replace ) );
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse serialized string and replace needed substitutions.
|
||||
* This function is case-sensitive.
|
||||
*
|
||||
* @param string $data Serialized data
|
||||
* @param integer $pos Character position
|
||||
* @param array $search List of string we're looking to replace
|
||||
* @param array $replace What we want it to be replaced with
|
||||
* @return string The original string with all elements replaced as needed
|
||||
*/
|
||||
public static function parse_serialized_values( $data, &$pos, $search = array(), $replace = array() ) {
|
||||
$length = strlen( $data );
|
||||
if ( $pos >= $length ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$type = $data[ $pos ];
|
||||
$pos++;
|
||||
|
||||
switch ( $type ) {
|
||||
case 's':
|
||||
if ( ! isset( $data[ $pos ] ) || $data[ $pos ] !== ':' ) {
|
||||
$pos--;
|
||||
return '';
|
||||
}
|
||||
|
||||
$pos++;
|
||||
$len_end = strpos( $data, ':', $pos );
|
||||
if ( $len_end === false ) {
|
||||
$pos--;
|
||||
return '';
|
||||
}
|
||||
|
||||
$str_length = (int) substr( $data, $pos, $len_end - $pos );
|
||||
|
||||
$pos = $len_end + 1;
|
||||
if ( ! isset( $data[ $pos ] ) || $data[ $pos ] !== '"' ) {
|
||||
$pos--;
|
||||
return '';
|
||||
}
|
||||
|
||||
$pos++;
|
||||
$str = substr( $data, $pos, $str_length );
|
||||
|
||||
$pos += $str_length;
|
||||
if ( ! isset( $data[ $pos ] ) || $data[ $pos ] !== '"' ) {
|
||||
$pos--;
|
||||
return '';
|
||||
}
|
||||
|
||||
$pos++;
|
||||
if ( ! isset( $data[ $pos ] ) || $data[ $pos ] !== ';' ) {
|
||||
$pos--;
|
||||
return '';
|
||||
}
|
||||
|
||||
$pos++;
|
||||
|
||||
// If the string is a single letter, skip any parsing or replacement.
|
||||
if ( $str_length === 1 ) {
|
||||
return 's:' . $str_length . ':"' . $str . '";';
|
||||
}
|
||||
|
||||
// Attempt to parse the string as serialized data
|
||||
$pos_inner = 0;
|
||||
$parsed_str = self::parse_serialized_values( $str, $pos_inner, $search, $replace );
|
||||
if ( $pos_inner === strlen( $str ) ) {
|
||||
// The string is serialized data, use the parsed string
|
||||
$new_str = $parsed_str;
|
||||
} else {
|
||||
// Regular string, perform replacement
|
||||
$new_str = strtr( $str, array_combine( $search, $replace ) );
|
||||
}
|
||||
|
||||
return 's:' . strlen( $new_str ) . ':"' . $new_str . '";';
|
||||
|
||||
case 'i':
|
||||
case 'd':
|
||||
case 'b':
|
||||
if ( ! isset( $data[ $pos ] ) || $data[ $pos ] !== ':' ) {
|
||||
$pos--;
|
||||
return '';
|
||||
}
|
||||
|
||||
$pos++;
|
||||
$end = strpos( $data, ';', $pos );
|
||||
if ( $end === false ) {
|
||||
$pos--;
|
||||
return '';
|
||||
}
|
||||
|
||||
$value = substr( $data, $pos, $end - $pos );
|
||||
$pos = $end + 1;
|
||||
|
||||
return $type . ':' . $value . ';';
|
||||
|
||||
case 'N':
|
||||
if ( ! isset( $data[ $pos ] ) || $data[ $pos ] !== ';' ) {
|
||||
$pos--;
|
||||
return '';
|
||||
}
|
||||
|
||||
$pos++;
|
||||
|
||||
return 'N;';
|
||||
|
||||
case 'a':
|
||||
if ( ! isset( $data[ $pos ] ) || $data[ $pos ] !== ':' ) {
|
||||
$pos--;
|
||||
return '';
|
||||
}
|
||||
|
||||
$pos++;
|
||||
$len_end = strpos( $data, ':', $pos );
|
||||
if ( $len_end === false ) {
|
||||
$pos--;
|
||||
return '';
|
||||
}
|
||||
|
||||
$array_length = (int) substr( $data, $pos, $len_end - $pos );
|
||||
|
||||
$pos = $len_end + 1;
|
||||
if ( ! isset( $data[ $pos ] ) || $data[ $pos ] !== '{' ) {
|
||||
$pos--;
|
||||
return '';
|
||||
}
|
||||
|
||||
$pos++;
|
||||
$result = 'a:' . $array_length . ':{';
|
||||
for ( $i = 0; $i < $array_length * 2; $i++ ) {
|
||||
$element = self::parse_serialized_values( $data, $pos, $search, $replace );
|
||||
if ( $element === '' ) {
|
||||
$pos--;
|
||||
return '';
|
||||
}
|
||||
|
||||
$result .= $element;
|
||||
}
|
||||
|
||||
if ( ! isset( $data[ $pos ] ) || $data[ $pos ] !== '}' ) {
|
||||
$pos--;
|
||||
return '';
|
||||
}
|
||||
|
||||
$pos++;
|
||||
$result .= '}';
|
||||
|
||||
return $result;
|
||||
|
||||
case 'O':
|
||||
if ( ! isset( $data[ $pos ] ) || $data[ $pos ] !== ':' ) {
|
||||
$pos--;
|
||||
return '';
|
||||
}
|
||||
|
||||
$pos++;
|
||||
$class_len_end = strpos( $data, ':', $pos );
|
||||
if ( $class_len_end === false ) {
|
||||
$pos--;
|
||||
return '';
|
||||
}
|
||||
|
||||
$class_length = (int) substr( $data, $pos, $class_len_end - $pos );
|
||||
|
||||
$pos = $class_len_end + 1;
|
||||
if ( ! isset( $data[ $pos ] ) || $data[ $pos ] !== '"' ) {
|
||||
$pos--;
|
||||
return '';
|
||||
}
|
||||
|
||||
$pos++;
|
||||
$class_name = substr( $data, $pos, $class_length );
|
||||
|
||||
$pos += $class_length;
|
||||
if ( ! isset( $data[ $pos ] ) || $data[ $pos ] !== '"' ) {
|
||||
$pos--;
|
||||
return '';
|
||||
}
|
||||
|
||||
$pos++;
|
||||
if ( ! isset( $data[ $pos ] ) || $data[ $pos ] !== ':' ) {
|
||||
$pos--;
|
||||
return '';
|
||||
}
|
||||
|
||||
$pos++;
|
||||
$prop_len_end = strpos( $data, ':', $pos );
|
||||
if ( $prop_len_end === false ) {
|
||||
$pos--;
|
||||
return '';
|
||||
}
|
||||
|
||||
$prop_count = (int) substr( $data, $pos, $prop_len_end - $pos );
|
||||
|
||||
$pos = $prop_len_end + 1;
|
||||
if ( ! isset( $data[ $pos ] ) || $data[ $pos ] !== '{' ) {
|
||||
$pos--;
|
||||
return '';
|
||||
}
|
||||
|
||||
$pos++;
|
||||
$result = 'O:' . strlen( $class_name ) . ':"' . $class_name . '":' . $prop_count . ':{';
|
||||
for ( $i = 0; $i < $prop_count * 2; $i++ ) {
|
||||
$element = self::parse_serialized_values( $data, $pos, $search, $replace );
|
||||
if ( $element === '' ) {
|
||||
$pos--;
|
||||
return '';
|
||||
}
|
||||
|
||||
$result .= $element;
|
||||
}
|
||||
|
||||
if ( ! isset( $data[ $pos ] ) || $data[ $pos ] !== '}' ) {
|
||||
$pos--;
|
||||
return '';
|
||||
}
|
||||
|
||||
$pos++;
|
||||
$result .= '}';
|
||||
|
||||
return $result;
|
||||
|
||||
case 'R':
|
||||
case 'r':
|
||||
if ( ! isset( $data[ $pos ] ) || $data[ $pos ] !== ':' ) {
|
||||
$pos--;
|
||||
return '';
|
||||
}
|
||||
|
||||
$pos++;
|
||||
$end = strpos( $data, ';', $pos );
|
||||
if ( $end === false ) {
|
||||
$pos--;
|
||||
return '';
|
||||
}
|
||||
|
||||
$ref = substr( $data, $pos, $end - $pos );
|
||||
$pos = $end + 1;
|
||||
|
||||
return $type . ':' . $ref . ';';
|
||||
|
||||
default:
|
||||
$pos--;
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse MySQL server version
|
||||
*
|
||||
* @param string $info Server info
|
||||
* @return string
|
||||
*/
|
||||
public static function parse_server_version( $info ) {
|
||||
$matches = array();
|
||||
if ( preg_match( '/(\d+\.\d+\.\d+)-(\d+\.\d+\.\d+)/i', $info, $matches ) ) {
|
||||
if ( isset( $matches[2] ) ) {
|
||||
return $matches[2];
|
||||
}
|
||||
}
|
||||
|
||||
if ( preg_match( '/(\d+\.\d+\.\d+)/i', $info, $matches ) ) {
|
||||
if ( isset( $matches[1] ) ) {
|
||||
return $matches[1];
|
||||
}
|
||||
}
|
||||
|
||||
return '0.0.0';
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape MySQL special characters
|
||||
*
|
||||
* @param string $data Data to escape
|
||||
* @return string
|
||||
*/
|
||||
public static function escape_mysql( $data ) {
|
||||
return strtr(
|
||||
$data,
|
||||
array_combine(
|
||||
array( "\x00", "\n", "\r", '\\', "'", '"', "\x1a" ),
|
||||
array( '\\0', '\\n', '\\r', '\\\\', "\\'", '\\"', '\\Z' )
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unescape MySQL special characters
|
||||
*
|
||||
* @param string $data Data to unescape
|
||||
* @return string
|
||||
*/
|
||||
public static function unescape_mysql( $data ) {
|
||||
return strtr(
|
||||
$data,
|
||||
array_combine(
|
||||
array( '\\0', '\\n', '\\r', '\\\\', "\\'", '\\"', '\\Z' ),
|
||||
array( "\x00", "\n", "\r", '\\', "'", '"', "\x1a" )
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode base64 characters
|
||||
*
|
||||
* @param string $data Data to encode
|
||||
* @return string
|
||||
*/
|
||||
public static function base64_encode( $data ) {
|
||||
return base64_encode( $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode base64 characters
|
||||
*
|
||||
* @param string $data Data to decode
|
||||
* @return string
|
||||
*/
|
||||
public static function base64_decode( $data ) {
|
||||
return base64_decode( $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate base64 data
|
||||
*
|
||||
* @param string $data Data to validate
|
||||
* @return boolean
|
||||
*/
|
||||
public static function base64_validate( $data ) {
|
||||
return base64_encode( base64_decode( $data ) ) === $data;
|
||||
}
|
||||
}
|
||||
2281
plugins/all-in-one-wp-migration/lib/vendor/servmask/database/class-ai1wm-database.php
vendored
Normal file
2281
plugins/all-in-one-wp-migration/lib/vendor/servmask/database/class-ai1wm-database.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
79
plugins/all-in-one-wp-migration/lib/vendor/servmask/filesystem/class-ai1wm-directory.php
vendored
Normal file
79
plugins/all-in-one-wp-migration/lib/vendor/servmask/filesystem/class-ai1wm-directory.php
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Directory {
|
||||
|
||||
/**
|
||||
* Create directory (recursively)
|
||||
*
|
||||
* @param string $path Path to the directory
|
||||
* @return boolean
|
||||
*/
|
||||
public static function create( $path ) {
|
||||
if ( @is_dir( $path ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return @mkdir( $path, 0777, true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete directory (recursively)
|
||||
*
|
||||
* @param string $path Path to the directory
|
||||
* @return boolean
|
||||
*/
|
||||
public static function delete( $path ) {
|
||||
if ( @is_dir( $path ) ) {
|
||||
try {
|
||||
// Iterate over directory
|
||||
$iterator = new Ai1wm_Recursive_Directory_Iterator( $path );
|
||||
|
||||
// Recursively iterate over directory
|
||||
$iterator = new Ai1wm_Recursive_Iterator_Iterator( $iterator, RecursiveIteratorIterator::CHILD_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD );
|
||||
|
||||
// Remove files and directories
|
||||
foreach ( $iterator as $item ) {
|
||||
if ( $item->isDir() ) {
|
||||
@rmdir( $item->getPathname() );
|
||||
} else {
|
||||
@unlink( $item->getPathname() );
|
||||
}
|
||||
}
|
||||
} catch ( Exception $e ) {
|
||||
}
|
||||
|
||||
return @rmdir( $path );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
119
plugins/all-in-one-wp-migration/lib/vendor/servmask/filesystem/class-ai1wm-file-htaccess.php
vendored
Normal file
119
plugins/all-in-one-wp-migration/lib/vendor/servmask/filesystem/class-ai1wm-file-htaccess.php
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_File_Htaccess {
|
||||
|
||||
/**
|
||||
* Create backups .htaccess file
|
||||
*
|
||||
* @param string $path Path to file
|
||||
* @return boolean
|
||||
*/
|
||||
public static function backups( $path ) {
|
||||
return Ai1wm_File::create(
|
||||
$path,
|
||||
implode(
|
||||
PHP_EOL,
|
||||
array(
|
||||
'<IfModule mod_mime.c>',
|
||||
' AddType application/octet-stream .wpress',
|
||||
'</IfModule>',
|
||||
'<IfModule mod_dir.c>',
|
||||
' DirectoryIndex index.php',
|
||||
'</IfModule>',
|
||||
'<IfModule mod_autoindex.c>',
|
||||
' Options -Indexes',
|
||||
'</IfModule>',
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create storage .htaccess file
|
||||
*
|
||||
* @param string $path Path to file
|
||||
* @return boolean
|
||||
*/
|
||||
public static function storage( $path ) {
|
||||
return Ai1wm_File::create(
|
||||
$path,
|
||||
implode(
|
||||
PHP_EOL,
|
||||
array(
|
||||
'<IfModule mod_authz_core.c>',
|
||||
' <FilesMatch ".*">',
|
||||
' Require all denied',
|
||||
' </FilesMatch>',
|
||||
' <FilesMatch "\.log$">',
|
||||
' Require all granted',
|
||||
' </FilesMatch>',
|
||||
'</IfModule>',
|
||||
'<IfModule !mod_authz_core.c>',
|
||||
' Order allow,deny',
|
||||
' Deny from all',
|
||||
' <FilesMatch "\.log$">',
|
||||
' Order allow,deny',
|
||||
' Allow from all',
|
||||
' </FilesMatch>',
|
||||
'</IfModule>',
|
||||
'<IfModule mod_mime.c>',
|
||||
' AddType text/plain .log',
|
||||
'</IfModule>',
|
||||
'<IfModule mod_dir.c>',
|
||||
' DirectoryIndex index.php',
|
||||
'</IfModule>',
|
||||
'<IfModule mod_autoindex.c>',
|
||||
' Options -Indexes',
|
||||
'</IfModule>',
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create LiteSpeed .htaccess file
|
||||
*
|
||||
* @param string $path Path to file
|
||||
* @return boolean
|
||||
*/
|
||||
public static function litespeed( $path ) {
|
||||
return Ai1wm_File::insert_with_markers(
|
||||
$path,
|
||||
'LiteSpeed',
|
||||
array(
|
||||
'<IfModule Litespeed>',
|
||||
' SetEnv noabort 1',
|
||||
'</IfModule>',
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
43
plugins/all-in-one-wp-migration/lib/vendor/servmask/filesystem/class-ai1wm-file-index.php
vendored
Normal file
43
plugins/all-in-one-wp-migration/lib/vendor/servmask/filesystem/class-ai1wm-file-index.php
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_File_Index {
|
||||
|
||||
/**
|
||||
* Create index file
|
||||
*
|
||||
* @param string $path Path to file
|
||||
* @return boolean
|
||||
*/
|
||||
public static function create( $path ) {
|
||||
return Ai1wm_File::create( $path, 'Kangaroos cannot jump here' );
|
||||
}
|
||||
}
|
||||
53
plugins/all-in-one-wp-migration/lib/vendor/servmask/filesystem/class-ai1wm-file-robots.php
vendored
Normal file
53
plugins/all-in-one-wp-migration/lib/vendor/servmask/filesystem/class-ai1wm-file-robots.php
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_File_Robots {
|
||||
|
||||
/**
|
||||
* Create robots.txt file
|
||||
*
|
||||
* @param string $path Path to file
|
||||
* @return boolean
|
||||
*/
|
||||
public static function create( $path ) {
|
||||
return Ai1wm_File::create(
|
||||
$path,
|
||||
implode(
|
||||
PHP_EOL,
|
||||
array(
|
||||
'User-agent: *',
|
||||
'Disallow: /ai1wm-backups/',
|
||||
'Disallow: /wp-content/ai1wm-backups/',
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
105
plugins/all-in-one-wp-migration/lib/vendor/servmask/filesystem/class-ai1wm-file-webconfig.php
vendored
Normal file
105
plugins/all-in-one-wp-migration/lib/vendor/servmask/filesystem/class-ai1wm-file-webconfig.php
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_File_Webconfig {
|
||||
|
||||
/**
|
||||
* Create backups web.config file
|
||||
*
|
||||
* @param string $path Path to file
|
||||
* @return boolean
|
||||
*/
|
||||
public static function backups( $path ) {
|
||||
return Ai1wm_File::create(
|
||||
$path,
|
||||
implode(
|
||||
PHP_EOL,
|
||||
array(
|
||||
'<?xml version="1.0" encoding="utf-8"?>',
|
||||
'<configuration>',
|
||||
' <system.webServer>',
|
||||
' <staticContent>',
|
||||
' <mimeMap fileExtension=".wpress" mimeType="application/octet-stream" />',
|
||||
' </staticContent>',
|
||||
' <defaultDocument>',
|
||||
' <files>',
|
||||
' <add value="index.php" />',
|
||||
' </files>',
|
||||
' </defaultDocument>',
|
||||
' <directoryBrowse enabled="false" />',
|
||||
' </system.webServer>',
|
||||
'</configuration>',
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create storage web.config file
|
||||
*
|
||||
* @param string $path Path to file
|
||||
* @return boolean
|
||||
*/
|
||||
public static function storage( $path ) {
|
||||
return Ai1wm_File::create(
|
||||
$path,
|
||||
implode(
|
||||
PHP_EOL,
|
||||
array(
|
||||
'<?xml version="1.0" encoding="utf-8"?>',
|
||||
'<configuration>',
|
||||
' <system.webServer>',
|
||||
' <security>',
|
||||
' <authorization>',
|
||||
' <deny users="*" />',
|
||||
' </authorization>',
|
||||
' </security>',
|
||||
' <requestFiltering>',
|
||||
' <fileExtensions allowUnlisted="false">',
|
||||
' <add fileExtension=".log" allowed="true" />',
|
||||
' </fileExtensions>',
|
||||
' </requestFiltering>',
|
||||
' <staticContent>',
|
||||
' <mimeMap fileExtension=".log" mimeType="text/plain" />',
|
||||
' </staticContent>',
|
||||
' <defaultDocument>',
|
||||
' <files>',
|
||||
' <add value="index.php" />',
|
||||
' </files>',
|
||||
' </defaultDocument>',
|
||||
' <directoryBrowse enabled="false" />',
|
||||
' </system.webServer>',
|
||||
'</configuration>',
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
98
plugins/all-in-one-wp-migration/lib/vendor/servmask/filesystem/class-ai1wm-file.php
vendored
Normal file
98
plugins/all-in-one-wp-migration/lib/vendor/servmask/filesystem/class-ai1wm-file.php
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_File {
|
||||
|
||||
/**
|
||||
* Create a file with content
|
||||
*
|
||||
* @param string $path Path to the file
|
||||
* @param string $content Content of the file
|
||||
* @return boolean
|
||||
*/
|
||||
public static function create( $path, $content ) {
|
||||
if ( ! @file_exists( $path ) ) {
|
||||
if ( ! @is_writable( dirname( $path ) ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! @touch( $path ) ) {
|
||||
return false;
|
||||
}
|
||||
} elseif ( ! @is_writable( $path ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// No changes were added
|
||||
if ( function_exists( 'md5_file' ) ) {
|
||||
if ( @md5_file( $path ) === md5( $content ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
$is_written = false;
|
||||
if ( ( $handle = @fopen( $path, 'w' ) ) !== false ) {
|
||||
if ( @fwrite( $handle, $content ) !== false ) {
|
||||
$is_written = true;
|
||||
}
|
||||
|
||||
@fclose( $handle );
|
||||
}
|
||||
|
||||
return $is_written;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a file with marker and content
|
||||
*
|
||||
* @param string $path Path to the file
|
||||
* @param string $marker Name of the marker
|
||||
* @param string $content Content of the file
|
||||
* @return boolean
|
||||
*/
|
||||
public static function insert_with_markers( $path, $marker, $content ) {
|
||||
return @insert_with_markers( $path, $marker, $content );
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a file by path
|
||||
*
|
||||
* @param string $path Path to the file
|
||||
* @return boolean
|
||||
*/
|
||||
public static function delete( $path ) {
|
||||
if ( ! @file_exists( $path ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return @unlink( $path );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Recursive_Exclude_Filter extends RecursiveFilterIterator {
|
||||
|
||||
protected $exclude = array();
|
||||
|
||||
public function __construct( RecursiveIterator $iterator, $exclude = array() ) {
|
||||
parent::__construct( $iterator );
|
||||
if ( is_array( $exclude ) ) {
|
||||
foreach ( $exclude as $path ) {
|
||||
$this->exclude[] = ai1wm_replace_forward_slash_with_directory_separator( $path );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function accept() {
|
||||
if ( in_array( ai1wm_replace_forward_slash_with_directory_separator( $this->getInnerIterator()->getSubPathname() ), $this->exclude ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( in_array( ai1wm_replace_forward_slash_with_directory_separator( $this->getInnerIterator()->getPathname() ), $this->exclude ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( in_array( ai1wm_replace_forward_slash_with_directory_separator( $this->getInnerIterator()->getPath() ), $this->exclude ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( strpos( $this->getInnerIterator()->getSubPathname(), "\n" ) !== false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( strpos( $this->getInnerIterator()->getSubPathname(), "\r" ) !== false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function getChildren() {
|
||||
return new self( $this->getInnerIterator()->getChildren(), $this->exclude );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Recursive_Extension_Filter extends RecursiveFilterIterator {
|
||||
|
||||
protected $include = array();
|
||||
|
||||
public function __construct( RecursiveIterator $iterator, $include = array() ) {
|
||||
parent::__construct( $iterator );
|
||||
if ( is_array( $include ) ) {
|
||||
$this->include = $include;
|
||||
}
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function accept() {
|
||||
if ( $this->getInnerIterator()->isFile() ) {
|
||||
if ( ! in_array( pathinfo( $this->getInnerIterator()->getFilename(), PATHINFO_EXTENSION ), $this->include ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function getChildren() {
|
||||
return new self( $this->getInnerIterator()->getChildren(), $this->include );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Recursive_Directory_Iterator extends RecursiveDirectoryIterator {
|
||||
|
||||
public function __construct( $path ) {
|
||||
parent::__construct( $path );
|
||||
|
||||
// Skip current and parent directory
|
||||
$this->skipdots();
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function rewind() {
|
||||
parent::rewind();
|
||||
|
||||
// Skip current and parent directory
|
||||
$this->skipdots();
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function next() {
|
||||
parent::next();
|
||||
|
||||
// Skip current and parent directory
|
||||
$this->skipdots();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether current entry is a directory and not '.' or '..'
|
||||
*
|
||||
* Explicitly set allow links flag, because RecursiveDirectoryIterator::FOLLOW_SYMLINKS
|
||||
* is not supported by <= PHP 5.3.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function hasChildren( $allow_links = true ) {
|
||||
return parent::hasChildren( $allow_links );
|
||||
}
|
||||
|
||||
protected function skipdots() {
|
||||
while ( $this->isDot() ) {
|
||||
parent::next();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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_Recursive_Iterator_Iterator extends RecursiveIteratorIterator {
|
||||
|
||||
}
|
||||
1
plugins/all-in-one-wp-migration/lib/view/assets/css/backups.min.css
vendored
Normal file
1
plugins/all-in-one-wp-migration/lib/view/assets/css/backups.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
plugins/all-in-one-wp-migration/lib/view/assets/css/encrypt.min.css
vendored
Normal file
1
plugins/all-in-one-wp-migration/lib/view/assets/css/encrypt.min.css
vendored
Normal file
@@ -0,0 +1 @@
|
||||
section.ai1wm-decrypt-backup-section{align-items:flex-end;box-sizing:border-box;display:flex;flex-direction:column;gap:16px;justify-content:center;padding:16px}section.ai1wm-decrypt-backup-section h1{align-self:center;font-size:20px}section.ai1wm-decrypt-backup-section p{align-self:center;margin:0;padding:0}section.ai1wm-decrypt-backup-section form{align-items:flex-start;align-self:center;display:flex;flex-direction:column;gap:8px;padding:0;width:75%}section.ai1wm-decrypt-backup-section .ai1wm-input-password-container{align-items:center;display:flex;flex-direction:column;position:relative;width:100%}section.ai1wm-decrypt-backup-section .ai1wm-input-password-container input{width:100%}section.ai1wm-decrypt-backup-section .ai1wm-input-password-container .ai1wm-toggle-password-visibility{box-shadow:none;color:#3c434a;font-size:16px;outline:none;position:absolute;right:10px;text-decoration:none;top:8px}section.ai1wm-decrypt-backup-section .ai1wm-input-password-container .ai1wm-error-message{display:none}section.ai1wm-decrypt-backup-section .ai1wm-input-password-container.ai1wm-has-error input{border-color:#e74c3c}section.ai1wm-decrypt-backup-section .ai1wm-input-password-container.ai1wm-has-error .ai1wm-error-message{color:#e74c3c;display:block;font-weight:400;text-align:left;width:100%}section.ai1wm-decrypt-backup-section .ai1wm-backup-decrypt-button-container{align-self:center;display:flex;flex-direction:row;gap:16px;justify-content:flex-end;width:75%}
|
||||
@@ -0,0 +1 @@
|
||||
section.ai1wm-decrypt-backup-section{align-items:flex-end;box-sizing:border-box;display:flex;flex-direction:column;gap:16px;justify-content:center;padding:16px}section.ai1wm-decrypt-backup-section h1{align-self:center;font-size:20px}section.ai1wm-decrypt-backup-section p{align-self:center;margin:0;padding:0}section.ai1wm-decrypt-backup-section form{align-items:flex-start;align-self:center;display:flex;flex-direction:column;gap:8px;padding:0;width:75%}section.ai1wm-decrypt-backup-section .ai1wm-input-password-container{align-items:center;display:flex;flex-direction:column;position:relative;width:100%}section.ai1wm-decrypt-backup-section .ai1wm-input-password-container input{width:100%}section.ai1wm-decrypt-backup-section .ai1wm-input-password-container .ai1wm-toggle-password-visibility{box-shadow:none;color:#3c434a;font-size:16px;outline:none;position:absolute;left:10px;text-decoration:none;top:8px}section.ai1wm-decrypt-backup-section .ai1wm-input-password-container .ai1wm-error-message{display:none}section.ai1wm-decrypt-backup-section .ai1wm-input-password-container.ai1wm-has-error input{border-color:#e74c3c}section.ai1wm-decrypt-backup-section .ai1wm-input-password-container.ai1wm-has-error .ai1wm-error-message{color:#e74c3c;display:block;font-weight:400;text-align:right;width:100%}section.ai1wm-decrypt-backup-section .ai1wm-backup-decrypt-button-container{align-self:center;display:flex;flex-direction:row;gap:16px;justify-content:flex-end;width:75%}
|
||||
1
plugins/all-in-one-wp-migration/lib/view/assets/css/export.min.css
vendored
Normal file
1
plugins/all-in-one-wp-migration/lib/view/assets/css/export.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
plugins/all-in-one-wp-migration/lib/view/assets/css/import.min.css
vendored
Normal file
1
plugins/all-in-one-wp-migration/lib/view/assets/css/import.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
plugins/all-in-one-wp-migration/lib/view/assets/css/reset.min.css
vendored
Normal file
1
plugins/all-in-one-wp-migration/lib/view/assets/css/reset.min.css
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.ai1wm-reset-container{align-items:stretch;background:transparent;display:flex;flex-direction:column;justify-content:center;padding:20px 20px 20px 0}.ai1wm-reset-container .ai1wm-reset-content{display:flex;flex-direction:column;gap:20px;max-width:762px;padding:20px}.ai1wm-reset-container .ai1wm-reset-content h1{align-items:center;display:flex;gap:8px;line-height:1.2;margin:0}.ai1wm-reset-container .ai1wm-reset-content h1>img{max-height:22px;width:auto}.ai1wm-reset-container .ai1wm-reset-content p{margin:0}.ai1wm-reset-container .ai1wm-reset-content img{margin:0;max-width:100%}@media(max-width:767px){.ai1wm-reset-container{margin-right:10px}.ai1wm-reset-container .ai1wm-reset-content{padding:0}}
|
||||
@@ -0,0 +1 @@
|
||||
.ai1wm-reset-container{align-items:stretch;background:transparent;display:flex;flex-direction:column;justify-content:center;padding:20px 0 20px 20px}.ai1wm-reset-container .ai1wm-reset-content{display:flex;flex-direction:column;gap:20px;max-width:762px;padding:20px}.ai1wm-reset-container .ai1wm-reset-content h1{align-items:center;display:flex;gap:8px;line-height:1.2;margin:0}.ai1wm-reset-container .ai1wm-reset-content h1>img{max-height:22px;width:auto}.ai1wm-reset-container .ai1wm-reset-content p{margin:0}.ai1wm-reset-container .ai1wm-reset-content img{margin:0;max-width:100%}@media(max-width:767px){.ai1wm-reset-container{margin-left:10px}.ai1wm-reset-container .ai1wm-reset-content{padding:0}}
|
||||
1
plugins/all-in-one-wp-migration/lib/view/assets/css/schedules.min.css
vendored
Normal file
1
plugins/all-in-one-wp-migration/lib/view/assets/css/schedules.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
plugins/all-in-one-wp-migration/lib/view/assets/css/servmask.min.css
vendored
Normal file
1
plugins/all-in-one-wp-migration/lib/view/assets/css/servmask.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
plugins/all-in-one-wp-migration/lib/view/assets/css/updater.min.css
vendored
Normal file
1
plugins/all-in-one-wp-migration/lib/view/assets/css/updater.min.css
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.ai1wm-error-message,.ai1wm-update-message{color:red;margin:0;padding:0}
|
||||
@@ -0,0 +1 @@
|
||||
.ai1wm-error-message,.ai1wm-update-message{color:red;margin:0;padding:0}
|
||||
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user