All-in-One WP Migration - Version 1.3.0

Version Description

  • Added support for mysql connection to happen over sockets or TCP
  • Added support for Windows OS and fully tested the plugin on IIS
  • Added support for limited memory_limit - 1MB - The plugin now requires only 1MB to operate properly
  • Added support for multisite
  • Use mysql_unbuffered_query instead of mysql_query to overcome any memory problems
  • Fixed a deprecated warning for mysql_pconnect when php 5.5 and above is used
  • Fixed memory_limit problem with PCLZIP library
  • Fixed a bug when the archive is exported with zero size when using PCLZIP
  • Fixed a bug when the archive was exported broken on some servers
  • Fixed a deprecated usage of preg_replace \e in php v5.5 and above
Download this release

Release Info

Developer yani.iliev
Plugin Icon 128x128 All-in-One WP Migration
Version 1.3.0
Comparing to
See all releases

Code changes from version 1.2.1 to 1.3.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.2.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.3.0
9
  *
10
  * Copyright (C) 2013 ServMask LLC
11
  *
constants.php CHANGED
@@ -19,7 +19,7 @@
19
  // ==================
20
  // = Plugin VERSION =
21
  // ==================
22
- define( 'AI1WM_VERSION', '1.2.1' );
23
 
24
  // ===============
25
  // = Plugin Name =
19
  // ==================
20
  // = Plugin VERSION =
21
  // ==================
22
+ define( 'AI1WM_VERSION', '1.3.0' );
23
 
24
  // ===============
25
  // = Plugin Name =
lib/controller/class-ai1wm-export-controller.php CHANGED
@@ -19,16 +19,19 @@
19
  class Ai1wm_Export_Controller
20
  {
21
  public static function index() {
22
- $model = new Ai1wm_Export;
 
23
  Ai1wm_Template::render( 'export/index', array(
24
- 'list_plugins' => get_plugins(),
 
 
25
  )
26
  );
27
  }
28
 
29
  public static function export() {
30
  if ( isset( $_POST['options'] ) && ( $options = $_POST['options'] ) ) {
31
- $output_file = tmpfile();
32
 
33
  // Export archive
34
  $model = new Ai1wm_Export;
@@ -52,10 +55,9 @@ class Ai1wm_Export_Controller
52
  header( 'Content-Length: ' . filesize( $file ) );
53
 
54
  // Clear output buffering and read file content
55
- if ( ob_get_length() ) {
56
- ob_end_clean();
57
- }
58
  readfile( $file );
 
59
  exit;
60
  }
61
  }
19
  class Ai1wm_Export_Controller
20
  {
21
  public static function index() {
22
+ $model = new Ai1wm_Export;
23
+ $temp_dir = sys_get_temp_dir();
24
  Ai1wm_Template::render( 'export/index', array(
25
+ 'list_plugins' => get_plugins(),
26
+ 'temp_dir' => $temp_dir,
27
+ 'temp_dir_access' => is_readable( $temp_dir ) && is_writable( $temp_dir ),
28
  )
29
  );
30
  }
31
 
32
  public static function export() {
33
  if ( isset( $_POST['options'] ) && ( $options = $_POST['options'] ) ) {
34
+ $output_file = tempnam( sys_get_temp_dir(), 'wm_' );
35
 
36
  // Export archive
37
  $model = new Ai1wm_Export;
55
  header( 'Content-Length: ' . filesize( $file ) );
56
 
57
  // Clear output buffering and read file content
58
+ @ob_end_flush();
 
 
59
  readfile( $file );
60
+ @unlink( $file );
61
  exit;
62
  }
63
  }
lib/controller/class-ai1wm-main-controller.php CHANGED
@@ -58,8 +58,12 @@ class Ai1wm_Main_Controller
58
  * @return Object Instance of this class
59
  */
60
  private function activate_actions() {
 
 
 
 
 
61
  add_action( 'admin_head', array( $this, 'admin_head' ) );
62
- add_action( 'admin_menu', array( $this, 'admin_menu' ) );
63
  add_action( 'init', array( $this, 'router' ) );
64
  add_action( 'wp_ajax_leave_feedback', array( $this, 'leave_feedback' ) );
65
  add_action( 'wp_ajax_upload_file', 'Ai1wm_Import_Controller::upload_file' );
58
  * @return Object Instance of this class
59
  */
60
  private function activate_actions() {
61
+ if ( is_multisite() ) {
62
+ add_action( 'network_admin_menu', array( $this, 'admin_menu' ) );
63
+ } else {
64
+ add_action( 'admin_menu', array( $this, 'admin_menu' ) );
65
+ }
66
  add_action( 'admin_head', array( $this, 'admin_head' ) );
 
67
  add_action( 'init', array( $this, 'router' ) );
68
  add_action( 'wp_ajax_leave_feedback', array( $this, 'leave_feedback' ) );
69
  add_action( 'wp_ajax_upload_file', 'Ai1wm_Import_Controller::upload_file' );
lib/model/class-ai1wm-export.php CHANGED
@@ -68,8 +68,9 @@ class Ai1wm_Export
68
  // Should we export database?
69
  if ( ! isset( $options['export-database' ] ) ) {
70
  $database_file = tmpfile();
 
71
  $archive->addFile(
72
- $this->prepare_database( $database_file, $options ),
73
  self::EXPORT_DATABASE_NAME
74
  );
75
  }
@@ -117,6 +118,8 @@ class Ai1wm_Export
117
  public function prepare_database( $output_file, array $options = array() ) {
118
  global $wpdb;
119
 
 
 
120
  // Set include tables
121
  $includeTables = array();
122
  if ( isset( $options['include-tables'] ) ) {
@@ -190,43 +193,20 @@ class Ai1wm_Export
190
  $new_values[] = $replace['new-value'][$i];
191
  }
192
  }
193
-
194
  // Do String Replacement
195
  if ( $old_values && $new_values ) {
196
- $data = str_replace(
 
197
  $old_values,
198
- $new_values,
199
- stream_get_contents( $output_file )
200
- );
201
-
202
- // Replace serialized string values
203
- $data = preg_replace(
204
- '!s:(\d+):([\\\\]?"[\\\\]?"|[\\\\]?"((.*?)[^\\\\])[\\\\]?");!e',
205
- "'s:'.strlen( Ai1wm_Export::unescape_mysql( '$3' ) ).':\"'. Ai1wm_Export::unescape_quotes( '$3' ) .'\";'",
206
- $data
207
  );
208
- if ( $data ) {
209
- ftruncate( $output_file, 0 );
210
- rewind( $output_file );
211
- fwrite( $output_file, $data );
212
- }
213
- } else {
214
- $data = stream_get_contents( $output_file );
215
- // Replace serialized string values
216
- $data = preg_replace(
217
- '!s:(\d+):([\\\\]?"[\\\\]?"|[\\\\]?"((.*?)[^\\\\])[\\\\]?");!e',
218
- "'s:'.strlen( Ai1wm_Export::unescape_mysql( '$3' ) ).':\"'. Ai1wm_Export::unescape_quotes( '$3' ) .'\";'",
219
- $data
220
- );
221
- if ( $data ) {
222
- ftruncate( $output_file, 0 );
223
- rewind( $output_file );
224
- fwrite( $output_file, $data );
225
- }
226
  }
227
  }
228
 
229
- return $output_meta['uri'];
 
 
 
230
  }
231
 
232
  /**
68
  // Should we export database?
69
  if ( ! isset( $options['export-database' ] ) ) {
70
  $database_file = tmpfile();
71
+ $database_file = $this->prepare_database( $database_file, $options );
72
  $archive->addFile(
73
+ $database_file,
74
  self::EXPORT_DATABASE_NAME
75
  );
76
  }
118
  public function prepare_database( $output_file, array $options = array() ) {
119
  global $wpdb;
120
 
121
+ $_f = new Ai1wm_File();
122
+
123
  // Set include tables
124
  $includeTables = array();
125
  if ( isset( $options['include-tables'] ) ) {
193
  $new_values[] = $replace['new-value'][$i];
194
  }
195
  }
 
196
  // Do String Replacement
197
  if ( $old_values && $new_values ) {
198
+ $output_file = $_f->str_replace_file(
199
+ $output_file,
200
  $old_values,
201
+ $new_values
 
 
 
 
 
 
 
 
202
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
  }
204
  }
205
 
206
+ return $_f->preg_replace_file(
207
+ $output_file,
208
+ '/s:(\d+):([\\\\]?"[\\\\]?"|[\\\\]?"((.*?)[^\\\\])[\\\\]?");/'
209
+ );
210
  }
211
 
212
  /**
lib/model/class-ai1wm-file.php ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright (C) 2013 ServMask LLC
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+
19
+ class Ai1wm_File
20
+ {
21
+
22
+ /**
23
+ * [str_replace_file description]
24
+ * @param [type] $fh [description]
25
+ * @param [type] $pattern [description]
26
+ * @param [type] $replacement [description]
27
+ * @return [type] [description]
28
+ */
29
+ public function str_replace_file( $fh, $pattern, $replacement ) {
30
+ $_new_file = tmpfile();
31
+
32
+ while ( ! feof( $fh ) ) {
33
+ $line = stream_get_line( $fh, 1000000, '\n' );
34
+
35
+ // append new line at the end of the line
36
+ if ( strlen( $line ) < 1000000 && ! feof( $fh ) ) {
37
+ $line .= '\n';
38
+ }
39
+
40
+ if (
41
+ false === fwrite(
42
+ $_new_file,
43
+ str_replace( $pattern, $replacement, $line )
44
+ )
45
+ ) {
46
+ wp_die(
47
+ 'Writting to a file failed! Probably, there is no more free space left?',
48
+ 'Out of disk space'
49
+ );
50
+ }
51
+ }
52
+
53
+ return $_new_file;
54
+ }
55
+
56
+ /**
57
+ * Replace a file, line by line with the regex pattern and then writes the
58
+ * output to a new file.
59
+ *
60
+ * @param [type] $fh [description]
61
+ * @param [type] $pattern [description]
62
+ *
63
+ * @return [type] [description]
64
+ */
65
+ public function preg_replace_file( $fh, $pattern ) {
66
+ $_new_file = tmpfile();
67
+
68
+ // set filehandle to the beginning of the file
69
+ rewind( $fh );
70
+
71
+ while ( ! feof( $fh ) ) {
72
+ $line = stream_get_line( $fh, 1000000, '\n' );
73
+ // append new line at the end of the line
74
+ if ( strlen( $line ) < 1000000 && ! feof( $fh ) ) {
75
+ $line .= '\n';
76
+ }
77
+
78
+ $replaced = $this->_preg_replace( $line, $pattern );
79
+ if (
80
+ false === fwrite(
81
+ $_new_file,
82
+ $replaced
83
+ )
84
+ ) {
85
+ wp_die(
86
+ 'Writting to a file failed! Probably, there is no more free space left?',
87
+ 'Out of disk space'
88
+ );
89
+ }
90
+ }
91
+ return $_new_file;
92
+ }
93
+
94
+ /**
95
+ * [_preg_replace description]
96
+ * @param [type] $line [description]
97
+ * @param [type] $pattern [description]
98
+ * @return [type] [description]
99
+ */
100
+ public function _preg_replace( $line, $pattern ) {
101
+ //php doesn't garbage collect functions created by create_function()
102
+ static $callback = null;
103
+
104
+ if ( $callback === null ) {
105
+ $callback = create_function(
106
+ '$matches',
107
+ "return isset(\$matches[3]) ? 's:' .
108
+ strlen( Ai1wm_Export::unescape_mysql( \$matches[3] ) ) .
109
+ ':\"'.
110
+ Ai1wm_Export::unescape_quotes( \$matches[3] ) .
111
+ '\";' : \$matches[0];
112
+ "
113
+ );
114
+ }
115
+
116
+ return preg_replace_callback( $pattern, $callback, $line );
117
+ }
118
+ }
lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlDumpFactory.php CHANGED
@@ -29,7 +29,7 @@
29
  * @author Bobby Angelov <bobby@servmask.com>
30
  * @copyright 2014 Yani Iliev, Bobby Angelov
31
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
32
- * @version GIT: 1.0.4
33
  * @link https://github.com/yani-/mysqldump-factory/
34
  */
35
 
@@ -42,7 +42,7 @@
42
  * @author Bobby Angelov <bobby@servmask.com>
43
  * @copyright 2014 Yani Iliev, Bobby Angelov
44
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
45
- * @version GIT: 1.0.4
46
  * @link https://github.com/yani-/mysqldump-factory/
47
  */
48
  class MysqlDumpFactory
29
  * @author Bobby Angelov <bobby@servmask.com>
30
  * @copyright 2014 Yani Iliev, Bobby Angelov
31
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
32
+ * @version GIT: 1.0.9
33
  * @link https://github.com/yani-/mysqldump-factory/
34
  */
35
 
42
  * @author Bobby Angelov <bobby@servmask.com>
43
  * @copyright 2014 Yani Iliev, Bobby Angelov
44
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
45
+ * @version GIT: 1.0.9
46
  * @link https://github.com/yani-/mysqldump-factory/
47
  */
48
  class MysqlDumpFactory
lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlDumpInterface.php CHANGED
@@ -29,7 +29,7 @@
29
  * @author Bobby Angelov <bobby@servmask.com>
30
  * @copyright 2014 Yani Iliev, Bobby Angelov
31
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
32
- * @version GIT: 1.0.4
33
  * @link https://github.com/yani-/mysqldump-factory/
34
  */
35
 
@@ -42,7 +42,7 @@
42
  * @author Bobby Angelov <bobby@servmask.com>
43
  * @copyright 2014 Yani Iliev, Bobby Angelov
44
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
45
- * @version GIT: 1.0.4
46
  * @link https://github.com/yani-/mysqldump-factory/
47
  */
48
  interface MysqlDumpInterface
29
  * @author Bobby Angelov <bobby@servmask.com>
30
  * @copyright 2014 Yani Iliev, Bobby Angelov
31
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
32
+ * @version GIT: 1.0.9
33
  * @link https://github.com/yani-/mysqldump-factory/
34
  */
35
 
42
  * @author Bobby Angelov <bobby@servmask.com>
43
  * @copyright 2014 Yani Iliev, Bobby Angelov
44
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
45
+ * @version GIT: 1.0.9
46
  * @link https://github.com/yani-/mysqldump-factory/
47
  */
48
  interface MysqlDumpInterface
lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlDumpPDO.php CHANGED
@@ -29,7 +29,7 @@
29
  * @author Bobby Angelov <bobby@servmask.com>
30
  * @copyright 2014 Yani Iliev, Bobby Angelov
31
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
32
- * @version GIT: 1.0.4
33
  * @link https://github.com/yani-/mysqldump-factory/
34
  */
35
 
@@ -46,7 +46,7 @@ require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'MysqlFileAdapter.php';
46
  * @author Bobby Angelov <bobby@servmask.com>
47
  * @copyright 2014 Yani Iliev, Bobby Angelov
48
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
49
- * @version GIT: 1.0.4
50
  * @link https://github.com/yani-/mysqldump-factory/
51
  */
52
  class MysqlDumpPDO implements MysqlDumpInterface
@@ -416,39 +416,62 @@ class MysqlDumpPDO implements MysqlDumpInterface
416
  }
417
 
418
  /**
419
- * Create MySQL connection (lazy loading)
420
  *
421
- * @return mixed
422
  */
423
  public function getConnection()
424
  {
425
  if ($this->connection === null) {
426
  try {
427
- // Make connection
428
- $this->connection = new PDO(
429
- sprintf('mysql:host=%s;dbname=%s', $this->hostname, $this->database),
430
- $this->username,
431
- $this->password,
432
- array(
433
- PDO::ATTR_PERSISTENT => true,
434
- PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
435
- )
436
- );
437
-
438
- // Set additional connection attributes
439
- $this->connection->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_NATURAL);
440
-
441
- // Set default encoding
442
- $query = $this->queryAdapter->set_names( 'utf8' );
443
- $this->connection->exec($query);
444
- } catch (PDOException $e) {
445
- throw new Exception('Unable to connect to MySQL database server: ' . $e->getMessage());
446
  }
447
  }
448
 
449
  return $this->connection;
450
  }
451
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
452
  /**
453
  * Returns header for dump file
454
  *
@@ -533,7 +556,8 @@ class MysqlDumpPDO implements MysqlDumpInterface
533
  );
534
 
535
  // Generate insert statements
536
- foreach ($this->getConnection()->query($query, PDO::FETCH_NUM) as $row) {
 
537
  $items = array();
538
  foreach ($row as $value) {
539
  if ($value) {
@@ -555,6 +579,9 @@ class MysqlDumpPDO implements MysqlDumpInterface
555
  }
556
  }
557
 
 
 
 
558
  if (!$insertFirst) {
559
  $this->fileAdapter->write(";\n");
560
  }
29
  * @author Bobby Angelov <bobby@servmask.com>
30
  * @copyright 2014 Yani Iliev, Bobby Angelov
31
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
32
+ * @version GIT: 1.0.9
33
  * @link https://github.com/yani-/mysqldump-factory/
34
  */
35
 
46
  * @author Bobby Angelov <bobby@servmask.com>
47
  * @copyright 2014 Yani Iliev, Bobby Angelov
48
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
49
+ * @version GIT: 1.0.9
50
  * @link https://github.com/yani-/mysqldump-factory/
51
  */
52
  class MysqlDumpPDO implements MysqlDumpInterface
416
  }
417
 
418
  /**
419
+ * Get MySQL connection (lazy loading)
420
  *
421
+ * @return PDO
422
  */
423
  public function getConnection()
424
  {
425
  if ($this->connection === null) {
426
  try {
427
+ // Make connection (Socket)
428
+ $this->connection = $this->makeConnection();
429
+ } catch (Exception $e) {
430
+ try {
431
+ // Make connection (TCP)
432
+ $this->connection = $this->makeConnection(false);
433
+ } catch (Exception $e) {
434
+ throw new Exception('Unable to connect to MySQL database server: ' . $e->getMessage());
435
+ }
 
 
 
 
 
 
 
 
 
 
436
  }
437
  }
438
 
439
  return $this->connection;
440
  }
441
 
442
+ /**
443
+ * Make MySQL connection
444
+ *
445
+ * @param bool $useSocket Use socket or TCP connection
446
+ * @return PDO
447
+ */
448
+ protected function makeConnection($useSocket = true)
449
+ {
450
+ // Use Socket or TCP
451
+ $hostname = ($useSocket ? $this->hostname : gethostbyname($this->hostname));
452
+
453
+ // Make connection
454
+ $connection = new PDO(
455
+ sprintf('mysql:host=%s;dbname=%s', $hostname, $this->database),
456
+ $this->username,
457
+ $this->password,
458
+ array(
459
+ PDO::ATTR_PERSISTENT => true,
460
+ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
461
+ )
462
+ );
463
+
464
+ // Set additional connection attributes
465
+ $connection->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_NATURAL);
466
+ $connection->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
467
+
468
+ // Set default encoding
469
+ $query = $this->queryAdapter->set_names('utf8');
470
+ $connection->exec($query);
471
+
472
+ return $connection;
473
+ }
474
+
475
  /**
476
  * Returns header for dump file
477
  *
556
  );
557
 
558
  // Generate insert statements
559
+ $result = $this->getConnection()->query($query, PDO::FETCH_NUM);
560
+ foreach ($result as $row) {
561
  $items = array();
562
  foreach ($row as $value) {
563
  if ($value) {
579
  }
580
  }
581
 
582
+ // Close result cursor
583
+ $result->closeCursor();
584
+
585
  if (!$insertFirst) {
586
  $this->fileAdapter->write(";\n");
587
  }
lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlDumpSQL.php CHANGED
@@ -29,7 +29,7 @@
29
  * @author Bobby Angelov <bobby@servmask.com>
30
  * @copyright 2014 Yani Iliev, Bobby Angelov
31
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
32
- * @version GIT: 1.0.4
33
  * @link https://github.com/yani-/mysqldump-factory/
34
  */
35
 
@@ -46,7 +46,7 @@ require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'MysqlFileAdapter.php';
46
  * @author Bobby Angelov <bobby@servmask.com>
47
  * @copyright 2014 Yani Iliev, Bobby Angelov
48
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
49
- * @version GIT: 1.0.4
50
  * @link https://github.com/yani-/mysqldump-factory/
51
  */
52
  class MysqlDumpSQL implements MysqlDumpInterface
@@ -356,11 +356,14 @@ class MysqlDumpSQL implements MysqlDumpInterface
356
  public function truncateDatabase()
357
  {
358
  $query = $this->queryAdapter->show_tables($this->database);
359
- $result = mysql_query($query, $this->getConnection());
 
360
  while ($row = mysql_fetch_assoc($result)) {
361
  // Drop table
362
- $delete = $this->queryAdapter->drop_table($row['table_name']);
363
- mysql_query($delete, $this->getConnection());
 
 
364
  }
365
  }
366
 
@@ -384,7 +387,7 @@ class MysqlDumpSQL implements MysqlDumpInterface
384
  $query .= $line;
385
  if (preg_match('/;\s*$/', $line)) {
386
  // Run SQL query
387
- $result = mysql_query($query, $this->getConnection());
388
  if ($result) {
389
  $query = null;
390
  }
@@ -405,7 +408,7 @@ class MysqlDumpSQL implements MysqlDumpInterface
405
  $tables = array();
406
 
407
  $query = $this->queryAdapter->show_tables($this->database);
408
- $result = mysql_query($query, $this->getConnection());
409
  while ($row = mysql_fetch_assoc($result)) {
410
  $tables[] = $row['table_name'];
411
  }
@@ -414,32 +417,57 @@ class MysqlDumpSQL implements MysqlDumpInterface
414
  }
415
 
416
  /**
417
- * Create MySQL connection (lazy loading)
418
  *
419
- * @return mixed
420
  */
421
  protected function getConnection()
422
  {
423
  if ($this->connection === null) {
424
- // Make connection
425
- $this->connection = mysql_pconnect($this->hostname, $this->username, $this->password);
426
-
427
- // Select database and set default encoding
428
- if ($this->connection) {
429
- if (mysql_select_db($this->database, $this->connection)) {
430
- $query = $this->queryAdapter->set_names( 'utf8' );
431
- mysql_query($query, $this->connection);
432
- } else {
433
- throw new Exception('Could not select MySQL database: ' . mysql_error($this->connection));
434
  }
435
- } else {
436
- throw new Exception('Unable to connect to MySQL database server: ' . mysql_error($this->connection));
437
  }
438
  }
439
 
440
  return $this->connection;
441
  }
442
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
443
  /**
444
  * Returns header for dump file
445
  *
@@ -469,7 +497,7 @@ class MysqlDumpSQL implements MysqlDumpInterface
469
  protected function getTableStructure($tableName)
470
  {
471
  $query = $this->queryAdapter->show_create_table($tableName);
472
- $result = mysql_query($query, $this->getConnection());
473
  while ($row = mysql_fetch_assoc($result)) {
474
  if (isset($row['Create Table'])) {
475
  // Replace table prefix
@@ -525,13 +553,13 @@ class MysqlDumpSQL implements MysqlDumpInterface
525
  );
526
 
527
  // Generate insert statements
528
- $result = mysql_query($query, $this->getConnection());
529
  while ($row = mysql_fetch_row($result)) {
530
  $items = array();
531
  foreach ($row as $value) {
532
  if ($value) {
533
  $value = $this->replaceTablePrefix($value);
534
- }
535
  $items[] = is_null($value) ? 'NULL' : "'" . mysql_real_escape_string($value) . "'";
536
  }
537
 
29
  * @author Bobby Angelov <bobby@servmask.com>
30
  * @copyright 2014 Yani Iliev, Bobby Angelov
31
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
32
+ * @version GIT: 1.0.9
33
  * @link https://github.com/yani-/mysqldump-factory/
34
  */
35
 
46
  * @author Bobby Angelov <bobby@servmask.com>
47
  * @copyright 2014 Yani Iliev, Bobby Angelov
48
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
49
+ * @version GIT: 1.0.9
50
  * @link https://github.com/yani-/mysqldump-factory/
51
  */
52
  class MysqlDumpSQL implements MysqlDumpInterface
356
  public function truncateDatabase()
357
  {
358
  $query = $this->queryAdapter->show_tables($this->database);
359
+ $result = mysql_unbuffered_query($query, $this->getConnection());
360
+ $_deleteTables = array();
361
  while ($row = mysql_fetch_assoc($result)) {
362
  // Drop table
363
+ $_deleteTables []= $this->queryAdapter->drop_table($row['table_name']);
364
+ }
365
+ foreach ($_deleteTables as $delete) {
366
+ mysql_unbuffered_query($delete, $this->getConnection());
367
  }
368
  }
369
 
387
  $query .= $line;
388
  if (preg_match('/;\s*$/', $line)) {
389
  // Run SQL query
390
+ $result = mysql_unbuffered_query($query, $this->getConnection());
391
  if ($result) {
392
  $query = null;
393
  }
408
  $tables = array();
409
 
410
  $query = $this->queryAdapter->show_tables($this->database);
411
+ $result = mysql_unbuffered_query($query, $this->getConnection());
412
  while ($row = mysql_fetch_assoc($result)) {
413
  $tables[] = $row['table_name'];
414
  }
417
  }
418
 
419
  /**
420
+ * Get MySQL connection (lazy loading)
421
  *
422
+ * @return resource
423
  */
424
  protected function getConnection()
425
  {
426
  if ($this->connection === null) {
427
+ // Make connection (Socket)
428
+ $this->connection = $this->makeConnection();
429
+
430
+ if ($this->connection === false) {
431
+ // Make connection (TCP)
432
+ $this->connection = $this->makeConnection(false);
433
+
434
+ // Unable to connect to MySQL database server
435
+ if ($this->connection === false) {
436
+ throw new Exception('Unable to connect to MySQL database server: ' . mysql_error($this->connection));
437
  }
 
 
438
  }
439
  }
440
 
441
  return $this->connection;
442
  }
443
 
444
+ /**
445
+ * Make MySQL connection
446
+ *
447
+ * @param bool $useSocket Use socket or TCP connection
448
+ * @return resource
449
+ */
450
+ protected function makeConnection($useSocket = true)
451
+ {
452
+ // Use Socket or TCP
453
+ $hostname = ($useSocket ? $this->hostname : gethostbyname($this->hostname));
454
+
455
+ // Make connection
456
+ $connection = @mysql_pconnect($hostname, $this->username, $this->password);
457
+
458
+ // Select database and set default encoding
459
+ if ($connection) {
460
+ if (mysql_select_db($this->database, $connection)) {
461
+ $query = $this->queryAdapter->set_names('utf8');
462
+ mysql_unbuffered_query($query, $connection);
463
+ } else {
464
+ throw new Exception('Could not select MySQL database: ' . mysql_error($connection));
465
+ }
466
+ }
467
+
468
+ return $connection;
469
+ }
470
+
471
  /**
472
  * Returns header for dump file
473
  *
497
  protected function getTableStructure($tableName)
498
  {
499
  $query = $this->queryAdapter->show_create_table($tableName);
500
+ $result = mysql_unbuffered_query($query, $this->getConnection());
501
  while ($row = mysql_fetch_assoc($result)) {
502
  if (isset($row['Create Table'])) {
503
  // Replace table prefix
553
  );
554
 
555
  // Generate insert statements
556
+ $result = mysql_unbuffered_query($query, $this->getConnection());
557
  while ($row = mysql_fetch_row($result)) {
558
  $items = array();
559
  foreach ($row as $value) {
560
  if ($value) {
561
  $value = $this->replaceTablePrefix($value);
562
+ }
563
  $items[] = is_null($value) ? 'NULL' : "'" . mysql_real_escape_string($value) . "'";
564
  }
565
 
lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlFileAdapter.php CHANGED
@@ -29,7 +29,7 @@
29
  * @author Bobby Angelov <bobby@servmask.com>
30
  * @copyright 2014 Yani Iliev, Bobby Angelov
31
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
32
- * @version GIT: 1.0.4
33
  * @link https://github.com/yani-/mysqldump-factory/
34
  */
35
 
@@ -42,7 +42,7 @@
42
  * @author Bobby Angelov <bobby@servmask.com>
43
  * @copyright 2014 Yani Iliev, Bobby Angelov
44
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
45
- * @version GIT: 1.0.4
46
  * @link https://github.com/yani-/mysqldump-factory/
47
  */
48
  class MysqlFileAdapter
29
  * @author Bobby Angelov <bobby@servmask.com>
30
  * @copyright 2014 Yani Iliev, Bobby Angelov
31
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
32
+ * @version GIT: 1.0.9
33
  * @link https://github.com/yani-/mysqldump-factory/
34
  */
35
 
42
  * @author Bobby Angelov <bobby@servmask.com>
43
  * @copyright 2014 Yani Iliev, Bobby Angelov
44
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
45
+ * @version GIT: 1.0.9
46
  * @link https://github.com/yani-/mysqldump-factory/
47
  */
48
  class MysqlFileAdapter
lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlQueryAdapter.php CHANGED
@@ -29,7 +29,7 @@
29
  * @author Bobby Angelov <bobby@servmask.com>
30
  * @copyright 2014 Yani Iliev, Bobby Angelov
31
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
32
- * @version GIT: 1.0.4
33
  * @link https://github.com/yani-/mysqldump-factory/
34
  */
35
 
@@ -42,7 +42,7 @@
42
  * @author Bobby Angelov <bobby@servmask.com>
43
  * @copyright 2014 Yani Iliev, Bobby Angelov
44
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
45
- * @version GIT: 1.0.4
46
  * @link https://github.com/yani-/mysqldump-factory/
47
  */
48
  class MysqlQueryAdapter
29
  * @author Bobby Angelov <bobby@servmask.com>
30
  * @copyright 2014 Yani Iliev, Bobby Angelov
31
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
32
+ * @version GIT: 1.0.9
33
  * @link https://github.com/yani-/mysqldump-factory/
34
  */
35
 
42
  * @author Bobby Angelov <bobby@servmask.com>
43
  * @copyright 2014 Yani Iliev, Bobby Angelov
44
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
45
+ * @version GIT: 1.0.9
46
  * @link https://github.com/yani-/mysqldump-factory/
47
  */
48
  class MysqlQueryAdapter
lib/vendor/zip-factory/zip-factory/lib/ArchiverInterface.php CHANGED
@@ -28,7 +28,7 @@
28
  * @author Yani Iliev <yani@iliev.me>
29
  * @copyright 2014 Yani Iliev
30
  * @license https://raw.github.com/yani-/zip-factory/master/LICENSE The MIT License (MIT)
31
- * @version GIT: 1.0.0
32
  * @link https://github.com/yani-/zip-factory/
33
  */
34
 
28
  * @author Yani Iliev <yani@iliev.me>
29
  * @copyright 2014 Yani Iliev
30
  * @license https://raw.github.com/yani-/zip-factory/master/LICENSE The MIT License (MIT)
31
+ * @version GIT: 1.0.3
32
  * @link https://github.com/yani-/zip-factory/
33
  */
34
 
lib/vendor/zip-factory/zip-factory/lib/ArchiverPclZip.php CHANGED
@@ -28,7 +28,7 @@
28
  * @author Yani Iliev <yani@iliev.me>
29
  * @copyright 2014 Yani Iliev
30
  * @license https://raw.github.com/yani-/zip-factory/master/LICENSE The MIT License (MIT)
31
- * @version GIT: 1.0.0
32
  * @link https://github.com/yani-/zip-factory/
33
  */
34
 
@@ -105,11 +105,15 @@ if (function_exists('gzopen')) {
105
  $start = null,
106
  $length = null
107
  ) {
 
 
 
 
108
  $this->pclzip->add(
109
  array(
110
  array(
111
- PCLZIP_ATT_FILE_NAME => $entryname,
112
- PCLZIP_ATT_FILE_CONTENT => file_get_contents($filepath)
113
  )
114
  )
115
  );
28
  * @author Yani Iliev <yani@iliev.me>
29
  * @copyright 2014 Yani Iliev
30
  * @license https://raw.github.com/yani-/zip-factory/master/LICENSE The MIT License (MIT)
31
+ * @version GIT: 1.0.3
32
  * @link https://github.com/yani-/zip-factory/
33
  */
34
 
105
  $start = null,
106
  $length = null
107
  ) {
108
+ if (is_resource($filepath)) {
109
+ $meta = stream_get_meta_data($filepath);
110
+ $filepath = $meta['uri'];
111
+ }
112
  $this->pclzip->add(
113
  array(
114
  array(
115
+ PCLZIP_ATT_FILE_NAME => $filepath,
116
+ PCLZIP_ATT_FILE_NEW_FULL_NAME => $entryname
117
  )
118
  )
119
  );
lib/vendor/zip-factory/zip-factory/lib/ArchiverZipArchive.php CHANGED
@@ -28,7 +28,7 @@
28
  * @author Yani Iliev <yani@iliev.me>
29
  * @copyright 2014 Yani Iliev
30
  * @license https://raw.github.com/yani-/zip-factory/master/LICENSE The MIT License (MIT)
31
- * @version GIT: 1.0.0
32
  * @link https://github.com/yani-/zip-factory/
33
  */
34
 
@@ -97,6 +97,10 @@ if (class_exists('ZipArchive')) {
97
  $start = null,
98
  $length = null
99
  ) {
 
 
 
 
100
  parent::addFile($filepath, $entryname, $start, $length);
101
  }
102
 
28
  * @author Yani Iliev <yani@iliev.me>
29
  * @copyright 2014 Yani Iliev
30
  * @license https://raw.github.com/yani-/zip-factory/master/LICENSE The MIT License (MIT)
31
+ * @version GIT: 1.0.3
32
  * @link https://github.com/yani-/zip-factory/
33
  */
34
 
97
  $start = null,
98
  $length = null
99
  ) {
100
+ if (is_resource($filepath)) {
101
+ $meta = stream_get_meta_data($filepath);
102
+ $filepath = $meta['uri'];
103
+ }
104
  parent::addFile($filepath, $entryname, $start, $length);
105
  }
106
 
lib/vendor/zip-factory/zip-factory/lib/ZipFactory.php CHANGED
@@ -28,7 +28,7 @@
28
  * @author Yani Iliev <yani@iliev.me>
29
  * @copyright 2014 Yani Iliev
30
  * @license https://raw.github.com/yani-/zip-factory/master/LICENSE The MIT License (MIT)
31
- * @version GIT: 1.0.0
32
  * @link https://github.com/yani-/zip-factory/
33
  */
34
 
28
  * @author Yani Iliev <yani@iliev.me>
29
  * @copyright 2014 Yani Iliev
30
  * @license https://raw.github.com/yani-/zip-factory/master/LICENSE The MIT License (MIT)
31
+ * @version GIT: 1.0.3
32
  * @link https://github.com/yani-/zip-factory/
33
  */
34
 
lib/view/export/index.php CHANGED
@@ -115,12 +115,18 @@
115
  </div>
116
 
117
  <div class="ai1wm-field">
 
118
  <div class="ai1wm-buttons">
119
  <button type="submit" name="options[action]" value="export" class="ai1wm-button-green">
120
  <i class="ai1wm-icon-arrow-down"></i>
121
  <?php _e( 'EXPORT PACKAGE' ); ?>
122
  </button>
123
  </div>
 
 
 
 
 
124
  </div>
125
  </form>
126
  </div>
115
  </div>
116
 
117
  <div class="ai1wm-field">
118
+ <?php if ( $temp_dir_access ): ?>
119
  <div class="ai1wm-buttons">
120
  <button type="submit" name="options[action]" value="export" class="ai1wm-button-green">
121
  <i class="ai1wm-icon-arrow-down"></i>
122
  <?php _e( 'EXPORT PACKAGE' ); ?>
123
  </button>
124
  </div>
125
+ <?php else: ?>
126
+ <div class="ai1wm-message ai1wm-red-message">
127
+ <?php printf( _( 'Please ensure that PHP temporary directory <strong>%s</strong> has read and write permissions.' ), $temp_dir ); ?>
128
+ </div>
129
+ <?php endif; ?>
130
  </div>
131
  </form>
132
  </div>
loader.php CHANGED
@@ -66,3 +66,5 @@ require_once AI1WM_MODEL_PATH .
66
  require_once AI1WM_MODEL_PATH . DIRECTORY_SEPARATOR . 'class-ai1wm-export.php';
67
 
68
  require_once AI1WM_MODEL_PATH . DIRECTORY_SEPARATOR . 'class-ai1wm-import.php';
 
 
66
  require_once AI1WM_MODEL_PATH . DIRECTORY_SEPARATOR . 'class-ai1wm-export.php';
67
 
68
  require_once AI1WM_MODEL_PATH . DIRECTORY_SEPARATOR . 'class-ai1wm-import.php';
69
+
70
+ require_once AI1WM_MODEL_PATH . DIRECTORY_SEPARATOR . 'class-ai1wm-file.php';
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.2.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,17 @@ 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
  = Bypass all upload size restriction =
19
  * We use chunks to import your data and that way we bypass any webserver upload size restrictions up to **512MB** - commercial version supports up to **5GB**
20
 
@@ -59,6 +70,18 @@ All in One WP Plugin is the first plugin to offer true mobile experience on Word
59
  3. Plugin Menu
60
 
61
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
 
62
  = 1.2.1 =
63
  * Fixed an issue when HTTP Error was shown on some hosts after import, credit to Michael Simon
64
  * Fixed an issue when exporting databases with different prefix than wp_, credit to najtrox
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.3.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
+ = Multisite compatible =
19
+ * The plugin menu is available for the network administrator only `wp-admin/network/admin.php?page=site-migration-export`
20
+
21
+ = Works on Windows OS and IIS =
22
+ * Tested the plugin on Windows 7 and Windows Server 2012 with the default available IIS
23
+ * You will need to make sure that Windows\TEMP folder has write permissions for the IIS user
24
+
25
+ = memory_limit requirement of only 32MB =
26
+ * The plugin handles archiving of files by using 2048 bytes of chunks
27
+ * The plugin processes database find/replacement in chunks of 1MB
28
+
29
  = Bypass all upload size restriction =
30
  * We use chunks to import your data and that way we bypass any webserver upload size restrictions up to **512MB** - commercial version supports up to **5GB**
31
 
70
  3. Plugin Menu
71
 
72
  == Changelog ==
73
+ = 1.3.0 =
74
+ * Added support for mysql connection to happen over sockets or TCP
75
+ * Added support for Windows OS and fully tested the plugin on IIS
76
+ * Added support for limited memory_limit - 1MB - The plugin now requires only 1MB to operate properly
77
+ * Added support for multisite
78
+ * Use mysql_unbuffered_query instead of mysql_query to overcome any memory problems
79
+ * Fixed a deprecated warning for mysql_pconnect when php 5.5 and above is used
80
+ * Fixed memory_limit problem with PCLZIP library
81
+ * Fixed a bug when the archive is exported with zero size when using PCLZIP
82
+ * Fixed a bug when the archive was exported broken on some servers
83
+ * Fixed a deprecated usage of preg_replace \e in php v5.5 and above
84
+
85
  = 1.2.1 =
86
  * Fixed an issue when HTTP Error was shown on some hosts after import, credit to Michael Simon
87
  * Fixed an issue when exporting databases with different prefix than wp_, credit to najtrox