update v6.73 to v6.74

This commit is contained in:
devHardik71
2024-04-14 22:18:26 +05:30
parent 36e6c5ba67
commit c5cc087df9
34 changed files with 1069 additions and 615 deletions

View File

@@ -1,4 +1,4 @@
# All-in-One WP Migration (v6.73) (Unlimited Import Size)
# All-in-One WP Migration (v6.74) (Unlimited Import Size)
Welcome to the modified version of All-in-One WP Migration! In this version, we've removed the size restriction on importing or restoring backups, allowing you to seamlessly transfer websites of any size.

View File

@@ -5,7 +5,7 @@
* Description: Migration tool for all your blog data. Import or Export your blog content with a single click.
* Author: ServMask
* Author URI: https://servmask.com/
* Version: 6.73
* Version: 6.74
* Text Domain: all-in-one-wp-migration
* Domain Path: /languages
* Network: True

View File

@@ -31,16 +31,16 @@ define( 'AI1WM_DEBUG', false );
// ==================
// = Plugin Version =
// ==================
define( 'AI1WM_VERSION', '6.73' );
define( 'AI1WM_VERSION', '6.74' );
// ===============
// = Plugin Name =
// ===============
define( 'AI1WM_PLUGIN_NAME', 'all-in-one-wp-migration' );
// ===================
// = Directory Index =
// ===================
// ============================
// = Directory index.php File =
// ============================
define( 'AI1WM_DIRECTORY_INDEX', 'index.php' );
// ================
@@ -83,11 +83,6 @@ define( 'AI1WM_EXPORT_PATH', AI1WM_MODEL_PATH . DIRECTORY_SEPARATOR . 'export' )
// ===============
define( 'AI1WM_IMPORT_PATH', AI1WM_MODEL_PATH . DIRECTORY_SEPARATOR . 'import' );
// =============
// = Http Path =
// =============
define( 'AI1WM_HTTP_PATH', AI1WM_MODEL_PATH . DIRECTORY_SEPARATOR . 'http' );
// =============
// = View Path =
// =============
@@ -159,7 +154,7 @@ define( 'AI1WM_SETTINGS_NAME', 'settings.json' );
define( 'AI1WM_MULTIPART_NAME', 'multipart.list' );
// ========================
// = Archive FileMap Name =
// = Archive Filemap Name =
// ========================
define( 'AI1WM_FILEMAP_NAME', 'filemap.list' );
@@ -203,16 +198,6 @@ define( 'AI1WM_IMPORT_NAME', 'import.log' );
// ==================
define( 'AI1WM_ERROR_NAME', 'error.log' );
// ==========
// = URL IP =
// ==========
define( 'AI1WM_URL_IP', 'ai1wm_url_ip' );
// ===============
// = URL Adapter =
// ===============
define( 'AI1WM_URL_ADAPTER', 'ai1wm_url_adapter' );
// ==============
// = Secret Key =
// ==============
@@ -228,6 +213,16 @@ define( 'AI1WM_AUTH_USER', 'ai1wm_auth_user' );
// =================
define( 'AI1WM_AUTH_PASSWORD', 'ai1wm_auth_password' );
// ============
// = Site URL =
// ============
define( 'AI1WM_SITE_URL', 'siteurl' );
// ============
// = Home URL =
// ============
define( 'AI1WM_HOME_URL', 'home' );
// ==================
// = Active Plugins =
// ==================
@@ -325,26 +320,31 @@ define( 'AI1WM_SITES_PATH', AI1WM_UPLOADS_PATH . DIRECTORY_SEPARATOR . 'sites' )
// ================
define( 'AI1WM_BACKUPS_PATH', WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'ai1wm-backups' );
// ======================
// = Storage Index File =
// ======================
// ==========================
// = Storage index.php File =
// ==========================
define( 'AI1WM_STORAGE_INDEX', AI1WM_STORAGE_PATH . DIRECTORY_SEPARATOR . 'index.php' );
// ======================
// = Backups Index File =
// ======================
// ==========================
// = Backups index.php File =
// ==========================
define( 'AI1WM_BACKUPS_INDEX', AI1WM_BACKUPS_PATH . DIRECTORY_SEPARATOR . 'index.php' );
// =========================
// = Backups Htaccess File =
// =========================
// ==========================
// = Backups .htaccess File =
// ==========================
define( 'AI1WM_BACKUPS_HTACCESS', AI1WM_BACKUPS_PATH . DIRECTORY_SEPARATOR . '.htaccess' );
// ==========================
// = Backups Webconfig File =
// ==========================
// ===========================
// = Backups web.config File =
// ===========================
define( 'AI1WM_BACKUPS_WEBCONFIG', AI1WM_BACKUPS_PATH . DIRECTORY_SEPARATOR . 'web.config' );
// ============================
// = WordPress .htaccess File =
// ============================
define( 'AI1WM_WORDPRESS_HTACCESS', ABSPATH . DIRECTORY_SEPARATOR . '.htaccess' );
// ================================
// = WP Migration Plugin Base Dir =
// ================================

View File

@@ -31,7 +31,7 @@
*/
function ai1wm_storage_path( $params ) {
if ( empty( $params['storage'] ) ) {
throw new Ai1wm_Storage_Exception( __( 'Unable to locate storage path', AI1WM_PLUGIN_NAME ) );
throw new Ai1wm_Storage_Exception( __( 'Unable to locate storage path. <a href="https://help.servmask.com/knowledgebase/invalid-storage-path/" target="_blank">Technical details</a>', AI1WM_PLUGIN_NAME ) );
}
// Get storage path
@@ -51,12 +51,12 @@ function ai1wm_storage_path( $params ) {
*/
function ai1wm_backup_path( $params ) {
if ( empty( $params['archive'] ) ) {
throw new Ai1wm_Archive_Exception( __( 'Unable to locate archive path', AI1WM_PLUGIN_NAME ) );
throw new Ai1wm_Archive_Exception( __( 'Unable to locate archive path. <a href="https://help.servmask.com/knowledgebase/invalid-archive-path/" target="_blank">Technical details</a>', AI1WM_PLUGIN_NAME ) );
}
// Validate archive path
if ( validate_file( $params['archive'] ) !== 0 ) {
throw new Ai1wm_Archive_Exception( __( 'Invalid archive path', AI1WM_PLUGIN_NAME ) );
throw new Ai1wm_Archive_Exception( __( 'Invalid archive path. <a href="https://help.servmask.com/knowledgebase/invalid-archive-path/" target="_blank">Technical details</a>', AI1WM_PLUGIN_NAME ) );
}
return AI1WM_BACKUPS_PATH . DIRECTORY_SEPARATOR . $params['archive'];
@@ -70,12 +70,12 @@ function ai1wm_backup_path( $params ) {
*/
function ai1wm_archive_path( $params ) {
if ( empty( $params['archive'] ) ) {
throw new Ai1wm_Archive_Exception( __( 'Unable to locate archive path', AI1WM_PLUGIN_NAME ) );
throw new Ai1wm_Archive_Exception( __( 'Unable to locate archive path. <a href="https://help.servmask.com/knowledgebase/invalid-archive-path/" target="_blank">Technical details</a>', AI1WM_PLUGIN_NAME ) );
}
// Validate archive path
if ( validate_file( $params['archive'] ) !== 0 ) {
throw new Ai1wm_Archive_Exception( __( 'Invalid archive path', AI1WM_PLUGIN_NAME ) );
throw new Ai1wm_Archive_Exception( __( 'Invalid archive path. <a href="https://help.servmask.com/knowledgebase/invalid-archive-path/" target="_blank">Technical details</a>', AI1WM_PLUGIN_NAME ) );
}
// Get archive path
@@ -1061,7 +1061,7 @@ function ai1wm_urlscheme( $url, $scheme = '' ) {
function ai1wm_open( $file, $mode ) {
$file_handle = @fopen( $file, $mode );
if ( false === $file_handle ) {
throw new Ai1wm_Not_Accessible_Exception( sprintf( __( 'Unable to open %s with mode %s', AI1WM_PLUGIN_NAME ), $file, $mode ) );
throw new Ai1wm_Not_Accessible_Exception( sprintf( __( 'Unable to open %s with mode %s. <a href="https://help.servmask.com/knowledgebase/invalid-file-permissions/" target="_blank">Technical details</a>', AI1WM_PLUGIN_NAME ), $file, $mode ) );
}
return $file_handle;
@@ -1080,10 +1080,12 @@ function ai1wm_write( $handle, $content ) {
$write_result = @fwrite( $handle, $content );
if ( false === $write_result ) {
if ( ( $meta = stream_get_meta_data( $handle ) ) ) {
throw new Ai1wm_Not_Writable_Exception( sprintf( __( 'Unable to write to: %s', AI1WM_PLUGIN_NAME ), $meta['uri'] ) );
throw new Ai1wm_Not_Writable_Exception( sprintf( __( 'Unable to write to: %s. <a href="https://help.servmask.com/knowledgebase/invalid-file-permissions/" target="_blank">Technical details</a>', AI1WM_PLUGIN_NAME ), $meta['uri'] ) );
}
} elseif ( strlen( $content ) !== $write_result ) {
throw new Ai1wm_Quota_Exceeded_Exception( __( 'Out of disk space.', AI1WM_PLUGIN_NAME ) );
if ( ( $meta = stream_get_meta_data( $handle ) ) ) {
throw new Ai1wm_Quota_Exceeded_Exception( sprintf( __( 'Out of disk space. Unable to write to: %s. <a href="https://help.servmask.com/knowledgebase/out-of-disk-space/" target="_blank">Technical details</a>', AI1WM_PLUGIN_NAME ), $meta['uri'] ) );
}
}
return $write_result;
@@ -1101,7 +1103,7 @@ function ai1wm_read( $handle, $filesize ) {
$read_result = @fread( $handle, $filesize );
if ( false === $read_result ) {
if ( ( $meta = stream_get_meta_data( $handle ) ) ) {
throw new Ai1wm_Not_Readable_Exception( sprintf( __( 'Unable to read file: %s', AI1WM_PLUGIN_NAME ), $meta['uri'] ) );
throw new Ai1wm_Not_Readable_Exception( sprintf( __( 'Unable to read file: %s. <a href="https://help.servmask.com/knowledgebase/invalid-file-permissions/" target="_blank">Technical details</a>', AI1WM_PLUGIN_NAME ), $meta['uri'] ) );
}
}
@@ -1118,7 +1120,7 @@ function ai1wm_seek( $handle, $offset, $mode = SEEK_SET ) {
$seek_result = @fseek( $handle, $offset, $mode );
if ( -1 === $seek_result ) {
if ( ( $meta = stream_get_meta_data( $handle ) ) ) {
throw new Ai1wm_Not_Seekable_Exception( sprintf( __( 'Unable to seek to offset %d on %s', AI1WM_PLUGIN_NAME ), $offset, $meta['uri'] ) );
throw new Ai1wm_Not_Seekable_Exception( sprintf( __( 'Unable to seek to offset %d on %s. <a href="https://help.servmask.com/knowledgebase/php-32bit/" target="_blank">Technical details</a>', AI1WM_PLUGIN_NAME ), $offset, $meta['uri'] ) );
}
}
@@ -1135,7 +1137,7 @@ function ai1wm_tell( $handle ) {
$tell_result = @ftell( $handle );
if ( false === $tell_result ) {
if ( ( $meta = stream_get_meta_data( $handle ) ) ) {
throw new Ai1wm_Not_Tellable_Exception( sprintf( __( 'Unable to get current pointer position of %s', AI1WM_PLUGIN_NAME ), $meta['uri'] ) );
throw new Ai1wm_Not_Tellable_Exception( sprintf( __( 'Unable to get current pointer position of %s. <a href="https://help.servmask.com/knowledgebase/php-32bit/" target="_blank">Technical details</a>', AI1WM_PLUGIN_NAME ), $meta['uri'] ) );
}
}
@@ -1298,7 +1300,7 @@ function ai1wm_fseek( $file_handle, Math_BigInteger $offset ) {
*/
function ai1wm_verify_secret_key( $secret_key ) {
if ( $secret_key !== get_option( AI1WM_SECRET_KEY ) ) {
throw new Ai1wm_Not_Valid_Secret_Key_Exception( __( 'Unable to authenticate the secret key.', AI1WM_PLUGIN_NAME ) );
throw new Ai1wm_Not_Valid_Secret_Key_Exception( __( 'Unable to authenticate the secret key. <a href="https://help.servmask.com/knowledgebase/invalid-secret-key/" target="_blank">Technical details</a>', AI1WM_PLUGIN_NAME ) );
}
return true;

View File

@@ -101,7 +101,14 @@ class Ai1wm_Export_Controller {
exit;
}
return Ai1wm_Http::get( admin_url( 'admin-ajax.php?action=ai1wm_export' ), $params );
wp_remote_post( apply_filters( 'ai1wm_http_export_url', admin_url( 'admin-ajax.php?action=ai1wm_export' ) ), array(
'timeout' => apply_filters( 'ai1wm_http_export_timeout', 5 ),
'blocking' => apply_filters( 'ai1wm_http_export_blocking', false ),
'sslverify' => apply_filters( 'ai1wm_http_export_sslverify', false ),
'headers' => apply_filters( 'ai1wm_http_export_headers', array() ),
'body' => apply_filters( 'ai1wm_http_export_body', $params ),
) );
exit;
}
}
@@ -126,4 +133,14 @@ class Ai1wm_Export_Controller {
apply_filters( 'ai1wm_export_azure_storage', Ai1wm_Template::get_content( 'export/button-azure-storage' ) ),
);
}
public static function http_export_headers( $headers = array() ) {
if ( ( $user = get_option( AI1WM_AUTH_USER ) ) && ( $password = get_option( AI1WM_AUTH_PASSWORD ) ) ) {
if ( ( $hash = base64_encode( sprintf( '%s:%s', $user, $password ) ) ) ) {
$headers['Authorization'] = sprintf( 'Basic %s', $hash );
}
}
return $headers;
}
}

View File

@@ -105,7 +105,14 @@ class Ai1wm_Import_Controller {
exit;
}
return Ai1wm_Http::get( admin_url( 'admin-ajax.php?action=ai1wm_import' ), $params );
wp_remote_post( apply_filters( 'ai1wm_http_import_url', admin_url( 'admin-ajax.php?action=ai1wm_import' ) ), array(
'timeout' => apply_filters( 'ai1wm_http_import_timeout', 5 ),
'blocking' => apply_filters( 'ai1wm_http_import_blocking', false ),
'sslverify' => apply_filters( 'ai1wm_http_import_sslverify', false ),
'headers' => apply_filters( 'ai1wm_http_import_headers', array() ),
'body' => apply_filters( 'ai1wm_http_import_body', $params ),
) );
exit;
}
}
@@ -132,6 +139,16 @@ class Ai1wm_Import_Controller {
);
}
public static function http_import_headers( $headers = array() ) {
if ( ( $user = get_option( AI1WM_AUTH_USER ) ) && ( $password = get_option( AI1WM_AUTH_PASSWORD ) ) ) {
if ( ( $hash = base64_encode( sprintf( '%s:%s', $user, $password ) ) ) ) {
$headers['Authorization'] = sprintf( 'Basic %s', $hash );
}
}
return $headers;
}
public static function max_chunk_size() {
return min(
ai1wm_parse_size( ini_get( 'post_max_size' ), AI1WM_MAX_CHUNK_SIZE ),

View File

@@ -34,35 +34,41 @@ class Ai1wm_Main_Controller {
register_activation_hook( AI1WM_PLUGIN_BASENAME, array( $this, 'activation_hook' ) );
// Activate hooks
$this->activate_actions()
->activate_filters()
->activate_textdomain();
$this->activate_actions();
$this->activate_filters();
$this->activate_textdomain();
}
/**
* Activation hook callback
*
* @return Object Instance of this class
* @return void
*/
public function activation_hook() {
if ( is_dir( AI1WM_BACKUPS_PATH ) ) {
$this->create_backups_htaccess( AI1WM_BACKUPS_HTACCESS );
$this->create_backups_webconfig( AI1WM_BACKUPS_WEBCONFIG );
$this->create_backups_index( AI1WM_BACKUPS_INDEX );
}
if ( extension_loaded( 'litespeed' ) ) {
$this->create_litespeed_htaccess( AI1WM_WORDPRESS_HTACCESS );
}
}
/**
* Initializes language domain for the plugin
*
* @return Object Instance of this class
* @return void
*/
private function activate_textdomain() {
load_plugin_textdomain( AI1WM_PLUGIN_NAME, false, false );
return $this;
}
/**
* Register listeners for actions
*
* @return Object Instance of this class
* @return void
*/
private function activate_actions() {
// Init
@@ -71,12 +77,12 @@ class Ai1wm_Main_Controller {
// Router
add_action( 'admin_init', array( $this, 'router' ) );
// Setup folders
add_action( 'admin_init', array( $this, 'setup_folders' ) );
// Admin header
add_action( 'admin_head', array( $this, 'admin_head' ) );
// Create initial folders
add_action( 'admin_init', array( $this, 'create_folders' ) );
// All in One WP Migration
add_action( 'plugins_loaded', array( $this, 'ai1wm_loaded' ), 10 );
@@ -100,23 +106,19 @@ class Ai1wm_Main_Controller {
// Enqueue updater scripts and styles
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_updater_scripts_and_styles' ), 5 );
return $this;
}
/**
* Register listeners for filters
*
* @return Object Instance of this class
* @return void
*/
private function activate_filters() {
// Add a links to plugin list page
// Add links to plugin list page
add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
// Add custom schedules
add_filter( 'cron_schedules', array( $this, 'add_cron_schedules' ), 9999 );
return $this;
}
/**
@@ -128,12 +130,6 @@ class Ai1wm_Main_Controller {
// Add export commands
add_filter( 'ai1wm_export', 'Ai1wm_Export_Init::execute', 5 );
add_filter( 'ai1wm_export', 'Ai1wm_Export_Compatibility::execute', 5 );
// Resolve URL address
if ( ai1wm_is_scheduled_backup() ) {
add_filter( 'ai1wm_export', 'Ai1wm_Export_Resolve::execute', 5 );
}
add_filter( 'ai1wm_export', 'Ai1wm_Export_Archive::execute', 10 );
add_filter( 'ai1wm_export', 'Ai1wm_Export_Config::execute', 50 );
add_filter( 'ai1wm_export', 'Ai1wm_Export_Config_File::execute', 60 );
@@ -147,12 +143,6 @@ class Ai1wm_Main_Controller {
// Add import commands
add_filter( 'ai1wm_import', 'Ai1wm_Import_Upload::execute', 5 );
add_filter( 'ai1wm_import', 'Ai1wm_Import_Compatibility::execute', 10 );
// Resolve URL address
if ( ai1wm_is_scheduled_backup() ) {
add_filter( 'ai1wm_import', 'Ai1wm_Import_Resolve::execute', 10 );
}
add_filter( 'ai1wm_import', 'Ai1wm_Import_Validate::execute', 50 );
add_filter( 'ai1wm_import', 'Ai1wm_Import_Confirm::execute', 100 );
add_filter( 'ai1wm_import', 'Ai1wm_Import_Blogs::execute', 150 );
@@ -200,6 +190,12 @@ class Ai1wm_Main_Controller {
// Add automatic plugins update
add_action( 'wp_maybe_auto_update', 'Ai1wm_Updater_Controller::check_for_updates' );
// Add HTTP export headers
add_filter( 'ai1wm_http_export_headers', 'Ai1wm_Export_Controller::http_export_headers' );
// Add HTTP import headers
add_filter( 'ai1wm_http_import_headers', 'Ai1wm_Import_Controller::http_import_headers' );
// Add chunk size limit
add_filter( 'ai1wm_max_chunk_size', 'Ai1wm_Import_Controller::max_chunk_size' );
@@ -216,6 +212,155 @@ class Ai1wm_Main_Controller {
add_filter( 'plugin_row_meta', 'Ai1wm_Updater_Controller::plugin_row_meta', 10, 2 );
}
/**
* Create folders and files needed for plugin operation, if they don't exist
*
* @return void
*/
public function setup_folders() {
// Check if storage folder is created
if ( ! is_dir( AI1WM_STORAGE_PATH ) ) {
$this->create_storage_folder( AI1WM_STORAGE_PATH );
}
// Check if backups folder is created
if ( ! is_dir( AI1WM_BACKUPS_PATH ) ) {
$this->create_backups_folder( AI1WM_BACKUPS_PATH );
}
// Check if index.php is created in storage folder
if ( ! is_file( AI1WM_STORAGE_INDEX ) ) {
$this->create_storage_index( AI1WM_STORAGE_INDEX );
}
// Check if index.php is created in backups folder
if ( ! is_file( AI1WM_BACKUPS_INDEX ) ) {
$this->create_backups_index( AI1WM_BACKUPS_INDEX );
}
// Check if .htaccess is created in backups folder
if ( ! is_file( AI1WM_BACKUPS_HTACCESS ) ) {
$this->create_backups_htaccess( AI1WM_BACKUPS_HTACCESS );
}
// Check if web.config is created in backups folder
if ( ! is_file( AI1WM_BACKUPS_WEBCONFIG ) ) {
$this->create_backups_webconfig( AI1WM_BACKUPS_WEBCONFIG );
}
}
/**
* Create storage folder
*
* @param string Path to folder
* @return void
*/
public function create_storage_folder( $path ) {
if ( ! Ai1wm_Directory::create( $path ) ) {
if ( is_multisite() ) {
return add_action( 'network_admin_notices', array( $this, 'storage_path_notice' ) );
} else {
return add_action( 'admin_notices', array( $this, 'storage_path_notice' ) );
}
}
}
/**
* Create backups folder
*
* @param string Path to folder
* @return void
*/
public function create_backups_folder( $path ) {
if ( ! Ai1wm_Directory::create( $path ) ) {
if ( is_multisite() ) {
return add_action( 'network_admin_notices', array( $this, 'backups_path_notice' ) );
} else {
return add_action( 'admin_notices', array( $this, 'backups_path_notice' ) );
}
}
}
/**
* Create storage index.php file
*
* @param string Path to file
* @return void
*/
public function create_storage_index( $path ) {
if ( ! Ai1wm_File_Index::create( $path ) ) {
if ( is_multisite() ) {
return add_action( 'network_admin_notices', array( $this, 'storage_index_notice' ) );
} else {
return add_action( 'admin_notices', array( $this, 'storage_index_notice' ) );
}
}
}
/**
* Create backups .htaccess file
*
* @param string Path to file
* @return void
*/
public function create_backups_htaccess( $path ) {
if ( ! Ai1wm_File_Htaccess::create( $path ) ) {
if ( is_multisite() ) {
return add_action( 'network_admin_notices', array( $this, 'backups_htaccess_notice' ) );
} else {
return add_action( 'admin_notices', array( $this, 'backups_htaccess_notice' ) );
}
}
}
/**
* Create backups web.config file
*
* @param string Path to file
* @return void
*/
public function create_backups_webconfig( $path ) {
if ( ! Ai1wm_File_Webconfig::create( $path ) ) {
if ( is_multisite() ) {
return add_action( 'network_admin_notices', array( $this, 'backups_webconfig_notice' ) );
} else {
return add_action( 'admin_notices', array( $this, 'backups_webconfig_notice' ) );
}
}
}
/**
* Create backups index.php file
*
* @param string Path to file
* @return void
*/
public function create_backups_index( $path ) {
if ( ! Ai1wm_File_Index::create( $path ) ) {
if ( is_multisite() ) {
return add_action( 'network_admin_notices', array( $this, 'backups_index_notice' ) );
} else {
return add_action( 'admin_notices', array( $this, 'backups_index_notice' ) );
}
}
}
/**
* If the "noabort" environment variable has been set,
* the script will continue to run even though the connection has been broken
*
* @return void
*/
public function create_litespeed_htaccess( $path ) {
if ( ! Ai1wm_File_Htaccess::litespeed( $path ) ) {
if ( is_multisite() ) {
return add_action( 'network_admin_notices', array( $this, 'wordpress_htaccess_notice' ) );
} else {
return add_action( 'admin_notices', array( $this, 'wordpress_htaccess_notice' ) );
}
}
}
/**
* Display multisite notice
*
@@ -280,7 +425,16 @@ class Ai1wm_Main_Controller {
}
/**
* Add a links to plugin list page
* Display notice for .htaccess file in WordPress directory
*
* @return void
*/
public function wordpress_htaccess_notice() {
Ai1wm_Template::render( 'main/wordpress-htaccess-notice' );
}
/**
* Add links to plugin list page
*
* @return array
*/
@@ -292,79 +446,6 @@ class Ai1wm_Main_Controller {
return $links;
}
/**
* Create folders needed for plugin operation, if they don't exist
*
* @return void
*/
public function create_folders() {
// Check if storage folder is created
if ( ! is_dir( AI1WM_STORAGE_PATH ) ) {
if ( ! mkdir( AI1WM_STORAGE_PATH ) ) {
if ( is_multisite() ) {
return add_action( 'network_admin_notices', array( $this, 'storage_path_notice' ) );
} else {
return add_action( 'admin_notices', array( $this, 'storage_path_notice' ) );
}
}
}
// Check if index.php is created in storage folder
if ( ! is_file( AI1WM_STORAGE_INDEX ) ) {
if ( ! Ai1wm_File_Index::create( AI1WM_STORAGE_INDEX ) ) {
if ( is_multisite() ) {
return add_action( 'network_admin_notices', array( $this, 'storage_index_notice' ) );
} else {
return add_action( 'admin_notices', array( $this, 'storage_index_notice' ) );
}
}
}
// Check if ai1wm-backups folder is created
if ( ! is_dir( AI1WM_BACKUPS_PATH ) ) {
if ( ! mkdir( AI1WM_BACKUPS_PATH ) ) {
if ( is_multisite() ) {
return add_action( 'network_admin_notices', array( $this, 'backups_path_notice' ) );
} else {
return add_action( 'admin_notices', array( $this, 'backups_path_notice' ) );
}
}
}
// Check if .htaccess is created in backups folder
if ( ! is_file( AI1WM_BACKUPS_HTACCESS ) ) {
if ( ! Ai1wm_File_Htaccess::create( AI1WM_BACKUPS_HTACCESS ) ) {
if ( is_multisite() ) {
return add_action( 'network_admin_notices', array( $this, 'backups_htaccess_notice' ) );
} else {
return add_action( 'admin_notices', array( $this, 'backups_htaccess_notice' ) );
}
}
}
// Check if web.config is created in backups folder
if ( ! is_file( AI1WM_BACKUPS_WEBCONFIG ) ) {
if ( ! Ai1wm_File_Webconfig::create( AI1WM_BACKUPS_WEBCONFIG ) ) {
if ( is_multisite() ) {
return add_action( 'network_admin_notices', array( $this, 'backups_webconfig_notice' ) );
} else {
return add_action( 'admin_notices', array( $this, 'backups_webconfig_notice' ) );
}
}
}
// Check if index.php is created in backups folder
if ( ! is_file( AI1WM_BACKUPS_INDEX ) ) {
if ( ! Ai1wm_File_Index::create( AI1WM_BACKUPS_INDEX ) ) {
if ( is_multisite() ) {
return add_action( 'network_admin_notices', array( $this, 'backups_index_notice' ) );
} else {
return add_action( 'admin_notices', array( $this, 'backups_index_notice' ) );
}
}
}
}
/**
* Register plugin menus
*
@@ -508,6 +589,22 @@ class Ai1wm_Main_Controller {
),
'secret_key' => get_option( AI1WM_SECRET_KEY ),
) );
wp_localize_script( 'ai1wm_export', 'ai1wm_locale', array(
'stop_exporting_your_website' => __( 'You are about to stop exporting your website, are you sure?', AI1WM_PLUGIN_NAME ),
'preparing_to_export' => __( 'Preparing to export...', AI1WM_PLUGIN_NAME ),
'unable_to_export' => __( 'Unable to export', AI1WM_PLUGIN_NAME ),
'unable_to_start_the_export' => __( 'Unable to start the export. Refresh the page and try again', AI1WM_PLUGIN_NAME ),
'unable_to_run_the_export' => __( 'Unable to run the export. Refresh the page and try again', AI1WM_PLUGIN_NAME ),
'unable_to_stop_the_export' => __( 'Unable to stop the export. Refresh the page and try again', AI1WM_PLUGIN_NAME ),
'please_wait_stopping_the_export' => __( 'Please wait, stopping the export...', AI1WM_PLUGIN_NAME ),
'close_export' => __( 'Close', AI1WM_PLUGIN_NAME ),
'stop_export' => __( 'Stop export', AI1WM_PLUGIN_NAME ),
'leave_feedback' => __( 'Leave plugin developers any feedback here', AI1WM_PLUGIN_NAME ),
'how_may_we_help_you' => __( 'How may we help you?', AI1WM_PLUGIN_NAME ),
'thanks_for_submitting_your_feedback' => __( 'Thanks for submitting your feedback!', AI1WM_PLUGIN_NAME ),
'thanks_for_submitting_your_request' => __( 'Thanks for submitting your request!', AI1WM_PLUGIN_NAME ),
) );
}
/**
@@ -568,20 +665,47 @@ class Ai1wm_Main_Controller {
'secret_key' => get_option( AI1WM_SECRET_KEY ),
),
'filters' => array(
'ai1wm_archive_extension' => array( 'wpress', 'bin' ),
'ai1wm_archive_extension' => array( 'wpress' ),
'ai1wm_archive_size' => apply_filters( 'ai1wm_max_file_size', AI1WM_MAX_FILE_SIZE ),
),
) );
wp_localize_script( 'ai1wm_import', 'ai1wm_import', array(
'ajax' => array(
'ajax' => array(
'url' => wp_make_link_relative( admin_url( 'admin-ajax.php?action=ai1wm_import' ) ),
),
'status' => array(
'status' => array(
'url' => wp_make_link_relative( add_query_arg( array( 'secret_key' => get_option( AI1WM_SECRET_KEY ) ), admin_url( 'admin-ajax.php?action=ai1wm_status' ) ) ),
),
'secret_key' => get_option( AI1WM_SECRET_KEY ),
'oversize' => sprintf(
'secret_key' => get_option( AI1WM_SECRET_KEY ),
) );
wp_localize_script( 'ai1wm_import', 'ai1wm_locale', array(
'stop_importing_your_website' => __( 'You are about to stop importing your website, are you sure?', AI1WM_PLUGIN_NAME ),
'preparing_to_import' => __( 'Preparing to import...', AI1WM_PLUGIN_NAME ),
'unable_to_import' => __( 'Unable to import', AI1WM_PLUGIN_NAME ),
'unable_to_start_the_import' => __( 'Unable to start the import. Refresh the page and try again', AI1WM_PLUGIN_NAME ),
'unable_to_confirm_the_import' => __( 'Unable to confirm the import. Refresh the page and try again', AI1WM_PLUGIN_NAME ),
'unable_to_prepare_blogs_on_import' => __( 'Unable to prepare blogs on import. Refresh the page and try again', AI1WM_PLUGIN_NAME ),
'unable_to_stop_the_import' => __( 'Unable to stop the import. Refresh the page and try again', AI1WM_PLUGIN_NAME ),
'please_wait_stopping_the_export' => __( 'Please wait, stopping the import...', AI1WM_PLUGIN_NAME ),
'close_import' => __( 'Close', AI1WM_PLUGIN_NAME ),
'stop_import' => __( 'Stop import', AI1WM_PLUGIN_NAME ),
'confirm_import' => __( 'Proceed', AI1WM_PLUGIN_NAME ),
'continue_import' => __( 'Continue', AI1WM_PLUGIN_NAME ),
'please_do_not_close_this_browser' => __( 'Please do not close this browser window or your import will fail', AI1WM_PLUGIN_NAME ),
'leave_feedback' => __( 'Leave plugin developers any feedback here', AI1WM_PLUGIN_NAME ),
'how_may_we_help_you' => __( 'How may we help you?', AI1WM_PLUGIN_NAME ),
'thanks_for_submitting_your_feedback' => __( 'Thanks for submitting your feedback!', AI1WM_PLUGIN_NAME ),
'thanks_for_submitting_your_request' => __( 'Thanks for submitting your request!', AI1WM_PLUGIN_NAME ),
'problem_while_uploading_your_file' => __( 'We are sorry, there seems to be a problem while uploading your file. Follow <a href="https://www.youtube.com/watch?v=mRp7qTFYKgs" target="_blank">this guide</a> to resolve it.', AI1WM_PLUGIN_NAME ),
'invalid_archive_extension' => __(
'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
),
'invalid_archive_size' => sprintf(
__(
'The file that you are trying to import is over the maximum upload file size limit of <strong>%s</strong>.<br />' .
'You can remove this restriction by purchasing our ' .
@@ -590,12 +714,6 @@ class Ai1wm_Main_Controller {
),
size_format( apply_filters( 'ai1wm_max_file_size', AI1WM_MAX_FILE_SIZE ) )
),
'invalid_extension' => __(
'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
),
) );
}
@@ -664,6 +782,27 @@ class Ai1wm_Main_Controller {
),
'secret_key' => get_option( AI1WM_SECRET_KEY ),
) );
wp_localize_script( 'ai1wm_backups', 'ai1wm_locale', array(
'stop_importing_your_website' => __( 'You are about to stop importing your website, are you sure?', AI1WM_PLUGIN_NAME ),
'preparing_to_import' => __( 'Preparing to import...', AI1WM_PLUGIN_NAME ),
'unable_to_import' => __( 'Unable to import', AI1WM_PLUGIN_NAME ),
'unable_to_start_the_import' => __( 'Unable to start the import. Refresh the page and try again', AI1WM_PLUGIN_NAME ),
'unable_to_confirm_the_import' => __( 'Unable to confirm the import. Refresh the page and try again', AI1WM_PLUGIN_NAME ),
'unable_to_prepare_blogs_on_import' => __( 'Unable to prepare blogs on import. Refresh the page and try again', AI1WM_PLUGIN_NAME ),
'unable_to_stop_the_import' => __( 'Unable to stop the import. Refresh the page and try again', AI1WM_PLUGIN_NAME ),
'please_wait_stopping_the_export' => __( 'Please wait, stopping the import...', AI1WM_PLUGIN_NAME ),
'close_import' => __( 'Close', AI1WM_PLUGIN_NAME ),
'stop_import' => __( 'Stop import', AI1WM_PLUGIN_NAME ),
'confirm_import' => __( 'Proceed', AI1WM_PLUGIN_NAME ),
'continue_import' => __( 'Continue', AI1WM_PLUGIN_NAME ),
'please_do_not_close_this_browser' => __( 'Please do not close this browser window or your import will fail', AI1WM_PLUGIN_NAME ),
'leave_feedback' => __( 'Leave plugin developers any feedback here', AI1WM_PLUGIN_NAME ),
'how_may_we_help_you' => __( 'How may we help you?', AI1WM_PLUGIN_NAME ),
'thanks_for_submitting_your_feedback' => __( 'Thanks for submitting your feedback!', AI1WM_PLUGIN_NAME ),
'thanks_for_submitting_your_request' => __( 'Thanks for submitting your request!', AI1WM_PLUGIN_NAME ),
'want_to_delete_this_file' => __( 'Are you sure you want to delete this file?', AI1WM_PLUGIN_NAME ),
) );
}
/**
@@ -700,6 +839,11 @@ class Ai1wm_Main_Controller {
'url' => wp_make_link_relative( admin_url( 'admin-ajax.php?action=ai1wm_updater' ) ),
),
) );
wp_localize_script( 'ai1wm_backups', 'ai1wm_locale', array(
'check_for_updates' => __( 'Check for updates', AI1WM_PLUGIN_NAME ),
'invalid_purchase_id' => __( 'Your purchase ID is invalid, please <a href="mailto:support@servmask.com">contact us</a>', AI1WM_PLUGIN_NAME ),
) );
}
/**
@@ -755,7 +899,6 @@ class Ai1wm_Main_Controller {
add_action( 'wp_ajax_nopriv_ai1wm_export', 'Ai1wm_Export_Controller::export' );
add_action( 'wp_ajax_nopriv_ai1wm_import', 'Ai1wm_Import_Controller::import' );
add_action( 'wp_ajax_nopriv_ai1wm_status', 'Ai1wm_Status_Controller::status' );
add_action( 'wp_ajax_nopriv_ai1wm_resolve', 'Ai1wm_Resolve_Controller::resolve' );
add_action( 'wp_ajax_nopriv_ai1wm_backups', 'Ai1wm_Backups_Controller::delete' );
add_action( 'wp_ajax_nopriv_ai1wm_feedback', 'Ai1wm_Feedback_Controller::feedback' );
add_action( 'wp_ajax_nopriv_ai1wm_report', 'Ai1wm_Report_Controller::report' );
@@ -764,7 +907,6 @@ class Ai1wm_Main_Controller {
add_action( 'wp_ajax_ai1wm_export', 'Ai1wm_Export_Controller::export' );
add_action( 'wp_ajax_ai1wm_import', 'Ai1wm_Import_Controller::import' );
add_action( 'wp_ajax_ai1wm_status', 'Ai1wm_Status_Controller::status' );
add_action( 'wp_ajax_ai1wm_resolve', 'Ai1wm_Resolve_Controller::resolve' );
add_action( 'wp_ajax_ai1wm_backups', 'Ai1wm_Backups_Controller::delete' );
add_action( 'wp_ajax_ai1wm_feedback', 'Ai1wm_Feedback_Controller::feedback' );
add_action( 'wp_ajax_ai1wm_report', 'Ai1wm_Report_Controller::report' );

View File

@@ -36,13 +36,13 @@ class Ai1wm_Backups {
// 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 RecursiveIteratorIterator( $iterator, RecursiveIteratorIterator::CHILD_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD );
$iterator->setMaxDepth( 3 );
$iterator = new Ai1wm_Recursive_Iterator_Iterator( $iterator, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD );
// Get backup files
$iterator = new Ai1wm_Extension_Filter( $iterator, array( 'wpress', 'bin' ) );
foreach ( $iterator as $item ) {
try {
if ( ai1wm_is_filesize_supported( $item->getPathname() ) ) {

View File

@@ -40,7 +40,7 @@ class Ai1wm_Extensions {
'about' => AI1WMZE_PLUGIN_ABOUT,
'basename' => AI1WMZE_PLUGIN_BASENAME,
'version' => AI1WMZE_VERSION,
'requires' => '1.0',
'requires' => '1.1',
'short' => AI1WMZE_PLUGIN_SHORT,
);
}
@@ -52,7 +52,7 @@ class Ai1wm_Extensions {
'about' => AI1WMAE_PLUGIN_ABOUT,
'basename' => AI1WMAE_PLUGIN_BASENAME,
'version' => AI1WMAE_VERSION,
'requires' => '1.0',
'requires' => '1.3',
'short' => AI1WMAE_PLUGIN_SHORT,
);
}
@@ -64,7 +64,7 @@ class Ai1wm_Extensions {
'about' => AI1WMBE_PLUGIN_ABOUT,
'basename' => AI1WMBE_PLUGIN_BASENAME,
'version' => AI1WMBE_VERSION,
'requires' => '1.10',
'requires' => '1.13',
'short' => AI1WMBE_PLUGIN_SHORT,
);
}
@@ -76,7 +76,7 @@ class Ai1wm_Extensions {
'about' => AI1WMIE_PLUGIN_ABOUT,
'basename' => AI1WMIE_PLUGIN_BASENAME,
'version' => AI1WMIE_VERSION,
'requires' => '1.1',
'requires' => '1.6',
'short' => AI1WMIE_PLUGIN_SHORT,
);
}
@@ -88,7 +88,7 @@ class Ai1wm_Extensions {
'about' => AI1WMDE_PLUGIN_ABOUT,
'basename' => AI1WMDE_PLUGIN_BASENAME,
'version' => AI1WMDE_VERSION,
'requires' => '3.29',
'requires' => '3.32',
'short' => AI1WMDE_PLUGIN_SHORT,
);
}
@@ -100,7 +100,7 @@ class Ai1wm_Extensions {
'about' => AI1WMFE_PLUGIN_ABOUT,
'basename' => AI1WMFE_PLUGIN_BASENAME,
'version' => AI1WMFE_VERSION,
'requires' => '2.34',
'requires' => '2.37',
'short' => AI1WMFE_PLUGIN_SHORT,
);
}
@@ -124,7 +124,7 @@ class Ai1wm_Extensions {
'about' => AI1WMGE_PLUGIN_ABOUT,
'basename' => AI1WMGE_PLUGIN_BASENAME,
'version' => AI1WMGE_VERSION,
'requires' => '2.31',
'requires' => '2.36',
'short' => AI1WMGE_PLUGIN_SHORT,
);
}
@@ -136,7 +136,7 @@ class Ai1wm_Extensions {
'about' => AI1WMEE_PLUGIN_ABOUT,
'basename' => AI1WMEE_PLUGIN_BASENAME,
'version' => AI1WMEE_VERSION,
'requires' => '1.7',
'requires' => '1.10',
'short' => AI1WMEE_PLUGIN_SHORT,
);
}
@@ -148,7 +148,7 @@ class Ai1wm_Extensions {
'about' => AI1WMME_PLUGIN_ABOUT,
'basename' => AI1WMME_PLUGIN_BASENAME,
'version' => AI1WMME_VERSION,
'requires' => '3.52',
'requires' => '3.56',
'short' => AI1WMME_PLUGIN_SHORT,
);
}
@@ -160,7 +160,7 @@ class Ai1wm_Extensions {
'about' => AI1WMOE_PLUGIN_ABOUT,
'basename' => AI1WMOE_PLUGIN_BASENAME,
'version' => AI1WMOE_VERSION,
'requires' => '1.20',
'requires' => '1.23',
'short' => AI1WMOE_PLUGIN_SHORT,
);
}
@@ -172,7 +172,7 @@ class Ai1wm_Extensions {
'about' => AI1WMSE_PLUGIN_ABOUT,
'basename' => AI1WMSE_PLUGIN_BASENAME,
'version' => AI1WMSE_VERSION,
'requires' => '3.23',
'requires' => '3.27',
'short' => AI1WMSE_PLUGIN_SHORT,
);
}
@@ -184,7 +184,7 @@ class Ai1wm_Extensions {
'about' => AI1WMUE_PLUGIN_ABOUT,
'basename' => AI1WMUE_PLUGIN_BASENAME,
'version' => AI1WMUE_VERSION,
'requires' => '2.16',
'requires' => '2.18',
'short' => AI1WMUE_PLUGIN_SHORT,
);
}
@@ -196,7 +196,7 @@ class Ai1wm_Extensions {
'about' => AI1WMLE_PLUGIN_ABOUT,
'basename' => AI1WMLE_PLUGIN_BASENAME,
'version' => AI1WMLE_VERSION,
'requires' => '2.23',
'requires' => '2.27',
'short' => AI1WMLE_PLUGIN_SHORT,
);
}

View File

@@ -67,24 +67,24 @@ class Ai1wm_Export_Database {
$mysql = new Ai1wm_Database_Mysqli( $wpdb );
}
// Spam comments
// Exclude spam comments
if ( isset( $params['options']['no_spam_comments'] ) ) {
$mysql->set_table_where_clauses( ai1wm_table_prefix() . 'comments', array( "`comment_approved` != 'spam'" ) )
->set_table_where_clauses( ai1wm_table_prefix() . 'commentmeta', array( sprintf( "`comment_ID` IN ( SELECT `comment_ID` FROM `%s` WHERE `comment_approved` != 'spam' )", ai1wm_table_prefix() . 'comments' ) ) );
}
// Post revisions
// Exclude post revisions
if ( isset( $params['options']['no_revisions'] ) ) {
$mysql->set_table_where_clauses( ai1wm_table_prefix() . 'posts', array( "`post_type` != 'revision'" ) );
}
$old_table_prefixes = array();
$new_table_prefixes = array();
$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();
$old_table_prefixes[] = $old_column_prefixes[] = ai1wm_table_prefix();
$new_table_prefixes[] = $new_column_prefixes[] = ai1wm_servmask_prefix();
} else {
// Set table prefixes based on table name
foreach ( $mysql->get_tables() as $table_name ) {
@@ -92,10 +92,16 @@ class Ai1wm_Export_Database {
$new_table_prefixes[] = ai1wm_servmask_prefix() . $table_name;
}
// Set table prefixes based on user meta
foreach ( array( 'capabilities', 'user_level', 'user_roles', 'dashboard_quick_press_last_post_id', 'user-settings', 'user-settings-time' ) as $user_meta ) {
$old_table_prefixes[] = $user_meta;
$new_table_prefixes[] = ai1wm_servmask_prefix() . $user_meta;
// Set table prefixes based on column name
foreach ( array( 'user_roles' ) as $option_name ) {
$old_column_prefixes[] = $option_name;
$new_column_prefixes[] = ai1wm_servmask_prefix() . $option_name;
}
// Set table prefixes based on column name
foreach ( array( 'capabilities', 'user_level', 'dashboard_quick_press_last_post_id', 'user-settings', 'user-settings-time' ) as $meta_key ) {
$old_column_prefixes[] = $meta_key;
$new_column_prefixes[] = ai1wm_servmask_prefix() . $meta_key;
}
}
@@ -114,11 +120,13 @@ class Ai1wm_Export_Database {
// Set database options
$mysql->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 )
->set_include_table_prefixes( $include_table_prefixes )
->set_exclude_table_prefixes( $exclude_table_prefixes );
// Exclude table options
$mysql->set_table_where_clauses( ai1wm_table_prefix() . 'options', array( sprintf( "`option_name` NOT IN ('%s', '%s', '%s', '%s')", AI1WM_ACTIVE_PLUGINS, AI1WM_ACTIVE_TEMPLATE, AI1WM_ACTIVE_STYLESHEET, AI1WM_STATUS ) ) );
// Exclude site options
$mysql->set_table_where_clauses( ai1wm_table_prefix() . 'options', array( sprintf( "`option_name` NOT IN ('%s', '%s', '%s', '%s', '%s', '%s', '%s')", AI1WM_ACTIVE_PLUGINS, AI1WM_ACTIVE_TEMPLATE, AI1WM_ACTIVE_STYLESHEET, AI1WM_STATUS, AI1WM_SECRET_KEY, AI1WM_AUTH_USER, AI1WM_AUTH_PASSWORD ) ) );
// Replace table prefix on columns
$mysql->set_table_prefix_columns( ai1wm_table_prefix() . 'options', array( 'option_name' ) )

View File

@@ -105,35 +105,28 @@ class Ai1wm_Export_Enumerate {
// Create map file
$filemap = ai1wm_open( ai1wm_filemap_path( $params ), 'w' );
try {
// Iterate over content directory
$iterator = new Ai1wm_Recursive_Directory_Iterator( WP_CONTENT_DIR );
// Iterate over content directory
$iterator = new Ai1wm_Recursive_Directory_Iterator( WP_CONTENT_DIR );
// Exclude new line file names
$iterator = new Ai1wm_Recursive_Newline_Filter( $iterator );
// Exclude new line file names
$iterator = new Ai1wm_Recursive_Newline_Filter( $iterator );
// Exclude uploads, plugins or themes
$iterator = new Ai1wm_Recursive_Exclude_Filter( $iterator, apply_filters( 'ai1wm_exclude_content_from_export', $exclude_filters ) );
// Exclude uploads, plugins or themes
$iterator = new Ai1wm_Recursive_Exclude_Filter( $iterator, apply_filters( 'ai1wm_exclude_content_from_export', $exclude_filters ) );
// Recursively iterate over content directory
$iterator = new Ai1wm_Recursive_Iterator_Iterator( $iterator, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD );
// Recursively iterate over content directory
$iterator = new RecursiveIteratorIterator( $iterator, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD );
// Write path line
foreach ( $iterator as $item ) {
if ( $item->isFile() ) {
if ( ai1wm_write( $filemap, $iterator->getSubPathName() . PHP_EOL ) ) {
$total_files_count++;
// Write path line
foreach ( $iterator as $item ) {
if ( $item->isFile() ) {
if ( ai1wm_write( $filemap, $iterator->getSubPathName() . PHP_EOL ) ) {
$total_files_count++;
// Add current file size
$total_files_size += $iterator->getSize();
}
// Add current file size
$total_files_size += $iterator->getSize();
}
}
} catch ( Ai1wm_Quota_Exceeded_Exception $e ) {
throw new Exception( 'Out of disk space.' );
} catch ( Exception $e ) {
// Skip bad file permissions
}
// Set progress

View File

@@ -73,11 +73,8 @@ class Ai1wm_Import_Database {
// Set progress
Ai1wm_Status::info( sprintf( __( 'Restoring database...<br />%d%% complete', AI1WM_PLUGIN_NAME ), $progress ) );
$old_values = array();
$new_values = array();
$old_raw_values = array();
$new_raw_values = array();
$old_replace_values = $old_replace_raw_values = array();
$new_replace_values = $new_replace_raw_values = array();
// Get Blog URLs
foreach ( $blogs as $blog ) {
@@ -91,104 +88,106 @@ class Ai1wm_Import_Database {
// Add Internal Home URL
if ( ! empty( $blog['Old']['InternalHomeURL'] ) ) {
$home_urls[] = $blog['Old']['InternalHomeURL'];
if ( parse_url( $blog['Old']['InternalHomeURL'], PHP_URL_SCHEME ) && parse_url( $blog['Old']['InternalHomeURL'], PHP_URL_HOST ) ) {
$home_urls[] = $blog['Old']['InternalHomeURL'];
}
}
// Get Home URL
foreach ( $home_urls as $home_url ) {
// Get blogs dir Upload Path
if ( ! in_array( sprintf( "'%s'", trim( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ), '/' ) ), $old_raw_values ) ) {
$old_raw_values[] = sprintf( "'%s'", trim( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ), '/' ) );
$new_raw_values[] = sprintf( "'%s'", get_option( 'upload_path' ) );
if ( ! in_array( sprintf( "'%s'", trim( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ), '/' ) ), $old_replace_raw_values ) ) {
$old_replace_raw_values[] = sprintf( "'%s'", trim( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ), '/' ) );
$new_replace_raw_values[] = sprintf( "'%s'", get_option( 'upload_path' ) );
}
// Get sites dir Upload Path
if ( ! in_array( sprintf( "'%s'", trim( ai1wm_uploads_path( $blog['Old']['BlogID'] ), '/' ) ), $old_raw_values ) ) {
$old_raw_values[] = sprintf( "'%s'", trim( ai1wm_uploads_path( $blog['Old']['BlogID'] ), '/' ) );
$new_raw_values[] = sprintf( "'%s'", get_option( 'upload_path' ) );
if ( ! in_array( sprintf( "'%s'", trim( ai1wm_uploads_path( $blog['Old']['BlogID'] ), '/' ) ), $old_replace_raw_values ) ) {
$old_replace_raw_values[] = sprintf( "'%s'", trim( ai1wm_uploads_path( $blog['Old']['BlogID'] ), '/' ) );
$new_replace_raw_values[] = sprintf( "'%s'", get_option( 'upload_path' ) );
}
// Handle old and new sites dir style
if ( defined( 'UPLOADBLOGSDIR' ) ) {
// Get plain Upload Path
if ( ! in_array( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ), $old_values ) ) {
$old_values[] = ai1wm_blogsdir_path( $blog['Old']['BlogID'] );
$new_values[] = ai1wm_blogsdir_path( $blog['New']['BlogID'] );
if ( ! in_array( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ), $old_replace_values ) ) {
$old_replace_values[] = ai1wm_blogsdir_path( $blog['Old']['BlogID'] );
$new_replace_values[] = ai1wm_blogsdir_path( $blog['New']['BlogID'] );
}
// Get URL encoded Upload Path
if ( ! in_array( urlencode( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ) ), $old_values ) ) {
$old_values[] = urlencode( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ) );
$new_values[] = urlencode( ai1wm_blogsdir_path( $blog['New']['BlogID'] ) );
if ( ! in_array( urlencode( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ) ), $old_replace_values ) ) {
$old_replace_values[] = urlencode( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ) );
$new_replace_values[] = urlencode( ai1wm_blogsdir_path( $blog['New']['BlogID'] ) );
}
// Get JSON escaped Upload Path
if ( ! in_array( addcslashes( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ), '/' ), $old_values ) ) {
$old_values[] = addcslashes( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ), '/' );
$new_values[] = addcslashes( ai1wm_blogsdir_path( $blog['New']['BlogID'] ), '/' );
if ( ! in_array( addcslashes( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ), '/' ), $old_replace_values ) ) {
$old_replace_values[] = addcslashes( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ), '/' );
$new_replace_values[] = addcslashes( ai1wm_blogsdir_path( $blog['New']['BlogID'] ), '/' );
}
// Get plain Upload Path
if ( ! in_array( ai1wm_uploads_path( $blog['Old']['BlogID'] ), $old_values ) ) {
$old_values[] = ai1wm_uploads_path( $blog['Old']['BlogID'] );
$new_values[] = ai1wm_blogsdir_path( $blog['New']['BlogID'] );
if ( ! in_array( ai1wm_uploads_path( $blog['Old']['BlogID'] ), $old_replace_values ) ) {
$old_replace_values[] = ai1wm_uploads_path( $blog['Old']['BlogID'] );
$new_replace_values[] = ai1wm_blogsdir_path( $blog['New']['BlogID'] );
}
// Get URL encoded Upload Path
if ( ! in_array( urlencode( ai1wm_uploads_path( $blog['Old']['BlogID'] ) ), $old_values ) ) {
$old_values[] = urlencode( ai1wm_uploads_path( $blog['Old']['BlogID'] ) );
$new_values[] = urlencode( ai1wm_blogsdir_path( $blog['New']['BlogID'] ) );
if ( ! in_array( urlencode( ai1wm_uploads_path( $blog['Old']['BlogID'] ) ), $old_replace_values ) ) {
$old_replace_values[] = urlencode( ai1wm_uploads_path( $blog['Old']['BlogID'] ) );
$new_replace_values[] = urlencode( ai1wm_blogsdir_path( $blog['New']['BlogID'] ) );
}
// Get JSON escaped Upload Path
if ( ! in_array( addcslashes( ai1wm_uploads_path( $blog['Old']['BlogID'] ), '/' ), $old_values ) ) {
$old_values[] = addcslashes( ai1wm_uploads_path( $blog['Old']['BlogID'] ), '/' );
$new_values[] = addcslashes( ai1wm_blogsdir_path( $blog['New']['BlogID'] ), '/' );
if ( ! in_array( addcslashes( ai1wm_uploads_path( $blog['Old']['BlogID'] ), '/' ), $old_replace_values ) ) {
$old_replace_values[] = addcslashes( ai1wm_uploads_path( $blog['Old']['BlogID'] ), '/' );
$new_replace_values[] = addcslashes( ai1wm_blogsdir_path( $blog['New']['BlogID'] ), '/' );
}
} else {
// Get files dir Upload URL
if ( ! in_array( sprintf( '%s/%s/', untrailingslashit( $home_url ), 'files' ), $old_values ) ) {
$old_values[] = sprintf( '%s/%s/', untrailingslashit( $home_url ), 'files' );
$new_values[] = ai1wm_uploads_url( $blog['New']['BlogID'] );
if ( ! in_array( sprintf( '%s/%s/', untrailingslashit( $home_url ), 'files' ), $old_replace_values ) ) {
$old_replace_values[] = sprintf( '%s/%s/', untrailingslashit( $home_url ), 'files' );
$new_replace_values[] = ai1wm_uploads_url( $blog['New']['BlogID'] );
}
// Get plain Upload Path
if ( ! in_array( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ), $old_values ) ) {
$old_values[] = ai1wm_blogsdir_path( $blog['Old']['BlogID'] );
$new_values[] = ai1wm_uploads_path( $blog['New']['BlogID'] );
if ( ! in_array( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ), $old_replace_values ) ) {
$old_replace_values[] = ai1wm_blogsdir_path( $blog['Old']['BlogID'] );
$new_replace_values[] = ai1wm_uploads_path( $blog['New']['BlogID'] );
}
// Get URL encoded Upload Path
if ( ! in_array( urlencode( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ) ), $old_values ) ) {
$old_values[] = urlencode( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ) );
$new_values[] = urlencode( ai1wm_uploads_path( $blog['New']['BlogID'] ) );
if ( ! in_array( urlencode( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ) ), $old_replace_values ) ) {
$old_replace_values[] = urlencode( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ) );
$new_replace_values[] = urlencode( ai1wm_uploads_path( $blog['New']['BlogID'] ) );
}
// Get JSON escaped Upload Path
if ( ! in_array( addcslashes( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ), '/' ), $old_values ) ) {
$old_values[] = addcslashes( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ), '/' );
$new_values[] = addcslashes( ai1wm_uploads_path( $blog['New']['BlogID'] ), '/' );
if ( ! in_array( addcslashes( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ), '/' ), $old_replace_values ) ) {
$old_replace_values[] = addcslashes( ai1wm_blogsdir_path( $blog['Old']['BlogID'] ), '/' );
$new_replace_values[] = addcslashes( ai1wm_uploads_path( $blog['New']['BlogID'] ), '/' );
}
// Get plain Upload Path
if ( ! in_array( ai1wm_uploads_path( $blog['Old']['BlogID'] ), $old_values ) ) {
$old_values[] = ai1wm_uploads_path( $blog['Old']['BlogID'] );
$new_values[] = ai1wm_uploads_path( $blog['New']['BlogID'] );
if ( ! in_array( ai1wm_uploads_path( $blog['Old']['BlogID'] ), $old_replace_values ) ) {
$old_replace_values[] = ai1wm_uploads_path( $blog['Old']['BlogID'] );
$new_replace_values[] = ai1wm_uploads_path( $blog['New']['BlogID'] );
}
// Get URL encoded Upload Path
if ( ! in_array( urlencode( ai1wm_uploads_path( $blog['Old']['BlogID'] ) ), $old_values ) ) {
$old_values[] = urlencode( ai1wm_uploads_path( $blog['Old']['BlogID'] ) );
$new_values[] = urlencode( ai1wm_uploads_path( $blog['New']['BlogID'] ) );
if ( ! in_array( urlencode( ai1wm_uploads_path( $blog['Old']['BlogID'] ) ), $old_replace_values ) ) {
$old_replace_values[] = urlencode( ai1wm_uploads_path( $blog['Old']['BlogID'] ) );
$new_replace_values[] = urlencode( ai1wm_uploads_path( $blog['New']['BlogID'] ) );
}
// Get JSON escaped Upload Path
if ( ! in_array( addcslashes( ai1wm_uploads_path( $blog['Old']['BlogID'] ), '/' ), $old_values ) ) {
$old_values[] = addcslashes( ai1wm_uploads_path( $blog['Old']['BlogID'] ), '/' );
$new_values[] = addcslashes( ai1wm_uploads_path( $blog['New']['BlogID'] ), '/' );
if ( ! in_array( addcslashes( ai1wm_uploads_path( $blog['Old']['BlogID'] ), '/' ), $old_replace_values ) ) {
$old_replace_values[] = addcslashes( ai1wm_uploads_path( $blog['Old']['BlogID'] ), '/' );
$new_replace_values[] = addcslashes( ai1wm_uploads_path( $blog['New']['BlogID'] ), '/' );
}
}
}
@@ -202,7 +201,9 @@ class Ai1wm_Import_Database {
// Add Internal Site URL
if ( ! empty( $blog['Old']['InternalSiteURL'] ) ) {
$site_urls[] = $blog['Old']['InternalSiteURL'];
if ( parse_url( $blog['Old']['InternalSiteURL'], PHP_URL_SCHEME ) && parse_url( $blog['Old']['InternalSiteURL'], PHP_URL_HOST ) ) {
$site_urls[] = $blog['Old']['InternalSiteURL'];
}
}
// Get Site URL
@@ -233,21 +234,21 @@ class Ai1wm_Import_Database {
$new_scheme = parse_url( $blog['New']['SiteURL'], PHP_URL_SCHEME );
// Add domain and path
if ( ! in_array( sprintf( "'%s','%s'", $old_domain, trailingslashit( $old_path ) ), $old_raw_values ) ) {
$old_raw_values[] = sprintf( "'%s','%s'", $old_domain, trailingslashit( $old_path ) );
$new_raw_values[] = sprintf( "'%s','%s'", $new_domain, trailingslashit( $new_path ) );
if ( ! in_array( sprintf( "'%s','%s'", $old_domain, trailingslashit( $old_path ) ), $old_replace_raw_values ) ) {
$old_replace_raw_values[] = sprintf( "'%s','%s'", $old_domain, trailingslashit( $old_path ) );
$new_replace_raw_values[] = sprintf( "'%s','%s'", $new_domain, trailingslashit( $new_path ) );
}
// Add domain and path with single quote
if ( ! in_array( sprintf( "='%s%s", $old_domain, untrailingslashit( $old_path ) ), $old_values ) ) {
$old_values[] = sprintf( "='%s%s", $old_domain, untrailingslashit( $old_path ) );
$new_values[] = sprintf( "='%s%s", $new_domain, untrailingslashit( $new_path ) );
if ( ! in_array( sprintf( "='%s%s", $old_domain, untrailingslashit( $old_path ) ), $old_replace_values ) ) {
$old_replace_values[] = sprintf( "='%s%s", $old_domain, untrailingslashit( $old_path ) );
$new_replace_values[] = sprintf( "='%s%s", $new_domain, untrailingslashit( $new_path ) );
}
// Add domain and path with double quote
if ( ! in_array( sprintf( '="%s%s', $old_domain, untrailingslashit( $old_path ) ), $old_values ) ) {
$old_values[] = sprintf( '="%s%s', $old_domain, untrailingslashit( $old_path ) );
$new_values[] = sprintf( '="%s%s', $new_domain, untrailingslashit( $new_path ) );
if ( ! in_array( sprintf( '="%s%s', $old_domain, untrailingslashit( $old_path ) ), $old_replace_values ) ) {
$old_replace_values[] = sprintf( '="%s%s', $old_domain, untrailingslashit( $old_path ) );
$new_replace_values[] = sprintf( '="%s%s', $new_domain, untrailingslashit( $new_path ) );
}
// Add Site URL scheme
@@ -258,29 +259,29 @@ class Ai1wm_Import_Database {
for ( $i = 0; $i < count( $old_schemes ); $i++ ) {
// Add plain Site URL
if ( ! in_array( ai1wm_urlscheme( $url, $old_schemes[ $i ] ), $old_values ) ) {
$old_values[] = ai1wm_urlscheme( $url, $old_schemes[ $i ] );
$new_values[] = ai1wm_urlscheme( $blog['New']['SiteURL'], $new_schemes[ $i ] );
if ( ! in_array( ai1wm_urlscheme( $url, $old_schemes[ $i ] ), $old_replace_values ) ) {
$old_replace_values[] = ai1wm_urlscheme( $url, $old_schemes[ $i ] );
$new_replace_values[] = ai1wm_urlscheme( $blog['New']['SiteURL'], $new_schemes[ $i ] );
}
// Add URL encoded Site URL
if ( ! in_array( urlencode( ai1wm_urlscheme( $url, $old_schemes[ $i ] ) ), $old_values ) ) {
$old_values[] = urlencode( ai1wm_urlscheme( $url, $old_schemes[ $i ] ) );
$new_values[] = urlencode( ai1wm_urlscheme( $blog['New']['SiteURL'], $new_schemes[ $i ] ) );
if ( ! in_array( urlencode( ai1wm_urlscheme( $url, $old_schemes[ $i ] ) ), $old_replace_values ) ) {
$old_replace_values[] = urlencode( ai1wm_urlscheme( $url, $old_schemes[ $i ] ) );
$new_replace_values[] = urlencode( ai1wm_urlscheme( $blog['New']['SiteURL'], $new_schemes[ $i ] ) );
}
// Add JSON escaped Site URL
if ( ! in_array( addcslashes( ai1wm_urlscheme( $url, $old_schemes[ $i ] ), '/' ), $old_values ) ) {
$old_values[] = addcslashes( ai1wm_urlscheme( $url, $old_schemes[ $i ] ), '/' );
$new_values[] = addcslashes( ai1wm_urlscheme( $blog['New']['SiteURL'], $new_schemes[ $i ] ), '/' );
if ( ! in_array( addcslashes( ai1wm_urlscheme( $url, $old_schemes[ $i ] ), '/' ), $old_replace_values ) ) {
$old_replace_values[] = addcslashes( ai1wm_urlscheme( $url, $old_schemes[ $i ] ), '/' );
$new_replace_values[] = addcslashes( ai1wm_urlscheme( $blog['New']['SiteURL'], $new_schemes[ $i ] ), '/' );
}
}
// Add email
if ( ! isset( $config['NoEmailReplace'] ) ) {
if ( ! in_array( sprintf( '@%s', $old_domain ), $old_values ) ) {
$old_values[] = sprintf( '@%s', $old_domain );
$new_values[] = sprintf( '@%s', $new_domain );
if ( ! in_array( sprintf( '@%s', $old_domain ), $old_replace_values ) ) {
$old_replace_values[] = sprintf( '@%s', $old_domain );
$new_replace_values[] = sprintf( '@%s', $new_domain );
}
}
}
@@ -296,7 +297,9 @@ class Ai1wm_Import_Database {
// Add Internal Home URL
if ( ! empty( $blog['Old']['InternalHomeURL'] ) ) {
$home_urls[] = $blog['Old']['InternalHomeURL'];
if ( parse_url( $blog['Old']['InternalHomeURL'], PHP_URL_SCHEME ) && parse_url( $blog['Old']['InternalHomeURL'], PHP_URL_HOST ) ) {
$home_urls[] = $blog['Old']['InternalHomeURL'];
}
}
// Get Home URL
@@ -327,21 +330,21 @@ class Ai1wm_Import_Database {
$new_scheme = parse_url( $blog['New']['HomeURL'], PHP_URL_SCHEME );
// Add domain and path
if ( ! in_array( sprintf( "'%s','%s'", $old_domain, trailingslashit( $old_path ) ), $old_raw_values ) ) {
$old_raw_values[] = sprintf( "'%s','%s'", $old_domain, trailingslashit( $old_path ) );
$new_raw_values[] = sprintf( "'%s','%s'", $new_domain, trailingslashit( $new_path ) );
if ( ! in_array( sprintf( "'%s','%s'", $old_domain, trailingslashit( $old_path ) ), $old_replace_raw_values ) ) {
$old_replace_raw_values[] = sprintf( "'%s','%s'", $old_domain, trailingslashit( $old_path ) );
$new_replace_raw_values[] = sprintf( "'%s','%s'", $new_domain, trailingslashit( $new_path ) );
}
// Add domain and path with single quote
if ( ! in_array( sprintf( "='%s%s", $old_domain, untrailingslashit( $old_path ) ), $old_values ) ) {
$old_values[] = sprintf( "='%s%s", $old_domain, untrailingslashit( $old_path ) );
$new_values[] = sprintf( "='%s%s", $new_domain, untrailingslashit( $new_path ) );
if ( ! in_array( sprintf( "='%s%s", $old_domain, untrailingslashit( $old_path ) ), $old_replace_values ) ) {
$old_replace_values[] = sprintf( "='%s%s", $old_domain, untrailingslashit( $old_path ) );
$new_replace_values[] = sprintf( "='%s%s", $new_domain, untrailingslashit( $new_path ) );
}
// Add domain and path with double quote
if ( ! in_array( sprintf( '="%s%s', $old_domain, untrailingslashit( $old_path ) ), $old_values ) ) {
$old_values[] = sprintf( '="%s%s', $old_domain, untrailingslashit( $old_path ) );
$new_values[] = sprintf( '="%s%s', $new_domain, untrailingslashit( $new_path ) );
if ( ! in_array( sprintf( '="%s%s', $old_domain, untrailingslashit( $old_path ) ), $old_replace_values ) ) {
$old_replace_values[] = sprintf( '="%s%s', $old_domain, untrailingslashit( $old_path ) );
$new_replace_values[] = sprintf( '="%s%s', $new_domain, untrailingslashit( $new_path ) );
}
// Set Home URL scheme
@@ -352,29 +355,29 @@ class Ai1wm_Import_Database {
for ( $i = 0; $i < count( $old_schemes ); $i++ ) {
// Add plain Home URL
if ( ! in_array( ai1wm_urlscheme( $url, $old_schemes[ $i ] ), $old_values ) ) {
$old_values[] = ai1wm_urlscheme( $url, $old_schemes[ $i ] );
$new_values[] = ai1wm_urlscheme( $blog['New']['HomeURL'], $new_schemes[ $i ] );
if ( ! in_array( ai1wm_urlscheme( $url, $old_schemes[ $i ] ), $old_replace_values ) ) {
$old_replace_values[] = ai1wm_urlscheme( $url, $old_schemes[ $i ] );
$new_replace_values[] = ai1wm_urlscheme( $blog['New']['HomeURL'], $new_schemes[ $i ] );
}
// Add URL encoded Home URL
if ( ! in_array( urlencode( ai1wm_urlscheme( $url, $old_schemes[ $i ] ) ), $old_values ) ) {
$old_values[] = urlencode( ai1wm_urlscheme( $url, $old_schemes[ $i ] ) );
$new_values[] = urlencode( ai1wm_urlscheme( $blog['New']['HomeURL'], $new_schemes[ $i ] ) );
if ( ! in_array( urlencode( ai1wm_urlscheme( $url, $old_schemes[ $i ] ) ), $old_replace_values ) ) {
$old_replace_values[] = urlencode( ai1wm_urlscheme( $url, $old_schemes[ $i ] ) );
$new_replace_values[] = urlencode( ai1wm_urlscheme( $blog['New']['HomeURL'], $new_schemes[ $i ] ) );
}
// Add JSON escaped Home URL
if ( ! in_array( addcslashes( ai1wm_urlscheme( $url, $old_schemes[ $i ] ), '/' ), $old_values ) ) {
$old_values[] = addcslashes( ai1wm_urlscheme( $url, $old_schemes[ $i ] ), '/' );
$new_values[] = addcslashes( ai1wm_urlscheme( $blog['New']['HomeURL'], $new_schemes[ $i ] ), '/' );
if ( ! in_array( addcslashes( ai1wm_urlscheme( $url, $old_schemes[ $i ] ), '/' ), $old_replace_values ) ) {
$old_replace_values[] = addcslashes( ai1wm_urlscheme( $url, $old_schemes[ $i ] ), '/' );
$new_replace_values[] = addcslashes( ai1wm_urlscheme( $blog['New']['HomeURL'], $new_schemes[ $i ] ), '/' );
}
}
// Add email
if ( ! isset( $config['NoEmailReplace'] ) ) {
if ( ! in_array( sprintf( '@%s', $old_domain ), $old_values ) ) {
$old_values[] = sprintf( '@%s', $old_domain );
$new_values[] = sprintf( '@%s', $new_domain );
if ( ! in_array( sprintf( '@%s', $old_domain ), $old_replace_values ) ) {
$old_replace_values[] = sprintf( '@%s', $old_domain );
$new_replace_values[] = sprintf( '@%s', $new_domain );
}
}
}
@@ -391,7 +394,9 @@ class Ai1wm_Import_Database {
// Add Internal Site URL
if ( ! empty( $config['InternalSiteURL'] ) ) {
$site_urls[] = $config['InternalSiteURL'];
if ( parse_url( $config['InternalSiteURL'], PHP_URL_SCHEME ) && parse_url( $config['InternalSiteURL'], PHP_URL_HOST ) ) {
$site_urls[] = $config['InternalSiteURL'];
}
}
// Get Site URL
@@ -422,21 +427,21 @@ class Ai1wm_Import_Database {
$new_scheme = parse_url( site_url(), PHP_URL_SCHEME );
// Add domain and path
if ( ! in_array( sprintf( "'%s','%s'", $old_domain, trailingslashit( $old_path ) ), $old_raw_values ) ) {
$old_raw_values[] = sprintf( "'%s','%s'", $old_domain, trailingslashit( $old_path ) );
$new_raw_values[] = sprintf( "'%s','%s'", $new_domain, trailingslashit( $new_path ) );
if ( ! in_array( sprintf( "'%s','%s'", $old_domain, trailingslashit( $old_path ) ), $old_replace_raw_values ) ) {
$old_replace_raw_values[] = sprintf( "'%s','%s'", $old_domain, trailingslashit( $old_path ) );
$new_replace_raw_values[] = sprintf( "'%s','%s'", $new_domain, trailingslashit( $new_path ) );
}
// Add domain and path with single quote
if ( ! in_array( sprintf( "='%s%s", $old_domain, untrailingslashit( $old_path ) ), $old_values ) ) {
$old_values[] = sprintf( "='%s%s", $old_domain, untrailingslashit( $old_path ) );
$new_values[] = sprintf( "='%s%s", $new_domain, untrailingslashit( $new_path ) );
if ( ! in_array( sprintf( "='%s%s", $old_domain, untrailingslashit( $old_path ) ), $old_replace_values ) ) {
$old_replace_values[] = sprintf( "='%s%s", $old_domain, untrailingslashit( $old_path ) );
$new_replace_values[] = sprintf( "='%s%s", $new_domain, untrailingslashit( $new_path ) );
}
// Add domain and path with double quote
if ( ! in_array( sprintf( '="%s%s', $old_domain, untrailingslashit( $old_path ) ), $old_values ) ) {
$old_values[] = sprintf( '="%s%s', $old_domain, untrailingslashit( $old_path ) );
$new_values[] = sprintf( '="%s%s', $new_domain, untrailingslashit( $new_path ) );
if ( ! in_array( sprintf( '="%s%s', $old_domain, untrailingslashit( $old_path ) ), $old_replace_values ) ) {
$old_replace_values[] = sprintf( '="%s%s', $old_domain, untrailingslashit( $old_path ) );
$new_replace_values[] = sprintf( '="%s%s', $new_domain, untrailingslashit( $new_path ) );
}
// Set Site URL scheme
@@ -447,29 +452,29 @@ class Ai1wm_Import_Database {
for ( $i = 0; $i < count( $old_schemes ); $i++ ) {
// Add plain Site URL
if ( ! in_array( ai1wm_urlscheme( $url, $old_schemes[ $i ] ), $old_values ) ) {
$old_values[] = ai1wm_urlscheme( $url, $old_schemes[ $i ] );
$new_values[] = ai1wm_urlscheme( site_url(), $new_schemes[ $i ] );
if ( ! in_array( ai1wm_urlscheme( $url, $old_schemes[ $i ] ), $old_replace_values ) ) {
$old_replace_values[] = ai1wm_urlscheme( $url, $old_schemes[ $i ] );
$new_replace_values[] = ai1wm_urlscheme( site_url(), $new_schemes[ $i ] );
}
// Add URL encoded Site URL
if ( ! in_array( urlencode( ai1wm_urlscheme( $url, $old_schemes[ $i ] ) ), $old_values ) ) {
$old_values[] = urlencode( ai1wm_urlscheme( $url, $old_schemes[ $i ] ) );
$new_values[] = urlencode( ai1wm_urlscheme( site_url(), $new_schemes[ $i ] ) );
if ( ! in_array( urlencode( ai1wm_urlscheme( $url, $old_schemes[ $i ] ) ), $old_replace_values ) ) {
$old_replace_values[] = urlencode( ai1wm_urlscheme( $url, $old_schemes[ $i ] ) );
$new_replace_values[] = urlencode( ai1wm_urlscheme( site_url(), $new_schemes[ $i ] ) );
}
// Add JSON escaped Site URL
if ( ! in_array( addcslashes( ai1wm_urlscheme( $url, $old_schemes[ $i ] ), '/' ), $old_values ) ) {
$old_values[] = addcslashes( ai1wm_urlscheme( $url, $old_schemes[ $i ] ), '/' );
$new_values[] = addcslashes( ai1wm_urlscheme( site_url(), $new_schemes[ $i ] ), '/' );
if ( ! in_array( addcslashes( ai1wm_urlscheme( $url, $old_schemes[ $i ] ), '/' ), $old_replace_values ) ) {
$old_replace_values[] = addcslashes( ai1wm_urlscheme( $url, $old_schemes[ $i ] ), '/' );
$new_replace_values[] = addcslashes( ai1wm_urlscheme( site_url(), $new_schemes[ $i ] ), '/' );
}
}
// Add email
if ( ! isset( $config['NoEmailReplace'] ) ) {
if ( ! in_array( sprintf( '@%s', $old_domain ), $old_values ) ) {
$old_values[] = sprintf( '@%s', $old_domain );
$new_values[] = sprintf( '@%s', $new_domain );
if ( ! in_array( sprintf( '@%s', $old_domain ), $old_replace_values ) ) {
$old_replace_values[] = sprintf( '@%s', $old_domain );
$new_replace_values[] = sprintf( '@%s', $new_domain );
}
}
}
@@ -485,7 +490,9 @@ class Ai1wm_Import_Database {
// Add Internal Home URL
if ( ! empty( $config['InternalHomeURL'] ) ) {
$home_urls[] = $config['InternalHomeURL'];
if ( parse_url( $config['InternalHomeURL'], PHP_URL_SCHEME ) && parse_url( $config['InternalHomeURL'], PHP_URL_HOST ) ) {
$home_urls[] = $config['InternalHomeURL'];
}
}
// Get Home URL
@@ -516,21 +523,21 @@ class Ai1wm_Import_Database {
$new_scheme = parse_url( home_url(), PHP_URL_SCHEME );
// Add domain and path
if ( ! in_array( sprintf( "'%s','%s'", $old_domain, trailingslashit( $old_path ) ), $old_raw_values ) ) {
$old_raw_values[] = sprintf( "'%s','%s'", $old_domain, trailingslashit( $old_path ) );
$new_raw_values[] = sprintf( "'%s','%s'", $new_domain, trailingslashit( $new_path ) );
if ( ! in_array( sprintf( "'%s','%s'", $old_domain, trailingslashit( $old_path ) ), $old_replace_raw_values ) ) {
$old_replace_raw_values[] = sprintf( "'%s','%s'", $old_domain, trailingslashit( $old_path ) );
$new_replace_raw_values[] = sprintf( "'%s','%s'", $new_domain, trailingslashit( $new_path ) );
}
// Add domain and path with single quote
if ( ! in_array( sprintf( "='%s%s", $old_domain, untrailingslashit( $old_path ) ), $old_values ) ) {
$old_values[] = sprintf( "='%s%s", $old_domain, untrailingslashit( $old_path ) );
$new_values[] = sprintf( "='%s%s", $new_domain, untrailingslashit( $new_path ) );
if ( ! in_array( sprintf( "='%s%s", $old_domain, untrailingslashit( $old_path ) ), $old_replace_values ) ) {
$old_replace_values[] = sprintf( "='%s%s", $old_domain, untrailingslashit( $old_path ) );
$new_replace_values[] = sprintf( "='%s%s", $new_domain, untrailingslashit( $new_path ) );
}
// Add domain and path with double quote
if ( ! in_array( sprintf( '="%s%s', $old_domain, untrailingslashit( $old_path ) ), $old_values ) ) {
$old_values[] = sprintf( '="%s%s', $old_domain, untrailingslashit( $old_path ) );
$new_values[] = sprintf( '="%s%s', $new_domain, untrailingslashit( $new_path ) );
if ( ! in_array( sprintf( '="%s%s', $old_domain, untrailingslashit( $old_path ) ), $old_replace_values ) ) {
$old_replace_values[] = sprintf( '="%s%s', $old_domain, untrailingslashit( $old_path ) );
$new_replace_values[] = sprintf( '="%s%s', $new_domain, untrailingslashit( $new_path ) );
}
// Add Home URL scheme
@@ -541,29 +548,29 @@ class Ai1wm_Import_Database {
for ( $i = 0; $i < count( $old_schemes ); $i++ ) {
// Add plain Home URL
if ( ! in_array( ai1wm_urlscheme( $url, $old_schemes[ $i ] ), $old_values ) ) {
$old_values[] = ai1wm_urlscheme( $url, $old_schemes[ $i ] );
$new_values[] = ai1wm_urlscheme( home_url(), $new_schemes[ $i ] );
if ( ! in_array( ai1wm_urlscheme( $url, $old_schemes[ $i ] ), $old_replace_values ) ) {
$old_replace_values[] = ai1wm_urlscheme( $url, $old_schemes[ $i ] );
$new_replace_values[] = ai1wm_urlscheme( home_url(), $new_schemes[ $i ] );
}
// Add URL encoded Home URL
if ( ! in_array( urlencode( ai1wm_urlscheme( $url, $old_schemes[ $i ] ) ), $old_values ) ) {
$old_values[] = urlencode( ai1wm_urlscheme( $url, $old_schemes[ $i ] ) );
$new_values[] = urlencode( ai1wm_urlscheme( home_url(), $new_schemes[ $i ] ) );
if ( ! in_array( urlencode( ai1wm_urlscheme( $url, $old_schemes[ $i ] ) ), $old_replace_values ) ) {
$old_replace_values[] = urlencode( ai1wm_urlscheme( $url, $old_schemes[ $i ] ) );
$new_replace_values[] = urlencode( ai1wm_urlscheme( home_url(), $new_schemes[ $i ] ) );
}
// Add JSON escaped Home URL
if ( ! in_array( addcslashes( ai1wm_urlscheme( $url, $old_schemes[ $i ] ), '/' ), $old_values ) ) {
$old_values[] = addcslashes( ai1wm_urlscheme( $url, $old_schemes[ $i ] ), '/' );
$new_values[] = addcslashes( ai1wm_urlscheme( home_url(), $new_schemes[ $i ] ), '/' );
if ( ! in_array( addcslashes( ai1wm_urlscheme( $url, $old_schemes[ $i ] ), '/' ), $old_replace_values ) ) {
$old_replace_values[] = addcslashes( ai1wm_urlscheme( $url, $old_schemes[ $i ] ), '/' );
$new_replace_values[] = addcslashes( ai1wm_urlscheme( home_url(), $new_schemes[ $i ] ), '/' );
}
}
// Add email
if ( ! isset( $config['NoEmailReplace'] ) ) {
if ( ! in_array( sprintf( '@%s', $old_domain ), $old_values ) ) {
$old_values[] = sprintf( '@%s', $old_domain );
$new_values[] = sprintf( '@%s', $new_domain );
if ( ! in_array( sprintf( '@%s', $old_domain ), $old_replace_values ) ) {
$old_replace_values[] = sprintf( '@%s', $old_domain );
$new_replace_values[] = sprintf( '@%s', $new_domain );
}
}
}
@@ -577,21 +584,21 @@ class Ai1wm_Import_Database {
if ( $content_dir !== WP_CONTENT_DIR ) {
// Add plain WordPress Content
if ( ! in_array( $content_dir, $old_values ) ) {
$old_values[] = $content_dir;
$new_values[] = WP_CONTENT_DIR;
if ( ! in_array( $content_dir, $old_replace_values ) ) {
$old_replace_values[] = $content_dir;
$new_replace_values[] = WP_CONTENT_DIR;
}
// Add URL encoded WordPress Content
if ( ! in_array( urlencode( $content_dir ), $old_values ) ) {
$old_values[] = urlencode( $content_dir );
$new_values[] = urlencode( WP_CONTENT_DIR );
if ( ! in_array( urlencode( $content_dir ), $old_replace_values ) ) {
$old_replace_values[] = urlencode( $content_dir );
$new_replace_values[] = urlencode( WP_CONTENT_DIR );
}
// Add JSON escaped WordPress Content
if ( ! in_array( addcslashes( $content_dir, '/' ), $old_values ) ) {
$old_values[] = addcslashes( $content_dir, '/' );
$new_values[] = addcslashes( WP_CONTENT_DIR, '/' );
if ( ! in_array( addcslashes( $content_dir, '/' ), $old_replace_values ) ) {
$old_replace_values[] = addcslashes( $content_dir, '/' );
$new_replace_values[] = addcslashes( WP_CONTENT_DIR, '/' );
}
}
}
@@ -602,31 +609,31 @@ class Ai1wm_Import_Database {
if ( ! empty( $replace['OldValues'][ $i ] ) && ! empty( $replace['NewValues'][ $i ] ) ) {
// Add plain replace values
if ( ! in_array( $replace['OldValues'][ $i ], $old_values ) ) {
$old_values[] = $replace['OldValues'][ $i ];
$new_values[] = $replace['NewValues'][ $i ];
if ( ! in_array( $replace['OldValues'][ $i ], $old_replace_values ) ) {
$old_replace_values[] = $replace['OldValues'][ $i ];
$new_replace_values[] = $replace['NewValues'][ $i ];
}
// Add URL encoded replace values
if ( ! in_array( urlencode( $replace['OldValues'][ $i ] ), $old_values ) ) {
$old_values[] = urlencode( $replace['OldValues'][ $i ] );
$new_values[] = urlencode( $replace['NewValues'][ $i ] );
if ( ! in_array( urlencode( $replace['OldValues'][ $i ] ), $old_replace_values ) ) {
$old_replace_values[] = urlencode( $replace['OldValues'][ $i ] );
$new_replace_values[] = urlencode( $replace['NewValues'][ $i ] );
}
// Add JSON Escaped replace values
if ( ! in_array( addcslashes( $replace['OldValues'][ $i ], '/' ), $old_values ) ) {
$old_values[] = addcslashes( $replace['OldValues'][ $i ], '/' );
$new_values[] = addcslashes( $replace['NewValues'][ $i ], '/' );
if ( ! in_array( addcslashes( $replace['OldValues'][ $i ], '/' ), $old_replace_values ) ) {
$old_replace_values[] = addcslashes( $replace['OldValues'][ $i ], '/' );
$new_replace_values[] = addcslashes( $replace['NewValues'][ $i ], '/' );
}
}
}
}
// Get URL IP
$url_ip = get_option( AI1WM_URL_IP );
// Get site URL
$site_url = get_option( AI1WM_SITE_URL );
// Get URL adapter
$url_adapter = get_option( AI1WM_URL_ADAPTER );
// Get home URL
$home_url = get_option( AI1WM_HOME_URL );
// Get secret key
$secret_key = get_option( AI1WM_SECRET_KEY );
@@ -637,40 +644,40 @@ class Ai1wm_Import_Database {
// Get HTTP password
$auth_password = get_option( AI1WM_AUTH_PASSWORD );
$old_prefixes = array();
$new_prefixes = array();
$old_table_prefixes = array();
$new_table_prefixes = array();
// Set main table prefixes
$old_prefixes[] = ai1wm_servmask_prefix( 'mainsite' );
$new_prefixes[] = ai1wm_table_prefix();
$old_table_prefixes[] = ai1wm_servmask_prefix( 'mainsite' );
$new_table_prefixes[] = ai1wm_table_prefix();
// Set site table prefixes
foreach ( $blogs as $blog ) {
if ( ai1wm_main_site( $blog['Old']['BlogID'] ) === false ) {
$old_prefixes[] = ai1wm_servmask_prefix( $blog['Old']['BlogID'] );
$new_prefixes[] = ai1wm_table_prefix( $blog['New']['BlogID'] );
$old_table_prefixes[] = ai1wm_servmask_prefix( $blog['Old']['BlogID'] );
$new_table_prefixes[] = ai1wm_table_prefix( $blog['New']['BlogID'] );
}
}
// Set base table prefixes
foreach ( $blogs as $blog ) {
if ( ai1wm_main_site( $blog['Old']['BlogID'] ) === true ) {
$old_prefixes[] = ai1wm_servmask_prefix( 'basesite' );
$new_prefixes[] = ai1wm_table_prefix( $blog['New']['BlogID'] );
$old_table_prefixes[] = ai1wm_servmask_prefix( 'basesite' );
$new_table_prefixes[] = ai1wm_table_prefix( $blog['New']['BlogID'] );
}
}
// Set site table prefixes
foreach ( $blogs as $blog ) {
if ( ai1wm_main_site( $blog['Old']['BlogID'] ) === true ) {
$old_prefixes[] = ai1wm_servmask_prefix( $blog['Old']['BlogID'] );
$new_prefixes[] = ai1wm_table_prefix( $blog['New']['BlogID'] );
$old_table_prefixes[] = ai1wm_servmask_prefix( $blog['Old']['BlogID'] );
$new_table_prefixes[] = ai1wm_table_prefix( $blog['New']['BlogID'] );
}
}
// Set table prefixes
$old_prefixes[] = ai1wm_servmask_prefix();
$new_prefixes[] = ai1wm_table_prefix();
$old_table_prefixes[] = ai1wm_servmask_prefix();
$new_table_prefixes[] = ai1wm_table_prefix();
// Get database client
if ( empty( $wpdb->use_mysqli ) ) {
@@ -680,12 +687,12 @@ class Ai1wm_Import_Database {
}
// Set database options
$mysql->set_old_table_prefixes( $old_prefixes )
->set_new_table_prefixes( $new_prefixes )
->set_old_replace_values( $old_values )
->set_new_replace_values( $new_values )
->set_old_replace_raw_values( $old_raw_values )
->set_new_replace_raw_values( $new_raw_values );
$mysql->set_old_table_prefixes( $old_table_prefixes )
->set_new_table_prefixes( $new_table_prefixes )
->set_old_replace_values( $old_replace_values )
->set_new_replace_values( $new_replace_values )
->set_old_replace_raw_values( $old_replace_raw_values )
->set_new_replace_raw_values( $new_replace_raw_values );
// Flush database
if ( isset( $config['Plugin']['Version'] ) && ( $version = $config['Plugin']['Version'] ) ) {
@@ -743,11 +750,11 @@ class Ai1wm_Import_Database {
// Activate plugins
ai1wm_activate_plugins( ai1wm_active_servmask_plugins() );
// Set the new URL IP
update_option( AI1WM_URL_IP, $url_ip );
// Set the new site URL
update_option( AI1WM_SITE_URL, $site_url );
// Set the new URL adapter
update_option( AI1WM_URL_ADAPTER, $url_adapter );
// Set the new home URL
update_option( AI1WM_HOME_URL, $home_url );
// Set the new secret key value
update_option( AI1WM_SECRET_KEY, $secret_key );

View File

@@ -121,7 +121,7 @@ if ( class_exists( 'WP_CLI_Command' ) ) {
foreach ( $model->get_files() as $backup ) {
$backups->addRow( array(
'name' => $backup['filename'],
'date' => human_time_diff( $backup['mtime'] ) . __( ' ago', AI1WM_PLUGIN_NAME ),
'date' => sprintf( __( '%s ago', AI1WM_PLUGIN_NAME ), human_time_diff( $backup['mtime'] ) ),
'size' => size_format( $backup['size'], 2 ),
) );
}
@@ -188,7 +188,6 @@ if ( class_exists( 'WP_CLI_Command' ) ) {
try {
// Remove filters
remove_filter( 'ai1wm_export', 'Ai1wm_Export_Resolve::execute', 5 );
remove_filter( 'ai1wm_export', 'Ai1wm_Export_Clean::execute', 300 );
// Run filters
@@ -251,7 +250,6 @@ if ( class_exists( 'WP_CLI_Command' ) ) {
// Remove filters
remove_filter( 'ai1wm_import', 'Ai1wm_Import_Upload::execute', 5 );
remove_filter( 'ai1wm_import', 'Ai1wm_Import_Resolve::execute', 10 );
remove_filter( 'ai1wm_import', 'Ai1wm_Import_Confirm::execute', 100 );
remove_filter( 'ai1wm_import', 'Ai1wm_Import_Clean::execute', 400 );

View File

@@ -53,6 +53,20 @@ abstract class Ai1wm_Database {
*/
protected $new_table_prefixes = array();
/**
* Old column prefixes
*
* @var array
*/
protected $old_column_prefixes = array();
/**
* New column prefixes
*
* @var array
*/
protected $new_column_prefixes = array();
/**
* Old replace values
*
@@ -185,6 +199,48 @@ abstract class Ai1wm_Database {
return $this->new_table_prefixes;
}
/**
* Set old column prefixes
*
* @param array $prefixes List of column prefixes
* @return Ai1wm_Database
*/
public function set_old_column_prefixes( $prefixes ) {
$this->old_column_prefixes = $prefixes;
return $this;
}
/**
* Get old column prefixes
*
* @return array
*/
public function get_old_column_prefixes() {
return $this->old_column_prefixes;
}
/**
* Set new column prefixes
*
* @param array $prefixes List of column prefixes
* @return Ai1wm_Database
*/
public function set_new_column_prefixes( $prefixes ) {
$this->new_column_prefixes = $prefixes;
return $this;
}
/**
* Get new column prefixes
*
* @return array
*/
public function get_new_column_prefixes() {
return $this->new_column_prefixes;
}
/**
* Set old replace values
*
@@ -610,7 +666,7 @@ abstract class Ai1wm_Database {
foreach ( $row as $key => $value ) {
// Replace table prefix columns
if ( isset( $columns[ strtolower( $key ) ] ) ) {
$value = $this->replace_table_prefixes( $value, 0 );
$value = $this->replace_column_prefixes( $value, 0 );
}
// Replace table values
@@ -906,8 +962,8 @@ abstract class Ai1wm_Database {
/**
* Replace table prefixes
*
* @param string $input Table value
* @param bool $position Replace first occurrence at a specified position
* @param string $input Table value
* @param mixed $position Replace first occurrence at a specified position
* @return string
*/
protected function replace_table_prefixes( $input, $position = false ) {
@@ -931,6 +987,34 @@ abstract class Ai1wm_Database {
return str_ireplace( $search, $replace, $input );
}
/**
* Replace column prefixes
*
* @param string $input Column value
* @param mixed $position Replace first occurrence at a specified position
* @return string
*/
protected function replace_column_prefixes( $input, $position = false ) {
// Get column prefixes
$search = $this->get_old_column_prefixes();
$replace = $this->get_new_column_prefixes();
// Replace first occurance at a specified position
if ( $position !== false ) {
for ( $i = 0; $i < count( $search ); $i++ ) {
$current = stripos( $input, $search[ $i ] );
if ( $current === $position ) {
$input = substr_replace( $input, $replace[ $i ], $current, strlen( $search[ $i ] ) );
}
}
return $input;
}
// Replace all occurrences
return str_ireplace( $search, $replace, $input );
}
/**
* Replace table values
*

View File

@@ -26,20 +26,27 @@
class Ai1wm_Directory {
/**
* Delete directory and its contents
* The method will recursively delete a directory and its contents.
* Create directory (recursively)
*
* @param string $path Path to the directory
* @param string $path Path to the directory
* @return boolean
*/
public static function create( $path ) {
return @mkdir( $path, 0777, true );
}
/**
* Delete directory (recursively)
*
* @throws UnexpectedValueException
* @param string $path Path to the directory
* @return boolean
*/
public static function delete( $path ) {
// Iterate over directory
$iterator = new Ai1wm_Recursive_Directory_Iterator( $path );
// Recursively iterate over directory
$iterator = new RecursiveIteratorIterator( $iterator, RecursiveIteratorIterator::CHILD_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD );
$iterator = new Ai1wm_Recursive_Iterator_Iterator( $iterator, RecursiveIteratorIterator::CHILD_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD );
// Remove files and directories
foreach ( $iterator as $item ) {
@@ -50,7 +57,6 @@ class Ai1wm_Directory {
}
}
// Remove path
return @rmdir( $path );
}
}

View File

@@ -24,23 +24,38 @@
*/
class Ai1wm_File_Htaccess {
/**
* Create .htaccess file
* Create .htaccess file (ServMask)
*
* The method will create .htaccess file with contents 'AddType application/octet-stream .wpress'
*
* @param string $path Path to the backups directory
* @param string $path Path to file
* @return boolean
*/
public static function create( $path ) {
$contents = "<IfModule mod_mime.c>\n" .
"AddType application/octet-stream .wpress\n" .
"</IfModule>\n" .
"<IfModule mod_dir.c>\n" .
"DirectoryIndex index.php\n" .
"</IfModule>\n" .
"Options -Indexes\n";
return Ai1wm_File::create( $path, implode( PHP_EOL, array(
'<IfModule mod_mime.c>',
'AddType application/octet-stream .wpress',
'</IfModule>',
'<IfModule mod_dir.c>',
'DirectoryIndex index.php',
'</IfModule>',
'<IfModule mod_autoindex.c>',
'Options -Indexes',
'</IfModule>',
) ) );
}
return Ai1wm_File::create( $path, $contents );
/**
* Create .htaccess file (LiteSpeed)
*
* @param string $path Path to file
* @return boolean
*/
public static function litespeed( $path ) {
return Ai1wm_File::create_with_markers( $path, 'LiteSpeed', array(
'<IfModule Litespeed>',
'SetEnv noabort 1',
'</IfModule>',
) );
}
}

View File

@@ -26,17 +26,12 @@
class Ai1wm_File_Index {
/**
* Create a index.php file
* Create index.php file
*
* The method will create index.php file with contents '<?php // silence is golden' without the single quotes
* at the path specified by the argument.
*
* @param string $path Path to the index.php file
* @param string $path Path to file
* @return boolean
*/
public static function create( $path ) {
$contents = '<?php // silence is golden';
return Ai1wm_File::create( $path, $contents );
return Ai1wm_File::create( $path, '<?php // silence is golden' );
}
}

View File

@@ -28,26 +28,23 @@ class Ai1wm_File_Webconfig {
/**
* Create web.config file
*
* The method will create web.config file with contents '<mimeMap fileExtension=".wpress" mimeType="application/octet-stream" />'
*
* @param string $path Path to the web.config file
* @param string $path Path to file
* @return boolean
*/
public static function create( $path ) {
$contents = "<configuration>\n" .
"<system.webServer>\n" .
"<staticContent>\n" .
"<mimeMap fileExtension=\".wpress\" mimeType=\"application/octet-stream\" />\n" .
"</staticContent>\n" .
"<defaultDocument>\n" .
"<files>\n" .
"<add value=\"index.php\" />\n" .
"</files>\n" .
"</defaultDocument>\n" .
"<directoryBrowse enabled=\"false\" />\n" .
"</system.webServer>\n" .
"</configuration>\n";
return Ai1wm_File::create( $path, $contents );
return Ai1wm_File::create( $path, implode( PHP_EOL, array(
'<configuration>',
'<system.webServer>',
'<mimeMap fileExtension=".wpress" mimeType="application/octet-stream" />',
'</staticContent>',
'<defaultDocument>',
'<files>',
'<add value="index.php" />',
'</files>',
'</defaultDocument>',
'<directoryBrowse enabled="false" />',
'</system.webServer>',
'</configuration>',
) ) );
}
}

View File

@@ -26,17 +26,28 @@
class Ai1wm_File {
/**
* Create a file with contents
*
* @param string $path Path to the file
* @param string $contents Contents of the file
* Create a file with content
*
* @param string $path Path to the file
* @param string $content Content of the file
* @return boolean
*/
public static function create( $path, $contents ) {
public static function create( $path, $content ) {
if ( ! @file_exists( $path ) ) {
if ( ! @is_writable( dirname( $path ) ) ) {
return false;
}
if ( ! @touch( $path ) ) {
return false;
}
} elseif ( ! @is_writable( $path ) ) {
return false;
}
$is_written = false;
if ( ( $handle = @fopen( $path, 'w' ) ) !== false ) {
if ( @fwrite( $handle, $contents ) !== false ) {
if ( @fwrite( $handle, $content ) !== false ) {
$is_written = true;
}
@@ -45,4 +56,16 @@ class Ai1wm_File {
return $is_written;
}
/**
* Create a file with marker and content
*
* @param string $path Path to the file
* @param string $marker Name of the marker
* @param string $content Content of the file
* @return boolean
*/
public static function create_with_markers( $path, $marker, $content ) {
return @insert_with_markers( $path, $marker, $content );
}
}

View File

@@ -0,0 +1,50 @@
<?php
/**
* Copyright (C) 2014-2018 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/>.
*
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
*/
class Ai1wm_Recursive_Extension_Filter extends RecursiveFilterIterator {
protected $include = array();
public function __construct( RecursiveIterator $iterator, $include = array() ) {
parent::__construct( $iterator );
// Set include filter
$this->include = $include;
}
public function accept() {
if ( $this->getInnerIterator()->isFile() ) {
if ( ! in_array( pathinfo( $this->getInnerIterator()->getFilename(), PATHINFO_EXTENSION ), $this->include ) ) {
return false;
}
}
return true;
}
public function getChildren() {
return new self( $this->getInnerIterator()->getChildren(), $this->include );
}
}

View File

@@ -25,8 +25,6 @@
class Ai1wm_Recursive_Directory_Iterator extends RecursiveDirectoryIterator {
protected $exclude = array();
public function __construct( $path ) {
parent::__construct( $path );

View File

@@ -0,0 +1,28 @@
<?php
/**
* Copyright (C) 2014-2018 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/>.
*
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
*/
class Ai1wm_Recursive_Iterator_Iterator extends RecursiveIteratorIterator {
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -174,11 +174,11 @@ Import.prototype.start = function (options, retries) {
// Initializing beforeunload event
$(window).bind('beforeunload', function () {
return 'You are about to stop importing your website, are you sure?';
return ai1wm_locale.stop_importing_your_website;
});
// Set initial status
this.setStatus({ type: 'info', message: 'Preparing to import...' });
this.setStatus({ type: 'info', message: ai1wm_locale.preparing_to_import });
// Set params
var params = this.params.concat({ name: 'secret_key', value: ai1wm_import.secret_key });
@@ -208,8 +208,8 @@ Import.prototype.start = function (options, retries) {
if (retries >= 5) {
return self.setStatus({
type: 'error',
title: 'Unable to import',
message: 'Unable to start the import. Refresh the page and try again'
title: ai1wm_locale.unable_to_import,
message: ai1wm_locale.unable_to_start_the_import
});
}
@@ -287,8 +287,8 @@ Import.prototype.confirm = function (options, retries) {
if (retries >= 5) {
return self.setStatus({
type: 'error',
title: 'Unable to import',
message: 'Unable to confirm the import. Refresh the page and try again'
title: ai1wm_locale.unable_to_import,
message: ai1wm_locale.unable_to_confirm_the_import
});
}
@@ -335,8 +335,8 @@ Import.prototype.blogs = function (options, retries) {
if (retries >= 5) {
return self.setStatus({
type: 'error',
title: 'Unable to import',
message: 'Unable to prepare blogs the import. Refresh the page and try again'
title: ai1wm_locale.unable_to_import,
message: ai1wm_locale.unable_to_prepare_blogs_on_import
});
}
@@ -354,7 +354,7 @@ Import.prototype.clean = function (options, retries) {
this.stopImport = true;
// Set initial status
this.setStatus({ type: 'info', message: 'Please wait, stopping the import...' });
this.setStatus({ type: 'info', message: ai1wm_locale.please_wait_stopping_the_export });
// Set params
var params = this.params.concat({ name: 'secret_key', value: ai1wm_import.secret_key }).concat({ name: 'priority', value: 400 });
@@ -384,8 +384,8 @@ Import.prototype.clean = function (options, retries) {
if (retries >= 5) {
return self.setStatus({
type: 'error',
title: 'Unable to import',
message: 'Unable to stop the import. Refresh the page and try again'
title: ai1wm_locale.unable_to_import,
message: ai1wm_locale.unable_to_stop_the_import
});
}
@@ -515,11 +515,14 @@ var Modal = function Modal() {
var title = $('<span></span>').addClass('ai1wm-title-red').text(params.title);
// Create close button
var closeButton = $('<button type="button" class="ai1wm-button-red">Close</button>').on('click', function () {
var closeButton = $('<button type="button" class="ai1wm-button-red"></button>').on('click', function () {
self.destroy();
});
// Append close button
// Append text to close button
closeButton.append(ai1wm_locale.close_import);
// Append close button to action
action.append(closeButton);
// Append title to section
@@ -540,10 +543,10 @@ var Modal = function Modal() {
this.progress = function (params) {
if (this.view === 'progress') {
// Update progressBarMeter
// Update progress bar meter
this.progress.progressBarMeter.width(params.percent + '%');
// Update progressBarPercent
// Update progress bar percent
this.progress.progressBarPercent.text(params.percent + '%');
} else {
@@ -562,25 +565,28 @@ var Modal = function Modal() {
// Create action section
var action = $('<div></div>');
// Create progressBar
// Create progress bar
var progressBar = $('<span class="ai1wm-progress-bar"></span>');
// Create progressBarMeter
// Create progress bar meter
this.progress.progressBarMeter = $('<span class="ai1wm-progress-bar-meter"></span>').width(params.percent + '%');
// Create progressBarPercent
this.progress.progressBarPercent = $('<span class="ai1wm-progress-bar-percent">0%</span>').text(params.percent + '%');
// Create progress bar percent
this.progress.progressBarPercent = $('<span class="ai1wm-progress-bar-percent"></span>').text(params.percent + '%');
// Create stop import
var stopButton = $('<button type="button" class="ai1wm-button-red"><i class="ai1wm-icon-notification"></i> Stop import</button>').on('click', function () {
var stopButton = $('<button type="button" class="ai1wm-button-red"></button>').on('click', function () {
$(this).attr('disabled', 'disabled');
self.onStop();
});
// Append text to stop button
stopButton.append('<i class="ai1wm-icon-notification"></i> ' + ai1wm_locale.stop_import);
// Append progress meter and progress percent
progressBar.append(this.progress.progressBarMeter).append(this.progress.progressBarPercent);
// Append stop button
// Append stop button to action
action.append(stopButton);
// Append progress bar to section
@@ -619,22 +625,28 @@ var Modal = function Modal() {
// Create warning
var warning = $('<i class="ai1wm-icon-notification"></i>');
// Create cancel button
var cancelButton = $('<button type="button" class="ai1wm-button-gray">Cancel</button>').on('click', function () {
// Create close button
var closeButton = $('<button type="button" class="ai1wm-button-gray"></button>').on('click', function () {
$(this).attr('disabled', 'disabled');
self.onStop();
});
// Create confirm button
var confirmButton = $('<button type="button" class="ai1wm-button-green">Proceed &gt;</button>').on('click', function () {
var confirmButton = $('<button type="button" class="ai1wm-button-green"></button>').on('click', function () {
$(this).attr('disabled', 'disabled');
self.onConfirm();
});
// Append cancel button
action.append(cancelButton);
// Append text to close button
closeButton.append(ai1wm_locale.close_import);
// Append confirm button
// Append text to confirm button
confirmButton.append(ai1wm_locale.confirm_import + ' &gt;');
// Append close button to action
action.append(closeButton);
// Append confirm button to action
action.append(confirmButton);
// Append warning to section
@@ -673,12 +685,15 @@ var Modal = function Modal() {
var title = $('<span></span>').addClass('ai1wm-title-grey').text(params.title);
// Create continue button
var continueButton = $('<button type="button" class="ai1wm-button-green">Continue</button>').on('click', function () {
var continueButton = $('<button type="button" class="ai1wm-button-green"></button>').on('click', function () {
$(this).attr('disabled', 'disabled');
self.onBlogs($(this).closest('form').serializeArray());
});
// Append continue button
// Append text to continue button
continueButton.append(ai1wm_locale.continue_import);
// Append continue button to action
action.append(continueButton);
// Append title to section
@@ -716,11 +731,17 @@ var Modal = function Modal() {
// Create loader
var loader = $('<span class="ai1wm-loader"></span>');
// Create notice to be displayed during import process
var importNotice = $('<div class="ai1wm-import-modal-notice"><p>Please do not close this browser window or your import will fail</p></div>');
// Create warning
var warning = $('<p></p>').html(ai1wm_locale.please_do_not_close_this_browser);
// Append stop button
action.append(importNotice);
// Create notice to be displayed during import process
var notice = $('<div class="ai1wm-import-modal-notice"></div>');
// Append warning to notice
notice.append(warning);
// Append stop button to action
action.append(notice);
// Append loader to header
header.append(loader);
@@ -758,11 +779,14 @@ var Modal = function Modal() {
var title = $('<span></span>').addClass('ai1wm-title-green').text(params.title);
// Create close button
var closeButton = $('<button type="button" class="ai1wm-button-red">Close</button>').on('click', function () {
var closeButton = $('<button type="button" class="ai1wm-button-red"></button>').on('click', function () {
self.destroy();
});
// Append close button
// Append text to close button
closeButton.append(ai1wm_locale.close_import);
// Append close button to action
action.append(closeButton);
// Append title to section
@@ -883,7 +907,7 @@ jQuery(document).ready(function ($) {
$('#ai1wm-feedback-type-1, #ai1wm-feedback-type-3').closest('li').hide();
// Change placeholder message
$('.ai1wm-feedback-form').find('.ai1wm-feedback-message').attr('placeholder', 'Leave plugin developers any feedback here');
$('.ai1wm-feedback-form').find('.ai1wm-feedback-message').attr('placeholder', ai1wm_locale.leave_feedback);
// Show feedback form
$('.ai1wm-feedback-form').fadeIn();
@@ -895,7 +919,7 @@ jQuery(document).ready(function ($) {
$('#ai1wm-feedback-type-1, #ai1wm-feedback-type-2').closest('li').hide();
// Change placeholder message
$('.ai1wm-feedback-form').find('.ai1wm-feedback-message').attr('placeholder', 'How may we help you?');
$('.ai1wm-feedback-form').find('.ai1wm-feedback-message').attr('placeholder', ai1wm_locale.how_may_we_help_you);
// Show feedback form
$('.ai1wm-feedback-form').fadeIn();
@@ -947,13 +971,13 @@ jQuery(document).ready(function ($) {
var errorMessage = $('<div />').addClass('ai1wm-message ai1wm-error-message');
$.each(data.errors, function (key, value) {
errorMessage.append('<p>' + value + '</p>');
errorMessage.append($('<p />').text(value));
});
$('.ai1wm-feedback').prepend(errorMessage);
} else {
var successMessage = $('<div />').addClass('ai1wm-message ai1wm-success-message');
successMessage.append('<p>Thanks for submitting your feedback!</p>');
successMessage.append($('<p />').text(ai1wm_locale.thanks_for_submitting_your_feedback));
$('.ai1wm-feedback').html(successMessage);
}
@@ -1013,7 +1037,7 @@ jQuery(document).ready(function ($) {
var self = $(this);
// Delete file
if (confirm('Are you sure you want to delete this file?')) {
if (confirm(ai1wm_locale.want_to_delete_this_file)) {
$.ajax({
url: ai1wm_backups.ajax.url,
type: 'POST',
@@ -1140,13 +1164,13 @@ jQuery(document).ready(function ($) {
var errorMessage = $('<div />').addClass('ai1wm-message ai1wm-error-message');
$.each(data.errors, function (key, value) {
errorMessage.append('<p>' + value + '</p>');
errorMessage.append($('<p />').text(value));
});
$('.ai1wm-report-problem-dialog').prepend(errorMessage);
} else {
var successMessage = $('<div />').addClass('ai1wm-message ai1wm-success-message');
successMessage.append('<p>Thanks for submitting your request!</p>');
successMessage.append($('<p />').text(ai1wm_locale.thanks_for_submitting_your_request));
$('.ai1wm-report-problem-dialog').html(successMessage);

View File

@@ -146,7 +146,7 @@ jQuery(document).ready(function ($) {
$('#ai1wm-feedback-type-1, #ai1wm-feedback-type-3').closest('li').hide();
// Change placeholder message
$('.ai1wm-feedback-form').find('.ai1wm-feedback-message').attr('placeholder', 'Leave plugin developers any feedback here');
$('.ai1wm-feedback-form').find('.ai1wm-feedback-message').attr('placeholder', ai1wm_locale.leave_feedback);
// Show feedback form
$('.ai1wm-feedback-form').fadeIn();
@@ -158,7 +158,7 @@ jQuery(document).ready(function ($) {
$('#ai1wm-feedback-type-1, #ai1wm-feedback-type-2').closest('li').hide();
// Change placeholder message
$('.ai1wm-feedback-form').find('.ai1wm-feedback-message').attr('placeholder', 'How may we help you?');
$('.ai1wm-feedback-form').find('.ai1wm-feedback-message').attr('placeholder', ai1wm_locale.how_may_we_help_you);
// Show feedback form
$('.ai1wm-feedback-form').fadeIn();
@@ -210,13 +210,13 @@ jQuery(document).ready(function ($) {
var errorMessage = $('<div />').addClass('ai1wm-message ai1wm-error-message');
$.each(data.errors, function (key, value) {
errorMessage.append('<p>' + value + '</p>');
errorMessage.append($('<p />').text(value));
});
$('.ai1wm-feedback').prepend(errorMessage);
} else {
var successMessage = $('<div />').addClass('ai1wm-message ai1wm-success-message');
successMessage.append('<p>Thanks for submitting your feedback!</p>');
successMessage.append($('<p />').text(ai1wm_locale.thanks_for_submitting_your_feedback));
$('.ai1wm-feedback').html(successMessage);
}
@@ -307,13 +307,13 @@ jQuery(document).ready(function ($) {
var errorMessage = $('<div />').addClass('ai1wm-message ai1wm-error-message');
$.each(data.errors, function (key, value) {
errorMessage.append('<p>' + value + '</p>');
errorMessage.append($('<p />').text(value));
});
$('.ai1wm-report-problem-dialog').prepend(errorMessage);
} else {
var successMessage = $('<div />').addClass('ai1wm-message ai1wm-success-message');
successMessage.append('<p>Thanks for submitting your request!</p>');
successMessage.append($('<p />').text(ai1wm_locale.thanks_for_submitting_your_request));
$('.ai1wm-report-problem-dialog').html(successMessage);
@@ -593,11 +593,11 @@ Export.prototype.start = function (options, retries) {
// Initializing beforeunload event
$(window).bind('beforeunload', function () {
return 'You are about to stop exporting your website, are you sure?';
return ai1wm_locale.stop_exporting_your_website;
});
// Set initial status
this.setStatus({ type: 'info', message: 'Preparing to export...' });
this.setStatus({ type: 'info', message: ai1wm_locale.preparing_to_export });
// Set params
var params = this.params.concat({ name: 'secret_key', value: ai1wm_export.secret_key });
@@ -627,8 +627,8 @@ Export.prototype.start = function (options, retries) {
if (retries >= 5) {
return self.setStatus({
type: 'error',
title: 'Unable to export',
message: 'Unable to start the export. Refresh the page and try again'
title: ai1wm_locale.unable_to_export,
message: ai1wm_locale.unable_to_start_the_export
});
}
@@ -665,8 +665,8 @@ Export.prototype.run = function (params, retries) {
if (retries >= 5) {
return self.setStatus({
type: 'error',
title: 'Unable to export',
message: 'Unable to run the export. Refresh the page and try again'
title: ai1wm_locale.unable_to_export,
message: ai1wm_locale.unable_to_run_the_export
});
}
@@ -684,7 +684,7 @@ Export.prototype.clean = function (options, retries) {
this.stopExport = true;
// Set initial status
this.setStatus({ type: 'info', message: 'Please wait, stopping the export...' });
this.setStatus({ type: 'info', message: ai1wm_locale.please_wait_stopping_the_export });
// Set params
var params = this.params.concat({ name: 'secret_key', value: ai1wm_export.secret_key }).concat({ name: 'priority', value: 300 });
@@ -714,8 +714,8 @@ Export.prototype.clean = function (options, retries) {
if (retries >= 5) {
return self.setStatus({
type: 'error',
title: 'Unable to export',
message: 'Unable to stop the export. Refresh the page and try again'
title: ai1wm_locale.unable_to_export,
message: ai1wm_locale.unable_to_stop_the_export
});
}
@@ -833,11 +833,14 @@ var Modal = function Modal() {
var title = $('<span></span>').addClass('ai1wm-title-red').text(params.title);
// Create close button
var closeButton = $('<button type="button" class="ai1wm-button-red">Close</button>').on('click', function () {
var closeButton = $('<button type="button" class="ai1wm-button-red"></button>').on('click', function () {
self.destroy();
});
// Append close button
// Append text to close button
closeButton.append(ai1wm_locale.close_export);
// Append close button to action
action.append(closeButton);
// Append title to section
@@ -876,12 +879,15 @@ var Modal = function Modal() {
var loader = $('<span class="ai1wm-loader"></span>');
// Create stop export
var stopButton = $('<button type="button" class="ai1wm-button-red"><i class="ai1wm-icon-notification"></i> Stop export</button>').on('click', function () {
var stopButton = $('<button type="button" class="ai1wm-button-red"></button>').on('click', function () {
$(this).attr('disabled', 'disabled');
self.onStop();
});
// Append stop button
// Append text to stop button
stopButton.append('<i class="ai1wm-icon-notification"></i> ' + ai1wm_locale.stop_export);
// Append stop button to action
action.append(stopButton);
// Append loader to header
@@ -920,11 +926,14 @@ var Modal = function Modal() {
var title = $('<span></span>').addClass('ai1wm-title-green').text(params.title);
// Create close button
var closeButton = $('<button type="button" class="ai1wm-button-red">Close</button>').on('click', function () {
var closeButton = $('<button type="button" class="ai1wm-button-red"></button>').on('click', function () {
self.destroy();
});
// Append close button
// Append text to close button
closeButton.append(ai1wm_locale.close_export);
// Append close button to action
action.append(closeButton);
// Append title to section
@@ -960,11 +969,14 @@ var Modal = function Modal() {
var action = $('<div></div>');
// Create close button
var closeButton = $('<button type="button" class="ai1wm-button-red">Close</button>').on('click', function () {
var closeButton = $('<button type="button" class="ai1wm-button-red"></button>').on('click', function () {
self.destroy();
});
// Append close button
// Append text to close button
closeButton.append(ai1wm_locale.close_export);
// Append close button to action
action.append(closeButton);
// Append message to section

View File

@@ -146,7 +146,7 @@ jQuery(document).ready(function ($) {
$('#ai1wm-feedback-type-1, #ai1wm-feedback-type-3').closest('li').hide();
// Change placeholder message
$('.ai1wm-feedback-form').find('.ai1wm-feedback-message').attr('placeholder', 'Leave plugin developers any feedback here');
$('.ai1wm-feedback-form').find('.ai1wm-feedback-message').attr('placeholder', ai1wm_locale.leave_feedback);
// Show feedback form
$('.ai1wm-feedback-form').fadeIn();
@@ -158,7 +158,7 @@ jQuery(document).ready(function ($) {
$('#ai1wm-feedback-type-1, #ai1wm-feedback-type-2').closest('li').hide();
// Change placeholder message
$('.ai1wm-feedback-form').find('.ai1wm-feedback-message').attr('placeholder', 'How may we help you?');
$('.ai1wm-feedback-form').find('.ai1wm-feedback-message').attr('placeholder', ai1wm_locale.how_may_we_help_you);
// Show feedback form
$('.ai1wm-feedback-form').fadeIn();
@@ -210,13 +210,13 @@ jQuery(document).ready(function ($) {
var errorMessage = $('<div />').addClass('ai1wm-message ai1wm-error-message');
$.each(data.errors, function (key, value) {
errorMessage.append('<p>' + value + '</p>');
errorMessage.append($('<p />').text(value));
});
$('.ai1wm-feedback').prepend(errorMessage);
} else {
var successMessage = $('<div />').addClass('ai1wm-message ai1wm-success-message');
successMessage.append('<p>Thanks for submitting your feedback!</p>');
successMessage.append($('<p />').text(ai1wm_locale.thanks_for_submitting_your_feedback));
$('.ai1wm-feedback').html(successMessage);
}

View File

@@ -173,7 +173,7 @@ jQuery(document).ready(function ($) {
$('#ai1wm-feedback-type-1, #ai1wm-feedback-type-3').closest('li').hide();
// Change placeholder message
$('.ai1wm-feedback-form').find('.ai1wm-feedback-message').attr('placeholder', 'Leave plugin developers any feedback here');
$('.ai1wm-feedback-form').find('.ai1wm-feedback-message').attr('placeholder', ai1wm_locale.leave_feedback);
// Show feedback form
$('.ai1wm-feedback-form').fadeIn();
@@ -185,7 +185,7 @@ jQuery(document).ready(function ($) {
$('#ai1wm-feedback-type-1, #ai1wm-feedback-type-2').closest('li').hide();
// Change placeholder message
$('.ai1wm-feedback-form').find('.ai1wm-feedback-message').attr('placeholder', 'How may we help you?');
$('.ai1wm-feedback-form').find('.ai1wm-feedback-message').attr('placeholder', ai1wm_locale.how_may_we_help_you);
// Show feedback form
$('.ai1wm-feedback-form').fadeIn();
@@ -237,13 +237,13 @@ jQuery(document).ready(function ($) {
var errorMessage = $('<div />').addClass('ai1wm-message ai1wm-error-message');
$.each(data.errors, function (key, value) {
errorMessage.append('<p>' + value + '</p>');
errorMessage.append($('<p />').text(value));
});
$('.ai1wm-feedback').prepend(errorMessage);
} else {
var successMessage = $('<div />').addClass('ai1wm-message ai1wm-success-message');
successMessage.append('<p>Thanks for submitting your feedback!</p>');
successMessage.append($('<p />').text(ai1wm_locale.thanks_for_submitting_your_feedback));
$('.ai1wm-feedback').html(successMessage);
}
@@ -333,13 +333,13 @@ jQuery(document).ready(function ($) {
var errorMessage = $('<div />').addClass('ai1wm-message ai1wm-error-message');
$.each(data.errors, function (key, value) {
errorMessage.append('<p>' + value + '</p>');
errorMessage.append($('<p />').text(value));
});
$('.ai1wm-report-problem-dialog').prepend(errorMessage);
} else {
var successMessage = $('<div />').addClass('ai1wm-message ai1wm-success-message');
successMessage.append('<p>Thanks for submitting your request!</p>');
successMessage.append($('<p />').text(ai1wm_locale.thanks_for_submitting_your_request));
$('.ai1wm-report-problem-dialog').html(successMessage);
@@ -542,11 +542,11 @@ Import.prototype.start = function (options, retries) {
// Initializing beforeunload event
$(window).bind('beforeunload', function () {
return 'You are about to stop importing your website, are you sure?';
return ai1wm_locale.stop_importing_your_website;
});
// Set initial status
this.setStatus({ type: 'info', message: 'Preparing to import...' });
this.setStatus({ type: 'info', message: ai1wm_locale.preparing_to_import });
// Set params
var params = this.params.concat({ name: 'secret_key', value: ai1wm_import.secret_key });
@@ -576,8 +576,8 @@ Import.prototype.start = function (options, retries) {
if (retries >= 5) {
return self.setStatus({
type: 'error',
title: 'Unable to import',
message: 'Unable to start the import. Refresh the page and try again'
title: ai1wm_locale.unable_to_import,
message: ai1wm_locale.unable_to_start_the_import
});
}
@@ -655,8 +655,8 @@ Import.prototype.confirm = function (options, retries) {
if (retries >= 5) {
return self.setStatus({
type: 'error',
title: 'Unable to import',
message: 'Unable to confirm the import. Refresh the page and try again'
title: ai1wm_locale.unable_to_import,
message: ai1wm_locale.unable_to_confirm_the_import
});
}
@@ -703,8 +703,8 @@ Import.prototype.blogs = function (options, retries) {
if (retries >= 5) {
return self.setStatus({
type: 'error',
title: 'Unable to import',
message: 'Unable to prepare blogs the import. Refresh the page and try again'
title: ai1wm_locale.unable_to_import,
message: ai1wm_locale.unable_to_prepare_blogs_on_import
});
}
@@ -722,7 +722,7 @@ Import.prototype.clean = function (options, retries) {
this.stopImport = true;
// Set initial status
this.setStatus({ type: 'info', message: 'Please wait, stopping the import...' });
this.setStatus({ type: 'info', message: ai1wm_locale.please_wait_stopping_the_export });
// Set params
var params = this.params.concat({ name: 'secret_key', value: ai1wm_import.secret_key }).concat({ name: 'priority', value: 400 });
@@ -752,8 +752,8 @@ Import.prototype.clean = function (options, retries) {
if (retries >= 5) {
return self.setStatus({
type: 'error',
title: 'Unable to import',
message: 'Unable to stop the import. Refresh the page and try again'
title: ai1wm_locale.unable_to_import,
message: ai1wm_locale.unable_to_stop_the_import
});
}
@@ -951,11 +951,14 @@ var Modal = function Modal() {
var title = $('<span></span>').addClass('ai1wm-title-red').text(params.title);
// Create close button
var closeButton = $('<button type="button" class="ai1wm-button-red">Close</button>').on('click', function () {
var closeButton = $('<button type="button" class="ai1wm-button-red"></button>').on('click', function () {
self.destroy();
});
// Append close button
// Append text to close button
closeButton.append(ai1wm_locale.close_import);
// Append close button to action
action.append(closeButton);
// Append title to section
@@ -976,10 +979,10 @@ var Modal = function Modal() {
this.progress = function (params) {
if (this.view === 'progress') {
// Update progressBarMeter
// Update progress bar meter
this.progress.progressBarMeter.width(params.percent + '%');
// Update progressBarPercent
// Update progress bar percent
this.progress.progressBarPercent.text(params.percent + '%');
} else {
@@ -998,25 +1001,28 @@ var Modal = function Modal() {
// Create action section
var action = $('<div></div>');
// Create progressBar
// Create progress bar
var progressBar = $('<span class="ai1wm-progress-bar"></span>');
// Create progressBarMeter
// Create progress bar meter
this.progress.progressBarMeter = $('<span class="ai1wm-progress-bar-meter"></span>').width(params.percent + '%');
// Create progressBarPercent
this.progress.progressBarPercent = $('<span class="ai1wm-progress-bar-percent">0%</span>').text(params.percent + '%');
// Create progress bar percent
this.progress.progressBarPercent = $('<span class="ai1wm-progress-bar-percent"></span>').text(params.percent + '%');
// Create stop import
var stopButton = $('<button type="button" class="ai1wm-button-red"><i class="ai1wm-icon-notification"></i> Stop import</button>').on('click', function () {
var stopButton = $('<button type="button" class="ai1wm-button-red"></button>').on('click', function () {
$(this).attr('disabled', 'disabled');
self.onStop();
});
// Append text to stop button
stopButton.append('<i class="ai1wm-icon-notification"></i> ' + ai1wm_locale.stop_import);
// Append progress meter and progress percent
progressBar.append(this.progress.progressBarMeter).append(this.progress.progressBarPercent);
// Append stop button
// Append stop button to action
action.append(stopButton);
// Append progress bar to section
@@ -1055,22 +1061,28 @@ var Modal = function Modal() {
// Create warning
var warning = $('<i class="ai1wm-icon-notification"></i>');
// Create cancel button
var cancelButton = $('<button type="button" class="ai1wm-button-gray">Cancel</button>').on('click', function () {
// Create close button
var closeButton = $('<button type="button" class="ai1wm-button-gray"></button>').on('click', function () {
$(this).attr('disabled', 'disabled');
self.onStop();
});
// Create confirm button
var confirmButton = $('<button type="button" class="ai1wm-button-green">Proceed &gt;</button>').on('click', function () {
var confirmButton = $('<button type="button" class="ai1wm-button-green"></button>').on('click', function () {
$(this).attr('disabled', 'disabled');
self.onConfirm();
});
// Append cancel button
action.append(cancelButton);
// Append text to close button
closeButton.append(ai1wm_locale.close_import);
// Append confirm button
// Append text to confirm button
confirmButton.append(ai1wm_locale.confirm_import + ' &gt;');
// Append close button to action
action.append(closeButton);
// Append confirm button to action
action.append(confirmButton);
// Append warning to section
@@ -1109,12 +1121,15 @@ var Modal = function Modal() {
var title = $('<span></span>').addClass('ai1wm-title-grey').text(params.title);
// Create continue button
var continueButton = $('<button type="button" class="ai1wm-button-green">Continue</button>').on('click', function () {
var continueButton = $('<button type="button" class="ai1wm-button-green"></button>').on('click', function () {
$(this).attr('disabled', 'disabled');
self.onBlogs($(this).closest('form').serializeArray());
});
// Append continue button
// Append text to continue button
continueButton.append(ai1wm_locale.continue_import);
// Append continue button to action
action.append(continueButton);
// Append title to section
@@ -1152,11 +1167,17 @@ var Modal = function Modal() {
// Create loader
var loader = $('<span class="ai1wm-loader"></span>');
// Create notice to be displayed during import process
var importNotice = $('<div class="ai1wm-import-modal-notice"><p>Please do not close this browser window or your import will fail</p></div>');
// Create warning
var warning = $('<p></p>').html(ai1wm_locale.please_do_not_close_this_browser);
// Append stop button
action.append(importNotice);
// Create notice to be displayed during import process
var notice = $('<div class="ai1wm-import-modal-notice"></div>');
// Append warning to notice
notice.append(warning);
// Append stop button to action
action.append(notice);
// Append loader to header
header.append(loader);
@@ -1194,11 +1215,14 @@ var Modal = function Modal() {
var title = $('<span></span>').addClass('ai1wm-title-green').text(params.title);
// Create close button
var closeButton = $('<button type="button" class="ai1wm-button-red">Close</button>').on('click', function () {
var closeButton = $('<button type="button" class="ai1wm-button-red"></button>').on('click', function () {
self.destroy();
});
// Append close button
// Append text to close button
closeButton.append(ai1wm_locale.close_import);
// Append close button to action
action.append(closeButton);
// Append title to section
@@ -1912,7 +1936,7 @@ FileUploader.prototype.upload = function (file, retries) {
}).catch(function (error) {
var timeout = retries * 1000;
if (retries >= 30) {
return _this2.onError(new Error('We are sorry, there seems to be a problem while uploading your file. Follow <a href="https://www.youtube.com/watch?v=mRp7qTFYKgs" target="_blank">this guide</a> to resolve it.'));
return _this2.onError(new Error(ai1wm_locale.problem_while_uploading_your_file));
}
retries++;
@@ -1938,7 +1962,7 @@ FileUploader.prototype.checkSize = function (file) {
var size = parseInt(ai1wm_uploader.filters.ai1wm_archive_size, 10);
if (file.size > size && size !== 0) {
throw new Error(ai1wm_import.oversize);
throw new Error(ai1wm_locale.invalid_archive_size);
}
};
@@ -1950,7 +1974,7 @@ FileUploader.prototype.checkExtension = function (file) {
});
if (!matchExtension) {
throw new Error(ai1wm_import.invalid_extension);
throw new Error(ai1wm_locale.invalid_archive_extension);
}
};
@@ -1960,7 +1984,7 @@ FileUploader.prototype.onFilesAdded = function (file) {
// Initializing beforeunload event
$(window).bind('beforeunload', function () {
return 'You are about to stop importing your website, are you sure?';
return ai1wm_locale.stop_importing_your_website;
});
};
@@ -2000,7 +2024,7 @@ FileUploader.prototype.onFileUploaded = function () {
};
FileUploader.prototype.onError = function (error) {
this.model.setStatus({ type: 'error', title: 'Unable to import', message: error.message });
this.model.setStatus({ type: 'error', title: ai1wm_locale.unable_to_import, message: error.message });
};
module.exports = FileUploader;

View File

@@ -172,13 +172,13 @@ jQuery(document).ready(function ($) {
var errorMessage = $('<div />').addClass('ai1wm-message ai1wm-error-message');
$.each(data.errors, function (key, value) {
errorMessage.append('<p>' + value + '</p>');
errorMessage.append($('<p />').text(value));
});
$('.ai1wm-report-problem-dialog').prepend(errorMessage);
} else {
var successMessage = $('<div />').addClass('ai1wm-message ai1wm-success-message');
successMessage.append('<p>Thanks for submitting your request!</p>');
successMessage.append($('<p />').text(ai1wm_locale.thanks_for_submitting_your_request));
$('.ai1wm-report-problem-dialog').html(successMessage);

View File

@@ -134,13 +134,13 @@ jQuery(document).ready(function ($) {
window.location.hash = '';
// Update plugin row
$('#ai1wm-update-section-' + index).html($('<a />').attr('href', updateLink).text('Check for updates'));
$('#ai1wm-update-section-' + index).html($('<a />').attr('href', updateLink).text(ai1wm_locale.check_for_updates));
self.attr('disabled', false);
});
}).fail(function () {
self.attr('disabled', false);
error.html('Your purchase ID is invalid, please <a href="mailto:support@servmask.com">contact us</a>');
error.html(ai1wm_locale.invalid_purchase_id);
});
e.preventDefault();

View File

@@ -61,7 +61,7 @@
<?php echo esc_html( basename( $backup['filename'] ) ); ?>
</td>
<td class="ai1wm-column-date">
<?php echo human_time_diff( $backup['mtime'] ); ?> <?php _e( 'ago', AI1WM_PLUGIN_NAME ); ?>
<?php echo esc_html( sprintf( __( '%s ago', AI1WM_PLUGIN_NAME ), human_time_diff( $backup['mtime'] ) ) ); ?>
</td>
<td class="ai1wm-column-size">
<?php if ( is_null( $backup['size'] ) ) : ?>

View File

@@ -0,0 +1,41 @@
<?php
/**
* Copyright (C) 2014-2018 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/>.
*
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
*/
?>
<div class="error">
<p>
<?php
printf(
__(
'All in One WP Migration is not able to create <strong>%s</strong> file. ' .
'Try to change permissions of the parent folder or send us an email at ' .
'<a href="mailto:support@servmask.com">support@servmask.com</a> for assistance.',
AI1WM_PLUGIN_NAME
),
AI1WM_WORDPRESS_HTACCESS
)
?>
</p>
</div>

View File

@@ -101,13 +101,21 @@ require_once AI1WM_VENDOR_PATH .
DIRECTORY_SEPARATOR .
'class-ai1wm-recursive-directory-iterator.php';
require_once AI1WM_VENDOR_PATH .
DIRECTORY_SEPARATOR .
'servmask' .
DIRECTORY_SEPARATOR .
'iterator' .
DIRECTORY_SEPARATOR .
'class-ai1wm-recursive-iterator-iterator.php';
require_once AI1WM_VENDOR_PATH .
DIRECTORY_SEPARATOR .
'servmask' .
DIRECTORY_SEPARATOR .
'filter' .
DIRECTORY_SEPARATOR .
'class-ai1wm-extension-filter.php';
'class-ai1wm-recursive-extension-filter.php';
require_once AI1WM_VENDOR_PATH .
DIRECTORY_SEPARATOR .
@@ -203,10 +211,6 @@ require_once AI1WM_CONTROLLER_PATH .
DIRECTORY_SEPARATOR .
'class-ai1wm-status-controller.php';
require_once AI1WM_CONTROLLER_PATH .
DIRECTORY_SEPARATOR .
'class-ai1wm-resolve-controller.php';
require_once AI1WM_CONTROLLER_PATH .
DIRECTORY_SEPARATOR .
'class-ai1wm-backups-controller.php';
@@ -231,10 +235,6 @@ require_once AI1WM_EXPORT_PATH .
DIRECTORY_SEPARATOR .
'class-ai1wm-export-compatibility.php';
require_once AI1WM_EXPORT_PATH .
DIRECTORY_SEPARATOR .
'class-ai1wm-export-resolve.php';
require_once AI1WM_EXPORT_PATH .
DIRECTORY_SEPARATOR .
'class-ai1wm-export-archive.php';
@@ -279,10 +279,6 @@ require_once AI1WM_IMPORT_PATH .
DIRECTORY_SEPARATOR .
'class-ai1wm-import-upload.php';
require_once AI1WM_IMPORT_PATH .
DIRECTORY_SEPARATOR .
'class-ai1wm-import-resolve.php';
require_once AI1WM_IMPORT_PATH .
DIRECTORY_SEPARATOR .
'class-ai1wm-import-validate.php';
@@ -319,22 +315,6 @@ require_once AI1WM_IMPORT_PATH .
DIRECTORY_SEPARATOR .
'class-ai1wm-import-clean.php';
require_once AI1WM_HTTP_PATH .
DIRECTORY_SEPARATOR .
'class-ai1wm-http-abstract.php';
require_once AI1WM_HTTP_PATH .
DIRECTORY_SEPARATOR .
'class-ai1wm-http-stream.php';
require_once AI1WM_HTTP_PATH .
DIRECTORY_SEPARATOR .
'class-ai1wm-http-curl.php';
require_once AI1WM_HTTP_PATH .
DIRECTORY_SEPARATOR .
'class-ai1wm-http-factory.php';
require_once AI1WM_MODEL_PATH .
DIRECTORY_SEPARATOR .
'class-ai1wm-deprecated.php';
@@ -386,8 +366,3 @@ require_once AI1WM_MODEL_PATH .
require_once AI1WM_MODEL_PATH .
DIRECTORY_SEPARATOR .
'class-ai1wm-handler.php';
require_once AI1WM_MODEL_PATH .
DIRECTORY_SEPARATOR .
'class-ai1wm-http.php';

View File

@@ -35,10 +35,8 @@ if ( defined( 'WP_UNINSTALL_PLUGIN' ) ) {
global $wpdb, $wp_filesystem;
// Delete any options or other data stored in the database here
delete_option( AI1WM_URL_IP );
delete_option( AI1WM_URL_ADAPTER );
delete_option( AI1WM_STATUS );
delete_option( AI1WM_SECRET_KEY );
delete_option( AI1WM_AUTH_USER );
delete_option( AI1WM_AUTH_PASSWORD );
delete_option( AI1WM_STATUS );
}