Version Description
- Importing files using chunks to overcome any webserver upload size restriction
- Fixed a bug where HTTP code error was shown to some users
Download this release
Release Info
| Developer | yani.iliev |
| Plugin | |
| Version | 1.1.0 |
| Comparing to | |
| See all releases | |
Code changes from version 1.0.0 to 1.1.0
all-in-one-wp-migration.php
CHANGED
|
@@ -5,7 +5,7 @@
|
|
| 5 |
* Description: Migration tool for all your blog data
|
| 6 |
* Author: ServMask
|
| 7 |
* Author URI: http://servmask.com/
|
| 8 |
-
* Version: 1.
|
| 9 |
*
|
| 10 |
* Copyright (C) 2013 ServMask LLC
|
| 11 |
*
|
| 5 |
* Description: Migration tool for all your blog data
|
| 6 |
* Author: ServMask
|
| 7 |
* Author URI: http://servmask.com/
|
| 8 |
+
* Version: 1.1.0
|
| 9 |
*
|
| 10 |
* Copyright (C) 2013 ServMask LLC
|
| 11 |
*
|
lib/controller/class-ai1wm-import-controller.php
CHANGED
|
@@ -26,8 +26,29 @@ class Ai1wm_Import_Controller
|
|
| 26 |
$result = array();
|
| 27 |
|
| 28 |
if ( isset( $_FILES['input_file'] ) && ( $input_file = $_FILES['input_file'] ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
$model = new Ai1wm_Import;
|
| 30 |
-
$result = $model->import( $input_file );
|
| 31 |
}
|
| 32 |
|
| 33 |
echo json_encode( $result );
|
| 26 |
$result = array();
|
| 27 |
|
| 28 |
if ( isset( $_FILES['input_file'] ) && ( $input_file = $_FILES['input_file'] ) ) {
|
| 29 |
+
$options = array(
|
| 30 |
+
'chunk' => 0,
|
| 31 |
+
'chunks' => 0,
|
| 32 |
+
'name' => null,
|
| 33 |
+
);
|
| 34 |
+
|
| 35 |
+
// Ordinal number of the current chunk in the set (starts with zero)
|
| 36 |
+
if ( isset( $_REQUEST['chunk'] ) ) {
|
| 37 |
+
$options['chunk'] = intval( $_REQUEST['chunk'] );
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
// Total number of chunks in the file
|
| 41 |
+
if ( isset( $_REQUEST['chunks'] ) ) {
|
| 42 |
+
$options['chunks'] = intval( $_REQUEST['chunks'] );
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
// Name of partial file
|
| 46 |
+
if ( isset( $_REQUEST['name'] ) ) {
|
| 47 |
+
$options['name'] = $_REQUEST['name'];
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
$model = new Ai1wm_Import;
|
| 51 |
+
$result = $model->import( $input_file, $options );
|
| 52 |
}
|
| 53 |
|
| 54 |
echo json_encode( $result );
|
lib/controller/class-ai1wm-main-controller.php
CHANGED
|
@@ -291,7 +291,9 @@ class Ai1wm_Main_Controller
|
|
| 291 |
'drop_element' => 'ai1wm-drag-drop-area',
|
| 292 |
'file_data_name' => 'input_file',
|
| 293 |
'multiple_queues' => false,
|
| 294 |
-
'max_file_size' =>
|
|
|
|
|
|
|
| 295 |
'url' => admin_url( 'admin-ajax.php' ),
|
| 296 |
'flash_swf_url' => includes_url(
|
| 297 |
'js/plupload/plupload.flash.swf'
|
|
@@ -309,6 +311,7 @@ class Ai1wm_Main_Controller
|
|
| 309 |
'urlstream_upload' => true,
|
| 310 |
'multipart_params' => array(
|
| 311 |
'action' => 'upload_file',
|
|
|
|
| 312 |
),
|
| 313 |
);
|
| 314 |
wp_localize_script( 'ai1wm-js-import', 'ai1wm_uploader', $plupload_init );
|
| 291 |
'drop_element' => 'ai1wm-drag-drop-area',
|
| 292 |
'file_data_name' => 'input_file',
|
| 293 |
'multiple_queues' => false,
|
| 294 |
+
'max_file_size' => Ai1wm_Import::MAX_FILE_SIZE,
|
| 295 |
+
'chunk_size' => Ai1wm_Import::MAX_CHUNK_SIZE,
|
| 296 |
+
'max_retries' => Ai1wm_Import::MAX_CHUNK_RETRIES,
|
| 297 |
'url' => admin_url( 'admin-ajax.php' ),
|
| 298 |
'flash_swf_url' => includes_url(
|
| 299 |
'js/plupload/plupload.flash.swf'
|
| 311 |
'urlstream_upload' => true,
|
| 312 |
'multipart_params' => array(
|
| 313 |
'action' => 'upload_file',
|
| 314 |
+
'name' => uniqid() . '.part',
|
| 315 |
),
|
| 316 |
);
|
| 317 |
wp_localize_script( 'ai1wm-js-import', 'ai1wm_uploader', $plupload_init );
|
lib/model/class-ai1wm-import.php
CHANGED
|
@@ -18,6 +18,11 @@
|
|
| 18 |
|
| 19 |
class Ai1wm_Import
|
| 20 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
public function __construct() {
|
| 23 |
$this->connection = new Mysqldump( DB_NAME, DB_USER, DB_PASSWORD, DB_HOST, 'mysql' );
|
|
@@ -27,116 +32,158 @@ class Ai1wm_Import
|
|
| 27 |
* Import archive file (database, media, package.json)
|
| 28 |
*
|
| 29 |
* @param array $input_file Upload file parameters
|
|
|
|
| 30 |
* @return array List of messages
|
| 31 |
*/
|
| 32 |
-
public function import( $input_file ) {
|
| 33 |
$errors = array();
|
| 34 |
|
| 35 |
if ( empty( $input_file['error'] ) ) {
|
| 36 |
-
//
|
| 37 |
-
$
|
| 38 |
-
.
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
}
|
| 43 |
|
| 44 |
-
//
|
| 45 |
-
$
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
$this->maintenance_mode( true );
|
| 53 |
-
|
| 54 |
-
// Media base directory
|
| 55 |
-
$upload_dir = wp_upload_dir();
|
| 56 |
-
$upload_basedir = $upload_dir['basedir'] . DIRECTORY_SEPARATOR;
|
| 57 |
-
if ( ! is_dir( $upload_basedir ) ) {
|
| 58 |
-
mkdir( $upload_basedir );
|
| 59 |
}
|
| 60 |
|
| 61 |
-
//
|
| 62 |
-
$
|
| 63 |
-
$
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
|
|
|
| 73 |
|
| 74 |
-
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
-
|
| 78 |
-
|
| 79 |
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
. DIRECTORY_SEPARATOR;
|
| 84 |
-
if ( ! is_dir( $backup_media_to ) ) {
|
| 85 |
-
mkdir( $backup_media_to );
|
| 86 |
-
}
|
| 87 |
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
-
|
| 91 |
-
$this->truncate_dir( $upload_basedir );
|
| 92 |
|
| 93 |
-
|
| 94 |
-
|
| 95 |
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
. DIRECTORY_SEPARATOR;
|
| 100 |
-
if ( ! is_dir( $backup_themes_to ) ) {
|
| 101 |
-
mkdir( $backup_themes_to );
|
| 102 |
-
}
|
| 103 |
|
| 104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
|
| 106 |
-
|
| 107 |
-
$this->truncate_dir( $themes_basedir );
|
| 108 |
|
| 109 |
-
|
| 110 |
-
|
| 111 |
|
| 112 |
-
|
| 113 |
-
|
|
|
|
| 114 |
|
| 115 |
-
|
| 116 |
-
if ( ! $this->test_website( get_option( 'siteurl' ) ) ) {
|
| 117 |
-
// Truncate database
|
| 118 |
-
$this->connection->truncateDatabase();
|
| 119 |
|
| 120 |
-
|
| 121 |
-
|
|
|
|
| 122 |
|
| 123 |
-
//
|
| 124 |
-
$this->
|
|
|
|
|
|
|
|
|
|
| 125 |
|
| 126 |
-
|
| 127 |
-
|
|
|
|
| 128 |
|
| 129 |
-
|
| 130 |
-
|
|
|
|
| 131 |
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
}
|
| 141 |
} else {
|
| 142 |
$errors[] = $this->code_to_message( $input_file['error'] );
|
| 18 |
|
| 19 |
class Ai1wm_Import
|
| 20 |
{
|
| 21 |
+
const MAX_FILE_SIZE = '128MB';
|
| 22 |
+
|
| 23 |
+
const MAX_CHUNK_SIZE = '1MB';
|
| 24 |
+
|
| 25 |
+
const MAX_CHUNK_RETRIES = 10;
|
| 26 |
|
| 27 |
public function __construct() {
|
| 28 |
$this->connection = new Mysqldump( DB_NAME, DB_USER, DB_PASSWORD, DB_HOST, 'mysql' );
|
| 32 |
* Import archive file (database, media, package.json)
|
| 33 |
*
|
| 34 |
* @param array $input_file Upload file parameters
|
| 35 |
+
* @param array $options Additional upload settings
|
| 36 |
* @return array List of messages
|
| 37 |
*/
|
| 38 |
+
public function import( $input_file, $options = array() ) {
|
| 39 |
$errors = array();
|
| 40 |
|
| 41 |
if ( empty( $input_file['error'] ) ) {
|
| 42 |
+
// Partial file path
|
| 43 |
+
$uploadfile = sys_get_temp_dir() . DIRECTORY_SEPARATOR
|
| 44 |
+
. $options['name'];
|
| 45 |
+
|
| 46 |
+
// Open partial file
|
| 47 |
+
$out = fopen( $uploadfile, $options['chunk'] == 0 ? 'wb' : 'ab' );
|
| 48 |
+
if ( $out ) {
|
| 49 |
+
// Read binary input stream and append it to temp file
|
| 50 |
+
$in = fopen( $input_file['tmp_name'], 'rb' );
|
| 51 |
+
if ( $in ) {
|
| 52 |
+
while ( $buff = fread( $in, 4096 ) ) {
|
| 53 |
+
fwrite( $out, $buff );
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
fclose( $in );
|
| 58 |
+
fclose( $out );
|
| 59 |
+
|
| 60 |
+
// Remove temporary uploaded file
|
| 61 |
+
unlink( $input_file['tmp_name'] );
|
| 62 |
}
|
| 63 |
|
| 64 |
+
// Check if file has been uploaded
|
| 65 |
+
if ( ! $options['chunks'] || $options['chunk'] == $options['chunks'] - 1 ) {
|
| 66 |
+
// Create temporary directory
|
| 67 |
+
$extract_to = sys_get_temp_dir() . DIRECTORY_SEPARATOR
|
| 68 |
+
. uniqid()
|
| 69 |
+
. DIRECTORY_SEPARATOR;
|
| 70 |
+
if ( ! is_dir( $extract_to ) ) {
|
| 71 |
+
mkdir( $extract_to );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
}
|
| 73 |
|
| 74 |
+
// Extract archive to a temporary directory
|
| 75 |
+
$archive = new Zipper( $uploadfile );
|
| 76 |
+
$archive->extractTo( $extract_to );
|
| 77 |
+
$archive->close();
|
| 78 |
+
|
| 79 |
+
// Verify whether this arhive is valid
|
| 80 |
+
if ( $this->is_valid( $extract_to ) ) {
|
| 81 |
+
// Enable maintenance mode
|
| 82 |
+
$this->maintenance_mode( true );
|
| 83 |
+
|
| 84 |
+
// Media base directory
|
| 85 |
+
$upload_dir = wp_upload_dir();
|
| 86 |
+
$upload_basedir = $upload_dir['basedir'] . DIRECTORY_SEPARATOR;
|
| 87 |
+
if ( ! is_dir( $upload_basedir ) ) {
|
| 88 |
+
mkdir( $upload_basedir );
|
| 89 |
+
}
|
| 90 |
|
| 91 |
+
// Themes base directory
|
| 92 |
+
$themes_dir = get_theme_root();
|
| 93 |
+
$themes_basedir = $themes_dir . DIRECTORY_SEPARATOR;
|
| 94 |
+
if ( ! is_dir( $themes_basedir ) ) {
|
| 95 |
+
mkdir( $themes_basedir );
|
| 96 |
+
}
|
| 97 |
|
| 98 |
+
if ( file_exists( $extract_to . Ai1wm_Export::EXPORT_DATABASE_NAME ) ) {
|
| 99 |
+
// Backup database
|
| 100 |
+
$model = new Ai1wm_Export;
|
| 101 |
+
$database_file = tmpfile();
|
| 102 |
+
$options = array( 'add-drop-table' => true, 'export-single-transaction' => true );
|
| 103 |
+
$model->prepare_database( $database_file, $options );
|
| 104 |
|
| 105 |
+
// Truncate database
|
| 106 |
+
$this->connection->truncateDatabase();
|
| 107 |
|
| 108 |
+
// Import database
|
| 109 |
+
$this->connection->importFromFile( $extract_to . Ai1wm_Export::EXPORT_DATABASE_NAME );
|
| 110 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
|
| 112 |
+
// Check if media files are present
|
| 113 |
+
if ( file_exists( $extract_to . Ai1wm_Export::EXPORT_MEDIA_NAME ) ) {
|
| 114 |
+
// Backup media files
|
| 115 |
+
$backup_media_to = sys_get_temp_dir() . DIRECTORY_SEPARATOR
|
| 116 |
+
. uniqid()
|
| 117 |
+
. DIRECTORY_SEPARATOR;
|
| 118 |
+
if ( ! is_dir( $backup_media_to ) ) {
|
| 119 |
+
mkdir( $backup_media_to );
|
| 120 |
+
}
|
| 121 |
|
| 122 |
+
$this->copy_dir( $upload_basedir, $backup_media_to );
|
|
|
|
| 123 |
|
| 124 |
+
// Truncate media files
|
| 125 |
+
$this->truncate_dir( $upload_basedir );
|
| 126 |
|
| 127 |
+
// Import media files
|
| 128 |
+
$this->copy_dir( $extract_to . Ai1wm_Export::EXPORT_MEDIA_NAME, $upload_basedir );
|
| 129 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
|
| 131 |
+
if ( file_exists( $extract_to . Ai1wm_Export::EXPORT_THEMES_NAME ) ) {
|
| 132 |
+
// Backup themes files
|
| 133 |
+
$backup_themes_to = sys_get_temp_dir() . DIRECTORY_SEPARATOR
|
| 134 |
+
. uniqid()
|
| 135 |
+
. DIRECTORY_SEPARATOR;
|
| 136 |
+
if ( ! is_dir( $backup_themes_to ) ) {
|
| 137 |
+
mkdir( $backup_themes_to );
|
| 138 |
+
}
|
| 139 |
|
| 140 |
+
$this->copy_dir( $themes_basedir, $backup_themes_to );
|
|
|
|
| 141 |
|
| 142 |
+
// Truncate themes files
|
| 143 |
+
$this->truncate_dir( $themes_basedir );
|
| 144 |
|
| 145 |
+
// Import themes files
|
| 146 |
+
$this->copy_dir( $extract_to . Ai1wm_Export::EXPORT_THEMES_NAME, $themes_basedir );
|
| 147 |
+
}
|
| 148 |
|
| 149 |
+
if ( file_exists( $extract_to . Ai1wm_Export::EXPORT_PACKAGE_NAME ) ) {
|
|
|
|
|
|
|
|
|
|
| 150 |
|
| 151 |
+
// Install selected plugins
|
| 152 |
+
$this->install_plugins( $extract_to . Ai1wm_Export::EXPORT_PACKAGE_NAME );
|
| 153 |
+
}
|
| 154 |
|
| 155 |
+
// Test website
|
| 156 |
+
if ( ! $this->test_website( get_option( 'siteurl' ) ) ) {
|
| 157 |
+
if ( file_exists( $extract_to . Ai1wm_Export::EXPORT_DATABASE_NAME ) ) {
|
| 158 |
+
// Truncate database
|
| 159 |
+
$this->connection->truncateDatabase();
|
| 160 |
|
| 161 |
+
// Import "OLD" database
|
| 162 |
+
$this->connection->importFromFile( $database_file );
|
| 163 |
+
}
|
| 164 |
|
| 165 |
+
if ( file_exists( $extract_to . Ai1wm_Export::EXPORT_MEDIA_NAME ) ) {
|
| 166 |
+
// Truncate media files
|
| 167 |
+
$this->truncate_dir( $upload_basedir );
|
| 168 |
|
| 169 |
+
// Import "OLD" media files
|
| 170 |
+
$this->copy_dir( $backup_media_to, $upload_basedir );
|
| 171 |
+
}
|
| 172 |
|
| 173 |
+
if ( file_exists( $extract_to . Ai1wm_Export::EXPORT_THEMES_NAME ) ) {
|
| 174 |
+
// Truncate themes files
|
| 175 |
+
$this->truncate_dir( $themes_basedir );
|
| 176 |
+
|
| 177 |
+
// Import "OLD" themes files
|
| 178 |
+
$this->copy_dir( $backup_themes_to, $themes_basedir );
|
| 179 |
+
}
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
// Disable maintenance mode
|
| 183 |
+
$this->maintenance_mode( false );
|
| 184 |
+
} else {
|
| 185 |
+
$errors[] = _( 'File is not compatible with "All In One WP Migration" plugin! Please verify your archive file.' );
|
| 186 |
+
}
|
| 187 |
}
|
| 188 |
} else {
|
| 189 |
$errors[] = $this->code_to_message( $input_file['error'] );
|
lib/view/import/index.php
CHANGED
|
@@ -47,7 +47,7 @@
|
|
| 47 |
|
| 48 |
<p class="max-upload-size">
|
| 49 |
<?php _e( 'Maximum upload file size:' ); ?>
|
| 50 |
-
<strong><?php
|
| 51 |
</p>
|
| 52 |
</form>
|
| 53 |
</div>
|
| 47 |
|
| 48 |
<p class="max-upload-size">
|
| 49 |
<?php _e( 'Maximum upload file size:' ); ?>
|
| 50 |
+
<strong><?php echo Ai1wm_Import::MAX_FILE_SIZE; ?></strong>
|
| 51 |
</p>
|
| 52 |
</form>
|
| 53 |
</div>
|
readme.txt
CHANGED
|
@@ -3,7 +3,7 @@ Contributors: yani.iliev, bangelov, mirkov
|
|
| 3 |
Tags: db migration, migration, wordpress migration, db backup, db restore, website backup, website restore, website migration, website deploy, wordpress deploy, db backup, database export, database serialization, database find replace
|
| 4 |
Requires at least: 3.3
|
| 5 |
Tested up to: 3.8
|
| 6 |
-
Stable tag: 1.
|
| 7 |
License: GPLv2 or later
|
| 8 |
|
| 9 |
All-in-One WP Migration is the only tools that you will ever needs when you need to perform site migration of your WordPress blog.
|
|
@@ -15,6 +15,11 @@ You can apply unlimited find and replace operations on your database and the plu
|
|
| 15 |
|
| 16 |
All in One WP Plugin is the first plugin to offer true mobile experience on WordPress versions 3.3 and up.
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
== Installation ==
|
| 19 |
|
| 20 |
1. Upload the `all-in-one-wp-migration` folder to the `/wp-content/plugins/` directory
|
|
@@ -29,6 +34,10 @@ All in One WP Plugin is the first plugin to offer true mobile experience on Word
|
|
| 29 |
|
| 30 |
== Changelog ==
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
= 1.0.0 =
|
| 33 |
|
| 34 |
* Export database as SQL file
|
| 3 |
Tags: db migration, migration, wordpress migration, db backup, db restore, website backup, website restore, website migration, website deploy, wordpress deploy, db backup, database export, database serialization, database find replace
|
| 4 |
Requires at least: 3.3
|
| 5 |
Tested up to: 3.8
|
| 6 |
+
Stable tag: 1.1.0
|
| 7 |
License: GPLv2 or later
|
| 8 |
|
| 9 |
All-in-One WP Migration is the only tools that you will ever needs when you need to perform site migration of your WordPress blog.
|
| 15 |
|
| 16 |
All in One WP Plugin is the first plugin to offer true mobile experience on WordPress versions 3.3 and up.
|
| 17 |
|
| 18 |
+
= Bypass all upload size restriction =
|
| 19 |
+
We use chunks to import your data and that way we bypass any webserver upload size restrictions
|
| 20 |
+
|
| 21 |
+
[youtube http://www.youtube.com/watch?v=5FMzLf9a4Dc]
|
| 22 |
+
|
| 23 |
== Installation ==
|
| 24 |
|
| 25 |
1. Upload the `all-in-one-wp-migration` folder to the `/wp-content/plugins/` directory
|
| 34 |
|
| 35 |
== Changelog ==
|
| 36 |
|
| 37 |
+
= 1.1.0 =
|
| 38 |
+
* Importing files using chunks to overcome any webserver upload size restriction
|
| 39 |
+
* Fixed a bug where HTTP code error was shown to some users
|
| 40 |
+
|
| 41 |
= 1.0.0 =
|
| 42 |
|
| 43 |
* Export database as SQL file
|
