changes
This commit is contained in:
@ -0,0 +1,182 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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_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 ) ) {
|
||||
return @unlink( ai1wm_backup_path( array( 'archive' => $file ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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,69 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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_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' ) ) {
|
||||
$messages[] = sprintf( __( '%s is not the latest version. You must update the plugin before you can use it. ', AI1WM_PLUGIN_NAME ), $extension_data['title'] );
|
||||
} else {
|
||||
$messages[] = sprintf( __( '<strong>%s</strong> is not the latest version. You must <a href="%s">update the plugin</a> before you can use it. <br />', AI1WM_PLUGIN_NAME ), $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,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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_Export_Abstract {}
|
||||
class Ai1wm_Import_Abstract {}
|
||||
class Ai1wm_Config {}
|
@ -0,0 +1,350 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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_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_PLUGIN_KEY,
|
||||
'title' => AI1WMZE_PLUGIN_TITLE,
|
||||
'about' => AI1WMZE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMZE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMZE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMZE_VERSION,
|
||||
'requires' => '1.41',
|
||||
'short' => AI1WMZE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add Backblaze B2 Extension
|
||||
if ( defined( 'AI1WMAE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMAE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMAE_PLUGIN_KEY,
|
||||
'title' => AI1WMAE_PLUGIN_TITLE,
|
||||
'about' => AI1WMAE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMAE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMAE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMAE_VERSION,
|
||||
'requires' => '1.46',
|
||||
'short' => AI1WMAE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add Backup Plugin
|
||||
if ( defined( 'AI1WMVE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMVE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMVE_PLUGIN_KEY,
|
||||
'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_PLUGIN_KEY,
|
||||
'title' => AI1WMBE_PLUGIN_TITLE,
|
||||
'about' => AI1WMBE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMBE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMBE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMBE_VERSION,
|
||||
'requires' => '1.57',
|
||||
'short' => AI1WMBE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add DigitalOcean Spaces Extension
|
||||
if ( defined( 'AI1WMIE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMIE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMIE_PLUGIN_KEY,
|
||||
'title' => AI1WMIE_PLUGIN_TITLE,
|
||||
'about' => AI1WMIE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMIE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMIE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMIE_VERSION,
|
||||
'requires' => '1.57',
|
||||
'short' => AI1WMIE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add Direct Extension
|
||||
if ( defined( 'AI1WMXE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMXE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMXE_PLUGIN_KEY,
|
||||
'title' => AI1WMXE_PLUGIN_TITLE,
|
||||
'about' => AI1WMXE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMXE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMXE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMXE_VERSION,
|
||||
'requires' => '1.26',
|
||||
'short' => AI1WMXE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add Dropbox Extension
|
||||
if ( defined( 'AI1WMDE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMDE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMDE_PLUGIN_KEY,
|
||||
'title' => AI1WMDE_PLUGIN_TITLE,
|
||||
'about' => AI1WMDE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMDE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMDE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMDE_VERSION,
|
||||
'requires' => '3.81',
|
||||
'short' => AI1WMDE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add File Extension
|
||||
if ( defined( 'AI1WMTE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMTE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMTE_PLUGIN_KEY,
|
||||
'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_PLUGIN_KEY,
|
||||
'title' => AI1WMFE_PLUGIN_TITLE,
|
||||
'about' => AI1WMFE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMFE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMFE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMFE_VERSION,
|
||||
'requires' => '2.80',
|
||||
'short' => AI1WMFE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add Google Cloud Storage Extension
|
||||
if ( defined( 'AI1WMCE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMCE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMCE_PLUGIN_KEY,
|
||||
'title' => AI1WMCE_PLUGIN_TITLE,
|
||||
'about' => AI1WMCE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMCE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMCE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMCE_VERSION,
|
||||
'requires' => '1.49',
|
||||
'short' => AI1WMCE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add Google Drive Extension
|
||||
if ( defined( 'AI1WMGE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMGE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMGE_PLUGIN_KEY,
|
||||
'title' => AI1WMGE_PLUGIN_TITLE,
|
||||
'about' => AI1WMGE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMGE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMGE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMGE_VERSION,
|
||||
'requires' => '2.85',
|
||||
'short' => AI1WMGE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add Amazon Glacier Extension
|
||||
if ( defined( 'AI1WMRE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMRE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMRE_PLUGIN_KEY,
|
||||
'title' => AI1WMRE_PLUGIN_TITLE,
|
||||
'about' => AI1WMRE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMRE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMRE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMRE_VERSION,
|
||||
'requires' => '1.43',
|
||||
'short' => AI1WMRE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add Mega Extension
|
||||
if ( defined( 'AI1WMEE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMEE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMEE_PLUGIN_KEY,
|
||||
'title' => AI1WMEE_PLUGIN_TITLE,
|
||||
'about' => AI1WMEE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMEE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMEE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMEE_VERSION,
|
||||
'requires' => '1.50',
|
||||
'short' => AI1WMEE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add Multisite Extension
|
||||
if ( defined( 'AI1WMME_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMME_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMME_PLUGIN_KEY,
|
||||
'title' => AI1WMME_PLUGIN_TITLE,
|
||||
'about' => AI1WMME_PLUGIN_ABOUT,
|
||||
'check' => AI1WMME_PLUGIN_CHECK,
|
||||
'basename' => AI1WMME_PLUGIN_BASENAME,
|
||||
'version' => AI1WMME_VERSION,
|
||||
'requires' => '4.33',
|
||||
'short' => AI1WMME_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add OneDrive Extension
|
||||
if ( defined( 'AI1WMOE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMOE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMOE_PLUGIN_KEY,
|
||||
'title' => AI1WMOE_PLUGIN_TITLE,
|
||||
'about' => AI1WMOE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMOE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMOE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMOE_VERSION,
|
||||
'requires' => '1.70',
|
||||
'short' => AI1WMOE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add pCloud Extension
|
||||
if ( defined( 'AI1WMPE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMPE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMPE_PLUGIN_KEY,
|
||||
'title' => AI1WMPE_PLUGIN_TITLE,
|
||||
'about' => AI1WMPE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMPE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMPE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMPE_VERSION,
|
||||
'requires' => '1.44',
|
||||
'short' => AI1WMPE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add Pro Plugin
|
||||
if ( defined( 'AI1WMKE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMKE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMKE_PLUGIN_KEY,
|
||||
'title' => AI1WMKE_PLUGIN_TITLE,
|
||||
'about' => AI1WMKE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMKE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMKE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMKE_VERSION,
|
||||
'requires' => '1.0',
|
||||
'short' => AI1WMKE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add S3 Client Extension
|
||||
if ( defined( 'AI1WMNE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMNE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMNE_PLUGIN_KEY,
|
||||
'title' => AI1WMNE_PLUGIN_TITLE,
|
||||
'about' => AI1WMNE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMNE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMNE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMNE_VERSION,
|
||||
'requires' => '1.41',
|
||||
'short' => AI1WMNE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add Amazon S3 Extension
|
||||
if ( defined( 'AI1WMSE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMSE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMSE_PLUGIN_KEY,
|
||||
'title' => AI1WMSE_PLUGIN_TITLE,
|
||||
'about' => AI1WMSE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMSE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMSE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMSE_VERSION,
|
||||
'requires' => '3.81',
|
||||
'short' => AI1WMSE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add Unlimited Extension
|
||||
if ( defined( 'AI1WMUE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMUE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMUE_PLUGIN_KEY,
|
||||
'title' => AI1WMUE_PLUGIN_TITLE,
|
||||
'about' => AI1WMUE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMUE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMUE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMUE_VERSION,
|
||||
'requires' => '2.55',
|
||||
'short' => AI1WMUE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add URL Extension
|
||||
if ( defined( 'AI1WMLE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMLE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMLE_PLUGIN_KEY,
|
||||
'title' => AI1WMLE_PLUGIN_TITLE,
|
||||
'about' => AI1WMLE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMLE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMLE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMLE_VERSION,
|
||||
'requires' => '2.67',
|
||||
'short' => AI1WMLE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
// Add WebDAV Extension
|
||||
if ( defined( 'AI1WMWE_PLUGIN_NAME' ) ) {
|
||||
$extensions[ AI1WMWE_PLUGIN_NAME ] = array(
|
||||
'key' => AI1WMWE_PLUGIN_KEY,
|
||||
'title' => AI1WMWE_PLUGIN_TITLE,
|
||||
'about' => AI1WMWE_PLUGIN_ABOUT,
|
||||
'check' => AI1WMWE_PLUGIN_CHECK,
|
||||
'basename' => AI1WMWE_PLUGIN_BASENAME,
|
||||
'version' => AI1WMWE_VERSION,
|
||||
'requires' => '1.38',
|
||||
'short' => AI1WMWE_PLUGIN_SHORT,
|
||||
);
|
||||
}
|
||||
|
||||
return $extensions;
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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_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( __( 'Your email is not valid.', AI1WM_PLUGIN_NAME ) );
|
||||
}
|
||||
|
||||
// Validate type
|
||||
if ( empty( $type ) ) {
|
||||
throw new Ai1wm_Feedback_Exception( __( 'Feedback type is not valid.', AI1WM_PLUGIN_NAME ) );
|
||||
}
|
||||
|
||||
// Validate message
|
||||
if ( empty( $message ) ) {
|
||||
throw new Ai1wm_Feedback_Exception( __( 'Please enter comments in the text area.', AI1WM_PLUGIN_NAME ) );
|
||||
}
|
||||
|
||||
// Validate terms
|
||||
if ( empty( $terms ) ) {
|
||||
throw new Ai1wm_Feedback_Exception( __( 'Please accept feedback term conditions.', AI1WM_PLUGIN_NAME ) );
|
||||
}
|
||||
|
||||
$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 ) ) {
|
||||
throw new Ai1wm_Feedback_Exception( sprintf( __( 'Something went wrong: %s', AI1WM_PLUGIN_NAME ), $response->get_error_message() ) );
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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_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 ) {
|
||||
Ai1wm_Log::error(
|
||||
array(
|
||||
'Number' => $errno,
|
||||
'Message' => $errstr,
|
||||
'File' => $errfile,
|
||||
'Line' => $errline,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shutdown handler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function shutdown() {
|
||||
if ( ( $error = error_get_last() ) ) {
|
||||
Ai1wm_Log::error( $error );
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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_Log {
|
||||
|
||||
public static function error( $params ) {
|
||||
$data = array();
|
||||
|
||||
// Add date
|
||||
$data[] = date( 'M d Y H:i:s' );
|
||||
|
||||
// Add params
|
||||
$data[] = json_encode( $params );
|
||||
|
||||
// Add empty line
|
||||
$data[] = PHP_EOL;
|
||||
|
||||
// Write log data
|
||||
if ( $handle = ai1wm_open( ai1wm_error_path(), 'a' ) ) {
|
||||
ai1wm_write( $handle, implode( PHP_EOL, $data ) );
|
||||
ai1wm_close( $handle );
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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_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,85 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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_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,77 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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_Status {
|
||||
|
||||
public static function error( $title, $message ) {
|
||||
self::log( array( 'type' => 'error', 'title' => $title, 'message' => $message ) );
|
||||
}
|
||||
|
||||
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,66 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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_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,214 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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_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'] ) ) {
|
||||
if ( ( $purchase_id = get_option( $extensions[ $slug ]['key'] ) ) ) {
|
||||
|
||||
// Get download URL
|
||||
if ( $slug === 'all-in-one-wp-migration-file-extension' ) {
|
||||
$download_url = add_query_arg( array( 'siteurl' => get_site_url() ), sprintf( '%s', $update['download_link'] ) );
|
||||
} else {
|
||||
$download_url = add_query_arg( array( 'siteurl' => get_site_url() ), sprintf( '%s/%s', $update['download_link'], $purchase_id ) );
|
||||
}
|
||||
|
||||
// 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
|
||||
if ( $slug !== 'all-in-one-wp-migration-file-extension' ) {
|
||||
if ( ( $purchase_id = get_option( $extension['key'] ) ) ) {
|
||||
$check = wp_remote_get(
|
||||
add_query_arg( array( 'site_url' => get_site_url(), 'admin_email' => get_option( 'admin_email' ) ), sprintf( '%s/%s', $extension['check'], $purchase_id ) ),
|
||||
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 ) {
|
||||
$modal_index = 0;
|
||||
|
||||
// Get current updates
|
||||
$updater = get_option( AI1WM_UPDATER, array() );
|
||||
|
||||
// Add link for each extension
|
||||
foreach ( Ai1wm_Extensions::get() as $slug => $extension ) {
|
||||
$modal_index++;
|
||||
|
||||
// Get plugin details
|
||||
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 purchase ID
|
||||
if ( get_option( $extension['key'] ) ) {
|
||||
$plugin_meta[] = Ai1wm_Template::get_content( 'updater/check', array( 'url' => $updater_url ) );
|
||||
} else {
|
||||
$plugin_meta[] = Ai1wm_Template::get_content( 'updater/modal', array( 'url' => $updater_url, 'modal' => $modal_index ) );
|
||||
}
|
||||
// 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,46 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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_Export_Archive {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Creating an empty archive...', AI1WM_PLUGIN_NAME ) );
|
||||
|
||||
// Create empty archive file
|
||||
$archive = new Ai1wm_Compressor( ai1wm_archive_path( $params ) );
|
||||
$archive->close();
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Done creating an empty archive.', AI1WM_PLUGIN_NAME ) );
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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_Export_Clean {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
// Delete storage files
|
||||
Ai1wm_Directory::delete( ai1wm_storage_path( $params ) );
|
||||
|
||||
// Exit in console
|
||||
if ( defined( 'WP_CLI' ) ) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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_Export_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 ) );
|
||||
}
|
||||
}
|
@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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_Export_Config_File {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
$package_bytes_written = 0;
|
||||
|
||||
// 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 package bytes offset
|
||||
if ( isset( $params['package_bytes_offset'] ) ) {
|
||||
$package_bytes_offset = (int) $params['package_bytes_offset'];
|
||||
} else {
|
||||
$package_bytes_offset = 0;
|
||||
}
|
||||
|
||||
// Get total package size
|
||||
if ( isset( $params['total_package_size'] ) ) {
|
||||
$total_package_size = (int) $params['total_package_size'];
|
||||
} else {
|
||||
$total_package_size = ai1wm_package_bytes( $params );
|
||||
}
|
||||
|
||||
// What percent of package have we processed?
|
||||
$progress = (int) min( ( $package_bytes_offset / $total_package_size ) * 100, 100 );
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( sprintf( __( 'Archiving configuration file...<br />%d%% complete', AI1WM_PLUGIN_NAME ), $progress ) );
|
||||
|
||||
// Open the archive file for writing
|
||||
$archive = new Ai1wm_Compressor( ai1wm_archive_path( $params ) );
|
||||
|
||||
// Set the file pointer to the one that we have saved
|
||||
$archive->set_file_pointer( $archive_bytes_offset );
|
||||
|
||||
// Add package.json to archive
|
||||
if ( $archive->add_file( ai1wm_package_path( $params ), AI1WM_PACKAGE_NAME, $package_bytes_written, $package_bytes_offset ) ) {
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Done archiving configuration file.', AI1WM_PLUGIN_NAME ) );
|
||||
|
||||
// Unset archive bytes offset
|
||||
unset( $params['archive_bytes_offset'] );
|
||||
|
||||
// Unset package bytes offset
|
||||
unset( $params['package_bytes_offset'] );
|
||||
|
||||
// Unset total package size
|
||||
unset( $params['total_package_size'] );
|
||||
|
||||
// Unset completed flag
|
||||
unset( $params['completed'] );
|
||||
|
||||
} else {
|
||||
|
||||
// Get archive bytes offset
|
||||
$archive_bytes_offset = $archive->get_file_pointer();
|
||||
|
||||
// What percent of package have we processed?
|
||||
$progress = (int) min( ( $package_bytes_offset / $total_package_size ) * 100, 100 );
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( sprintf( __( 'Archiving configuration file...<br />%d%% complete', AI1WM_PLUGIN_NAME ), $progress ) );
|
||||
|
||||
// Set archive bytes offset
|
||||
$params['archive_bytes_offset'] = $archive_bytes_offset;
|
||||
|
||||
// Set package bytes offset
|
||||
$params['package_bytes_offset'] = $package_bytes_offset;
|
||||
|
||||
// Set total package size
|
||||
$params['total_package_size'] = $total_package_size;
|
||||
|
||||
// Set completed flag
|
||||
$params['completed'] = false;
|
||||
}
|
||||
|
||||
// Truncate the archive file
|
||||
$archive->truncate();
|
||||
|
||||
// Close the archive file
|
||||
$archive->close();
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
@ -0,0 +1,184 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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_Export_Config {
|
||||
|
||||
public static function execute( $params ) {
|
||||
global $table_prefix, $wp_version;
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Preparing configuration file...', AI1WM_PLUGIN_NAME ) );
|
||||
|
||||
// Get options
|
||||
$options = wp_load_alloptions();
|
||||
|
||||
// Get database client
|
||||
$mysql = Ai1wm_Database_Utility::create_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, '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' => $mysql->version(),
|
||||
'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;
|
||||
}
|
||||
}
|
||||
|
||||
// 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() ) );
|
||||
|
||||
if ( isset( $params['options']['encrypt_backups'] ) ) {
|
||||
$config['Encrypted'] = true;
|
||||
$config['EncryptedSignature'] = base64_encode( ai1wm_encrypt_string( AI1WM_SIGN_TEXT, $params['options']['encrypt_password'] ) );
|
||||
}
|
||||
|
||||
// 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( __( 'Done preparing configuration file.', AI1WM_PLUGIN_NAME ) );
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
@ -0,0 +1,193 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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_Export_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 = 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 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;
|
||||
}
|
||||
|
||||
// What percent of files have we processed?
|
||||
$progress = (int) min( ( $processed_files_size / $total_content_files_size ) * 100, 100 );
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( sprintf( __( 'Archiving %d content files...<br />%d%% complete', AI1WM_PLUGIN_NAME ), $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 ) );
|
||||
|
||||
// Set the file pointer to the one that we have saved
|
||||
$archive->set_file_pointer( $archive_bytes_offset );
|
||||
|
||||
// Loop over files
|
||||
while ( list( $file_abspath, $file_relpath, $file_size, $file_mtime ) = fgetcsv( $content_list ) ) {
|
||||
$file_bytes_written = 0;
|
||||
|
||||
// Add file to archive
|
||||
if ( ( $completed = $archive->add_file( $file_abspath, $file_relpath, $file_bytes_written, $file_bytes_offset ) ) ) {
|
||||
$file_bytes_offset = 0;
|
||||
|
||||
// Get content bytes offset
|
||||
$content_bytes_offset = ftell( $content_list );
|
||||
}
|
||||
|
||||
// Increment processed files size
|
||||
$processed_files_size += $file_bytes_written;
|
||||
|
||||
// What percent of files have we processed?
|
||||
$progress = (int) min( ( $processed_files_size / $total_content_files_size ) * 100, 100 );
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( sprintf( __( 'Archiving %d content files...<br />%d%% complete', AI1WM_PLUGIN_NAME ), $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 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 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 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 completed flag
|
||||
$params['completed'] = $completed;
|
||||
}
|
||||
|
||||
// Close the content list file
|
||||
ai1wm_close( $content_list );
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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_Export_Database_File {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
// Set exclude database
|
||||
if ( isset( $params['options']['no_database'] ) ) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
$database_bytes_written = 0;
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
// 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
|
||||
Ai1wm_Status::info( sprintf( __( 'Archiving database...<br />%d%% complete', AI1WM_PLUGIN_NAME ), $progress ) );
|
||||
|
||||
// Open the archive file for writing
|
||||
$archive = new Ai1wm_Compressor( ai1wm_archive_path( $params ) );
|
||||
|
||||
// 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_written, $database_bytes_offset ) ) {
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Done archiving database.', AI1WM_PLUGIN_NAME ) );
|
||||
|
||||
// Unset archive bytes offset
|
||||
unset( $params['archive_bytes_offset'] );
|
||||
|
||||
// Unset database bytes offset
|
||||
unset( $params['database_bytes_offset'] );
|
||||
|
||||
// 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
|
||||
Ai1wm_Status::info( sprintf( __( 'Archiving database...<br />%d%% complete', AI1WM_PLUGIN_NAME ), $progress ) );
|
||||
|
||||
// Set archive bytes offset
|
||||
$params['archive_bytes_offset'] = $archive_bytes_offset;
|
||||
|
||||
// Set database bytes offset
|
||||
$params['database_bytes_offset'] = $database_bytes_offset;
|
||||
|
||||
// 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,208 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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_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
|
||||
Ai1wm_Status::info( sprintf( __( 'Exporting database...<br />%d%% complete<br />%s records saved', AI1WM_PLUGIN_NAME ), $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 ( list( $table_name ) = fgetcsv( $tables_list ) ) {
|
||||
$tables[] = $table_name;
|
||||
}
|
||||
|
||||
// Close the tables list file
|
||||
ai1wm_close( $tables_list );
|
||||
|
||||
// Get database client
|
||||
$mysql = Ai1wm_Database_Utility::create_client();
|
||||
|
||||
// Exclude spam comments
|
||||
if ( isset( $params['options']['no_spam_comments'] ) ) {
|
||||
$mysql->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'] ) ) {
|
||||
$mysql->set_table_where_query( ai1wm_table_prefix() . 'posts', "`post_type` != 'revision'" );
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
$mysql->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
|
||||
$mysql->set_reserved_column_prefixes( array( 'wp_force_deactivated_plugins', 'wp_page_for_privacy_policy' ) );
|
||||
|
||||
// Exclude site options
|
||||
$mysql->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 = $mysql->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 );
|
||||
}
|
||||
|
||||
$mysql->set_table_select_columns( ai1wm_table_prefix() . 'options', $column_names );
|
||||
}
|
||||
|
||||
// Set table prefix columns
|
||||
$mysql->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 ( $mysql->export( ai1wm_database_path( $params ), $query_offset, $table_index, $table_offset, $table_rows ) ) {
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Done exporting database.', AI1WM_PLUGIN_NAME ) );
|
||||
|
||||
// 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
|
||||
Ai1wm_Status::info( sprintf( __( 'Exporting database...<br />%d%% complete<br />%s records saved', AI1WM_PLUGIN_NAME ), $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,84 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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_Export_Download {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Renaming exported file...', AI1WM_PLUGIN_NAME ) );
|
||||
|
||||
// Open the archive file for writing
|
||||
$archive = new Ai1wm_Compressor( ai1wm_archive_path( $params ) );
|
||||
|
||||
// Append EOF block
|
||||
$archive->close( true );
|
||||
|
||||
// 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
|
||||
Ai1wm_Status::download(
|
||||
sprintf(
|
||||
__(
|
||||
'<a href="%s" class="ai1wm-button-green ai1wm-emphasize ai1wm-button-download" title="%s" download="%s">' .
|
||||
'<span>Download %s</span>' .
|
||||
'<em>Size: %s</em>' .
|
||||
'</a>',
|
||||
AI1WM_PLUGIN_NAME
|
||||
),
|
||||
$link,
|
||||
$name,
|
||||
$file,
|
||||
$name,
|
||||
$size
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
do_action( 'ai1wm_status_export_done', $params );
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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_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( __( 'Retrieving a list of WordPress content files...', AI1WM_PLUGIN_NAME ) );
|
||||
|
||||
// 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 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( __( 'Done retrieving a list of WordPress content files.', AI1WM_PLUGIN_NAME ) );
|
||||
|
||||
// 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,106 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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_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( __( 'Retrieving a list of WordPress media files...', AI1WM_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 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( __( 'Done retrieving a list of WordPress media files.', AI1WM_PLUGIN_NAME ) );
|
||||
|
||||
// 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,113 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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_Export_Enumerate_Plugins {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
$exclude_filters = array();
|
||||
|
||||
// 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( __( 'Retrieving a list of WordPress plugin files...', AI1WM_PLUGIN_NAME ) );
|
||||
|
||||
// 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( __( 'Done retrieving a list of WordPress plugin files.', AI1WM_PLUGIN_NAME ) );
|
||||
|
||||
// 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,90 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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_Export_Enumerate_Tables {
|
||||
|
||||
public static function execute( $params, Ai1wm_Database $mysql = null ) {
|
||||
// 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( __( 'Retrieving a list of WordPress database tables...', AI1WM_PLUGIN_NAME ) );
|
||||
|
||||
// Get database client
|
||||
if ( is_null( $mysql ) ) {
|
||||
$mysql = Ai1wm_Database_Utility::create_client();
|
||||
}
|
||||
|
||||
// Include table prefixes
|
||||
if ( ai1wm_table_prefix() ) {
|
||||
$mysql->add_table_prefix_filter( ai1wm_table_prefix() );
|
||||
|
||||
// Include table prefixes (Webba Booking)
|
||||
foreach ( array( 'wbk_services', 'wbk_days_on_off', 'wbk_locked_time_slots', 'wbk_appointments', 'wbk_cancelled_appointments', 'wbk_email_templates', 'wbk_service_categories', 'wbk_gg_calendars', 'wbk_coupons' ) as $table_name ) {
|
||||
$mysql->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 ( $mysql->get_tables() as $table_name ) {
|
||||
if ( ! in_array( $table_name, $excluded_db_tables ) && ai1wm_putcsv( $tables_list, array( $table_name ) ) ) {
|
||||
$total_tables_count++;
|
||||
}
|
||||
}
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Done retrieving a list of WordPress database tables.', AI1WM_PLUGIN_NAME ) );
|
||||
|
||||
// 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,119 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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_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( __( 'Retrieving a list of WordPress theme files...', AI1WM_PLUGIN_NAME ) );
|
||||
|
||||
// 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( __( 'Done retrieving a list of WordPress theme files.', AI1WM_PLUGIN_NAME ) );
|
||||
|
||||
// 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,57 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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_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 );
|
||||
}
|
||||
}
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Preparing to export...', AI1WM_PLUGIN_NAME ) );
|
||||
|
||||
// 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,193 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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_Export_Media {
|
||||
|
||||
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 = 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 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;
|
||||
}
|
||||
|
||||
// What percent of files have we processed?
|
||||
$progress = (int) min( ( $processed_files_size / $total_media_files_size ) * 100, 100 );
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( sprintf( __( 'Archiving %d media files...<br />%d%% complete', AI1WM_PLUGIN_NAME ), $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 ) );
|
||||
|
||||
// Set the file pointer to the one that we have saved
|
||||
$archive->set_file_pointer( $archive_bytes_offset );
|
||||
|
||||
// Loop over files
|
||||
while ( list( $file_abspath, $file_relpath, $file_size, $file_mtime ) = fgetcsv( $media_list ) ) {
|
||||
$file_bytes_written = 0;
|
||||
|
||||
// Add file to archive
|
||||
if ( ( $completed = $archive->add_file( $file_abspath, 'uploads' . DIRECTORY_SEPARATOR . $file_relpath, $file_bytes_written, $file_bytes_offset ) ) ) {
|
||||
$file_bytes_offset = 0;
|
||||
|
||||
// Get media bytes offset
|
||||
$media_bytes_offset = ftell( $media_list );
|
||||
}
|
||||
|
||||
// Increment processed files size
|
||||
$processed_files_size += $file_bytes_written;
|
||||
|
||||
// What percent of files have we processed?
|
||||
$progress = (int) min( ( $processed_files_size / $total_media_files_size ) * 100, 100 );
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( sprintf( __( 'Archiving %d media files...<br />%d%% complete', AI1WM_PLUGIN_NAME ), $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 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 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 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 completed flag
|
||||
$params['completed'] = $completed;
|
||||
}
|
||||
|
||||
// Close the media list file
|
||||
ai1wm_close( $media_list );
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
@ -0,0 +1,193 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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_Export_Plugins {
|
||||
|
||||
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 = 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 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;
|
||||
}
|
||||
|
||||
// What percent of files have we processed?
|
||||
$progress = (int) min( ( $processed_files_size / $total_plugins_files_size ) * 100, 100 );
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( sprintf( __( 'Archiving %d plugin files...<br />%d%% complete', AI1WM_PLUGIN_NAME ), $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 ) );
|
||||
|
||||
// Set the file pointer to the one that we have saved
|
||||
$archive->set_file_pointer( $archive_bytes_offset );
|
||||
|
||||
// Loop over files
|
||||
while ( list( $file_abspath, $file_relpath, $file_size, $file_mtime ) = fgetcsv( $plugins_list ) ) {
|
||||
$file_bytes_written = 0;
|
||||
|
||||
// Add file to archive
|
||||
if ( ( $completed = $archive->add_file( $file_abspath, 'plugins' . DIRECTORY_SEPARATOR . $file_relpath, $file_bytes_written, $file_bytes_offset ) ) ) {
|
||||
$file_bytes_offset = 0;
|
||||
|
||||
// Get plugins bytes offset
|
||||
$plugins_bytes_offset = ftell( $plugins_list );
|
||||
}
|
||||
|
||||
// Increment processed files size
|
||||
$processed_files_size += $file_bytes_written;
|
||||
|
||||
// What percent of files have we processed?
|
||||
$progress = (int) min( ( $processed_files_size / $total_plugins_files_size ) * 100, 100 );
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( sprintf( __( 'Archiving %d plugin files...<br />%d%% complete', AI1WM_PLUGIN_NAME ), $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 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 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 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 completed flag
|
||||
$params['completed'] = $completed;
|
||||
}
|
||||
|
||||
// Close the plugins list file
|
||||
ai1wm_close( $plugins_list );
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
@ -0,0 +1,193 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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_Export_Themes {
|
||||
|
||||
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 = 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 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;
|
||||
}
|
||||
|
||||
// What percent of files have we processed?
|
||||
$progress = (int) min( ( $processed_files_size / $total_themes_files_size ) * 100, 100 );
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( sprintf( __( 'Archiving %d theme files...<br />%d%% complete', AI1WM_PLUGIN_NAME ), $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 ) );
|
||||
|
||||
// Set the file pointer to the one that we have saved
|
||||
$archive->set_file_pointer( $archive_bytes_offset );
|
||||
|
||||
// Loop over files
|
||||
while ( list( $file_abspath, $file_relpath, $file_size, $file_mtime ) = fgetcsv( $themes_list ) ) {
|
||||
$file_bytes_written = 0;
|
||||
|
||||
// Add file to archive
|
||||
if ( ( $completed = $archive->add_file( $file_abspath, 'themes' . DIRECTORY_SEPARATOR . $file_relpath, $file_bytes_written, $file_bytes_offset ) ) ) {
|
||||
$file_bytes_offset = 0;
|
||||
|
||||
// Get themes bytes offset
|
||||
$themes_bytes_offset = ftell( $themes_list );
|
||||
}
|
||||
|
||||
// Increment processed files size
|
||||
$processed_files_size += $file_bytes_written;
|
||||
|
||||
// What percent of files have we processed?
|
||||
$progress = (int) min( ( $processed_files_size / $total_themes_files_size ) * 100, 100 );
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( sprintf( __( 'Archiving %d theme files...<br />%d%% complete', AI1WM_PLUGIN_NAME ), $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 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 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 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 completed flag
|
||||
$params['completed'] = $completed;
|
||||
}
|
||||
|
||||
// Close the themes list file
|
||||
ai1wm_close( $themes_list );
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
@ -0,0 +1,154 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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;
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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;
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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;
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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 ) {
|
||||
// Get database client
|
||||
$mysql = Ai1wm_Database_Utility::create_client();
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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 ) );
|
||||
}
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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'] ) ) {
|
||||
// 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' ) ) {
|
||||
$message = __(
|
||||
'Your backup is from a PHP %s but the site that you are importing to is PHP %s. ' .
|
||||
'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
|
||||
);
|
||||
} else {
|
||||
$message = __(
|
||||
'<i class="ai1wm-import-info">Your backup is from a PHP %s but the site that you are importing to is PHP %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></i>',
|
||||
AI1WM_PLUGIN_NAME
|
||||
);
|
||||
}
|
||||
|
||||
$messages[] = sprintf( $message, $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,264 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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
@ -0,0 +1,374 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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' ),
|
||||
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!', 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;
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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;
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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;
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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 ) {
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Preparing options...', AI1WM_PLUGIN_NAME ) );
|
||||
|
||||
// Get database client
|
||||
if ( is_null( $mysql ) ) {
|
||||
$mysql = Ai1wm_Database_Utility::create_client();
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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;
|
||||
}
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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;
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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 );
|
||||
|
||||
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( __( 'Done preparing users.', AI1WM_PLUGIN_NAME ) );
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
@ -0,0 +1,159 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user