plugin succed to : get published posts

+                    print them onlly in map page
+ wordpress plugin directory changed to save work in git
This commit is contained in:
lenovo
2022-10-23 21:44:38 +02:00
parent e783428a51
commit 039134cd96
236 changed files with 37596 additions and 0 deletions

View File

@@ -0,0 +1,154 @@
<?php
/**
* Copyright (C) 2014-2020 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/>.
*
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
*/
if ( ! defined( 'ABSPATH' ) ) {
die( 'Kangaroos cannot jump here' );
}
class Ai1wm_Import_Blogs {
public static function execute( $params ) {
// Set progress
Ai1wm_Status::info( __( 'Preparing blogs...', AI1WM_PLUGIN_NAME ) );
$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( __( 'The archive should contain <strong>Single WordPress</strong> site! Please revisit your export settings.', AI1WM_PLUGIN_NAME ) );
}
} else {
throw new Ai1wm_Import_Exception( __( 'At least <strong>one WordPress</strong> site should be presented in the archive.', AI1WM_PLUGIN_NAME ) );
}
} else {
throw new Ai1wm_Import_Exception( __( 'Unable to import <strong>WordPress Network</strong> into WordPress <strong>Single</strong> site.', AI1WM_PLUGIN_NAME ) );
}
}
// 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( __( 'Done preparing blogs.', AI1WM_PLUGIN_NAME ) );
return $params;
}
}

View File

@@ -0,0 +1,71 @@
<?php
/**
* Copyright (C) 2014-2020 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/>.
*
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
*/
if ( ! defined( 'ABSPATH' ) ) {
die( 'Kangaroos cannot jump here' );
}
class Ai1wm_Import_Check_Decryption_Password {
public static function execute( $params ) {
global $ai1wm_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 );
if ( ! empty( $params['decryption_password'] ) ) {
if ( ai1wm_is_decryption_password_valid( $package['EncryptedSignature'], $params['decryption_password'] ) ) {
$params['is_decryption_password_valid'] = true;
$archive = new Ai1wm_Extractor( ai1wm_archive_path( $params ), $params['decryption_password'] );
$archive->extract_by_files_array( ai1wm_storage_path( $params ), array( AI1WM_MULTISITE_NAME, AI1WM_DATABASE_NAME ), array(), array() );
Ai1wm_Status::info( __( 'Done validating the decryption password.', AI1WM_PLUGIN_NAME ) );
$ai1wm_params = $params;
return $params;
}
$decryption_password_error = __( 'The decryption password is not valid.', AI1WM_PLUGIN_NAME );
if ( defined( 'WP_CLI' ) ) {
WP_CLI::error( $decryption_password_error );
} else {
Ai1wm_Status::backup_is_encrypted( $decryption_password_error );
exit;
}
}
return $params;
}
}

View File

@@ -0,0 +1,72 @@
<?php
/**
* Copyright (C) 2014-2020 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/>.
*
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
*/
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 );
if ( empty( $package['Encrypted'] ) || empty( $package['EncryptedSignature'] ) || ! empty( $params['is_decryption_password_valid'] ) ) {
return $params;
}
if ( ! ai1wm_can_decrypt() ) {
$message = __( 'Importing an encrypted backup is not supported on this server. <a href="https://help.servmask.com/knowledgebase/unable-to-encrypt-and-decrypt-backups/" target="_blank">Technical details</a>', AI1WM_PLUGIN_NAME );
if ( defined( 'WP_CLI' ) ) {
WP_CLI::error( $message );
} else {
Ai1wm_Status::server_cannot_decrypt( $message );
exit;
}
}
if ( defined( 'WP_CLI' ) ) {
$message = __(
'Backup is encrypted. Please provide decryption password: ',
AI1WM_PLUGIN_NAME
);
$params['decryption_password'] = readline( $message );
return $params;
}
Ai1wm_Status::backup_is_encrypted( null );
exit;
}
}

View File

@@ -0,0 +1,56 @@
<?php
/**
* Copyright (C) 2014-2020 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/>.
*
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
*/
if ( ! defined( 'ABSPATH' ) ) {
die( 'Kangaroos cannot jump here' );
}
class Ai1wm_Import_Clean {
public static function execute( $params ) {
global $wpdb;
// Get database client
if ( empty( $wpdb->use_mysqli ) ) {
$mysql = new Ai1wm_Database_Mysql( $wpdb );
} else {
$mysql = new Ai1wm_Database_Mysqli( $wpdb );
}
// Flush mainsite tables
$mysql->add_table_prefix_filter( ai1wm_table_prefix( 'mainsite' ) );
$mysql->flush();
// Delete storage files
Ai1wm_Directory::delete( ai1wm_storage_path( $params ) );
// Exit in console
if ( defined( 'WP_CLI' ) ) {
return $params;
}
exit;
}
}

View File

@@ -0,0 +1,48 @@
<?php
/**
* Copyright (C) 2014-2020 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/>.
*
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
*/
if ( ! defined( 'ABSPATH' ) ) {
die( 'Kangaroos cannot jump here' );
}
class Ai1wm_Import_Compatibility {
public static function execute( $params ) {
// Set progress
Ai1wm_Status::info( __( 'Checking extensions compatibility...', AI1WM_PLUGIN_NAME ) );
// Get messages
$messages = Ai1wm_Compatibility::get( $params );
// Set messages
if ( empty( $messages ) ) {
return $params;
}
// Error message
throw new Ai1wm_Compatibility_Exception( implode( $messages ) );
}
}

View File

@@ -0,0 +1,130 @@
<?php
/**
* Copyright (C) 2014-2020 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/>.
*
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
*/
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[] = __(
'The import process will overwrite your website including the database, media, plugins, and themes. ' .
'Are you sure to proceed?',
AI1WM_PLUGIN_NAME
);
} else {
$messages[] = __(
'The import process will overwrite your website including the database, media, plugins, and themes. ' .
'Please ensure that you have a backup of your data before proceeding to the next step.',
AI1WM_PLUGIN_NAME
);
}
// Check compatibility of PHP versions
if ( isset( $package['PHP']['Version'] ) ) {
switch ( true ) {
case ( version_compare( $package['PHP']['Version'], '7.0.0', '<' ) && version_compare( PHP_VERSION, '8.0.0', '>=' ) ):
$php_version_message_cli = __(
'Your backup is from a PHP 5 but the site that you are importing to is PHP 8. ' .
'This could cause the import to fail. Technical details: https://help.servmask.com/knowledgebase/migrate-wordpress-from-php-5-to-php-7/',
AI1WM_PLUGIN_NAME
);
$php_version_message = __(
'<i class="ai1wm-import-info">Your backup is from a PHP 5 but the site that you are importing to is PHP 8. ' .
'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></i>',
AI1WM_PLUGIN_NAME
);
break;
case ( version_compare( $package['PHP']['Version'], '8.0.0', '<' ) && version_compare( PHP_VERSION, '8.0.0', '>=' ) ):
$php_version_message_cli = __(
'Your backup is from a PHP 7 but the site that you are importing to is PHP 8. ' .
'This could cause the import to fail. Technical details: https://help.servmask.com/knowledgebase/migrate-wordpress-from-php-5-to-php-7/',
AI1WM_PLUGIN_NAME
);
$php_version_message = __(
'<i class="ai1wm-import-info">Your backup is from a PHP 7 but the site that you are importing to is PHP 8. ' .
'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></i>',
AI1WM_PLUGIN_NAME
);
break;
case ( version_compare( $package['PHP']['Version'], '7.0.0', '<' ) && version_compare( PHP_VERSION, '7.0.0', '>=' ) ):
$php_version_message_cli = __(
'Your backup is from a PHP 5 but the site that you are importing to is PHP 7. ' .
'This could cause the import to fail. Technical details: https://help.servmask.com/knowledgebase/migrate-wordpress-from-php-5-to-php-7/',
AI1WM_PLUGIN_NAME
);
$php_version_message = __(
'<i class="ai1wm-import-info">Your backup is from a PHP 5 but the site that you are importing to is PHP 7. ' .
'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></i>',
AI1WM_PLUGIN_NAME
);
break;
default:
}
if ( isset( $php_version_message_cli, $php_version_message ) ) {
if ( defined( 'WP_CLI' ) ) {
$messages[] = $php_version_message_cli;
} else {
$messages[] = $php_version_message;
}
}
}
if ( defined( 'WP_CLI' ) ) {
$assoc_args = array();
if ( isset( $params['cli_args'] ) ) {
$assoc_args = $params['cli_args'];
}
WP_CLI::confirm( implode( $messages ), $assoc_args );
return $params;
}
// Set progress
Ai1wm_Status::confirm( implode( $messages ) );
exit;
}
}

View File

@@ -0,0 +1,264 @@
<?php
/**
* Copyright (C) 2014-2020 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/>.
*
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
*/
if ( ! defined( 'ABSPATH' ) ) {
die( 'Kangaroos cannot jump here' );
}
class Ai1wm_Import_Content {
public static function execute( $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 file bytes offset
if ( isset( $params['file_bytes_offset'] ) ) {
$file_bytes_offset = (int) $params['file_bytes_offset'];
} else {
$file_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 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 );
// What percent of files have we processed?
$progress = (int) min( ( $processed_files_size / $total_files_size ) * 100, 100 );
// Set progress
Ai1wm_Status::info( sprintf( __( 'Restoring %d files...<br />%d%% complete', AI1WM_PLUGIN_NAME ), $total_files_count, $progress ) );
// Flag to hold if file data has been processed
$completed = true;
// Start time
$start = microtime( true );
// Open the archive file for reading
$archive = new Ai1wm_Extractor( ai1wm_archive_path( $params ) );
// 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_written = 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 content extensions
$exclude_extensions = array( AI1WM_LESS_CACHE_NAME );
// 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_written, $file_bytes_offset ) ) ) {
$file_bytes_offset = 0;
}
// Get archive bytes offset
$archive_bytes_offset = $archive->get_file_pointer();
// Increment processed files size
$processed_files_size += $file_bytes_written;
// What percent of files have we processed?
$progress = (int) min( ( $processed_files_size / $total_files_size ) * 100, 100 );
// Set progress
Ai1wm_Status::info( sprintf( __( 'Restoring %d files...<br />%d%% complete', AI1WM_PLUGIN_NAME ), $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 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 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;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,371 @@
<?php
/**
* Copyright (C) 2014-2020 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/>.
*
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
*/
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' ),
)
);
// 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' ),
)
);
// 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' ),
)
);
// 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!', AI1WM_PLUGIN_NAME ), 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!', AI1WM_PLUGIN_NAME ), Ai1wm_Template::get_content( 'import/oxygen', array( 'should_reset_permalinks' => $should_reset_permalinks ) ) );
} else {
Ai1wm_Status::done( __( 'Your site has been imported successfully!', AI1WM_PLUGIN_NAME ), Ai1wm_Template::get_content( 'import/done', array( 'should_reset_permalinks' => $should_reset_permalinks ) ) );
}
do_action( 'ai1wm_status_import_done', $params );
return $params;
}
}

View File

@@ -0,0 +1,54 @@
<?php
/**
* Copyright (C) 2014-2020 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/>.
*
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
*/
if ( ! defined( 'ABSPATH' ) ) {
die( 'Kangaroos cannot jump here' );
}
class Ai1wm_Import_Enumerate {
public static function execute( $params ) {
// Set progress
Ai1wm_Status::info( __( 'Retrieving a list of all WordPress files...', AI1WM_PLUGIN_NAME ) );
// 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( __( 'Done retrieving a list of all WordPress files.', AI1WM_PLUGIN_NAME ) );
return $params;
}
}

View File

@@ -0,0 +1,65 @@
<?php
/**
* Copyright (C) 2014-2020 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/>.
*
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
*/
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...', AI1WM_PLUGIN_NAME ) );
$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,
);
// Open the archive file for reading
$archive = new Ai1wm_Extractor( ai1wm_archive_path( $params ) );
// 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( __( 'Done activating mu-plugins.', AI1WM_PLUGIN_NAME ) );
return $params;
}
}

View File

@@ -0,0 +1,85 @@
<?php
/**
* Copyright (C) 2014-2020 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/>.
*
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
*/
if ( ! defined( 'ABSPATH' ) ) {
die( 'Kangaroos cannot jump here' );
}
class Ai1wm_Import_Options {
public static function execute( $params, Ai1wm_Database $mysql = null ) {
global $wpdb;
// Set progress
Ai1wm_Status::info( __( 'Preparing options...', AI1WM_PLUGIN_NAME ) );
// Get database client
if ( is_null( $mysql ) ) {
if ( empty( $wpdb->use_mysqli ) ) {
$mysql = new Ai1wm_Database_Mysql( $wpdb );
} else {
$mysql = new Ai1wm_Database_Mysqli( $wpdb );
}
}
$tables = $mysql->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 = $mysql->query( "SELECT meta_value FROM `{$mainsite_prefix}sitemeta` WHERE meta_key = 'fs_accounts'" );
if ( ( $row = $mysql->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( __( 'Done preparing options.', AI1WM_PLUGIN_NAME ) );
return $params;
}
}

View File

@@ -0,0 +1,46 @@
<?php
/**
* Copyright (C) 2014-2020 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/>.
*
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
*/
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( __( 'Getting WordPress permalinks settings...', AI1WM_PLUGIN_NAME ) );
// Get using permalinks
$params['using_permalinks'] = (int) $wp_rewrite->using_permalinks();
// Set progress
Ai1wm_Status::info( __( 'Done getting WordPress permalinks settings.', AI1WM_PLUGIN_NAME ) );
return $params;
}
}

View File

@@ -0,0 +1,97 @@
<?php
/**
* Copyright (C) 2014-2020 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/>.
*
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
*/
if ( ! defined( 'ABSPATH' ) ) {
die( 'Kangaroos cannot jump here' );
}
class Ai1wm_Import_Upload {
private static function validate() {
if ( ! array_key_exists( 'upload-file', $_FILES ) || ! is_array( $_FILES['upload-file'] ) ) {
throw new Ai1wm_Import_Retry_Exception( __( 'Missing upload file.', AI1WM_PLUGIN_NAME ), 400 );
}
if ( ! array_key_exists( 'error', $_FILES['upload-file'] ) ) {
throw new Ai1wm_Import_Retry_Exception( __( 'Missing error key in upload file.', AI1WM_PLUGIN_NAME ), 400 );
}
if ( ! array_key_exists( 'tmp_name', $_FILES['upload-file'] ) ) {
throw new Ai1wm_Import_Retry_Exception( __( 'Missing tmp_name in upload file.', AI1WM_PLUGIN_NAME ), 400 );
}
}
public static function execute( $params ) {
self::validate();
$error = $_FILES['upload-file']['error'];
$upload = $_FILES['upload-file']['tmp_name'];
// Verify file name extension
if ( ! ai1wm_is_filename_supported( ai1wm_archive_path( $params ) ) ) {
throw new Ai1wm_Import_Exception(
__(
'The file type that you have tried to upload is not compatible with this plugin. ' .
'Please ensure that your file is a <strong>.wpress</strong> file that 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>',
AI1WM_PLUGIN_NAME
)
);
}
switch ( $error ) {
case UPLOAD_ERR_OK:
try {
ai1wm_copy( $upload, ai1wm_archive_path( $params ) );
ai1wm_unlink( $upload );
} catch ( Exception $e ) {
throw new Ai1wm_Import_Retry_Exception( sprintf( __( 'Unable to upload the file because %s', AI1WM_PLUGIN_NAME ), $e->getMessage() ), 400 );
}
break;
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
case UPLOAD_ERR_PARTIAL:
case UPLOAD_ERR_NO_FILE:
// File is too large
throw new Ai1wm_Import_Retry_Exception( __( 'The file is too large for this server.', AI1WM_PLUGIN_NAME ), 413 );
case UPLOAD_ERR_NO_TMP_DIR:
throw new Ai1wm_Import_Retry_Exception( __( 'Missing a temporary folder.', AI1WM_PLUGIN_NAME ), 400 );
case UPLOAD_ERR_CANT_WRITE:
throw new Ai1wm_Import_Retry_Exception( __( 'Failed to write file to disk.', AI1WM_PLUGIN_NAME ), 400 );
case UPLOAD_ERR_EXTENSION:
throw new Ai1wm_Import_Retry_Exception( __( 'A PHP extension stopped the file upload.', AI1WM_PLUGIN_NAME ), 400 );
default:
throw new Ai1wm_Import_Retry_Exception( sprintf( __( 'Unrecognized error %s during upload.', AI1WM_PLUGIN_NAME ), $error ), 400 );
}
ai1wm_json_response( array( 'errors' => array() ) );
exit;
}
}

View File

@@ -0,0 +1,67 @@
<?php
/**
* Copyright (C) 2014-2020 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/>.
*
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
*/
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 users...', AI1WM_PLUGIN_NAME ) );
// 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 );
// 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( __( 'Done preparing users.', AI1WM_PLUGIN_NAME ) );
}
return $params;
}
}

View File

@@ -0,0 +1,159 @@
<?php
/**
* Copyright (C) 2014-2020 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/>.
*
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
*/
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(
__(
'Your PHP is 32-bit. In order to import 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>',
AI1WM_PLUGIN_NAME
)
);
}
// Verify file name extension
if ( ! ai1wm_is_filename_supported( ai1wm_archive_path( $params ) ) ) {
throw new Ai1wm_Import_Exception(
__(
'The file type that you have tried to import is not compatible with this plugin. ' .
'Please ensure that your file is a <strong>.wpress</strong> file that 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>',
AI1WM_PLUGIN_NAME
)
);
}
// 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;
}
// 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 );
}
// What percent of archive have we processed?
$progress = (int) min( ( $archive_bytes_offset / $total_archive_size ) * 100, 100 );
// Set progress
Ai1wm_Status::info( sprintf( __( 'Unpacking archive...<br />%d%% complete', AI1WM_PLUGIN_NAME ), $progress ) );
// Open the archive file for reading
$archive = new Ai1wm_Extractor( ai1wm_archive_path( $params ) );
// Set the file pointer to the one that we have saved
$archive->set_file_pointer( $archive_bytes_offset );
// Validate the archive file consistency
if ( ! $archive->is_valid() ) {
throw new Ai1wm_Import_Exception( __( 'The archive file is corrupted. Follow <a href="https://help.servmask.com/knowledgebase/corrupted-archive/" target="_blank">this article</a> to resolve the problem.', AI1WM_PLUGIN_NAME ) );
}
// Flag to hold if file data has been processed
$completed = true;
if ( $archive->has_not_reached_eof() ) {
$file_bytes_written = 0;
// Unpack package.json, multisite.json and database.sql files
if ( ( $completed = $archive->extract_by_files_array( ai1wm_storage_path( $params ), array( AI1WM_PACKAGE_NAME, AI1WM_MULTISITE_NAME, AI1WM_DATABASE_NAME ), array(), array(), $file_bytes_written, $file_bytes_offset ) ) ) {
$file_bytes_offset = 0;
}
// Get archive bytes offset
$archive_bytes_offset = $archive->get_file_pointer();
}
// End of the archive?
if ( $archive->has_reached_eof() ) {
// Check package.json file
if ( false === is_file( ai1wm_package_path( $params ) ) ) {
throw new Ai1wm_Import_Exception( __( 'Please make sure that your file was exported using <strong>All-in-One WP Migration</strong> plugin. <a href="https://help.servmask.com/knowledgebase/invalid-backup-file/" target="_blank">Technical details</a>', AI1WM_PLUGIN_NAME ) );
}
// Set progress
Ai1wm_Status::info( __( 'Done unpacking archive.', AI1WM_PLUGIN_NAME ) );
// Unset archive bytes offset
unset( $params['archive_bytes_offset'] );
// Unset file bytes offset
unset( $params['file_bytes_offset'] );
// 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
Ai1wm_Status::info( sprintf( __( 'Unpacking archive...<br />%d%% complete', AI1WM_PLUGIN_NAME ), $progress ) );
// Set archive bytes offset
$params['archive_bytes_offset'] = $archive_bytes_offset;
// Set file bytes offset
$params['file_bytes_offset'] = $file_bytes_offset;
// 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;
}
}